Beispiel #1
0
        /// <summary>
        /// Initializes the Shared Session Server Manager with the setting in the application
        /// configuration file
        /// </summary>
        public static void Initialize()
        {
            var config = ConfigurationManager.GetSection(ProviderConfiguration.ConfigurationKey) as ProviderConfiguration;


            //string cfg = "rrr";
            //if (config != null) cfg = "wwww";
            //System.IO.FileStream fs = new System.IO.FileStream("c:/log4.txt", System.IO.FileMode.CreateNew);
            //System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            //byte[] b = encoding.GetBytes(cfg);
            //fs.Write(b, 0, b.Length);
            //fs.Close();


            if (config != null)
            {
                //Create a provider with the type specified in the configuration



                Type providerType = Type.GetType(config.ProviderType, false, true);


                if (providerType == null)
                {
                    throw new ConfigurationException(
                              String.Format("Type '{0} was not found",
                                            config.ProviderType));
                }

                var provider = Activator.CreateInstance(providerType) as ISharedSessionServerProvider;

                if (provider == null)
                {
                    throw new ConfigurationException(
                              String.Format("Unable to create an ISharedSessionServerProvider from type '{0}'",
                                            config.ProviderType));
                }

                _provider = provider;
            }
            else
            {
                throw new ConfigurationException("SharedSessionServerManager configuration was not found.");
            }
        }
        /// <summary>
        /// Initializes the Shared Session Server Manager with the setting in the application
        /// configuration file
        /// </summary>
        public static void Initialize()
        {
            var config = ConfigurationManager.GetSection(ProviderConfiguration.ConfigurationKey) as ProviderConfiguration;

            //string cfg = "rrr";
            //if (config != null) cfg = "wwww";
            //System.IO.FileStream fs = new System.IO.FileStream("c:/log4.txt", System.IO.FileMode.CreateNew);
            //System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            //byte[] b = encoding.GetBytes(cfg);
            //fs.Write(b, 0, b.Length);
            //fs.Close();

            if (config != null)
            {
                //Create a provider with the type specified in the configuration

                Type providerType = Type.GetType(config.ProviderType, false, true);

                if (providerType == null)
                {
                    throw new ConfigurationException(
                        String.Format("Type '{0} was not found",
                            config.ProviderType));
                }

                var provider = Activator.CreateInstance(providerType) as ISharedSessionServerProvider;

                if (provider == null)
                {
                    throw new ConfigurationException(
                        String.Format("Unable to create an ISharedSessionServerProvider from type '{0}'",
                            config.ProviderType));
                }

                _provider = provider;
            }
            else
            {
                throw new ConfigurationException("SharedSessionServerManager configuration was not found.");
            }
        }