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); } } }
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()); }
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); } }
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()); }
public static void ClearCache(int pollId) { ItemManagerCache.Clear(pollId); }