Ejemplo n.º 1
0
        private static void LoadServices()
        {
            if (services == null)
            {
                services = new List <ICppCompilerService>();
                AppDomain.CurrentDomain.GetAssemblies().ParallelFor((assembly) =>
                {
                    foreach (Type service in assembly.GetTypes <ICppCompilerService>())
                    {
                        try
                        {
                            ICppCompilerService instance; if (service.IsAbstract && MixinType.IsAssignableFrom(service))
                            {
                                instance = MixinManager.Create(service) as ICppCompilerService;
                            }
                            else if (!service.IsAbstract)
                            {
                                instance = service.CreateInstance <ICppCompilerService>();
                            }
                            else
                            {
                                continue;
                            }

                            if (instance != null)
                            {
                                services.Add(instance);
                            }
                        }
                        catch
                        { }
                    }
                });
            }
        }
Ejemplo n.º 2
0
        public static void DisplayManual()
        {
            Application.Log(SeverityFlags.None, "Forge {0}, distributed under the Schroedinger Entertainment EULA (See EULA.md for details)", Application.Version);

            StorageDescriptor mixinCache = new StorageDescriptor(Application.CacheDirectory, ModuleCacheFileName);

            if (mixinCache.Load() && mixinCache.Nodes.Count > 0)
            {
                Application.Log(SeverityFlags.None, "Loaded {0} Mixin(s) from root", mixinCache.Nodes.Count - 1);
                foreach (StorageContainer mixin in mixinCache.Nodes.Values)
                {
                    if (mixin.Tag == 0)
                    {
                        Application.Log(SeverityFlags.None, "  {0}", mixin.Element.GetRelativePath(Application.SdkDirectory));
                    }
                }
            }
            mixinCache = null;

            Application.Log(SeverityFlags.None, "Loaded {0} Plugin(s) from root", plugins.Count);
            foreach (Plugin plugin in plugins)
            {
                Application.Log(SeverityFlags.None, "  {0}", plugin.Path.GetRelativePath(Application.SdkDirectory));
            }

            Application.Log(SeverityFlags.None, string.Empty);

            PageFormatter page = new PageFormatter();

            AutoConfig.GetAttributePage <Application>(page);
            page.Sort();

            PageFormatter subPage = new PageFormatter();

            AutoConfig.GetAttributePage(Application.Profile.GetType(), subPage);
            AutoConfig.GetAttributePage(Application.Profile, subPage);
            subPage.Sort();

            if (subPage.Rows.Count > 0)
            {
                page.AddRow("");
                page.AddRow(string.Format("{0} Profile", Application.Profile.Name.ToTitleCase()));
                page.Rows.AddRange(subPage.Rows);
            }

            Dictionary <string, PageFormatter> subSystems = new Dictionary <string, PageFormatter>();

            AppDomain.CurrentDomain.GetAssemblies().ParallelFor((assembly) =>
            {
                foreach (Type receiver in assembly.GetTypes <IConfigReceiver>())
                {
                    try
                    {
                        PageFormatter systemPage = new PageFormatter();
                        AutoConfig.GetAttributePage(receiver, systemPage);

                        IConfigReceiver instance; if (receiver.IsAbstract && MixinType.IsAssignableFrom(receiver))
                        {
                            instance = MixinManager.Create(receiver) as IConfigReceiver;
                        }
                        else if (!receiver.IsAbstract)
                        {
                            instance = receiver.CreateInstance <IConfigReceiver>();
                        }
                        else
                        {
                            continue;
                        }

                        if (instance != null && instance.Display)
                        {
                            instance.GetAdditionalManualInfo(systemPage);
                            if (systemPage.Rows.Count > 0)
                            {
                                lock (subSystems)
                                {
                                    PageFormatter tmp; if (subSystems.TryGetValue(instance.DisplayName, out tmp))
                                    {
                                        tmp.AddRows(systemPage.Rows);
                                    }
                                    else
                                    {
                                        subSystems.Add(instance.DisplayName, systemPage);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    { }
                }
            });
            foreach (KeyValuePair <string, PageFormatter> systems in subSystems.OrderBy(x => x.Key))
            {
                systems.Value.Sort();

                page.AddRow("");
                page.AddRow(string.Format("{0} System", systems.Key));
                page.Rows.AddRange(systems.Value.Rows);
            }
            foreach (Plugin plugin in plugins)
            {
                subPage = new PageFormatter();
                plugin.GetManualPage(subPage);
                subPage.Sort();

                if (subPage.Rows.Count > 0)
                {
                    page.AddRow("");
                    page.AddRow(string.Format("{0} Plugin", plugin.Path.Name.ToTitleCase()));
                    page.Rows.AddRange(subPage.Rows);
                }
            }

            Application.Log(SeverityFlags.None, page.ToString());
        }