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();
     }
 }
Beispiel #2
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;
                }
            }
Beispiel #3
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 void GenerateSession(MetadataClassList classes, StringBuilder sb)
 {
     sb.Append("\npublic class Session: DataSession\n{\n\tpublic Application Application { get { return (InMeta.Application)base.Application; } }\n\tpublic Session(DataApplication application, string authUser): base(application, authUser) { }\n");
     for (int index = 0; index < classes.Count; ++index)
     {
         CodeGenerator.ApplyTemplate(classes[index], sb, "\tprivate {QType}Storage F{SessionMember};\n\tpublic {QType}Storage {SessionMember} { get { if(F{SessionMember} == null) F{SessionMember} = ({QType}Storage)base[\"{Name}\"]; return F{SessionMember}; } }\n");
     }
     sb.Append("\tprotected override DataStorage CreateStorageInstance(MetadataClass cls)\n\t{\n\t\tswitch(cls.Name)\n\t\t{\n");
     for (int index = 0; index < classes.Count; ++index)
     {
         CodeGenerator.ApplyTemplate(classes[index], sb, "\t\t\tcase \"{Name}\": return new {QType}Storage(this, cls);\n");
     }
     sb.Append("\t\t\tdefault: return base.CreateStorageInstance(cls);\n\t\t}\n\t}\n}\n");
 }
Beispiel #5
0
            public static SqlUtils.NavigationPathItem[] Parse(
                MetadataClassList classes,
                string path)
            {
                List <SqlUtils.NavigationPathItem> navigationPathItemList = new List <SqlUtils.NavigationPathItem>();
                int num;

                for (int startIndex = 0; startIndex < path.Length; startIndex = num + 1)
                {
                    num = path.IndexOf('.', startIndex);
                    if (num < 0)
                    {
                        num = path.Length;
                    }
                    navigationPathItemList.Add(SqlUtils.NavigationPathItem.ParseItem(classes, path.Substring(startIndex, num - startIndex)));
                }
                return(navigationPathItemList.ToArray());
            }
        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");
                }
            }
        }