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


C# Property.CheckAccess方法代码示例

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


在下文中一共展示了Property.CheckAccess方法的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.CheckAccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。