/// <summary> /// Initializes a new instance of the <see cref="ModelInstance"/> class. /// </summary> /// <param name="entityDescriptor"> /// The <see cref="ModelEntityDescriptor"/> descriptor. /// </param> /// <param name="instance"> /// The <see cref="IModelEntity"/> instance. /// </param> /// <param name="currentViewMode"> /// The current View Mode. /// </param> public ModelInstance(ModelEntityDescriptor entityDescriptor, IModelEntity instance, ViewMode currentViewMode) { _modelEntityDescriptor = entityDescriptor; DomainModelInstance = instance; CurrentViewMode = currentViewMode; Key = instance.Key.Trim(); MembersSingleValue = new MemberList <MemberSingleValue>(entityDescriptor.MembersSingleValue.Select(mmd => new MemberSingleValue(mmd, instance))); MembersMultipleValues = new MemberList <MemberMultipleValues>(entityDescriptor.MembersMultipleValues.Select(mmd => new MemberMultipleValues(mmd, instance))); Members = new MemberList <Member>(MembersSingleValue.Cast <Member>().Concat(MembersMultipleValues.Cast <Member>())); }