RunParser() private method

private RunParser ( IConfigHandler factory, String fileName ) : void
factory IConfigHandler
fileName String
return void
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
 }