AcManager.Tools.Starters.ModuleStarter.InstallModule C# (CSharp) Method

InstallModule() private static method

private static InstallModule ( ) : bool
return bool
        private static bool InstallModule() {
            try {
                var ini = new IniFile(Path.Combine(FileUtils.GetDocumentsCfgDirectory(), "launcher.ini"));
                var theme = ini["WINDOW"].GetNonEmpty("theme");
                var directory = Path.Combine(AcRootDirectory.Instance.RequireValue, @"launcher", @"themes", theme ?? @"default", @"modules", ModuleId);

                var installed = false;
                if (!Directory.Exists(directory)) {
                    Directory.CreateDirectory(directory);

                    using (var stream = new MemoryStream(BinaryResources.ModuleCmHelper))
                    using (var archive = new ZipArchive(stream)) {
                        archive.ExtractToDirectory(directory);
                    }

                    installed = true;
                }

                var active = ini["MODULES"].GetStrings("ACTIVE");
                if (!active.Contains(ModuleId)) {
                    ini["MODULES"].Set("ACTIVE", active.Append(@"CmHelper").Distinct());
                    ini.Save();
                    installed = true;
                }

                return installed;
            } catch (Exception e) {
                throw new InformativeException("Can’t install UI module", e);
            }
        }