public InputListPageModel(IList Value, string searchUrl) { if (Value is null) { throw new System.ArgumentNullException(nameof(Value)); } this.SearchUrl = searchUrl; this.SelectedItems = new List <InputListOptionPageModel>(); this.SourceType = new MetaType(-1) { CoreType = CoreType.Collection, CollectionType = new MetaTypeHolder(Value.GetType().GetCollectionType()) }; foreach (object thisItem in Value.Cast <object>()) { InputListOptionPageModel optionModel = new InputListOptionPageModel(thisItem) { SourceType = this.SourceType, ValuePropertyName = this.ValuePropertyName }; this.SelectedItems.Add(optionModel); } }
private void SetUp(IMetaObject Model) { this.BackingObject = Model; this.SourceType = Model.Type; if (Model.GetCoreType() != CoreType.Collection) { this.ItemType = Model.Type; if (!Model.Null) { this.SelectedItems.Add( new InputListOptionPageModel(this.LabelPropertyName, this.ValuePropertyName, Model) { ItemType = this.ItemType }); } } else if (Model.GetCoreType() == CoreType.Collection) { //Add all of the currently selected items to the display box this.ItemType = Model.Template.Type; foreach (IMetaObject thisItem in Model.CollectionItems) { InputListOptionPageModel optionModel = new InputListOptionPageModel(this.LabelPropertyName, this.ValuePropertyName, thisItem) { ItemType = this.ItemType, SourceType = this.SourceType }; this.SelectedItems.Add(optionModel); } } }