Advertisement
chekalin-v

Untitled

Apr 23rd, 2013
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. [Schema("93CC69FC-AB6F-451A-B075-A5D9467569C2",
  2.     "ComplexSchema")]
  3. public class ComplexEntity : IRevitEntity
  4. {      
  5.     [Field]
  6.     public string SimpleField { get; set; }
  7.  
  8.     [Field]
  9.     public List<IntEntity> ArrayField { get; set; }
  10.  
  11.     [Field]
  12.     public Dictionary<int, IntEntity> MapField { get; set; }
  13. }
  14.  
  15. // the same with Extension
  16. ComplexEntity complexEntity =
  17.     new ComplexEntity();
  18. complexEntity.SimpleField = "Hello, Simple entity";
  19.  
  20. complexEntity.ArrayField =
  21.     new List<IntEntity>
  22.         {
  23.             new IntEntity() {SomeValue = 7},
  24.             new IntEntity() {SomeValue = 8}
  25.         };
  26.  
  27. complexEntity.MapField =
  28.     new Dictionary<int, IntEntity>
  29.         {
  30.             {9, new IntEntity(){SomeValue = 9}},
  31.             {10, new IntEntity(){SomeValue = 10}}
  32.         };
  33.  
  34. element.SetEntity(complexEntity);
  35.  
  36. //Change value in map field
  37. var complexEntity2 =
  38.     element.GetEntity<ComplexEntity>();
  39. if (complexEntity2!=null)
  40. {
  41.     if (complexEntity.MapField.ContainsKey(9))
  42.     {
  43.         var entityInMapField =
  44.             complexEntity.MapField[9];
  45.         entityInMapField.SomeValue = 9898;
  46.  
  47.         element.SetEntity(complexEntity2);
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement