Example #1
0
        private AssociationRefLoadPlan EnsureAssociationRef(
            MetadataAssociationRef assRef,
            LoadPlan plan,
            LoadPlan.MergedPlans mergedPlans)
        {
            for (int index = 0; index < this.Links.Count; ++index)
            {
                AssociationRefLoadPlan link = this.Links[index];
                if (link.Ref == assRef)
                {
                    link.Plan.MergeWith(plan, mergedPlans);
                    return(link);
                }
            }
            AssociationRefLoadPlan associationRefLoadPlan = new AssociationRefLoadPlan(assRef, plan);

            this.Links.Add((object)associationRefLoadPlan);
            return(associationRefLoadPlan);
        }
Example #2
0
 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);
     }
 }