private ChildRefLoadPlan EnsureChildRef( MetadataChildRef childRef, LoadPlan plan, LoadPlan.MergedPlans mergedPlans) { for (int index = 0; index < this.Childs.Count; ++index) { ChildRefLoadPlan child = this.Childs[index]; if (child.ChildRef == childRef) { child.Plan.MergeWith(plan, mergedPlans); return(child); } } ChildRefLoadPlan childRefLoadPlan = new ChildRefLoadPlan(childRef, plan); this.Childs.Add((object)childRefLoadPlan); return(childRefLoadPlan); }
internal void MergeWith(LoadPlan plan, LoadPlan.MergedPlans mergedPlans) { if (mergedPlans != null) { if (mergedPlans.Contains(this, plan)) { return; } mergedPlans.Add(this, plan); } for (int index = 0; index < plan.Data.Count; ++index) { string name = plan.Data[index].Name; MetadataProperty propertyMetadata = this.Class.Properties.Need(name); if (!propertyMetadata.IsData) { throw new DataException(string.Format("Ошибка слияния планов загрузки.\nКласс '{0}' не содержит свойство данных '{1}'.", (object)this.Class.Name, (object)name)); } this.EnsureDataProperty(propertyMetadata); } for (int index = 0; index < plan.Links.Count; ++index) { AssociationRefLoadPlan link = plan.Links[index]; string name = link.Ref.Association.Property.Name; MetadataProperty metadataProperty = this.Class.Properties.Need(name); if (!metadataProperty.IsLink) { throw new DataException(string.Format("Ошибка слияния планов загрузки.\nКласс '{0}' не содержит свойство связи '{1}'.", (object)this.Class.Name, (object)name)); } this.EnsureAssociationRef(metadataProperty.Association.Refs.Need(link.Ref.RefClass), link.Plan, mergedPlans); } for (int index = 0; index < plan.Childs.Count; ++index) { ChildRefLoadPlan child = plan.Childs[index]; this.EnsureChildRef(this.Class.Childs.Need(child.ChildRef.ChildClass), child.Plan, mergedPlans); } }