예제 #1
1
        static public bool SetupConfigSystem(string configFilePath)
        {
            ModManager.ApplicationExit += ModManagerApplicationExit;
            LoggingManager.SendMessage("ConfigManager - Setting up config system...");
            if (!File.Exists(configFilePath))
                LoggingManager.SendMessage("ConfingManager - No plugins.config found, creating one from scratch");

            s_sConfigFilePath = configFilePath;
            FileStream config = null;
            try
            {
                config = File.Open(configFilePath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
                s_pluginsConfig = XmlConfigReader.Read(config);
            }
            catch (Exception e)
            {
                LoggingManager.SendMessage("ConfigManager - Failed to set up config system from file: " + configFilePath);
                LoggingManager.HandleException(e);
                return false;
            }
            finally
            {
                if (config != null)
                    config.Close();
            }
            LoggingManager.SendMessage("ConfigManager - Config system set up successfully!");
            return true;
        }
예제 #2
0
 /// <summary>
 /// Create a IExitHook list from a class names list using the provided configuration and service
 /// </summary>
 /// <param name="hookClassNames"></param>
 /// <param name="settings"></param>
 /// <param name="service"></param>
 public HookRepository(String hookClassNames, XmlConfig.XmlConfig settings, IRunAsService service)
 {
     _hookClassNames = hookClassNames;
     _settings = settings;
     _service = service;
     Reset();
 }
예제 #3
0
        public RunAsService(XmlConfig.XmlConfig settings, HookRepository repository, CommandBuilder builder)
        {
            _repository = repository;
            _builder = builder;
            _settings = settings;

            InitProperties();
        }
예제 #4
0
 protected override void OnBeforeBuild()
 {
     XmlConfig    = ResourceUtil.LoadAsXml(_resourceType, _resourcePath);
     XmlNsManager = new XmlNamespaceManager(XmlConfig.NameTable);
     XmlNsManager.AddNamespace(CONFIG_PREFIX, SMART_SQL_CONFIG_NAMESPACE);
     XmlConfigRoot = XmlConfig.SelectSingleNode($"/{CONFIG_PREFIX}:SmartSqlMapConfig", XmlNsManager);
     if (Logger.IsEnabled(LogLevel.Debug))
     {
         Logger.LogDebug($"XmlConfigBuilder Build ->> ResourceType:[{_resourceType}] , Path :[{_resourcePath}] Starting.");
     }
 }
예제 #5
0
    private XmlConfig loadXmlConfig(string file, XmlConfigMaker c, bool add = true)
    {
        string    fullfile = Path.Combine(m_path, file);
        XmlConfig xml      = c.loadFromFile(fullfile);

        if (xml != null && add)
        {
            m_allRes.Add(file, xml);
        }
        return(xml);
    }
예제 #6
0
        public void TestNewPath()
        {
            Action act = () => XmlConfig.From(@"TestFileNewPath.xml");

            act.Should().NotThrow();

            var config = XmlConfig.From(@"TestFileNewPath.xml");

            config.Write("Ajuste:Prueba", "Valor");

            config.Read("Ajuste:Prueba").Should().Be("Valor");
        }
        public override void OnLevelLoaded(LoadMode mode)
        {
            if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame)
            {
                XmlConfig.SafeLoad();

                Debug.PrintMessage("Successfully loaded mod v" + Debug.GetVersion());
                Debug.PrintMessage("The config file can be found at: " + Path.Combine(DataLocation.applicationBase, "EnhancedBuildingCapacityConfig.xml"));

                Patch.PatchEveryBuildingAI();
            }
        }
예제 #8
0
        private void DoCodeGen(string pdbFile, bool singleFileExport = true, bool compileWithRoslyn = true, bool transformations = true)
        {
            XmlConfig xmlConfig = GetXmlConfig(pdbFile);

            xmlConfig.SingleFileExport           = singleFileExport;
            xmlConfig.GenerateAssemblyWithRoslyn = compileWithRoslyn;
            if (!transformations)
            {
                xmlConfig.Transformations = new XmlTypeTransformation[0];
            }
            DoCodeGen(xmlConfig);
        }
예제 #9
0
    public XmlConfig loadXmlConfig(string file, bool save = true)
    {
        XmlConfigMaker c        = new XmlConfigMaker();
        string         fullfile = Path.Combine(m_path, file);
        XmlConfig      xml      = c.loadFromFile(fullfile);

        if (xml != null && save)
        {
            m_allRes.Add(file, xml);
        }
        return(xml);
    }
예제 #10
0
        private static string SerializeXmlConfig()
        {
            var xmlConfig = new XmlConfig();

            xmlConfig.Settings.Add(new ConfigSetting {
                Name = "Item1", Value = "Value1"
            });
            xmlConfig.Settings.Add(new ConfigSetting {
                Name = "Item2", Value = "Value2"
            });
            return(XmlConfig.Serialize(xmlConfig));
        }
예제 #11
0
        private void Login_Load(object sender, EventArgs e)
        {
            XmlConfig.getInstance().LoadConfig("ServerInfo.xml");

            this.checkBoxSSL.Checked  = (Convert.ToInt32(XmlConfig.getInstance().GetParam("server", "ssl", "1")) > 0);
            this.textBoxServerIP.Text = XmlConfig.getInstance().GetParam("server", "host", "localhost"); // "localhost";
            this.textBoxPort.Text     = XmlConfig.getInstance().GetParam("server", "port", "9443");      //"9443";
            this.textBoxUser.Text     = XmlConfig.getInstance().GetParam("server", "user", "admin");     //"admin";
            this.textBoxPass.Text     = XmlConfig.getInstance().GetParam("server", "pass", "");          //"";

            _reqSession = new WebRequestSession();
        }
예제 #12
0
        public void InitCompiler()
        {
            XmlConfig runSourceConfig = GetRunSourceConfig();

            CompilerManager.Current.Init(runSourceConfig.GetConfigElementExplicit("CompilerConfig"));
            CompilerManager.Current.AddCompiler("CSharp1", () => new CSharp1Compiler());
            CompilerManager.Current.AddCompiler("CSharp5", () => new CSharp5Compiler(CompilerManager.Current.FrameworkDirectories, CompilerManager.Current.MessageFilter));
            CompilerManager.Current.AddCompiler("JScript", () => new JScriptCompiler());
            //_resourceCompiler = new ResourceCompiler(CompilerManager.Current.ResourceCompiler);
            //RunSourceInitEndMethods_v2.TraceRunOnce = runSourceConfig.Get("TraceInitEndOnceMethods").zTryParseAs(false);
            //RunSourceInitEndMethods_v2.TraceRunAlways = runSourceConfig.Get("TraceInitEndAlwaysMethods").zTryParseAs(false);
        }
예제 #13
0
 public XmlConfigBuilder(ResourceType resourceType, string resourcePath, ILoggerFactory loggerFactory = null)
 {
     _resourceType  = resourceType;
     _resourcePath  = resourcePath;
     _loggerFactory = loggerFactory ?? NullLoggerFactory.Instance;
     Logger         = _loggerFactory.CreateLogger <XmlConfigBuilder>();
     XmlConfig      = ResourceUtil.LoadAsXml(resourceType, resourcePath);
     XmlNsManager   = new XmlNamespaceManager(XmlConfig.NameTable);
     XmlNsManager.AddNamespace(CONFIG_PREFIX, SMART_SQL_CONFIG_NAMESPACE);
     XmlConfigRoot  = XmlConfig.SelectSingleNode($"/{CONFIG_PREFIX}:SmartSqlMapConfig", XmlNsManager);
     SmartSqlConfig = new SmartSqlConfig();
 }
예제 #14
0
파일: Parser10.cs 프로젝트: vjmira/fomm
        /// <seealso cref="Parser.GetInstallSteps()" />
        public override IList <InstallStep> GetInstallSteps()
        {
            var xndGroups = XmlConfig.SelectSingleNode("/config/optionalFileGroups");
            var lstGroups = loadGroupedPlugins(xndGroups);
            var lstSteps  = new List <InstallStep>();

            if (lstGroups.Count > 0)
            {
                lstSteps.Add(new InstallStep(null, null, lstGroups));
            }
            return(lstSteps);
        }
예제 #15
0
        public void InvalidFileTransfer()
        {
            var    iniCio = IniConfig.From("TestFile.ini");
            Action act    = () => iniCio.TransferTo(HJsonConfig.From("Incorrecto.json"));

            //act.Should().Throw<InvalidFileFormatException>(); New version allows any file format
            act.Should().NotThrow();

            act = () => iniCio.TransferTo(XmlConfig.From("Incorrecto.txt"));

            //act.Should().Throw<InvalidFileFormatException>(); New version allows any file format
            act.Should().NotThrow();
        }
예제 #16
0
        private static DebridLinkFr_v3 CreateDebridLinkFr(XmlConfig config)
        {
            DebridLinkFr_v3 debrider    = new DebridLinkFr_v3();
            XmlConfig       localConfig = config.GetConfig("LocalConfig");

            debrider.Login             = localConfig.GetExplicit("DownloadAutomateManager/DebridLink/Login");
            debrider.Password          = localConfig.GetExplicit("DownloadAutomateManager/DebridLink/Password");
            debrider.PublicKey         = localConfig.GetExplicit("DownloadAutomateManager/DebridLink/PublicKey");
            debrider.ConnexionLifetime = DebridLinkFr_v3.GetConnexionLifetime(localConfig.GetExplicit("DownloadAutomateManager/DebridLink/ConnexionLifetime"));
            debrider.ConnexionFile     = config.GetExplicit("DebridLink/ConnexionFile");
            //debrider.ServerTimeFile = XmlConfig.CurrentConfig.GetExplicit("DebridLink/ServerTimeFile");
            return(debrider);
        }
예제 #17
0
        public Backup()
        {
            gTaskName  = "Backup";
            gTaskTrace = Trace.CurrentTrace;
            gConfig    = new XmlConfig();
            //string sPath = gConfig.Get("Backup/Log");
            //if (sPath != null)
            //    gTaskTrace.SetLogFile(sPath, LogOptions.IndexedFile);
            gTaskTrace.SetWriter(gConfig.Get("Backup/Log"), gConfig.Get("Backup/Log/@option").zTextDeserialize(FileOption.None));

            gTaskProgress       = new Progress();
            gTaskProgressDetail = new Progress();
        }
예제 #18
0
 public XmlConfig GetProjectConfig()
 {
     if (_projectConfig == null && _projectFile != null && zFile.Exists(_projectFile))
     {
         _projectConfig = new XmlConfig(_projectFile);
     }
     else if (_projectConfig != null && _refreshProjectConfig)
     {
         _projectConfig.Refresh();
     }
     _refreshProjectConfig = false;
     return(_projectConfig);
 }
예제 #19
0
        /// <summary>
        /// 获取配置文件(Wbm.TencV2.config)的api节点
        /// </summary>
        /// <param name="cfgApiNodeName">api子节点的Name</param>
        /// <returns></returns>
        public static string GetConfigAPI(string cfgApiNodeName)
        {
            string xpath = CONFIG_ROOT + CONFIG_API + "/" + cfgApiNodeName.Trim('/');

            if (XmlConfig.IsExists(xpath) && !string.IsNullOrEmpty(XmlConfig.SelectSingleNodeText(xpath)))
            {
                return(XmlConfig.SelectSingleNodeText(xpath));
            }
            else
            {
                throw new ArgumentNullException(string.Format("{0}节点:找不到该节点或该值为空", xpath));
            }
        }
예제 #20
0
        private Dictionary <string, string> GetSettings()
        {
            Dictionary <string, string> retVal = new Dictionary <string, string>();

            foreach (XmlAttribute attr in XmlConfig.SelectSingleNode("/autoNode").Attributes)
            {
                retVal.Add(attr.Name, attr.Value);
            }

            _settings = retVal;

            return(retVal);
        }
예제 #21
0
        public void ActivateProfile(Profile profile)
        {
            DefaultProfileId = profile.ProfileId;
            CurrentProfile   = profile;

            foreach (Profile otherProfile in Profiles)
            {
                otherProfile.Active = false;
            }
            profile.Active = true;

            XmlConfig.Save(PROFILES_XML);
        }
예제 #22
0
        public CompilerProjectReader GetProjectCompilerProject()
        {
            XmlConfig config = GetProjectConfig();

            if (config != null)
            {
                return(CompilerProjectReader.Create(GetProjectConfig().GetConfigElementExplicit("/AssemblyProject")));
            }
            else
            {
                return(null);
            }
        }
예제 #23
0
        internal static IEnumerable <string> AllUsers()
        {
            var path = Path.Combine(DressingRoom.AppDirectory, "Vestis");

            path = Path.Combine(path, "GlobalSettings.xml");

            var config = XmlConfig.From(path);

            foreach (var profile in config.SettingsIn("UserProfiles"))
            {
                yield return(profile.Key);
            }
        }
예제 #24
0
        public static QpConnectionInfo GetConnectionInfo(string customerCode, string appName = "QP8Backend")
        {
            if (!String.IsNullOrWhiteSpace(customerCode))
            {
                string       connectionString;
                DatabaseType dbType = default(DatabaseType);
                if (ConfigServiceUrl != null && ConfigServiceToken != null)
                {
                    var service = new CachedQPConfigurationService(ConfigServiceUrl, ConfigServiceToken, Options.QpConfigPollingInterval);

                    var customer = AsyncHelper.RunSync(() => service.GetCustomer(customerCode));

                    // TODO: handle 404

                    if (customer == null)
                    {
                        throw new Exception($"Данный customer code: {customerCode} - отсутствует в конфиге");
                    }

                    connectionString = customer.ConnectionString;
                    dbType           = (DatabaseType)(int)customer.DbType;
                }
                else
                {
                    XElement customerElement = XmlConfig
                                               .Descendants("customer")
                                               .SingleOrDefault(n => n.Attribute("customer_name")?.Value == customerCode);

                    if (customerElement == null)
                    {
                        throw new Exception($"Данный customer code: {customerCode} - отсутствует в конфиге");
                    }

                    connectionString = customerElement.Element("db")?.Value;
                    var dbTypeString = customerElement.Attribute("db_type")?.Value;
                    if (!string.IsNullOrEmpty(dbTypeString) && Enum.TryParse(dbTypeString, true, out DatabaseType parsed))
                    {
                        dbType = parsed;
                    }
                }

                if (!String.IsNullOrEmpty(connectionString))
                {
                    connectionString = TuneConnectionString(connectionString, appName, dbType);
                    return(new QpConnectionInfo(connectionString, dbType));
                }
            }

            return(null);
        }
예제 #25
0
        public override void saveClickData()
        {
            RFCLICK click = new RFCLICK();

            click.tm = Time.DateTime2DbTime(System.DateTime.Now);
            if (0 == g_nRecords)
            {
                click.numJmp = click.contJmp = 1;
                clickPoint.Clear();
                contAndDailyTime.contJumpTime = click.tm;
                XmlConfig.writeContStartTime(contAndDailyTime.contJumpTime.ToString());
                //初始化配置参数
            }
            else
            {
                if (!IsSameWorkDay(click.tm, g_pList[g_nRecords - 1].tm))
                {
                    click.numJmp = 1;
                    contAndDailyTime.numJumpTime = click.tm;
                    XmlConfig.writeDailyStartTime(click.tm.ToString());
                    if (difftime(click.tm, g_pList[g_nRecords - 1].tm) > 24 * 3600)
                    {
                        contAndDailyTime.numJumpTime = click.tm;
                        XmlConfig.writeDailyStartTime(click.tm.ToString());
                        contAndDailyTime.contJumpTime = click.tm;
                        XmlConfig.writeContStartTime(contAndDailyTime.contJumpTime.ToString());
                        click.contJmp = 1;
                        clickPoint.Clear();
                        //清空配置文件
                    }
                    else
                    {
                        click.contJmp = g_pList[g_nRecords - 1].contJmp + 1;
                    }
                }
                else
                {
                    click.numJmp  = g_pList[g_nRecords - 1].numJmp + 1;
                    click.contJmp = g_pList[g_nRecords - 1].contJmp + 1;
                }
            }
            g_pList[g_nRecords].tm      = click.tm;
            g_pList[g_nRecords].numJmp  = click.numJmp;
            g_pList[g_nRecords].contJmp = click.contJmp;
            ++g_nRecords;
            //写入数据库

            CSQLite.G_CSQLite.InertRainToDB(click);
            OneMinuteIsThan40(click.tm);
        }
예제 #26
0
        public static void LoadSettings()
        {
            m_config = new XmlConfig(ConfigPath);
            m_config.AddAssembly(typeof(Settings).Assembly);

            if (!File.Exists(ConfigPath))
            {
                m_config.Create();
            }
            else
            {
                m_config.Load();
            }
        }
예제 #27
0
    public override void initService()
    {
        XmlConfig xml = ResMgr.getInstance().getRes("dbserver.xml");

        m_httpMonitor = xml.getString("httpMonitor", "");

        initState();

        m_orderMgr = new OrderMgr();
        m_orderMgr.init();

        m_threadWork = new Thread(new ThreadStart(run));
        m_threadWork.Start();
    }
예제 #28
0
        public void StartAssemblyResolve()
        {
            XmlConfig config = GetRunSourceConfig();

            if (config != null)
            {
                AssemblyResolve.TraceAssemblyResolve = config.Get("TraceAssemblyResolve").zTryParseAs(false);
                //AssemblyResolve.TraceAssemblyLoad = config.Get("TraceAssemblyLoad").zTryParseAs(false);
                //AssemblyResolve.UpdateAssembly = config.Get("UpdateAssembly").zTryParseAs(false); ;
                //AssemblyResolve.UpdateSubDirectory = config.Get("UpdateAssemblySubDirectory", AssemblyResolve.UpdateSubDirectory); ;
                //AssemblyResolve.TraceUpdateAssembly = config.Get("TraceUpdateAssembly").zTryParseAs(false);
            }
            AssemblyResolve.Start();
        }
예제 #29
0
        public void TestDeleteSectionNewFormat()
        {
            var config = XmlConfig.From(@"TestNewFormat.xml");

            config.Write("SectionToDelete:Key1", "Foo");
            config.Write("SectionToDelete:Key2", "Bar");

            Action act = () => config.DeleteSection("SectionToDelete");

            act.Should().NotThrow();

            config.Read("SectionToDelete:Key1").Should().Be(null);
            config.Read("SectionToDelete:Key2").Should().Be(null);
        }
예제 #30
0
        public void TestSettingsInSectionNewFormat()
        {
            var config = XmlConfig.From(@"TestNewFormat.xml");
            IDictionary <string, string> settings = null;

            Action act = () => settings = config.SettingsIn("Categoria");

            act.Should().NotThrow();

            settings.Should().HaveCountGreaterOrEqualTo(2);
            settings.Should().ContainKeys("SubClave", "Comentada");
            settings.Should().ContainValue("1");
            settings.Should().NotContainKeys("ClaveSinCategoria", "Doble");
        }
        public void PatternConverterProperties()
        {
            XmlDocument log4netConfig = new XmlDocument();

            log4netConfig.LoadXml(@"
                <Soyo.Base.Log>
                  <appender name=""PatternStringAppender"" type=""UnitTest.Base.Log.PatternStringAppender"">
                    <layout type=""Soyo.Base.Text.LayoutLoggerSimple"" />
                    <setting>
                        <converter>
                            <name value=""propertyKeyCount"" />
                            <type value=""UnitTest.Base.Log.PropertyKeyCountPatternConverter"" />
                            <property>
                                <key value=""one-plus-one"" />
                                <value value=""2"" />
                            </property>
                            <property>
                               <key value=""two-plus-two"" />
                               <value value=""4"" />
                            </property> 
                        </converter>
                        <pattern value=""%propertyKeyCount"" />
                    </setting>
                  </appender>
                  <root>
                    <level value=""ALL"" />                  
                    <appender-ref ref=""PatternStringAppender"" />
                  </root>  
                </Soyo.Base.Log>");

            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());

            XmlConfig.Config(rep, log4netConfig["Soyo.Base.Log"]);

            ILog log = LogManager.Get(rep.Name, "PatternConverterProperties");

            log.Debug("Message");

            PropertyKeyCountPatternConverter converter =
                PropertyKeyCountPatternConverter.MostRecentInstance;

            Assert.AreEqual(2, converter.PropertySet.Count);
            Assert.AreEqual("4", converter.PropertySet["two-plus-two"]);

            PatternStringAppender appender =
                (PatternStringAppender)LogManager.GetController(rep.Name).AppenderSet[0];

            Assert.AreEqual("2", appender.Setting.Format());
        }
예제 #32
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RightMgr.getInstance().opCheck("", Session, Response);
            if (!IsPostBack)
            {
                m_queryWay.Items.Add("通过账号查询");
                m_queryWay.Items.Add("通过玩家id查询");

                XmlConfig xml = ResMgr.getInstance().getRes("money_reason.xml");
                if (xml != null)
                {
                    m_filter.Items.Add(new ListItem("全部", "0"));
                    m_filter.Items.Add(new ListItem(xml.getString(36.ToString(), ""), "36"));
                    m_filter.Items.Add(new ListItem(xml.getString(21.ToString(), ""), "21"));

                    /*int i = 1;
                     * for (; i < (int)PropertyReasonType.type_max; i++)
                     * {
                     *  m_filter.Items.Add(xml.getString(i.ToString(), ""));
                     * }*/
                }

                // m_property.Items.Add("全部");
                //m_property.Items.Add("金币");
                // m_property.Items.Add("礼券");

                m_whichGame.Items.Add(new ListItem("全部", ((int)GameId.gameMax).ToString()));

                for (int i = 0; i < StrName.s_gameList.Count; i++)
                {
                    GameInfo info = StrName.s_gameList[i];
                    m_whichGame.Items.Add(new ListItem(info.m_gameName, info.m_gameId.ToString()));
                }

                // m_whichGame.SelectedIndex = m_whichGame.Items.Count - 1;

                if (m_gen.parse(Request))
                {
                    m_param.Text             = m_gen.m_param;
                    m_queryWay.SelectedIndex = m_gen.m_way;
                    __time__.Text            = m_gen.m_time;
                    m_filter.SelectedIndex   = m_gen.m_filter;
                    // m_property.SelectedIndex = m_gen.m_property;
                    // m_range.Text = m_gen.m_range;
                    m_whichGame.SelectedIndex = m_gen.m_gameId;
                    onQuery(null, null);
                }
            }
        }
예제 #33
0
        private static async Task <IHostBuilder> ConfigureServicesAsync(IConfiguration configuration, string[] args)
        {
            var connectionstring = configuration.GetConnectionString("ContractConnectionString");

            // Run with console or service
            var asService = !(Debugger.IsAttached || args.Contains("--console"));

            var builder = new HostBuilder()
                          .ConfigureServices((hostContext, services) =>
            {
                services.AddHostedService <XmlService>();

                var serviceCollection = services.AddDbContext <ContractDbContext>(options =>
                                                                                  options.UseDatabase(SupportedDatabase.SqlServer, connectionstring));

                services.AddSingleton <IContractRepository, ContractRepository>();

                var config = new XmlConfig();
                configuration.GetSection("XmlConfiguration").Bind(config);
                services.AddSingleton(config);

                var serviceProvider = services.BuildServiceProvider();

                using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
                {
                    var contextService = serviceScope.ServiceProvider.GetService <ContractDbContext>();
                    if (contextService.AllMigrationsApplied())
                    {
                        contextService.EnsureMigrated();
                    }
                }
            });

            builder.UseEnvironment(asService ? EnvironmentName.Production :
                                   EnvironmentName.Development);

            if (asService)
            {
                Console.WriteLine("as Service");
                await builder.RunAsServiceAsync();
            }
            else
            {
                Console.WriteLine("as Console");
                await builder.RunConsoleAsync();
            }

            return(builder);
        }
예제 #34
0
        protected override bool Configure(XmlConfig.XmlConfig settings)
        {
            String timesStr = settings.GetItem("restart/times").Value;

            if (!String.IsNullOrEmpty(timesStr))
            {
                if (!Int32.TryParse(timesStr, out _remainingTimes))
                {
                    Log.Warn("Cannot limit the number of restart: the times property is not well defined.");
                    return false;
                }
            }

            return true;
        }
예제 #35
0
 public XmlConfigNode(XmlConfigNode parent, string name)
 {
     _parent = parent;
     _name = name;
     if (parent == null) {
         _fullpath = string.Empty;
         _doc = (this as XmlConfig);
     } else {
         _doc = parent._doc;
         parent._nodes.Add (this);
         if (_parent._fullpath.Length > 0)
             _fullpath = _parent._fullpath + PathSeparatorChar + name;
         else
             _fullpath = name;
     }
 }
예제 #36
0
        public bool Init(XmlConfig.XmlConfig settings, IRunAsService service)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            Service = service;
            Initialized = Configure(settings);
            return Initialized;
        }
예제 #37
0
파일: Program.cs 프로젝트: kazuki/p2pncs
        static void LoadConfig(XmlConfig config, out ECKeyPair privateKey)
        {
            bool saveFlag = false;

            config.Define<int> (CONFIG_BIND_PORT, IntParser.Instance, new IntRangeValidator (1, ushort.MaxValue), 8080);
            config.Define<byte[]> (CONFIG_PRIVATE_KEY, BinaryParser.Instance, null, null);
            config.Define<string> (CONFIG_HOST, StringParser.Instance, null, string.Empty);

            try {
                if (File.Exists (CONFIG_PATH))
                    config.Load (CONFIG_PATH);
            } catch {
                saveFlag = true;
            }

            byte[] raw = config.GetValue<byte[]> (CONFIG_PRIVATE_KEY);
            while (true) {
                if (raw == null || raw.Length == 0) {
                    privateKey = ECKeyPair.Create (DefaultAlgorithm.ECDomainName);
                    config.SetValue<byte[]> (CONFIG_PRIVATE_KEY, privateKey.PrivateKey, false);
                    saveFlag = true;
                } else {
                    privateKey = ECKeyPairExtensions.CreatePrivate (raw);
                    if (privateKey.DomainName != DefaultAlgorithm.ECDomainName) {
                        raw = null;
                        continue;
                    }
                }
                break;
            }

            if (config.GetValue<string> (CONFIG_HOST).Length == 0) {
                config.SetValue<string> (CONFIG_HOST, "localhost", false);
                saveFlag = true;
            }

            if (saveFlag)
                config.Save (CONFIG_PATH);
        }
예제 #38
0
        public static void LoadFromConfig(WorkItem workItem, ToolStripPanel toolStripPanel, XmlDocument doc)
        {
            XmlConfig xcfg = new XmlConfig(doc);

            ConfigSetting newplugin = xcfg.Settings["toolstrips"];

            foreach (ConfigSetting setting in newplugin.Children())
            {
                if (setting.Name.Contains("comment"))
                    continue;
                MenuItemElement menuItem = new MenuItemElement();

                menuItem.CommandName = setting["commandname"].Value;
                menuItem.Icon = setting["icon"].Value;
                menuItem.Label = setting["label"].Value;
                menuItem.ID = setting["id"].Value == "" ? 0 : Convert.ToInt32(setting["id"].Value);
                menuItem.Key = setting["key"].Value;
                menuItem.IsContainer = setting["iscontainer"].Value == "" ? false : true;
                menuItem.Site = setting["site"].Value;

                ProcessConfigItem(workItem, toolStripPanel, menuItem);
            }
        }
예제 #39
0
        protected override bool Configure(XmlConfig.XmlConfig settings)
        {
            String rootXPath = string.Format("email{0}smtp{0}", XmlConfig.XmlConfig.XPathSeparator);
            String host = settings.GetItem(rootXPath + "host").Value;
            String port = settings.GetItem(rootXPath + "port").Value;
            String login = settings.GetItem(rootXPath + "login").Value;
            String password = settings.GetItem(rootXPath + "password").Value;

            // smtp client is mandatory!
            if (!CreateSmtpClient(host, port, login, password))
            {
                return false;
            }

            rootXPath = string.Format("email{0}address{0}", XmlConfig.XmlConfig.XPathSeparator);
            String toAddress = settings.GetItem(rootXPath + "to").Value;
            String fromAddress = settings.GetItem(rootXPath + "from").Value;
            rootXPath = string.Format("email{0}subject", XmlConfig.XmlConfig.XPathSeparator);
            String subject = settings.GetItem(rootXPath).Value;
            String executable = settings.GetItem("executable").Value;

            // message is mandatory too!
            return PrepareMessage(toAddress, fromAddress, subject, executable, Service.DisplayName);
        }
예제 #40
0
        private void DoCodeGen(XmlConfig xmlConfig)
        {
            TextWriter error = Console.Error;

            try
            {
                using (StringWriter writer = new StringWriter())
                {
                    Console.SetError(writer);

                    Task mtaTask = new Task(() =>
                    {
                        Generator.Generate(xmlConfig);
                    });

                    mtaTask.Start();
                    mtaTask.Wait();

                    writer.Flush();
                    string errorText = writer.GetStringBuilder().ToString();

                    if (!string.IsNullOrEmpty(errorText))
                        throw new Exception(errorText);
                }
            }
            finally
            {
                Console.SetError(error);
            }
        }
예제 #41
0
파일: ASql.cs 프로젝트: burstas/rmps
 public void ImportXml(string xmlFile, XmlConfig xmlCfg)
 {
     _SqlEngine.ImportXml(xmlFile, xmlCfg);
 }
예제 #42
0
 public int ImportXml(string xmlFile, XmlConfig xmlCfg)
 {
     return 0;
 }
예제 #43
0
파일: Program.cs 프로젝트: kazuki/p2pncs
        public static bool LoadConfig(XmlConfig config)
        {
            bool exists = false;
            config.Define<int> (ConfigFields.NetBindUdp, IntParser.Instance, new IntRangeValidator (1, ushort.MaxValue), new Random ().Next (49152, ushort.MaxValue));
            config.Define<int> (ConfigFields.NetBindTcp, IntParser.Instance, new IntRangeValidator (1, ushort.MaxValue), config.GetValue<int> (ConfigFields.NetBindUdp));
            config.Define<int> (ConfigFields.GwBindTcp, IntParser.Instance, new IntRangeValidator (1, ushort.MaxValue), 8080);
            config.Define<bool> (ConfigFields.GwBindAny, BooleanParser.Instance, null, false);
            try {
                exists = File.Exists (CONFIG_PATH);
                if (exists)
                    config.Load (CONFIG_PATH);
            } catch {}

            config.Save (CONFIG_PATH);
            return exists;
        }
예제 #44
0
파일: Program.cs 프로젝트: kazuki/p2pncs
 static void Main(string[] args)
 {
     XmlConfig config = new XmlConfig ();
     ECKeyPair privateKey;
     LoadConfig (config, out privateKey);
     SimpleCaptcha captcha = new SimpleCaptcha (new ECDSA (privateKey), 4);
     CaptchaApp app = new CaptchaApp (captcha, privateKey, config.GetValue<string> (CONFIG_HOST),
         (ushort)config.GetValue<int> (CONFIG_BIND_PORT), "templates/captcha-server.xsl");
     using (IHttpServer server = HttpServer.CreateEmbedHttpServer (app, null, true, false, true, config.GetValue<int> (CONFIG_BIND_PORT), 64)) {
         Console.WriteLine ("Captcha Authentication Server is Running...");
         Console.WriteLine ("Press enter key to exit");
         Console.ReadLine ();
     }
 }
예제 #45
0
 /// <summary>
 /// Configure the hook with available settings
 /// </summary>
 /// <param name="settings">the available settings (can't be null)</param>
 /// <returns>true if the hook is well configured, false is probably due to a missing/Wrong setting</returns>
 protected abstract bool Configure(XmlConfig.XmlConfig settings);
예제 #46
0
 protected override bool Configure(XmlConfig.XmlConfig settings)
 {
     return true;
 }