public IEditableObject ToEditable(IEditableFactory factory) { var choiceSet = factory.CreateItem(Schema.BuiltIn[BuiltInSchema.ChoiceSet]); choiceSet.GetField((int)ItemLayout.Id).Set(this.Id); choiceSet.GetField((int)ItemLayout.Name).Set(this.Name); choiceSet.GetField((int)ItemLayout.Revision).Set(this.Revision); IEditableObject dataField = choiceSet.GetField((int)ItemLayout.Data).Get <IEditableObject>(); dataField.GetField("Description").Set(this.Description); dataField.GetField("Caption").Set(this.Caption); var defaultsList = (IEditableList)dataField.GetField("Defaults"); this.Defaults.ForEach(x => defaultsList.Add().Set(x)); var optionList = (IEditableList)dataField.GetField("Options"); this.Options.ForEach(x => optionList.Add().Set(x.ToEditable(factory))); return(choiceSet); }
public static IEditable GetField(this IEditableObject source, ItemLayout itemField) { return(source.GetField((int)itemField)); }