Ejemplo n.º 1
0
 /// <summary>
 /// 获取当前对象直系名称集合
 /// </summary>
 /// <returns></returns>
 public IEnumerable <string> GetNames()
 {
     return(_root.GetEntities().Select((e) =>
     {
         return e.Name;
     }));
 }
Ejemplo n.º 2
0
        private List <TypeEntry> Parse(DTEObject root)
        {
            List <TypeEntry> entries = new List <TypeEntry>();

            var entities = root.GetEntities();

            foreach (var entity in entities)
            {
                var value = entity as DTEValue;
                if (value != null)
                {
                    entries.Add(CreateEntry(value));
                    continue;
                }

                var obj = entity as DTEObject;
                if (obj != null)
                {
                    entries.Add(CreateEntry(obj));
                    continue;
                }

                var list = entity as DTEList;
                if (list != null)
                {
                    entries.Add(CreateEntry(list));
                    continue;
                }
            }

            return(entries);
        }
Ejemplo n.º 3
0
        private static bool ContainsSchemaCode(DTEObject source, DTEObject target)
        {
            var es = target.GetEntities();

            foreach (var e in es)
            {
                var se = source.Find(e.Name);
                if (se == null)
                {
                    return(false);            //源中没有找到成员
                }
                var obj = e as DTEObject;
                if (obj != null)
                {
                    //对比子项
                    var sObj = se as DTEObject;
                    if (sObj == null)
                    {
                        return(false);              //类型不同
                    }
                    if (!ContainsSchemaCode(sObj, obj))
                    {
                        return(false);
                    }
                }
                else
                {
                    var list = e as DTEList;
                    if (list != null)
                    {
                        //对比子项
                        var sList = se as DTEList;
                        if (sList == null)
                        {
                            return(false);               //类型不同
                        }
                        if (!list.ItemTemplate.ContainsSchemaCode(sList.ItemTemplate))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }