Ejemplo n.º 1
0
        // NOTE: This parser takes a path eg. /configuration/system.runtime.remoting
        // and will return a node which matches this.

        internal ConfigNode Parse(String fileName, String configPath)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            this.fileName = fileName;
            if (configPath[0] == '/')
            {
                treeRootPath  = configPath.Substring(1).Split('/');
                pathDepth     = treeRootPath.Length - 1;
                bNoSearchPath = false;
            }
            else
            {
                treeRootPath    = new String[1];
                treeRootPath[0] = configPath;
                bNoSearchPath   = true;
            }

            (new FileIOPermission(FileIOPermissionAccess.Read, System.IO.Path.GetFullPathInternal(fileName))).Demand();
            (new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)).Assert();
            try
            {
                ConfigServer.RunParser(this, fileName);
            }
            catch (Exception inner) {
                throw new ApplicationException(String.Format(Environment.GetResourceString("XML_Syntax_InvalidSyntaxInFile"),
                                                             fileName,
                                                             lastProcessed),
                                               inner);
            }
            return(rootNode);
        }
Ejemplo n.º 2
0
        internal ConfigNode Parse(String fileName, String configPath, bool skipSecurityStuff)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            this.fileName = fileName;
            if (configPath[0] == '/')
            {
                treeRootPath  = configPath.Substring(1).Split('/');
                pathDepth     = treeRootPath.Length - 1;
                bNoSearchPath = false;
            }
            else
            {
                treeRootPath    = new String[1];
                treeRootPath[0] = configPath;
                bNoSearchPath   = true;
            }

            if (!skipSecurityStuff)
            {
                (new FileIOPermission(FileIOPermissionAccess.Read, System.IO.Path.GetFullPathInternal(fileName))).Demand();
            }
            (new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)).Assert();

            try
            {
                ConfigServer.RunParser(this, fileName);
            }
            catch (FileNotFoundException) {
                throw; // Pass these through unadulterated.
            }
            catch (DirectoryNotFoundException) {
                throw; // Pass these through unadulterated.
            }
            catch (UnauthorizedAccessException) {
                throw;
            }
            catch (FileLoadException) {
                throw;
            }
            catch (Exception inner) {
                throw new ApplicationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("XML_Syntax_InvalidSyntaxInFile"),
                                                             fileName,
                                                             lastProcessed),
                                               inner);
            }
            catch {
                throw new ApplicationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("XML_Syntax_InvalidSyntaxInFile"),
                                                             fileName,
                                                             lastProcessed));
            }
            return(rootNode);
        }
Ejemplo n.º 3
0
 internal ConfigNode Parse(string fileName, string configPath, bool skipSecurityStuff)
 {
     if (fileName == null)
     {
         throw new ArgumentNullException("fileName");
     }
     this.fileName = fileName;
     if (configPath[0] == '/')
     {
         this.treeRootPath  = configPath.Substring(1).Split(new char[] { '/' });
         this.pathDepth     = this.treeRootPath.Length - 1;
         this.bNoSearchPath = false;
     }
     else
     {
         this.treeRootPath  = new string[] { configPath };
         this.bNoSearchPath = true;
     }
     if (!skipSecurityStuff)
     {
         new FileIOPermission(FileIOPermissionAccess.Read, Path.GetFullPathInternal(fileName)).Demand();
     }
     new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
     try
     {
         ConfigServer.RunParser(this, fileName);
     }
     catch (FileNotFoundException)
     {
         throw;
     }
     catch (DirectoryNotFoundException)
     {
         throw;
     }
     catch (UnauthorizedAccessException)
     {
         throw;
     }
     catch (FileLoadException)
     {
         throw;
     }
     catch (Exception exception)
     {
         throw new ApplicationException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("XML_Syntax_InvalidSyntaxInFile"), new object[] { fileName, this.lastProcessed }), exception);
     }
     catch
     {
         throw new ApplicationException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("XML_Syntax_InvalidSyntaxInFile"), new object[] { fileName, this.lastProcessed }));
     }
     return(this.rootNode);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="configServer"></param>
        internal static void ConfigServer( ref ConfigServer configServer )
        {
            //////////////////////////////////////////////////////////////////////////
            // 获取配置的信息

            LoadServerConfig();

            //////////////////////////////////////////////////////////////////////////
            // 设置配置的信息

            configServer.Service = ProcessServer.ConfigInfo.ServerConfig.Service;
            configServer.LogFile = ProcessServer.ConfigInfo.ServerConfig.LogFile;
            configServer.Cache = ProcessServer.ConfigInfo.ServerConfig.Cache;
            configServer.Debug = ProcessServer.ConfigInfo.ServerConfig.Debug;
            configServer.HaltOnWarning = ProcessServer.ConfigInfo.ServerConfig.HaltOnWarning;
            configServer.Profiling = ProcessServer.ConfigInfo.ServerConfig.Profiling;
            configServer.WorldThreadCount = ProcessServer.ConfigInfo.ServerConfig.WorldThreadCount;

            if ( ProcessServer.ConfigInfo.ServerConfig.ServerCachedSize > 0
                 && ProcessServer.ConfigInfo.ServerConfig.ServerBufferSize > 0
                 && ProcessServer.ConfigInfo.ServerConfig.ServerManageThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ServerSendThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ServerReceiveThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ServerProcessThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ServerMaxClients > 0
                && ProcessServer.ConfigInfo.ServerConfig.ServerOutTimeInterval >= 0 )
            {
                configServer.SetServerNetConfig( (int)ProcessServer.ConfigInfo.ServerConfig.ServerCachedSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ServerBufferSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ServerManageThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ServerSendThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ServerReceiveThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ServerProcessThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ServerMaxClients
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ServerOutTimeInterval );
            }


            if ( ProcessServer.ConfigInfo.ServerConfig.ClientCachedSize > 0
                 && ProcessServer.ConfigInfo.ServerConfig.ClientBufferSize > 0
                 && ProcessServer.ConfigInfo.ServerConfig.ClientManageThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ClientSendThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ClientReceiveThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ClientProcessThreadPoolSize > 0
                && ProcessServer.ConfigInfo.ServerConfig.ClientOutTimeInterval >= 0 )
            {
                configServer.SetClientNetConfig( (int)ProcessServer.ConfigInfo.ServerConfig.ClientCachedSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ClientBufferSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ClientManageThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ClientSendThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ClientReceiveThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ClientProcessThreadPoolSize
                    , (int)ProcessServer.ConfigInfo.ServerConfig.ClientOutTimeInterval );
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="configServer"></param>
        private static void BaseServer_ConfigServer( ref ConfigServer configServer )
        {
            //////////////////////////////////////////////////////////////////////////
            // 获取配置的信息

            LoadVariables();

            configServer.Service = s_ConfigInfo.Service;
            configServer.LogFile = s_ConfigInfo.LogFile;
            configServer.Cache = s_ConfigInfo.Cache;
            configServer.Debug = s_ConfigInfo.Debug;
            configServer.HaltOnWarning = s_ConfigInfo.HaltOnWarning;
            configServer.Profiling = s_ConfigInfo.Profiling;
            configServer.WorldThreadCount = (byte)s_ConfigInfo.WorldThreadCount;

            if ( s_ConfigInfo.ServerCachedSize > 0
                 && s_ConfigInfo.ServerBufferSize > 0
                 && s_ConfigInfo.ServerManageThreadPoolSize > 0
                && s_ConfigInfo.ServerSendThreadPoolSize > 0
                && s_ConfigInfo.ServerReceiveThreadPoolSize > 0
                && s_ConfigInfo.ServerProcessThreadPoolSize > 0
                && s_ConfigInfo.ServerMaxClients > 0
                && s_ConfigInfo.ServerOutTimeInterval >= 0 )
            {
                configServer.SetServerNetConfig( (int)s_ConfigInfo.ServerCachedSize
                    , (int)s_ConfigInfo.ServerBufferSize
                    , (int)s_ConfigInfo.ServerManageThreadPoolSize
                    , (int)s_ConfigInfo.ServerSendThreadPoolSize
                    , (int)s_ConfigInfo.ServerReceiveThreadPoolSize
                    , (int)s_ConfigInfo.ServerProcessThreadPoolSize
                    , (int)s_ConfigInfo.ServerMaxClients
                    , (int)s_ConfigInfo.ServerOutTimeInterval );
            }


            if ( s_ConfigInfo.ClientCachedSize > 0
                && s_ConfigInfo.ClientBufferSize > 0
                && s_ConfigInfo.ClientManageThreadPoolSize > 0
                && s_ConfigInfo.ClientSendThreadPoolSize > 0
                && s_ConfigInfo.ClientReceiveThreadPoolSize > 0
                && s_ConfigInfo.ClientProcessThreadPoolSize > 0
                && s_ConfigInfo.ClientOutTimeInterval >= 0 )
            {
                configServer.SetClientNetConfig( (int)s_ConfigInfo.ClientCachedSize
                    , (int)s_ConfigInfo.ClientBufferSize
                    , (int)s_ConfigInfo.ClientManageThreadPoolSize
                    , (int)s_ConfigInfo.ClientSendThreadPoolSize
                    , (int)s_ConfigInfo.ClientReceiveThreadPoolSize
                    , (int)s_ConfigInfo.ClientProcessThreadPoolSize
                    , (int)s_ConfigInfo.ClientOutTimeInterval );
            }
        }