示例#1
0
        internal static IEnumerable <IPackItem> GetItems(Type type, XElement config)
        {
            var manager = ItemManagerCache.GetItemManager(type);

            if (manager != null)
            {
                var results = manager.GetItems(type, config);
                foreach (var result in results)
                {
                    yield return(result);
                }
            }
            else
            {
                var method = type.GetMethod("GetItems",
                                            BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static,
                                            null,
                                            CallingConventions.Any,
                                            new Type[] { typeof(Type), typeof(XElement) },
                                            null
                                            );

                if (method == null)
                {
                    LoggingService.LogError("Type {0} doesnot have static methos GetItems", type.FullName);
                    yield break;
                }
                var results = (IEnumerable <IPackItem>)method.Invoke(Type.Missing, new object[] { type, config });
                foreach (var result in results)
                {
                    yield return(result);
                }
            }
        }
示例#2
0
        public static ItemInfo GetItemInfo(int pollId, int id)
        {
            var entries = ItemManagerCache.GetAllItemInfoList(pollId);

            var entry = entries.FirstOrDefault(x => x.Value != null && x.Value.Id == id);

            return(entry.IsDefault() ? null : (ItemInfo)entry.Value.Clone());
        }
示例#3
0
        public static IPackItem GetPackageCreatorItem(string category, string name)
        {
            var type = CategoryTypes.Where(d => d.Key.Name == category).Select(d => d.Value).First();

            var manager = ItemManagerCache.GetItemManager(type);

            if (manager != null)
            {
                return(manager.GetItem(type, name));
            }
            else
            {
                var result = Activator.CreateInstance(type, new object[] { name });
                return((IPackItem)result);
            }
        }
示例#4
0
        public static List <ItemInfo> GetItemInfoList(int pollId)
        {
            var fieldInfoList = new List <ItemInfo>();

            var entries  = ItemManagerCache.GetAllItemInfoList(pollId);
            var startKey = GetKeyPrefix(pollId);
            var list     = entries.Where(tuple => tuple.Key.StartsWith(startKey)).ToList();

            foreach (var pair in list)
            {
                if (pair.IsDefault())
                {
                    continue;
                }

                fieldInfoList.Add((ItemInfo)pair.Value.Clone());
            }

            return(fieldInfoList.OrderBy(fieldInfo => fieldInfo.Taxis == 0 ? int.MaxValue : fieldInfo.Taxis).ToList());
        }
示例#5
0
 public static void ClearCache(int pollId)
 {
     ItemManagerCache.Clear(pollId);
 }