Exemple #1
0
            internal static void ParseLastPartOfPath(
                MetadataClassList classes,
                string path,
                out string predecessorPath,
                out string identifier,
                out MetadataClass refClass,
                out bool isExternalRef)
            {
                int length = path.LastIndexOf('.');

                predecessorPath = length >= 0 ? path.Substring(0, length) : (string)null;
                string pathItem = length >= 0 ? path.Substring(length + 1) : path;

                if (string.IsNullOrEmpty(pathItem))
                {
                    identifier    = (string)null;
                    refClass      = (MetadataClass)null;
                    isExternalRef = false;
                }
                else
                {
                    SqlUtils.NavigationPathItem navigationPathItem = SqlUtils.NavigationPathItem.ParseItem(classes, pathItem);
                    identifier    = navigationPathItem.Name;
                    refClass      = navigationPathItem.RefClass;
                    isExternalRef = navigationPathItem.Through == SqlUtils.NavigationThrough.ExternalLink;
                }
            }
        internal void LoadFromXml(XmlNode node)
        {
            MetadataClass metadataClass1 = this.Association.Class;

            try
            {
                MetadataClass metadataClass2 = metadataClass1.Metadata.Classes.Need(XmlUtils.NeedAttr(node, "ref-class"));
                this.FRefProperty           = metadataClass2.Properties.Find(XmlUtils.GetAttr(node, "ref-property")) ?? metadataClass2.IDProperty;
                this.FSelectorValue         = node.Name == "case" ? XmlUtils.NeedAttr(node, "value") : string.Empty;
                this.FAssociationObjectView = XmlUtils.GetAttr(node, "association-object-view", "default");
                if (this.Association.Property.IsAggregation)
                {
                    this.FAggregationRoleMemberName = XmlUtils.GetAttr(node, "role-prog-id", this.Association.Class.IdentName);
                    this.FAggregationBuiltIn        = XmlUtils.GetBoolAttr(node, "is-built-in");
                    this.FAggregationType           = (AggregationType)XmlUtils.GetEnumAttr(node, "aggregation-type", MetadataAssociationRef.FAggregationTypeNames, 0);
                    this.FAggregationObjectView     = XmlUtils.GetAttr(node, "aggregation-object-view", "default");
                    metadataClass2.Childs.Ensure(this);
                }
                metadataClass2.ExternalRefs.Add(this);
            }
            catch (Exception ex)
            {
                throw new MetadataException(string.Format("Ошибка загрузки свойства {0}", (object)this.Association.Property.Name), ex);
            }
        }
 public ApplicationMetadata(XmlNode sourceNode)
 {
     this.SourceNode      = sourceNode;
     this.Classes         = new MetadataClassList();
     this.ScriptLibraries = new MetadataScriptLibraries(sourceNode);
     foreach (XmlNode selectNode in this.SourceNode.SelectNodes("class"))
     {
         string        name          = XmlUtils.NeedAttr(selectNode, "name");
         MetadataClass metadataClass = this.Classes.Find(name);
         if (metadataClass == null)
         {
             metadataClass = new MetadataClass(this, name, this.Classes.Count);
             this.Classes.Add(metadataClass);
         }
         metadataClass.LoadFromXml(selectNode);
     }
     foreach (MetadataClass metadataClass in this.Classes)
     {
         metadataClass.LoadAssociations();
     }
     foreach (MetadataClass metadataClass in this.Classes)
     {
         metadataClass.LoadObjectViews();
     }
     foreach (MetadataClass metadataClass in this.Classes)
     {
         metadataClass.LoadVirtualProperties();
     }
 }
Exemple #4
0
            public static SqlUtils.NavigationPathItem ParseItem(
                MetadataClassList classes,
                string pathItem)
            {
                int length1 = pathItem.LastIndexOf('^');

                if (length1 >= 0)
                {
                    string identName = pathItem.Substring(0, length1);
                    return(new SqlUtils.NavigationPathItem(SqlUtils.NavigationThrough.ExternalLink, pathItem.Substring(length1 + 1), classes.FindByIdentName(identName) ?? throw new Exception(string.Format("Не найден класс \"{0}\".", (object)identName))));
                }
                int length2 = pathItem.LastIndexOf(':');

                if (length2 >= 0)
                {
                    string        identName   = pathItem.Substring(length2 + 1);
                    MetadataClass byIdentName = classes.FindByIdentName(identName);
                    if (byIdentName == null)
                    {
                        string format = "Не найден класс \"{0}\".";
                        if (identName.IndexOf("/") >= 0)
                        {
                            format += "Замечание: при задании составных идентификаторов в условиях поиска, символ \"/\" в именах классов необходимо заменять на символ \"_\".";
                        }
                        throw new Exception(string.Format(format, (object)identName));
                    }
                    return(new SqlUtils.NavigationPathItem(SqlUtils.NavigationThrough.Link, pathItem.Substring(0, length2), byIdentName));
                }
                MetadataClass byIdentName1 = classes.FindByIdentName(pathItem);

                return(byIdentName1 != null ? new SqlUtils.NavigationPathItem(SqlUtils.NavigationThrough.Child, pathItem, byIdentName1) : new SqlUtils.NavigationPathItem(SqlUtils.NavigationThrough.Link, pathItem, (MetadataClass)null));
            }
        public bool TryFindMember(
            string memberName,
            out MetadataProperty property,
            out MetadataChildRef childRef)
        {
            property = this.Properties.Find(memberName);
            if (property != null)
            {
                childRef = (MetadataChildRef)null;
                return(true);
            }
            MetadataClass byIdentName = this.Metadata.Classes.FindByIdentName(memberName);

            if (byIdentName != null)
            {
                childRef = this.Childs.Find(byIdentName);
                if (childRef != null)
                {
                    return(true);
                }
            }
            else
            {
                childRef = (MetadataChildRef)null;
            }
            return(false);
        }
 public StorageCommitPlan(DataStorage storage)
 {
     this.FStorage = storage;
     if (storage.Session.MasterSession != null)
     {
         this.FMasterStorage = storage.Session.MasterSession[storage.Class];
     }
     this.FClass    = storage.Class;
     this.FSession  = storage.Session;
     this.FCreation = new UpdatePlan(PropertyStateFilter.Assigned);
     this.FUpdating = new UpdatePlan(PropertyStateFilter.Modified);
     this.FDeletion = new List <DataObject>();
     foreach (DataObject update in storage.GetUpdateQueue())
     {
         if (update.IsDeleted)
         {
             if (!update.IsNew)
             {
                 this.FDeletion.Add(update);
             }
         }
         else if (update.IsNew)
         {
             this.FCreation.AddObject(update);
         }
         else if (update.IsPropertiesModified)
         {
             this.FUpdating.AddObject(update);
         }
     }
 }
 internal MetadataChildRef(MetadataAssociationRef aggregationRef, int index)
 {
     this.AggregationRef          = aggregationRef;
     aggregationRef.OwnerChildRef = this;
     this.ChildClass = aggregationRef.Association.Class;
     this.MemberName = aggregationRef.AggregationRoleMemberName;
     this.Index      = index;
 }
 public void GenerateClass(MetadataClass cls, StringBuilder sb)
 {
     CodeGenerator.GenerateDoc(string.Empty, "summary", cls.Caption, sb);
     CodeGenerator.ApplyTemplate(cls, sb, "\npublic class {Type}: DataObject\n{\n\tpublic {Type}(): base() { }\n\tpublic {Type}Meta Meta { get { return (({QType}Storage)Storage).Meta; } }\n\tnew public {Type}Storage Storage { get { return ({QType}Storage)base.Storage; } }\n");
     CodeGenerator.GenerateProperties(cls, sb);
     CodeGenerator.GenerateChilds(cls, sb);
     sb.Append("}\n");
 }
Exemple #9
0
 public LoadPlan(MetadataClass cls)
 {
     this.Class  = cls;
     this.Data   = new MetadataPropertyList();
     this.Links  = new AssociationRefLoadPlanList();
     this.Childs = new ChildRefLoadPlanList();
     this.Views  = new MetadataObjectViewList(cls);
 }
Exemple #10
0
 public MetadataProperty(MetadataClass cls, string name, int index)
 {
     this.Class        = cls;
     this.Name         = name;
     this.Index        = index;
     this.FPurpose     = MetadataPropertyPurpose.Data;
     this.FDataType    = DataType.Unknown;
     this.LookupValues = new MetadataLookupValueList();
 }
Exemple #11
0
 protected internal DataStorage(DataSession session, MetadataClass cls)
 {
     this.Session          = session;
     this.Class            = cls;
     this.FObjects         = new Dictionary <DataId, DataObject>();
     this.FObjectsToUpdate = new Dictionary <DataId, DataObject>();
     this.NullObject       = this.CreateObjectInstance();
     this.NullObject.Init(this, DataId.Empty, ObjectSessionState.NullObject);
 }
 public void GenerateStorage(MetadataClass cls, StringBuilder sb)
 {
     CodeGenerator.ApplyTemplate(cls, sb, "\npublic class {Type}Storage: DataStorage\n{\n\tpublic readonly {Type}Meta Meta;\n\tnew public InMeta.Session Session { get { return (InMeta.Session)base.Session; } }\n\tinternal {Type}Storage(DataSession session, MetadataClass cls): base(session, cls) { Meta = new {Type}Meta(cls); }\n\tprotected override LinkProperty CreateLinkPropertyInstance(DataObject obj, MetadataProperty propMetadata) { return new {QType}LinkProperty(obj, propMetadata); }\n\tprotected override DataObject CreateObjectInstance() { return new {QType}(); }\n\tprotected override DataObjectList CreateListInstance() { return new {QType}List(); }\n\tprotected override DataObjectChildList CreateChildListInstance(DataObject obj, MetadataChildRef childRef){ return new {QType}ChildList(obj, childRef); }\n\tnew public {QType} NullObject { get { return ({QType})base.NullObject; } }\n\tnew public {QType} this[string strId] { get { return ({QType})base[strId]; } }\n\tnew public {QType} this[DataId id] { get { return ({QType})base[id]; } }\n\tnew public {QType} AddNew() { return ({QType})base.AddNew(); }\n\tnew public {QType}List Query(string plan, string condition, params object[] paramArray) { return ({QType}List)base.Query(plan, condition, paramArray); }\n\tnew public {QType}List Query(string plan, {QType}ConditionBuilder conditionBuilder) { return ({QType}List)base.Query(plan, conditionBuilder); }\n\tnew public {QType}List Query(string plan) { return ({QType}List)base.Query(plan); }\n\tnew public {QType}List Query(string plan, params DataId[] ids) { return ({QType}List)base.Query(plan, ids); }\n\tnew public {QType} QueryObject(string plan, DataId id) { return ({QType})base.QueryObject(plan, id); }\n");
     if ((this.Options & CodeGeneratorOptions.GenerateConditionBuilder) != (CodeGeneratorOptions)0)
     {
         CodeGenerator.ApplyTemplate(cls, sb, "\tpublic {Type}ConditionBuilder Condition { get { return new {Type}ConditionBuilder(Meta); } }\n");
     }
     sb.Append("}\n");
 }
Exemple #13
0
 public NavigationPathItem(
     SqlUtils.NavigationThrough through,
     string name,
     MetadataClass refClass)
 {
     this.Through  = through;
     this.Name     = name;
     this.RefClass = refClass;
 }
 private static void GenerateChilds(MetadataClass cls, StringBuilder sb)
 {
     for (int index = 0; index < cls.Childs.Count; ++index)
     {
         MetadataChildRef child      = cls.Childs[index];
         MetadataClass    childClass = child.ChildClass;
         CodeGenerator.GenerateDoc("\t", "summary", childClass.Caption, sb);
         sb.AppendFormat("\tpublic {0}ChildList {1} {{ get {{ return ({0}ChildList)base.GetChilds(Meta.{1}); }} }}\n", (object)childClass.QTypeName, (object)child.MemberName);
     }
 }
 internal ClassUpdatesInfo(
     MetadataClass @class,
     NewObjectInfo[] @new,
     ModifiedObjectInfo[] modified,
     string[] deleted)
 {
     this.Class    = @class;
     this.New      = @new;
     this.Modified = modified;
     this.Deleted  = deleted;
 }
 private static void GenerateProperties(MetadataClass cls, StringBuilder sb)
 {
     for (int index = 0; index < cls.Properties.Count; ++index)
     {
         MetadataProperty property = cls.Properties[index];
         if (!property.IsSelector && !property.IsId)
         {
             CodeGenerator.GenerateProperty(property, sb);
         }
     }
 }
Exemple #17
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);
        }
Exemple #18
0
            public SqlUtils.NavigationStep EnsureRootStep(string path)
            {
                SqlUtils.NavigationStep navigationStep1 = !string.IsNullOrEmpty(path) ? this.FindRootStep(path) : throw new ArgumentNullException(nameof(path));
                if (navigationStep1 != null)
                {
                    return(navigationStep1);
                }
                string        predecessorPath;
                string        identifier;
                MetadataClass refClass1;
                bool          isExternalRef;

                SqlUtils.Navigation.ParseLastPartOfPath(this.Class.Metadata.Classes, path, out predecessorPath, out identifier, out refClass1, out isExternalRef);
                SqlUtils.NavigationStep predecessor = !string.IsNullOrEmpty(predecessorPath) ? this.EnsureRootStep(predecessorPath) : (SqlUtils.NavigationStep)null;
                MetadataClass           refClass2   = predecessor != null ? predecessor.TargetClass : this.Class;

                SqlUtils.NavigationStep navigationStep2;
                if (isExternalRef)
                {
                    MetadataProperty metadataProperty = refClass1.Properties.Need(identifier);
                    if (!metadataProperty.IsLink)
                    {
                        throw new Exception(string.Format("Свойство \"{0}.{1}\" не является отношением.", (object)refClass1.Name, (object)identifier));
                    }
                    navigationStep2 = (SqlUtils.NavigationStep) new SqlUtils.ExternalAssociationNavigationStep(this, predecessor, path, metadataProperty.Association.Refs.Need(refClass2));
                }
                else
                {
                    MetadataProperty property;
                    MetadataChildRef childRef;
                    refClass2.NeedMember(identifier, out property, out childRef);
                    if (property != null)
                    {
                        if (!property.IsLink)
                        {
                            throw new DataException(string.Format("\"{0}\" не является ассоциацией или дочерним объектом.", (object)identifier));
                        }
                        MetadataAssociationRefList refs = property.Association.Refs;
                        if (refClass1 == null && refs.Count != 1)
                        {
                            throw new DataException(string.Format("\"{0}\" является ассоциацией с вариантами связи. В тексте запроса такое поле следует указывать в форме \"имя-свойства:имя-связанного-класса\" (например, \"Subject:Person\").", (object)identifier));
                        }
                        navigationStep2 = (SqlUtils.NavigationStep) new SqlUtils.AssociationNavigationStep(this, predecessor, path, refClass1 == null ? refs[0] : refs.Need(refClass1));
                    }
                    else
                    {
                        navigationStep2 = (SqlUtils.NavigationStep) new SqlUtils.ChildNavigationStep(this, predecessor, path, childRef);
                    }
                }
                navigationStep2.TargetAlias = this.CreateUniqueAlias(navigationStep2.TargetClass.DataTable);
                this.RootSteps.Add(navigationStep2);
                return(navigationStep2);
            }
Exemple #19
0
 public MetadataChildRef Find(MetadataClass childClass)
 {
     for (int index = 0; index < this.FItems.Count; ++index)
     {
         MetadataChildRef metadataChildRef = this[index];
         if (metadataChildRef.ChildClass == childClass)
         {
             return(metadataChildRef);
         }
     }
     return((MetadataChildRef)null);
 }
Exemple #20
0
 public MetadataClass FindByIdentName(string identName)
 {
     for (int index = 0; index < this.FItems.Count; ++index)
     {
         MetadataClass fitem = (MetadataClass)this.FItems[index];
         if (fitem.IdentName == identName)
         {
             return(fitem);
         }
     }
     return((MetadataClass)null);
 }
 public DataStorage this[MetadataClass cls]
 {
     get
     {
         DataStorage fstorage = this.FStorages[cls.Index];
         if (fstorage != null)
         {
             return(fstorage);
         }
         DataStorage storageInstance = this.CreateStorageInstance(cls);
         this.FStorages[cls.Index] = storageInstance;
         return(storageInstance);
     }
 }
Exemple #22
0
 private void GetAssociationPropertyTypes(out string valueType, out string propertyType)
 {
     if (this.Association.Selector == null)
     {
         MetadataClass refClass = this.Association.Refs[0].RefClass;
         valueType    = refClass.QTypeName;
         propertyType = refClass.QTypeName + "LinkProperty";
     }
     else
     {
         valueType    = "DataObject";
         propertyType = "LinkProperty";
     }
 }
 public void GenerateConditionBuilder(MetadataClass cls, StringBuilder sb)
 {
     CodeGenerator.ApplyTemplate(cls, sb, "\npublic class {Type}ConditionBuilder: QueryCondition\n{\n\tpublic readonly {Type}Meta Meta;\n\tpublic {Type}ConditionBuilder({Type}Meta meta): base() { Meta = meta; }\n");
     for (int index = 0; index < cls.Properties.Count; ++index)
     {
         MetadataProperty property = cls.Properties[index];
         if (!property.IsSelector && !property.IsId)
         {
             string valueType;
             property.GetMemberTypes(out valueType, out string _);
             sb.AppendFormat("\tpublic {0} {1}IsNull {{ get {{ return ({0})base.PropIsNull({2}); }}}}\n\tpublic {0} {1}IsNotNull {{ get {{ return ({0})base.PropIsNotNull({2}); }}}}\n\tpublic {0} {1}Is({3} value) {{ return ({0})base.PropIs({2}, value); }}\n\tpublic {0} {1}(CompareOp op, {3} value) {{ return ({0})base.PropCompare({2}, op, value); }}\n\tpublic {0} {1}Like(string value) {{ return ({0})base.PropLike({2}, value); }}\n\tpublic {0} {1}In(params {3}[] value) {{ return ({0})base.PropIn({2}, value); }}\n\tpublic {0} {1}Between({3} minValue, {3} maxValue) {{ return ({0})base.PropBetween({2}, minValue, maxValue); }}\n", (object)(cls.TypeName + "ConditionBuilder"), (object)property.MemberName, (object)("Meta." + property.MemberName), (object)valueType);
         }
     }
     sb.AppendFormat("\tnew public {0} Begin {{ get {{ return ({0})base.Begin; }}}}\n\tnew public {0} End {{ get {{ return ({0})base.End; }}}}\n\tnew public {0} And {{ get {{ return ({0})base.And; }}}}\n\tnew public {0} Or {{ get {{ return ({0})base.Or; }}}}\n\tnew public {0} Not {{ get {{ return ({0})base.Not; }}}}\n}}\n", (object)(cls.TypeName + "ConditionBuilder"));
 }
 internal MetadataObjectView(MetadataClass cls, XmlNode node, int index)
 {
     this.Index = index;
     this.Class = cls;
     this.Name  = XmlUtils.NeedAttr(node, "name");
     if (this.Name.Length == 0)
     {
         this.Name = "default";
     }
     this.VirtualProperties = new MetadataVirtualPropertyList(this);
     this.SourceNode        = node;
     this.Caption           = XmlUtils.GetAttr(node, "caption", this.Name);
     this.ScriptLanguage    = XmlUtils.GetAttr(node, "language", "VBScript");
     this.ContentType       = (ContentType)XmlUtils.GetEnumAttr(node, "content-type", MetadataObjectView.FContentTypeNames, 0);
     this.Using             = XmlUtils.GetAttr(node, "using").Split(',');
     this.Script            = XmlUtils.GetOwnText(node);
 }
 public void GenerateMeta(MetadataClass cls, StringBuilder sb)
 {
     CodeGenerator.ApplyTemplate(cls, sb, "\npublic class {Type}Meta\n{\n\tprivate MetadataClass FClass;\n");
     for (int index = 0; index < cls.Properties.Count; ++index)
     {
         MetadataProperty property = cls.Properties[index];
         if (!property.IsSelector && !property.IsId)
         {
             sb.AppendFormat("\tprivate MetadataProperty F{0};\n\tpublic MetadataProperty {0} {{ get {{ if(F{0} == null) {{ F{0} = FClass.Properties.Need(\"{1}\"); }} return F{0}; }} }}\n", (object)property.MemberName, (object)property.Name);
         }
     }
     for (int index = 0; index < cls.Childs.Count; ++index)
     {
         sb.AppendFormat("\tprivate MetadataChildRef F{0};\n\tpublic MetadataChildRef {0} {{ get {{ if(F{0} == null) {{ F{0} = FClass.Childs.Need(\"{1}\"); }} return F{0}; }} }}\n", (object)cls.Childs[index].MemberName, (object)cls.Childs[index].ChildClass.Name);
     }
     CodeGenerator.ApplyTemplate(cls, sb, "\tpublic {Type}Meta(MetadataClass cls) { FClass = cls; }\n");
     sb.Append("}\n");
 }
Exemple #26
0
 internal void Load(IDataReader reader, DataObjectList dstObjs, LoadContext loadContext)
 {
     object[] values = new object[reader.FieldCount];
     while (reader.Read())
     {
         reader.GetValues(values);
         DataId id = new DataId((string)values[0]);
         if (this.LoadedObjects[(object)id] == null)
         {
             DataObject dataObject = this.FStorage.EnsureCacheItem(id);
             if (!dataObject.IsDeleted)
             {
                 int index = 0;
                 int num   = 1;
                 for (; index < this.ObjectLoader.Count; ++index)
                 {
                     ObjectPartLoader objectPartLoader = this.ObjectLoader[index];
                     object           obj     = objectPartLoader.FieldName != null ? values[num++] : (object)null;
                     object           exValue = objectPartLoader.ExFieldName != null ? values[num++] : (object)null;
                     objectPartLoader.Load(dataObject, obj, exValue, loadContext);
                 }
                 dstObjs?.Add((object)dataObject);
             }
             this.LoadedObjects.Add((object)dataObject.Id, (object)dataObject);
             dataObject.IncludeSessionState(ObjectSessionState.Existing);
         }
     }
     if (loadContext != LoadContext.FetchAllObjects)
     {
         return;
     }
     for (int index1 = 0; index1 < this.ObjectLoader.Count; ++index1)
     {
         if (this.ObjectLoader[index1] is LinkPropertyLoader linkPropertyLoader && linkPropertyLoader.Association.Property.IsAggregation)
         {
             for (int index2 = 0; index2 < linkPropertyLoader.RefLoaders.Length; ++index2)
             {
                 MetadataClass cls = linkPropertyLoader.RefLoaders[index2].Class;
                 this.FStorage.Session[cls].CompleteChildLists(cls.Childs.Need(this.Class));
             }
         }
     }
 }
        public void GenerateClasses(MetadataClassList classes, StringBuilder sb)
        {
            Hashtable hashtable = new Hashtable();

            for (int index = 0; index < classes.Count; ++index)
            {
                MetadataClass metadataClass = classes[index];
                ArrayList     arrayList     = (ArrayList)hashtable[(object)metadataClass.TypeNamespace];
                if (arrayList == null)
                {
                    arrayList = new ArrayList();
                    hashtable[(object)metadataClass.TypeNamespace] = (object)arrayList;
                }
                arrayList.Add((object)metadataClass);
            }
            foreach (string key in (IEnumerable)hashtable.Keys)
            {
                if (key.Trim().Length > 0)
                {
                    sb.Append("namespace ").Append(key).Append("{\n");
                }
                foreach (MetadataClass cls in (ArrayList)hashtable[(object)key])
                {
                    this.GenerateMeta(cls, sb);
                    if ((this.Options & CodeGeneratorOptions.GenerateConditionBuilder) != (CodeGeneratorOptions)0)
                    {
                        this.GenerateConditionBuilder(cls, sb);
                    }
                    this.GenerateClass(cls, sb);
                    this.GenerateIList(cls, sb);
                    this.GenerateList(cls, sb);
                    this.GenerateChildList(cls, sb);
                    this.GenerateLinkProperty(cls, sb);
                    this.GenerateStorage(cls, sb);
                }
                if (key.Trim().Length > 0)
                {
                    sb.Append("}\n");
                }
            }
        }
Exemple #28
0
            public void RegisterIdentifier(
                string ident,
                out SqlUtils.NavigationStep step,
                out MetadataProperty prop)
            {
                int    length = ident.LastIndexOf('.');
                string name;

                if (length >= 0)
                {
                    step = this.EnsureRootStep(ident.Substring(0, length));
                    name = ident.Substring(length + 1);
                }
                else
                {
                    step = (SqlUtils.NavigationStep)null;
                    name = ident;
                }
                MetadataClass metadataClass = step != null ? step.TargetClass : this.Class;

                prop = metadataClass.Properties.Find(name);
            }
Exemple #29
0
        public static Navigator[] ParseNavigation(MetadataClass sourceClass, string navigation)
        {
            List <Navigator> navigatorList = new List <Navigator>();

            foreach (SqlUtils.NavigationPathItem navigationPathItem in SqlUtils.NavigationPathItem.Parse(sourceClass.Metadata.Classes, navigation))
            {
                switch (navigationPathItem.Through)
                {
                case SqlUtils.NavigationThrough.Link:
                    navigatorList.Add((Navigator) new AssociationNavigator(navigationPathItem.Name, navigationPathItem.RefClass));
                    break;

                case SqlUtils.NavigationThrough.Child:
                    navigatorList.Add((Navigator) new ChildRefNavigator(navigationPathItem.RefClass));
                    break;

                case SqlUtils.NavigationThrough.ExternalLink:
                    navigatorList.Add((Navigator) new ExternalLinkNavigator(navigationPathItem.RefClass.Properties.Need(navigationPathItem.Name).Association ?? throw new Exception(string.Format("Ошибка в навигационном пути \"{0}\": свойство \"{1}\" класса \"{2}\", используемое в навигации по обратной ссылке, не является ассоциацией.", (object)navigation, (object)navigationPathItem.Name, (object)navigationPathItem.RefClass.Name))));
                    break;
                }
            }
            return(navigatorList.ToArray());
        }
Exemple #30
0
 public ChildRefNavigator(MetadataClass childClass) => this.FChildClass = childClass;