当前位置: 首页>>代码示例>>C#>>正文


C# Categories.Exists方法代码示例

本文整理汇总了C#中Categories.Exists方法的典型用法代码示例。如果您正苦于以下问题:C# Categories.Exists方法的具体用法?C# Categories.Exists怎么用?C# Categories.Exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Categories的用法示例。


在下文中一共展示了Categories.Exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateStructure

		/// <summary>
		/// Validates the contents of the comments file.
		/// </summary>
		protected override void ValidateStructure ( )
		   {
			foreach  ( XmlNode  node  in  DocumentElement )
			   {
				if  ( node. NodeType  !=  XmlNodeType. Element )
					continue ;

				switch  ( node. Name. ToLower ( ) )
				   {
					case	"author" :
						Author		=  new Author ( this, node ) ;
						break ;

					case	"categories" :
						Categories	=  new Categories ( this, node ) ;
						break ;

					case	"templates" :
						Templates	=  new Templates ( this, node ) ;
						break ;

					case	"groups" :
						Groups		=  new Groups ( this, node ) ;
						break ;

					default :
						AddValidationMessage ( XmlParseErrorSeverity. Error, "Unrecognized tag <" +
									node. Name + ">" ) ;
						break ;
				    }
			    }

			// Check that all required nodes are present (paranoia, since the xsd validation has already been performed)
			if  ( Author  ==  null )
				AddValidationMessage ( XmlParseErrorSeverity. Error, "Missing tag '<author>'" ) ;

			if  ( Categories  ==  null )
				AddValidationMessage ( XmlParseErrorSeverity. Error, "Missing tag '<categories>'" ) ;

			if  ( Templates  ==  null )
				AddValidationMessage ( XmlParseErrorSeverity. Error, "Missing tag '<templates>'" ) ;

			if  ( Groups  ==  null )
				AddValidationMessage ( XmlParseErrorSeverity. Error, "Missing tag '<groups>'" ) ;

			// Checks on <templates> entries
			if  ( Templates  !=  null )
			   {
				// Check that each comment in the <template> nodes reference an existing category
				foreach  ( Template  template  in  Templates )
				   {
					foreach  ( Comment  comment  in  template. Comments )
					   {
						if  ( ! Categories. Exists ( comment. Name ) )
							AddValidationMessage ( XmlParseErrorSeverity. Error, 
								"Comment category \"" + comment. Name + "\" specified in template \"" +
								template. Name  + "\" does not exist" ) ;
					    }
				    }

				// Check that template names are unique
				if  ( Templates. Count  ==  0 )
					AddValidationMessage ( XmlParseErrorSeverity. Warning, "No template defined in the <templates> node" ) ;
				else
				   { 
					for  ( int  i = 1 ; i  <  Templates. Count ; i ++ )
					    {
						for  ( int  j = 0 ; j  <  i ; j ++ )
						   {
							if  ( String. Compare ( Templates [i]. Name, Templates [j]. Name, true )  ==  0 )
							   {
								AddValidationMessage ( XmlParseErrorSeverity. Error, 
									"Template \"" + Templates [i]. Name + "\" is defined more than once" ) ;
								break ;
							    }
						    }
					     }
				    }
			    }

			// Checks on <groups> entries
			if  ( Groups  !=  null )
			   {
				// Check that each comment in the <group> nodes reference an existing category
				foreach  ( Group  group  in  Groups )
				   {
					foreach  ( Comment  comment  in  group. Comments )
					   {
						if  ( ! Categories. Exists ( comment. Name ) )
							AddValidationMessage ( XmlParseErrorSeverity. Error, 
								"Comment category \"" + comment. Name + "\" specified in group \"" +
								group. Name  + "\" does not exist" ) ;
					    }

					if  ( String. IsNullOrWhiteSpace  ( group. ExtensionsAsString ) )
						AddValidationMessage ( XmlParseErrorSeverity. Error, 
							"Group \"" + group. Name  + "\" is not associated with any file extension ('extensions' attribute value is empty)" ) ;
//.........这里部分代码省略.........
开发者ID:wuthering-bytes,项目名称:wuthering-vsix,代码行数:101,代码来源:CommentsDocument.cs


注:本文中的Categories.Exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。