public static IList <XmlNode> GetStructureMapConfiguration()
        {
            var nodes = ConfigurationSettings.GetConfig(XmlConstants.STRUCTUREMAP) as IList <XmlNode>;

            if (nodes == null)
            {
                throw new StructureMapException(105, XmlConstants.STRUCTUREMAP);
            }
            return(nodes);
        }
        static ReadRedisConfig()
        {
            DicHosts = new Dictionary <string, RedisConfig>();
            var configList = ConfigurationSettings.GetConfig("Redis.Service") as List <RedisConfig>;

            foreach (var item in configList)
            {
                DicHosts.Add(item.DbName, item);
            }
        }
Exemple #3
0
        /// <summary>
        ///     Get the current settings from the xml config file
        /// </summary>
        public static Settings GetSettings()
        {
            var settings = (Settings)ConfigurationSettings.GetConfig("blowery.web/httpCompress");

            if (settings == null)
            {
                return(Default);
            }
            return(settings);
        }
        /// <summary>
        /// Constructor that retrieve the queue related information
        /// for MessageQueueConfiguration object
        /// </summary>
        /// <param name="queueName">the name of the queue</param>
        public MQSeries(string queueName)
        {
            cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
            XmlNode queueInfo = cm.MessageQueueConfig.RetrieveQueueInformation("*[@name='" + queueName + "']");

            queueManager = queueInfo.SelectSingleNode("QueueManager").InnerText;
            QueueName    = queueInfo.SelectSingleNode("QueueName").InnerText;
            sleepTime    = Int32.Parse(queueInfo.SelectSingleNode("SleepTime").InnerText);
            queueSession = new MQSessionClass();
        }
        protected void Application_Start(Object sender, EventArgs e)
        {
            IConfigurationSource source =
                ConfigurationSettings.GetConfig("activerecord") as IConfigurationSource;

            ActiveRecordStarter.Initialize(source,
                                           typeof(Blog), typeof(Person), typeof(Customer), typeof(Account),
                                           typeof(AccountPermission), typeof(ProductLicense),
                                           typeof(SimplePerson));
        }
Exemple #6
0
 private DataManager()
 {
     if (trace)
     {
         lm.Write("TRACE:  DataSetManager/InitDataSetManager");
     }
     lm.Debug          = debug;
     ODMDataSetFactory = new ODMDataFactory();
     ConfigData        = (NameValueCollection)ConfigurationSettings.GetConfig("appSettings");
     connectStr        = ConfigData.Get("cnct_eProc");
 }
 private static void Initialize()
 {
     if (FeedConfiguration.configuration != null)
     {
         return;
     }
     lock (FeedConfiguration.configLock)
     {
         configuration = ConfigurationSettings.GetConfig("feed.net") as FeedConfiguration;
     }
 }
Exemple #8
0
        /// <summary>
        /// 有参构造函数
        /// </summary>
        /// <param name="dataAccessInit">引擎初始化接口</param>
        /// <param name="readConfig">读取配置文件接口</param>
        public GreenData(IDataAccessInit dataAccessInit)
        {
            this.dataAccessInit = dataAccessInit;
            ConfigurationManager framConfMana = (ConfigurationManager)ConfigurationSettings.GetConfig("GreenFram");

            this.conStr      = framConfMana.DataBaseConfig.GetConnStr();
            this.conn        = this.dataAccessInit.GetConnection();
            this.command     = this.dataAccessInit.GetCommand();
            this.dataAdapter = this.dataAccessInit.GetDataAdapter();
            InitAccess();
        }
Exemple #9
0
 static ProviderFactory()
 {
     providers = (ProviderCollection)ConfigurationSettings.GetConfig("mono.data/providers");
     if (providers == null)
     {
         providers = new ProviderCollection();
         // warn the developer or administrator that the provider list is empty
         System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(Console.Out));
         System.Diagnostics.Debug.WriteLine("No providers found. Did you set up a mono.data/providers area in your app.config or in machine.config?");
     }
 }
Exemple #10
0
        // Make sure that the trace configuration is loaded.
        internal static void Initialize()
        {
            // Bail out if already initialized, or called recursively.
            if (initialized)
            {
                return;
            }
            initialized = true;

            // Create the default trace listener.
            DefaultTraceListener defListener =
                new DefaultTraceListener();

            // Create the initial listeners collection.
            listeners = new TraceListenerCollection();
            listeners.Add(defListener);

            // Get the diagnostics configuration options.
            Hashtable options = (Hashtable)
                                ConfigurationSettings.GetConfig
                                    ("system.diagnostics",
                                    new DiagnosticsConfigurationHandler());

            if (options == null)
            {
                options = new Hashtable();
            }

            // Process the options for the default trace listener.
            Object value = options["assertuienabled"];

            if (value != null)
            {
                defListener.AssertUiEnabled = (bool)value;
            }
            value = options["logfilename"];
            if (value != null)
            {
                defListener.LogFileName = (String)value;
            }

            // Process the trace options.
            value = options["autoflush"];
            if (value != null)
            {
                autoFlush = (bool)value;
            }
            value = options["indentsize"];
            if (value != null)
            {
                indentSize = (int)value;
            }
            switches = (Hashtable)(options["switches"]);
        }
Exemple #11
0
        public static IList <XmlNode> GetStructureMapConfiguration()
        {
            var nodes = ConfigurationSettings.GetConfig(XmlConstants.STRUCTUREMAP) as IList <XmlNode>;

            if (nodes == null)
            {
                // TODO -- make sure there's a UT on this behavior
                throw new StructureMapConfigurationException("The <{0}> section could not be loaded from the application configuration file.", XmlConstants.STRUCTUREMAP);
            }
            return(nodes);
        }
Exemple #12
0
        public void ChangePrinter(string printerType, string portName)
        {
            //Change station printer
            try {
                if (printerType != "" && portName != "")
                {
                    ILabelPrinter       oPrinter   = DeviceFactory.CreatePrinter(printerType, portName);
                    PortSettings        oSettings  = oPrinter.DefaultSettings;
                    NameValueCollection nvcPrinter = (NameValueCollection)ConfigurationSettings.GetConfig("station/printer");
                    oSettings.PortName = portName;
                    oSettings.BaudRate = Convert.ToInt32(nvcPrinter["BaudRate"]);
                    oSettings.DataBits = Convert.ToInt32(nvcPrinter["DataBits"]);
                    switch (nvcPrinter["Parity"].ToString().ToLower())
                    {
                    case "none": oSettings.Parity = Parity.None; break;

                    case "even": oSettings.Parity = Parity.Even; break;

                    case "odd": oSettings.Parity = Parity.Odd; break;
                    }
                    switch (Convert.ToInt32(nvcPrinter["StopBits"]))
                    {
                    case 1: oSettings.StopBits = StopBits.One; break;

                    case 2: oSettings.StopBits = StopBits.Two; break;
                    }
                    switch (nvcPrinter["Handshake"].ToString().ToLower())
                    {
                    case "none": oSettings.Handshake = Handshake.None; break;

                    case "rts/cts": oSettings.Handshake = Handshake.RequestToSend; break;

                    case "xon/xoff": oSettings.Handshake = Handshake.XOnXOff; break;
                    }
                    oPrinter.Settings = oSettings;

                    //Atach printer to sort station and turn-on
                    if (this.mLabelPrinter != null)
                    {
                        this.mLabelPrinter.TurnOff();
                    }
                    this.mLabelPrinter = oPrinter;
                    this.mLabelPrinter.TurnOn();

                    //Notify clients
                    if (this.PrinterChanged != null)
                    {
                        this.PrinterChanged(this, new EventArgs());
                    }
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error changing to workstation printer type " + printerType + " on port " + portName + ".", ex); }
        }
Exemple #13
0
        public static object GetMySQLConnection()
        {
            Utility objUtil = new Utility();
            string  constr  = objUtil.Decrypt(((NameValueCollection)ConfigurationSettings.GetConfig("appSettings"))["MySQLConnectionString"]);
            //constr += "connect timeout=" + ((NameValueCollection)ConfigurationSettings.GetConfig("appSettings"))["SessionTimeOut"].ToString();
            //constr += ";packet size=4128;Min Pool Size=3;Max Pool Size=200;";
            MySqlConnection connection = new MySqlConnection(constr);

            connection.Open();
            return(connection);
        }
Exemple #14
0
 /// <summary>
 /// Create applications
 ///
 /// Publish specific instance via remoting.
 /// http://www.dotnetremoting.cc/FAQs/PUBLISHING_OBJECT.asp
 /// </summary>
 public ApplicationServer(int AdminPort, string ApplicationBaseDir, LogStringEvent logstringevent) : base()
 {
     EnterMethod();
     try
     {
         AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler);
         if (logstringevent != null)
         {
             OnLog += logstringevent;
         }
         Applications = new ApplicationCollection();
         LogString("{0}: {1}",
                   GetType().Assembly.GetName().Name,
                   GetType().Assembly.GetName().Version.ToString());
         LogString("Publishing server objects on port {0}", AdminPort);
         AdminChannel = new TcpChannel(AdminPort);
         ChannelServices.RegisterChannel(AdminChannel);
         _ServerEnvironment = new ServerEnvironment();
         string path = @"users" + Path.DirectorySeparatorChar.ToString();
         byte[] Key  = new byte[8] {
             5, 100, 5, 2, 4, 24, 34, 55
         };
         byte[] IV = new byte[8] {
             5, 100, 5, 2, 4, 24, 34, 55
         };
         SecurityManager = new SecurityManager(new EncryptedFileStorage(path, Key, IV));
         RemotingServices.Marshal(this, "Mono.AppServer.ApplicationServer");
         AvailableApplicationTypes = (ApplicationType[])ConfigurationSettings.GetConfig("Mono.AppServer");
         DirectoryInfo curdir = new DirectoryInfo(ApplicationBaseDir);
         this.ApplicationsBaseDir = curdir.FullName + Path.DirectorySeparatorChar;
         LogString("\nHosting applications in {0}", Path.GetFullPath(ApplicationBaseDir));
         foreach (DirectoryInfo dir in curdir.GetDirectories())
         {
             try
             {
                 LoadApplication(dir);
             }
             catch (Exception e)
             {
                 SendError(e);
                 LogString("ERROR: " + e.Message);
             }
         }
     }
     catch (Exception E)
     {
         SendError(E);
         throw;
     }
     finally
     {
         ExitMethod();
     }
 }
Exemple #15
0
        internal static STViewEngineConfiguration GetConfig(string sectionName)
        {
            STViewEngineConfiguration config = (STViewEngineConfiguration)
                                               ConfigurationSettings.GetConfig(sectionName);

            if (config == null)
            {
                return(new STViewEngineConfiguration());
            }
            return(config);
        }
Exemple #16
0
        /// <summary>
        /// Loads the shapes from the libraries specified in the application configuration file.
        /// </summary>
        public void LoadLibraries()
        {
            ArrayList graphLibs = ConfigurationSettings.GetConfig("GraphLibs") as ArrayList;

            if (graphLibs.Count > 0)
            {
                for (int k = 0; k < graphLibs.Count; k++)
                {
                    this.ImportEntities(graphLibs[k] as string);
                }
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            string     Url = ((NameValueCollection)ConfigurationSettings.GetConfig("JobList/Job"))["Url"];
            WebClient  wc  = new WebClient();
            WebRequest wr  = WebRequest.Create(new Uri(Url));

            using (StreamWriter sw = File.AppendText(@"d:\SchedulerService.txt"))
            {
                sw.WriteLine("------------------" + "MyService服务在:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "     执行了一次任务" + "------------------");
                sw.Flush();
            }
        }
Exemple #18
0
 public DataManager()
 {
     if (trace)
     {
         lm.Write("TRACE:  DataManager.DataManager(constructor)");
     }
     lm.Write("PCUConsole:DataManager:(constructor)");
     ODMDataSetFactory = new ODMDataFactory();
     ConfigData        = (NameValueCollection)ConfigurationSettings.GetConfig("PatientChargeUpdate");
     connectStr        = ConfigData.Get("cnctBIAdmin");
     attributeCount    = Convert.ToInt32(ConfigData.Get("attribCount"));
 }
Exemple #19
0
        /// <summary>
        /// Automatically configures the <see cref="ILoggerRepository"/> using settings
        /// stored in the application's configuration file.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Each application has a configuration file. This has the
        /// same name as the application with '.config' appended.
        /// This file is XML and calling this function prompts the
        /// configurator to look in that file for a section called
        /// <c>log4net</c> that contains the configuration data.
        /// </para>
        /// <para>
        /// To use this method to configure log4net you must specify
        /// the <see cref="Log4NetConfigurationSectionHandler"/> section
        /// handler for the <c>log4net</c> configuration section. See the
        /// <see cref="Log4NetConfigurationSectionHandler"/> for an example.
        /// </para>
        /// </remarks>
        /// <param name="repository">The repository to configure.</param>
#else
        /// <summary>
        /// Automatically configures the <see cref="ILoggerRepository"/> using settings
        /// stored in the application's configuration file.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Each application has a configuration file. This has the
        /// same name as the application with '.config' appended.
        /// This file is XML and calling this function prompts the
        /// configurator to look in that file for a section called
        /// <c>log4net</c> that contains the configuration data.
        /// </para>
        /// </remarks>
        /// <param name="repository">The repository to configure.</param>
#endif

        public static void Configure(ILoggerRepository repository)
        {
            LogLog.Debug("XmlConfigurator: configuring repository [" + repository.Name + "] using .config file section");

            try {
                LogLog.Debug("XmlConfigurator: Application config file is [" + SystemInfo.ConfigurationFileLocation +
                             "]");
            } catch {
                // ignore error
                LogLog.Debug("XmlConfigurator: Application config file location unknown");
            }

#if NETCF
            // No config file reading stuff. Just go straight for the file
            Configure(repository, new FileInfo(SystemInfo.ConfigurationFileLocation));
#else
            try {
                XmlElement configElement = null;
#if NET_2_0
                configElement = System.Configuration.ConfigurationManager.GetSection("log4net") as XmlElement;
#else
                configElement = ConfigurationSettings.GetConfig("log4net") as XmlElement;
#endif
                if (configElement == null) // Failed to load the xml config using configuration settings handler
                {
                    LogLog.Error(
                        "XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler,log4net\" />");
                }
                else // Configure using the xml loaded from the config file
                {
                    ConfigureFromXml(repository, configElement);
                }
            } catch (ConfigurationException confEx) {
                if (confEx.BareMessage.IndexOf("Unrecognized element") >= 0) // Looks like the XML file is not valid
                {
                    LogLog.Error(
                        "XmlConfigurator: Failed to parse config file. Check your .config file is well formed XML.",
                        confEx);
                }
                else
                {
                    // This exception is typically due to the assembly name not being correctly specified in the section type.
                    string configSectionStr =
                        "<section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler," +
                        Assembly.GetExecutingAssembly().FullName + "\" />";
                    LogLog.Error(
                        "XmlConfigurator: Failed to parse config file. Is the <configSections> specified as: " +
                        configSectionStr,
                        confEx);
                }
            }
#endif
        }
Exemple #20
0
        /// <summary>
        /// 私有构造方法, 需要单例设计模式
        /// </summary>
        private Cache()
        {
            //从配置文件读取配置
            ConfigurationManager cm = (ConfigurationManager)ConfigurationSettings.GetConfig("GreenFram");

            //加载缓存策略对象
            cs = (ICacheStrategy)cm.CacheConfig.GetCacheStrategy();
            //创建一个物理存储XML作为缓存在XML表达和对象之间的映射
            objectXmlMap = rootXml.CreateElement("Cache");
            //创建内部的xml文档
            rootXml.AppendChild(objectXmlMap);
        }
        static Assembler()
        {
            //通过配置文件加载相关“抽象工厂类型”/“具体工厂类型”的映射关系
            NameValueCollection collection = (NameValueCollection)ConfigurationSettings.GetConfig(SectionName);

            for (int i = 0; i < collection.Count; i++)
            {
                string target = collection.GetKey(i);
                string source = collection[i];
                dictionary.Add(Type.GetType(target), Type.GetType(source));
            }
        }
Exemple #22
0
        static CallTracer()
        {
            NameValueCollection pluginConfig = (NameValueCollection)ConfigurationSettings.GetConfig("settings/tracer");

            if (pluginConfig != null)
            {
                if (pluginConfig["isactive"] != null && pluginConfig["isactive"] == "true")
                {
                    Console.WriteLine("Woohoo is active");
                }
            }
        }
        /// <summary>
        /// constructor takes the SAFIdentity as its parameter.
        /// </summary>
        /// <param name="sid">SAFIdentity object which contain the identity and appplication name information</param>
        public SAFPrincipal(SAFIdentity sid)
        {
            //retrieve the authentication configuraiton from the configuraiton file
            ConfigurationManager        cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
            AuthenticationConfiguration ac = cm.AuthenticationConfig;

            //set identity object and the SAFUser property
            identity = sid;
            safUser  = ac.GetSAFUserName(sid.Name, sid.ApplicationName);
            //set the application inforamtion of the SAFPrincipal
            SetApplication(sid.ApplicationName);
        }
Exemple #24
0
 public SqlConnection GetConnectionQueryBuilder()
 {
     lock (this)
     {
         Utility objUtil = new Utility();
         string  constr  = objUtil.Decrypt(((NameValueCollection)ConfigurationSettings.GetConfig("appSettings"))["ConnectionString"]);
         constr += ";connect timeout=" + ((NameValueCollection)ConfigurationSettings.GetConfig("appSettings"))["SessionTimeOut"].ToString();
         constr += ";packet size=8192";
         SqlConnection connection = new SqlConnection(constr);
         connection.Open();
         return(connection);
     }
 }
        /// <summary>
        /// Loads all collection classes.
        /// </summary>
        private void Load()
        {
#if (NET_COMPACT_1_0)
            throw new NotSupportedException("This loading method is not supported");
#else
            this.Merge(this);              // required for SaveAll
            for (int i = 0; i < sections.Length; i++)
            {
                LoadCollection(sections[i], (NameValueCollection)ConfigurationSettings
                               .GetConfig(sections[i]));
            }
#endif
        }
        /// <summary>
        /// Private construtor, required for singleton design pattern.
        /// </summary>
        private Cache()
        {
            //retrieve setting from configuration file
            ConfigurationManager cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");

            //load the cache strategy object
            cs = (ICacheStrategy)cm.CacheConfig.GetCacheStrategy();
            //create an Xml used as a map between  xml expression and object cached in the
            //physical storage.
            objectXmlMap = rootXml.CreateElement("Cache");
            //build the internal xml document.
            rootXml.AppendChild(objectXmlMap);
        }
        /// <summary>
        /// Constructor that retrieve the queue related information
        /// for MessageQueueConfiguration object
        /// </summary>
        /// <param name="queueName">name of the queue</param>
        public MSMQ(string queueName)
        {
            cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
            XmlNode queueInfo = cm.MessageQueueConfig.RetrieveQueueInformation("*[@name='" + queueName + "']");

            formatName     = queueInfo.SelectSingleNode("FormatName").InnerText;
            sleepTime      = Int32.Parse(queueInfo.SelectSingleNode("SleepTime").InnerText);
            this.queueName = queueName;
            //supportedTypes is used to provide information to System.Messaging.MessageQueue
            //information on how to serialize and deserialize the object sent to and retrieved from
            //the queue.  The default data type is string type.
            supportedTypes.Add(typeof(System.String).ToString());
        }
 public UpdatePatCharges()
 {
     ConfigData        = (NameValueCollection)ConfigurationSettings.GetConfig("PatientChargeUpdate");
     biAdminConnectStr = ConfigData.Get("cnctBIAdmin");
     uwmConnectStr     = ConfigData.Get("cnctHEMM_HMC");
     OkToUpdate        = Convert.ToBoolean(ConfigData.Get("updateTables"));
     trace             = Convert.ToBoolean(ConfigData.Get("trace"));
     ODMDataSetFactory = new ODMDataFactory();
     if (trace)
     {
         lm.Write("TRACE:  UpdatePatCharges.UpdatePatCharges(constructor)");
     }
 }
Exemple #29
0
        static void Main()
        {
            mainForm = new MainForm();
            ConfigurationSettings.GetConfig("MyConfig");            //读取自定义配置节,在这个过程中会初始化所有的托管容器对象

            LoginForm loginForm = new LoginForm();

            loginForm.StartPosition = FormStartPosition.CenterScreen;
            if (loginForm.ShowDialog() == DialogResult.OK)
            {
                Application.Run(mainForm);                //启动主窗体
            }
        }
Exemple #30
0
        public static object CreateObject(string ConfigSection)
        {
            ProviderConfiguration config = (ProviderConfiguration)ConfigurationSettings.GetConfig(ConfigSection);
            Type typProvider             = null;

            try
            {
                typProvider = Type.GetType(config.Providers[config.DefaultProvider].ProviderType, true);
            }
            catch (Exception e) { }

            return(Activator.CreateInstance(typProvider));
        }