internal void CheckTypedefEnd(CommandStatus status, Exception ex, List <TypedefItem> items)
 {
     if (status == CommandStatus.Succeed)
     {
         TypedefItems.AddRange(items);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 加入实体
 /// </summary>
 /// <param name="api"></param>
 public void Add(TypedefItem api)
 {
     api.Parent = this;
     if (!TypedefItems.Contains(api))
     {
         TypedefItems.Add(api);
     }
 }
Esempio n. 3
0
        public void SaveTypedefs(string dir, ConfigWriter write)
        {
            var path = GlobalConfig.CheckPath(dir, "Typedef");

            foreach (var type in TypedefItems.ToArray())
            {
                SaveTypedef(write, type, path);
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     通过标签查找类型定义对象
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public TypedefItem GetTypedefByTag(string tag)
        {
            if (string.IsNullOrWhiteSpace(tag))
            {
                return(null);
            }
            var array = tag.Split(',');

            if (array.Length != 2)
            {
                return(null);
            }
            return(TypedefItems.FirstOrDefault(p => p.Option.ReferenceTag == array[0] && p.Name == array[1]));
        }
 /// <summary>
 /// 重置全局对象
 /// </summary>
 public static void ResetGloblaCollection()
 {
     Entities.Clear();
     Projects.Clear();
     Enums.Clear();
     TypedefItems.Clear();
     NotifyItems.Clear();
     ApiItems.Clear();
     foreach (var solution in Solutions)
     {
         var model = new SolutionModel
         {
             Solution = solution
         };
         model.OnSolutionLoad();
     }
 }
        /// <summary>
        /// 载入处理
        /// </summary>
        public void OnSolutionLoad()
        {
            if (!Solutions.Contains(Solution))
            {
                Solutions.Add(Solution);
            }
            Entities.AddRange(Solution.Entities);
            Projects.AddRange(Solution.Projects);
            Enums.AddRange(Solution.Enums);
            TypedefItems.AddRange(Solution.TypedefItems);
            NotifyItems.AddRange(Solution.NotifyItems);
            ApiItems.AddRange(Solution.ApiItems);

            Solution.Entities.CollectionChanged     += (s, e) => CollectionChanged(Entities, e);
            Solution.Projects.CollectionChanged     += (s, e) => CollectionChanged(Projects, e);
            Solution.Enums.CollectionChanged        += (s, e) => CollectionChanged(Projects, e);
            Solution.TypedefItems.CollectionChanged += (s, e) => CollectionChanged(TypedefItems, e);
            Solution.ApiItems.CollectionChanged     += (s, e) => CollectionChanged(Projects, e);
            Solution.NotifyItems.CollectionChanged  += (s, e) => CollectionChanged(Projects, e);
        }
Esempio n. 7
0
 /// <summary>
 /// 加入实体
 /// </summary>
 /// <param name="api"></param>
 public void Remove(TypedefItem api)
 {
     api.Parent = this;
     TypedefItems.Remove(api);
 }
Esempio n. 8
0
 /// <summary>
 ///     取得类型定义对象
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public TypedefItem GetTypedef(Guid key)
 {
     return(TypedefItems.FirstOrDefault(p => p.Key == key));
 }
Esempio n. 9
0
 /// <summary>
 ///     取得类型定义对象
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public TypedefItem GetTypedef(string name)
 {
     return(TypedefItems.FirstOrDefault(p => p.Name == name));
 }
Esempio n. 10
0
 /// <summary>
 ///     查找类型定义对象
 /// </summary>
 /// <param name="func"></param>
 /// <returns></returns>
 public TypedefItem Find(Func <TypedefItem, bool> func)
 {
     return(TypedefItems.FirstOrDefault(func));
 }
 private TypedefItem FindTypedef(string name)
 {
     return(SolutionConfig.Current.TypedefItems.FirstOrDefault(p => p.Name == name) ?? TypedefItems.FirstOrDefault(p => p.Name == name));
 }
        public List <EntityConfig> CheckCppFieldes(string text)
        {
            List <EntityConfig> tables = new List <EntityConfig>();

            string[]     lines      = text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            int          idx        = 0;
            EntityConfig entity     = new EntityConfig();
            bool         isNewTable = true;
            bool         isInStruct = false;

            foreach (string l in lines)
            {
                if (string.IsNullOrEmpty(l))
                {
                    continue;
                }
                var line = l.Trim(' ', '\t', ';');
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                switch (line)
                {
                case "{":
                    isInStruct = true;
                    continue;

                case "}":
                    isNewTable = true;
                    isInStruct = false;
                    entity     = new EntityConfig();
                    continue;
                }
                if (line.IndexOf("//", StringComparison.Ordinal) == 0) //注释
                {
                    if (isNewTable || line.Contains("//!"))
                    {
                        entity.Caption = line.Trim(CoderBase.NoneLanguageChar);
                        isNewTable     = false;
                    }
                    else
                    {
                        entity.Description = line.Trim(CoderBase.NoneLanguageChar);
                    }
                    continue;
                }
                string[] words = line.Split(new[] { ' ', ';', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                switch (words[0])
                {
                case "typedef":
                    var item = new TypedefItem
                    {
                        Tag = SystemName
                    };
                    var i = l.IndexOf('[');
                    if (i < 0)
                    {
                        item.Name = words[words.Length - 1];
                    }
                    else
                    {
                        var ks = l.Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
                        item.ArrayLen = ks[1];
                        words         = ks[0].Split(new[] { '\t', ' ', ';', '=' }, StringSplitOptions.RemoveEmptyEntries);
                    }
                    item.Description = entity.Caption;
                    item.Name        = words[words.Length - 1].Trim(CoderBase.NoneLanguageChar);
                    item.KeyWork     = string.Empty;
                    for (int index = 1; index < words.Length - 1; index++)
                    {
                        item.KeyWork += " " + words[index];
                    }
                    InvokeInUiThread(() => TypedefItems.Add(item));
                    continue;

                case "struct":
                    entity.Name = words[1];
                    if (words.Length > 2)
                    {
                        entity.Caption = words[2].Trim(CoderBase.NoneNameChar);
                    }
                    tables.Add(entity);
                    isInStruct = false;
                    idx        = 0;
                    continue;

                case "private":
                case "protected":
                case "public":
                    continue;
                }
                if (!isInStruct)
                {
                    continue;
                }
                PropertyConfig column;
                entity.Properties.Add(column = new PropertyConfig
                {
                    Index  = idx++,
                    DbType = "nvarchar"
                });
                words = line.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (words.Length > 1)
                {
                    column.Description = column.Caption = words[1].Trim('/', '\t', ' ');
                }

                words = words[0].Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
                if (words.Length > 1)
                {
                    column.Datalen = int.Parse(words[1].Trim('/', '\t', ' '));
                }
                words = words[0].Split(new[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                int nameIdx = words.Length - 1;
                column.Name    = column.ColumnName = words[nameIdx].Trim(CoderBase.NoneLanguageChar);
                column.CppType = "";
                for (int index = 0; index < nameIdx; index++)
                {
                    if (index > 0)
                    {
                        column.CppType += " " + words[index];
                    }
                    else
                    {
                        column.CppType = words[index];
                    }
                }
            }
            foreach (var t in tables)
            {
                t.Parent  = Project;
                t.Tag     = SystemName + "," + t.Name;
                t.CppName = t.Name;
                CoderBase.RepairConfigName(t, true);
                foreach (var pro in t.Properties)
                {
                    pro.Parent  = t;
                    pro.CppName = pro.CppName;
                    CoderBase.RepairConfigName(pro, true);
                    pro.CppLastType = CppTypeHelper.CppLastType(pro.CppType);
                    pro.CsType      = CppTypeHelper.CppTypeToCsType(pro);
                }
                t.IsClass = true;

                //EntityBusinessModel business = new EntityBusinessModel
                //{
                //    Entity = t
                //};
                //t.IsReference = true;
                //business.RepairByModel(true);
                //t.IsReference = false;
            }
            return(tables);
        }
Esempio n. 13
0
 /// <summary>
 ///     查找类型定义对象
 /// </summary>
 /// <param name="func"></param>
 /// <returns></returns>
 public static TypedefItem GetTypedef(Func <TypedefItem, bool> func)
 {
     return(TypedefItems.FirstOrDefault(func));
 }