Esempio n. 1
0
        private static void Main(params string[] args)
        {
            //Prepare
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            addOns = new AddOnFactoryManager();

            //Check
            if (!Directory.Exists(AbideRegistry.AddOnsDirectory))
            {
                Directory.CreateDirectory(AbideRegistry.AddOnsDirectory);
            }

            //Load Update Manifset
            XmlDocument updateManifestDocument = new XmlDocument();

            try { updateManifestDocument.Load(manifestUrl); }
            catch { updateManifestDocument = null; }
            if (updateManifestDocument != null)
            {
                updateManifest = new UpdateManifest(updateManifestDocument);
            }

            //Load AddOns
            AddOnManifest manifest = new AddOnManifest();

            foreach (string directory in Directory.EnumerateDirectories(AbideRegistry.AddOnsDirectory))
            {
                //Get Manifest Path
                if (File.Exists(Path.Combine(directory, "Manifest.xml")))
                {
                    //Load Manifest
                    manifest.LoadXml(Path.Combine(directory, "Manifest.xml"));

                    //Load
                    string assemblyPath = Path.Combine(directory, manifest.PrimaryAssemblyFile);
                    if (File.Exists(assemblyPath))
                    {
                        addOnAssemblies.Add(assemblyPath);
                    }
                }
            }

            //Handle Arguments
            if (Main_HandleArguments(args))
            {
                Main_Continue();
            }
        }
Esempio n. 2
0
        private static void Main_Continue()
        {
            //Prepare
            AddOnInstaller addOnInstaller = null;
            FileInfo       info           = null;

            //Loop through files
            foreach (string filename in files)
            {
                //Initialize
                info = new FileInfo(filename);
                if (info.Extension == ".aao")    //Check Extension
                {
                    //Prepare...
                    AddOnPackageFile package = new AddOnPackageFile();
                    package.DecompressData += Package_DecompressData;

                    //Load
                    try { package.Load(filename); } catch { }

                    //Extract
                    try
                    {
                        if (package.Entries.Count > 0 && package.Entries.ContainsFilename("Manifest.xml"))
                        {
                            //Create?
                            if (addOnInstaller == null)
                            {
                                addOnInstaller = new AddOnInstaller();
                            }

                            //Load Manifest
                            AddOnManifest manifest = new AddOnManifest();
                            manifest.LoadXml(package.LoadFile("Manifest.xml"));

                            //Add
                            addOnInstaller.AddPackage(package, manifest);
                        }
                    }
                    catch (Exception) { }
                }
            }

            //Check...
            if (addOnInstaller != null)
            {
                mainForm = addOnInstaller;
            }
            else
            {
                foreach (string assembly in addOnAssemblies)
                {
                    if (safeMode)
                    {
                        addOns.AddAssemblySafe(assembly);
                    }
                    else
                    {
                        addOns.AddAssembly(assembly);
                    }
                }
            }

            //Check Main Form
            if (mainForm == null)
            {
                mainForm = new Main();
            }

            //Run Main App
            Application.Run(mainForm);
        }