Пример #1
0
        public DataObjectList Query(LoadPlan loadPlan)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.LoadData(loadPlan, listInstance, (DataId[])null, "");
            return(listInstance);
        }
Пример #2
0
        public DataObjectList Query(LoadPlan loadPlan, params DataId[] ids)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.LoadData(loadPlan, listInstance, ids, (string)null);
            return(listInstance);
        }
Пример #3
0
        private LoadPlan CreatePlanFromString(string loadPlan)
        {
            XmlDocument     xmlDocument     = XmlUtils.LoadDocumentFromXml("<root>" + loadPlan + "</root>");
            LoadPlanBuilder loadPlanBuilder = new LoadPlanBuilder(this.Session);
            LoadPlan        loadPlan1       = loadPlanBuilder.BuildPlan(this.Class, (XmlNode)xmlDocument.DocumentElement);

            loadPlanBuilder.ProcessObjectViewRequests();
            return(loadPlan1);
        }
Пример #4
0
        public DataObject QueryObject(LoadPlan loadPlan, DataId id)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.LoadData(loadPlan, listInstance, new DataId[1]
            {
                id
            }, (string)null);
            return(listInstance.Count != 0 ? listInstance[0] : this.Session[loadPlan.Class].NullObject);
        }
Пример #5
0
        internal static LoadPlan UseExistingOrCreateNew(LoadPlan plan, MetadataClass cls)
        {
            if (plan.Class == cls)
            {
                return(plan);
            }
            LoadPlan loadPlan = new LoadPlan(cls);

            loadPlan.MergeWith(plan);
            return(loadPlan);
        }
Пример #6
0
 public bool Contains(LoadPlan dst, LoadPlan src)
 {
     for (int index = 0; index < this.DstPlans.Count; ++index)
     {
         if (this.DstPlans[index] == dst && this.SrcPlans[index] == src)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #7
0
        public DataObjectList Query(
            LoadPlan loadPlan,
            string condition,
            params object[] paramArray)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.TraceQueryStarted(this.Class);
            this.Session.LoadData(loadPlan, listInstance, (DataId[])null, condition, paramArray);
            this.Session.TraceQueryFinished();
            return(listInstance);
        }
Пример #8
0
 internal LoadPlan GetLoadPlan(DataSession session)
 {
     if (this.FOnDemandLoadPlan != null)
     {
         return(this.FOnDemandLoadPlan);
     }
     this.FOnDemandLoadPlan = new LoadPlan(this.FObjectView.Class);
     for (int index = 0; index < this.FParamLoaders.Count; ++index)
     {
         this.FParamLoaders[index].PrepareLoadPlan(this.FOnDemandLoadPlan, session);
     }
     return(this.FOnDemandLoadPlan);
 }
Пример #9
0
        internal ObjectLoader EnsureObjectLoader(LoadPlan plan)
        {
            for (int index = 0; index < this.ObjectLoaders.Count; ++index)
            {
                ObjectLoader objectLoader = this.ObjectLoaders[index];
                if (objectLoader.BasePlan == plan)
                {
                    return(objectLoader);
                }
            }
            ObjectLoader objectLoader1 = new ObjectLoader(plan);

            this.ObjectLoaders.Add(objectLoader1);
            objectLoader1.Prepare(this);
            return(objectLoader1);
        }
Пример #10
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);
        }
Пример #11
0
        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);
        }
Пример #12
0
 private void CheckComplete()
 {
     if (this.FIsComplete)
     {
         return;
     }
     if (this.Object.IsNull)
     {
         this.FIsComplete = true;
     }
     else
     {
         DataStorage storage       = this.Object.Storage;
         DataSession masterSession = this.Session.MasterSession;
         if (masterSession != null)
         {
             DataObjectChildList childs      = masterSession[storage.Class][this.Object.Id].GetChilds(this.ChildRef);
             DataStorage         dataStorage = this.Session[this.ChildRef.ChildClass];
             MetadataProperty    property    = this.ChildRef.AggregationRef.Association.Property;
             for (int index = 0; index < childs.Count; ++index)
             {
                 DataObject untypedValue = (DataObject)dataStorage[childs[index].Id][property].UntypedValue;
             }
             this.FIsComplete = true;
         }
         else if (storage.IsChildListCompleted(this.ChildRef))
         {
             this.FIsComplete = true;
         }
         else
         {
             this.Session.TraceUnplannedChildrenLoading(this.ChildRef);
             LoadPlan plan = new LoadPlan(storage.Class);
             plan.EnsureChildRef(this.ChildRef, new LoadPlan(this.ChildRef.ChildClass));
             storage.Session.LoadData(plan, (DataObjectList)null, new DataId[1]
             {
                 this.Object.Id
             }, (string)null);
         }
     }
 }
Пример #13
0
        public override void PrepareLoadPlan(LoadPlan plan, DataSession session)
        {
            LoadPlanList loadPlanList1 = new LoadPlanList();

            loadPlanList1.Add(plan);
            LoadPlanList loadPlanList2 = loadPlanList1;

            foreach (Navigator navigator in this.FNavigation)
            {
                LoadPlanList navigationPlans = new LoadPlanList();
                foreach (LoadPlan sourcePlan in (List <LoadPlan>)loadPlanList2)
                {
                    navigator.GetNavigationLoadPlans(session, sourcePlan, navigationPlans);
                }
                loadPlanList2 = navigationPlans;
            }
            foreach (LoadPlan plan1 in (List <LoadPlan>)loadPlanList2)
            {
                this.FMemberValueGetter.PrepareLoadPlan(plan1, session);
            }
        }
Пример #14
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);
     }
 }
Пример #15
0
        internal void LoadNotAssignedProperties()
        {
            this.CheckNotUntypedNull();
            LoadPlan             plan       = new LoadPlan(this.FStorage.Class);
            MetadataPropertyList properties = this.Class.Properties;

            DataProperty[] dataPropertyArray = this.FProperties ?? (this.FProperties = new DataProperty[properties.Count]);
            for (int index = 0; index < properties.Count; ++index)
            {
                MetadataProperty propertyMetadata = properties[index];
                if (!propertyMetadata.IsId)
                {
                    DataProperty dataProperty = dataPropertyArray[index];
                    if (dataProperty == null || !dataProperty.IsAssigned)
                    {
                        plan.EnsureProperty(propertyMetadata);
                    }
                }
            }
            this.Session.LoadData(plan, (DataObjectList)null, new DataId[1]
            {
                this.Id
            }, (string)null);
        }
Пример #16
0
 public void EnsureProperty(MetadataProperty propertyMetadata)
 {
     if (propertyMetadata.IsData)
     {
         this.EnsureDataProperty(propertyMetadata);
     }
     else
     {
         if (!propertyMetadata.IsLink)
         {
             throw new DataException(string.Format("DataLoadPlan.EnsureProperty: Свойство {0}.{1}, добавляемое в план загрузки, не является простым типом или связанным объектом.", (object)this.Class.QTypeName, (object)propertyMetadata.Name));
         }
         LoadPlan plan = (LoadPlan)null;
         for (int index = 0; index < propertyMetadata.Association.Refs.Count; ++index)
         {
             MetadataAssociationRef assRef = propertyMetadata.Association.Refs[index];
             if (plan == null)
             {
                 plan = new LoadPlan(assRef.RefClass);
             }
             this.EnsureAssociationRef(assRef, plan);
         }
     }
 }
Пример #17
0
 public Loader(LoadPlan plan) => this.RootLoader = this.EnsureObjectLoader(plan);
Пример #18
0
 public override void PrepareLoadPlan(LoadPlan plan, DataSession session)
 {
 }
Пример #19
0
 public ChildRefLoadPlan EnsureChildRef(MetadataChildRef childRef, LoadPlan plan) => this.EnsureChildRef(childRef, plan, new LoadPlan.MergedPlans());
Пример #20
0
 public AssociationRefLoadPlan EnsureAssociationRef(
     MetadataAssociationRef assRef,
     LoadPlan plan)
 {
     return(this.EnsureAssociationRef(assRef, plan, new LoadPlan.MergedPlans()));
 }
Пример #21
0
 public AssociationRefLoadPlan(MetadataAssociationRef assRef, LoadPlan plan)
 {
     this.Ref  = assRef;
     this.Plan = LoadPlan.UseExistingOrCreateNew(plan, assRef.RefClass);
 }
Пример #22
0
 public ChildRefLoadPlan(MetadataChildRef childRef, LoadPlan plan)
 {
     this.ChildRef = childRef;
     this.Plan     = LoadPlan.UseExistingOrCreateNew(plan, childRef.ChildClass);
 }
Пример #23
0
 public void Add(LoadPlan dst, LoadPlan src)
 {
     this.DstPlans.Add((object)dst);
     this.SrcPlans.Add((object)src);
 }
Пример #24
0
 public abstract void GetNavigationLoadPlans(
     DataSession session,
     LoadPlan sourcePlan,
     LoadPlanList navigationPlans);
Пример #25
0
 internal void MergeWith(LoadPlan plan) => this.MergeWith(plan, new LoadPlan.MergedPlans());
Пример #26
0
 internal ObjectLoader(LoadPlan basePlan) => this.BasePlan = basePlan;
 public abstract void PrepareLoadPlan(LoadPlan plan, DataSession session);