Exemple #1
0
        // Словарь модели
        public string GenClassesDic(MEDMProject mr)
        {
            _ = $"#region Словарь";
            foreach (MEDMClass mc in mr.Classes)
            {
                if (mc.Type == MEDMClassType.MODELCLASS || mc.Type == MEDMClassType.CLASS || mc.Type == MEDMClassType.CFG)
                {
                    _ = $"#region [{mc.Name}] {mc.Header}";
                    if (mc.Type == MEDMClassType.CFG)
                    {
                        _ = $"private static MEDMObjectDic _{mc.Name}Dic = null;";
                    }
                    else
                    {
                        _ = $"private MEDMObjectDic _{mc.Name}Dic = null;";
                    }
                    _ = $"public MEDMObjectDic {mc.Name}Dic";
                    _ = $"{{";
                    _ = $"get";
                    _ = $"{{";
                    _ = $"if (_{mc.Name}Dic == null) _{mc.Name}Dic = new MEDMObjectDic(this, typeof({mc.Name}));";
                    _ = $"if (!MainDic.ContainsKey(typeof({mc.Name}))) MainDic[typeof({mc.Name})] = _{mc.Name}Dic;";
                    _ = $"return _{mc.Name}Dic;";
                    _ = $"}}";
                    _ = $"}}";
                    _ = $"#endregion";
                }
            }
            _ = $"#endregion";

            return(Result.ToString());
        }
Exemple #2
0
        // Генерация классов

        // Генерация модели
        public string GenClasses(MEDMProject mr)
        {
            Result.Clear();
            _ = $"//--------------------------------------------------------------------------------";
            _ = $"// MBuilder3X Генератор модели данных (классы)                ({DateTime.Now})";
            _ = $"//--------------------------------------------------------------------------------";

            _ = $"using System;";
            _ = $"using MEDMCoreLibrary;";
            _ = $"using System.Collections.Generic;";

            _ = $"#region [{mr.Name}] {mr.Header}";
            _ = $"namespace Models.{mr.Name}";
            _ = $"{{";
            _ = $"public partial class {mr.Name} : MEDMSql";
            _ = $"{{";
            GenClassesConstructor(mr);
            GenClassesDic(mr);
            _ = $"}}";
            foreach (MEDMClass mc in mr.Classes)
            {
                GenClassesClass(mc);
            }
            _ = $"}}";
            _ = $"#endregion";

            return(Result.ToString());
        }
Exemple #3
0
        // Конструктор модели
        public string GenClassesConstructor(MEDMProject mr)
        {
            _ = $"#region Конструктор";
            _ = $"public {mr.Name}()";
            _ = $"{{";
            foreach (MEDMClass mc in mr.Classes)
            {
                if (mc.Type == MEDMClassType.MODELCLASS || mc.Type == MEDMClassType.CLASS || mc.Type == MEDMClassType.CFG)
                {
                    _ = $"{mc.Name}Dic.FindObj(null);";
                }
            }
            _ = $"}}";
            _ = $"#endregion";

            return(Result.ToString());
        }
Exemple #4
0
        public void Load(XmlDocument xdoc)
        {
            LoadStandart();

            foreach (XmlNode xproject in xdoc.SelectNodes("descendant::project"))
            {
                MEDMProject pr = Load <MEDMProject>(xproject);
                foreach (XmlNode xclass in xproject.SelectNodes("descendant::class"))
                {
                    MEDMClass c = Load <MEDMClass>(xclass);
                    pr.Classes.Add(c);
                    foreach (XmlNode xprop in xclass.SelectNodes("descendant::prop"))
                    {
                        MEDMProp p = Load <MEDMProp>(xprop, c.Name);
                        c.Props.Add(p);
                    }
                }
            }
        }