コード例 #1
0
        /// <summary>
        /// Associates a parser with a namespace.
        /// </summary>
        /// <remarks>
        /// <note>
        /// Parsers registered with the same <paramref name="namespaceUri"/> as that
        /// of a parser that has previously been registered will overwrite the existing
        /// parser.
        /// </note>
        /// </remarks>
        /// <param name="namespaceUri">
        /// The namespace with which to associate instance of the parser.
        /// </param>
        /// <param name="parser">
        /// The parser instance.
        /// </param>
        /// <param name="schemaLocation">
        /// The location of the XML schema that should be used for validation 
        /// of the XML elements that belong to the specified namespace 
        /// (can be any valid Spring.NET resource URI).
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="parser"/> is <see langword="null"/>, or if 
        /// <paramref name="namespaceUri"/> is not specified and parser class
        /// does not have default value defined using <see cref="NamespaceParserAttribute"/>.
        /// </exception>
        public static void RegisterParser(INamespaceParser parser, string namespaceUri, string schemaLocation)
        {
            AssertUtils.ArgumentNotNull(parser, "parser");

            // determine and use defaults for the namespace and schema location, if necessary
            if (StringUtils.IsNullOrEmpty(namespaceUri) || StringUtils.IsNullOrEmpty(schemaLocation))
            {
                NamespaceParserAttribute defaults = GetDefaults(parser.GetType());
                if (defaults == null)
                {
                    throw new ArgumentNullException(
                        "Either default or an explicit namespace value must be specified for a configuration parser.");
                }
                if (StringUtils.IsNullOrEmpty(namespaceUri))
                {
                    namespaceUri = defaults.Namespace;
                }
                if (StringUtils.IsNullOrEmpty(schemaLocation))
                {
                    schemaLocation = defaults.SchemaLocation;
                    if (defaults.SchemaLocationAssemblyHint != null)
                    {
                        schemaLocation = GetAssemblySchemaLocation(defaults.SchemaLocationAssemblyHint, schemaLocation);
                    }
                }
            }

            // initialize the parser
            parser.Init();

            // register parser
            lock (parsers.SyncRoot)
                lock (schemas)
                {
                    parsers[namespaceUri] = parser;
                    if (StringUtils.HasText(schemaLocation) && !schemas.Contains(namespaceUri))
                    {
                        RegisterSchema(namespaceUri, schemaLocation);
                    }
                }
        }
コード例 #2
0
 /// <summary>
 /// Pegisters parser, using default namespace and schema location
 /// as defined by the <see cref="NamespaceParserAttribute"/>.
 /// </summary>
 /// <param name="parser">
 /// The parser instance.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// If <paramref name="parser"/> is <see langword="null"/>.
 /// </exception>
 public static void RegisterParser(INamespaceParser parser)
 {
     RegisterParser(parser, null, null);
 }
コード例 #3
0
ファイル: CsParser.cs プロジェクト: gamificationvn/cstoas3
		public CsParser(string pOutDir, INamespaceParser pParser) {
			_parser = pParser;
			_output = pOutDir.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;
		}
 public IntNamespaceHandlerDelegate(INamespaceParser outer)
 {
     this.outer = outer;
 }
コード例 #5
0
		public static void AddParser(INamespaceParser pCsAstVisitor, string pName) {
			_parsers[pName.ToLowerInvariant()] = pCsAstVisitor;
		}