當前位置: 首頁>>代碼示例>>C#>>正文


C# Property.BindTo方法代碼示例

本文整理匯總了C#中System.Property.BindTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Property.BindTo方法的具體用法?C# Property.BindTo怎麽用?C# Property.BindTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Property的用法示例。


在下文中一共展示了Property.BindTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParseDirect

		public static ObjectConditional ParseDirect( Mobile from, string[] args, int offset, int size )
		{
			if ( args == null || size == 0 )
				return Empty;

			int index = 0;

			Type objectType = ScriptCompiler.FindTypeByName( args[offset + index], true );

			if ( objectType == null )
				throw new Exception( String.Format( "No type with that name ({0}) was found.", args[offset + index] ) );

			++index;

			List<ICondition[]> conditions = new List<ICondition[]>();
			List<ICondition> current = new List<ICondition>();

			current.Add( TypeCondition.Default );

			while ( index < size )
			{
				string cur = args[offset + index];

				bool inverse = false;

				if ( Insensitive.Equals( cur, "not" ) || cur == "!" )
				{
					inverse = true;
					++index;

					if ( index >= size )
						throw new Exception( "Improperly formatted object conditional." );
				}
				else if ( Insensitive.Equals( cur, "or" ) || cur == "||" )
				{
                    if (current.Count > 1)
                    {
						conditions.Add( current.ToArray() );

						current.Clear();
						current.Add( TypeCondition.Default );
					}

					++index;

					continue;
				}

				string binding = args[offset + index];
				index++;

				if ( index >= size )
					throw new Exception( "Improperly formatted object conditional." );

				string oper = args[offset + index];
				index++;

				if ( index >= size )
					throw new Exception( "Improperly formatted object conditional." );

				string val = args[offset + index];
				index++;

				Property prop = new Property( binding );

				prop.BindTo( objectType, PropertyAccess.Read );
				prop.CheckAccess( from );

				ICondition condition = null;

				switch ( oper )
				{
					#region Equality
					case "=":
					case "==":
					case "is":
						condition = new ComparisonCondition( prop, inverse, ComparisonOperator.Equal, val );
						break;

					case "!=":
						condition = new ComparisonCondition( prop, inverse, ComparisonOperator.NotEqual, val );
						break;
					#endregion

					#region Relational
					case ">":
						condition = new ComparisonCondition( prop, inverse, ComparisonOperator.Greater, val );
						break;

					case "<":
						condition = new ComparisonCondition( prop, inverse, ComparisonOperator.Lesser, val );
						break;

					case ">=":
						condition = new ComparisonCondition( prop, inverse, ComparisonOperator.GreaterEqual, val );
						break;

					case "<=":
						condition = new ComparisonCondition( prop, inverse, ComparisonOperator.LesserEqual, val );
						break;
//.........這裏部分代碼省略.........
開發者ID:FreeReign,項目名稱:imaginenation,代碼行數:101,代碼來源:ObjectConditional.cs


注:本文中的System.Property.BindTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。