Пример #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 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);
            }
        }