Пример #1
0
        /// <summary>
        /// 由给出的编码列表获取枚举字典列表
        /// </summary>
        /// <returns></returns>
        public static EasyDictionary <string, EasyDictionary> GetEnumDicts(params string[] codes)
        {
            EasyDictionary <string, EasyDictionary> rtndict = new EasyDictionary <string, EasyDictionary>();

            SysEnumeration[] tents = SysEnumeration.FindAll(Expression.In(SysEnumeration.Prop_Code, codes));
            string[]         pids  = tents.Select(tent => tent.EnumerationID).ToArray();

            IEnumerable <SysEnumeration> subents = SysEnumeration.FindAll(Expression.In(SysEnumeration.Prop_ParentID, pids));

            subents = subents.OrderBy(tsubtent => tsubtent.SortIndex).ThenBy(tsubtent => tsubtent.CreatedDate);

            foreach (SysEnumeration tent in tents)
            {
                EasyDictionary dict = new EasyDictionary();

                IEnumerable <SysEnumeration> tsubents = subents.Where(ttent => ttent.ParentID == tent.EnumerationID);
                foreach (SysEnumeration tsubent in tsubents)
                {
                    dict.Set(tsubent.Value, tsubent.Name);
                }

                rtndict.Set(tent.Code, dict);
            }

            return(rtndict);
        }
Пример #2
0
        /// <summary>
        /// 由编码获取Enumeration字典
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static EasyDictionary <string, SysEnumeration> Get(params string[] codes)
        {
            EasyDictionary <string, SysEnumeration> enums = new EasyDictionary <string, SysEnumeration>();

            IEnumerable <SysEnumeration> tents = SysEnumeration.FindAll(Expression.In(SysEnumeration.Prop_Code, codes));

            tents = tents.OrderBy(tent => tent.SortIndex).ThenBy(tent => tent.CreatedDate);

            foreach (SysEnumeration tent in tents)
            {
                enums.Set(tent.Code, tent);
            }

            return(enums);
        }
Пример #3
0
        public static IList <EasyDictionary> DataTableToDictList(DataTable dt)
        {
            IList <EasyDictionary> list = new List <EasyDictionary>();

            foreach (DataRow row in dt.Rows)
            {
                EasyDictionary item = new EasyDictionary();
                foreach (DataColumn column in dt.Columns)
                {
                    item.Set(column.ColumnName, row[column]);
                }
                list.Add(item);
            }
            return(list);
        }
Пример #4
0
        /// <summary>
        /// 由enums列表获取Enum字典
        /// </summary>
        /// <param name="enums"></param>
        /// <returns></returns>
        public static EasyDictionary GetEnumDict(IEnumerable <SysEnumeration> enums)
        {
            EasyDictionary dict = new EasyDictionary();

            IEnumerable <SysEnumeration> tenums = null;

            if (enums is IOrderedEnumerable <SysEnumeration> )
            {
                tenums = enums;
            }
            else
            {
                tenums = enums.OrderBy(tent => tent.SortIndex).ThenBy(tent => tent.CreatedDate);
            }

            foreach (SysEnumeration item in tenums)
            {
                dict.Set(item.Value, item.Name);
            }

            return(dict);
        }
        public static string Serialize(this IEntity entity, HashSet <Type> includedTypes = null, HashSet <Type> ignoredTypes = null)
        {
            var writer = new EasyDictionary <string, EasyObject>();

            foreach (var component in entity.Components)
            {
                var type = component.GetType();
                if (includedTypes != null && !includedTypes.Contains(type))
                {
                    continue;
                }
                if (type.ShouldIgnore(ignoredTypes))
                {
                    continue;
                }
                writer.Set(type.ToString(), component, type);
            }

#if UNITY_EDITOR
            return(JsonUtility.ToJson(writer, true));
#else
            return(JsonUtility.ToJson(writer));
#endif
        }