示例#1
0
        public static IModType IdentifyModType(string dllRoot)
        {
            var interfaceType = typeof(IModType);
            var types         = Assembly.GetExecutingAssembly().GetTypes()
                                .Where(p => interfaceType.IsAssignableFrom(p) &&
                                       p.FullName != "VortexHarmonyInstaller.IModType");

            UnityContainer container = new UnityContainer();

            foreach (Type type in types)
            {
                try
                {
                    container.RegisterType(typeof(IModType), type);
                    IModType modType = container.Resolve(type) as IModType;
                    if (modType.ParseModData(dllRoot))
                    {
                        return(modType);
                    }
                }
                catch (Exception exc)
                {
                    Logger.Error("Unable to parse mod data", exc);
                    continue;
                }
            }

            return(null);
        }
        public static IModType IdentifyModType(string dllRoot)
        {
            var interfaceType = typeof(IModType);
            var types         = AppDomain.CurrentDomain.GetAssemblies()
                                .SelectMany(s => s.GetTypes())
                                .Where(p => interfaceType.IsAssignableFrom(p) &&
                                       p.FullName != "VortexHarmonyInstaller.IModType");

            UnityContainer container = new UnityContainer();

            foreach (Type type in types)
            {
                container.RegisterType(typeof(IModType), type);
                IModType modType = container.Resolve(type) as IModType;
                if (modType.ParseModData(dllRoot))
                {
                    return(modType);
                }
            }

            return(null);
        }