Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Schema("93CC69FC-AB6F-451A-B075-A5D9467569C2",
- "ComplexSchema")]
- public class ComplexEntity : IRevitEntity
- {
- [Field]
- public string SimpleField { get; set; }
- [Field]
- public List<IntEntity> ArrayField { get; set; }
- [Field]
- public Dictionary<int, IntEntity> MapField { get; set; }
- }
- // the same with Extension
- ComplexEntity complexEntity =
- new ComplexEntity();
- complexEntity.SimpleField = "Hello, Simple entity";
- complexEntity.ArrayField =
- new List<IntEntity>
- {
- new IntEntity() {SomeValue = 7},
- new IntEntity() {SomeValue = 8}
- };
- complexEntity.MapField =
- new Dictionary<int, IntEntity>
- {
- {9, new IntEntity(){SomeValue = 9}},
- {10, new IntEntity(){SomeValue = 10}}
- };
- element.SetEntity(complexEntity);
- //Change value in map field
- var complexEntity2 =
- element.GetEntity<ComplexEntity>();
- if (complexEntity2!=null)
- {
- if (complexEntity.MapField.ContainsKey(9))
- {
- var entityInMapField =
- complexEntity.MapField[9];
- entityInMapField.SomeValue = 9898;
- element.SetEntity(complexEntity2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement