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


C# CSharp.MemberAccess類代碼示例

本文整理匯總了C#中Mono.CSharp.MemberAccess的典型用法代碼示例。如果您正苦於以下問題:C# MemberAccess類的具體用法?C# MemberAccess怎麽用?C# MemberAccess使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MemberAccess類屬於Mono.CSharp命名空間,在下文中一共展示了MemberAccess類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FallbackSetMember

		public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
		{
			var ctx = DynamicContext.Create ();
			var source = ctx.CreateCompilerExpression (argumentInfo [1], value);
			var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);

			// Field assignment
			expr = new Compiler.MemberAccess (expr, Name);

			// Compound assignment under dynamic context does not convert result
			// expression but when setting member type we need to do explicit
			// conversion to ensure type match between member type and dynamic
			// expression type
			if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0) {
				expr = new Compiler.RuntimeExplicitAssign (expr, source);
			} else {
				expr = new Compiler.SimpleAssign (expr, source);
			}

			expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (value);

			return binder.Bind (ctx, callingContext);
		}
開發者ID:jdecuyper,項目名稱:mono,代碼行數:27,代碼來源:CSharpSetMemberBinder.cs

示例2: FallbackGetMember

		public override DynamicMetaObject FallbackGetMember (DynamicMetaObject target, DynamicMetaObject errorSuggestion)
		{
			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			expr = new Compiler.MemberAccess (expr, Name);
			expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);

			return binder.Bind (callingContext, target);
		}
開發者ID:afaerber,項目名稱:mono,代碼行數:11,代碼來源:CSharpGetMemberBinder.cs

示例3: FallbackSetMember

		public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
		{
			var ctx = DynamicContext.Create ();
			var source = ctx.CreateCompilerExpression (argumentInfo [1], value);
			var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);

			// Field assignment
			expr = new Compiler.MemberAccess (expr, Name);
			expr = new Compiler.SimpleAssign (expr, source);
			expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (value);

			return binder.Bind (ctx, callingContext);
		}
開發者ID:stabbylambda,項目名稱:mono,代碼行數:17,代碼來源:CSharpSetMemberBinder.cs

示例4: FallbackInvokeMember

		public override DynamicMetaObject FallbackInvokeMember (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
		{
			var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
			var t_args = typeArguments == null ?
				null :
				new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (TypeImporter.Import (l), Compiler.Location.Null)).ToArray ());

			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo[0], target);

			//
			// Simple name invocation is actually member access invocation
 			// to capture original this argument. This  brings problem when
			// simple name is resolved as a static invocation and member access
			// has to be reduced back to simple name without reporting an error
			//
			if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0) {
				var value = expr as Compiler.RuntimeValueExpression;
				if (value != null)
					value.IsSuggestionOnly = true;
			}

			expr = new Compiler.MemberAccess (expr, Name, t_args, Compiler.Location.Null);
			expr = new Compiler.Invocation (expr, c_args);

			if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
				expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
				binder.ResolveOptions |= Compiler.ResolveContext.Options.InvokeSpecialName;

			return binder.Bind (callingContext, target);
		}
開發者ID:afaerber,項目名稱:mono,代碼行數:38,代碼來源:CSharpInvokeMemberBinder.cs

示例5: case_439

void case_439()
#line 3273 "cs-parser.jay"
{
		var lt = (LocatedToken) yyVals[-1+yyTop];
		yyVal = new MemberAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:7,代碼來源:cs-parser.cs

示例6: CreateCallSiteBinder

		public Expression CreateCallSiteBinder (ResolveContext ec, Arguments args)
		{
			Arguments binder_args = new Arguments (3);

			MemberAccess sle = new MemberAccess (new MemberAccess (
				new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Linq", loc), "Expressions", loc);

			MemberAccess binder = GetBinderNamespace (loc);

			binder_args.Add (new Argument (new MemberAccess (new MemberAccess (sle, "ExpressionType", loc), name, loc)));
			binder_args.Add (new Argument (new BoolLiteral (ec.HasSet (ResolveContext.Options.CheckedScope), loc)));
			binder_args.Add (new Argument (new ImplicitlyTypedArrayCreation ("[]", args.CreateDynamicBinderArguments (), loc)));

			return new New (new MemberAccess (binder, "CSharpUnaryOperationBinder", loc), binder_args, loc);
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:15,代碼來源:dynamic.cs

示例7: case_361

void case_361()
#line 2975 "cs-parser.jay"
{
		var lt = (LocatedToken) yyVals[-2+yyTop];
		yyVal = new MemberAccess ((ATypeNameExpression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location);
		lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
	  }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:7,代碼來源:cs-parser.cs

示例8: Visit

			public override object Visit(MemberAccess memberAccess)
			{
				Expression result;
				var ind = memberAccess.LeftExpression as Indirection;
				if (ind != null) {
					result = new PointerReferenceExpression();
					result.AddChild((Expression)ind.Expr.Accept(this), Roles.TargetExpression);
					result.AddChild(new CSharpTokenNode(Convert(ind.Location), PointerReferenceExpression.ArrowRole), PointerReferenceExpression.ArrowRole);
				} else {
					result = new MemberReferenceExpression();
					if (memberAccess.LeftExpression != null) {
						var leftExpr = memberAccess.LeftExpression.Accept(this);
						result.AddChild((Expression)leftExpr, Roles.TargetExpression);
					}
					var loc = LocationsBag.GetLocations(memberAccess);

					if (loc != null) {
						result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Dot), Roles.Dot);
					}
				}
				
				result.AddChild(Identifier.Create(memberAccess.Name, Convert(memberAccess.Location)), Roles.Identifier);
				
				AddTypeArguments(result, memberAccess);
				return result;
			}
開發者ID:0xb1dd1e,項目名稱:NRefactory,代碼行數:26,代碼來源:CSharpParser.cs

示例9: case_544

void case_544()
#line 3741 "cs-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		yyVal = new MemberAccess (new Indirection ((Expression) yyVals[-2+yyTop], GetLocation (yyVals[-1+yyTop])), lt.Value, lt.Location);
	  }
開發者ID:Ein,項目名稱:monodevelop,代碼行數:6,代碼來源:cs-parser.cs

示例10: case_538

void case_538()
#line 3890 "cs-parser.jay"
{
		var tne = (ATypeNameExpression) yyVals[-3+yyTop];
		if (tne.HasTypeArguments)
			Error_TypeExpected (GetLocation (yyVals[0+yyTop]));

		var lt = (LocatedToken) yyVals[-1+yyTop];
		var ma = new MemberAccess (tne, lt.Value, (int) yyVals[0+yyTop], lt.Location);		
		yyVal = ma;
		lbag.AddLocation (ma.TypeArguments, Lexer.GetGenericDimensionLocations ());
	  }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:12,代碼來源:cs-parser.cs

示例11: Visit

			public override object Visit (MemberAccess memberAccess)
			{
				Expression result;
				if (memberAccess.LeftExpression is Indirection) {
					var ind = memberAccess.LeftExpression as Indirection;
					result = new PointerReferenceExpression ();
					result.AddChild ((Expression)ind.Expr.Accept (this), PointerReferenceExpression.Roles.TargetExpression);
					result.AddChild (new CSharpTokenNode (Convert (ind.Location), "->".Length), PointerReferenceExpression.ArrowRole);
				} else {
					result = new MemberReferenceExpression ();
					if (memberAccess.LeftExpression != null) {
						var leftExpr = memberAccess.LeftExpression.Accept (this);
						result.AddChild ((Expression)leftExpr, MemberReferenceExpression.Roles.TargetExpression);
					}
					if (!memberAccess.DotLocation.IsNull) {
						result.AddChild (new CSharpTokenNode (Convert (memberAccess.DotLocation), 1), MemberReferenceExpression.Roles.Dot);
					}
				}
						
				result.AddChild (Identifier.Create (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier);
				
				if (memberAccess.TypeArguments != null)  {
					AddTypeArguments (result, memberAccess.TypeArguments);
				}
				return result;
			}
開發者ID:N3X15,項目名稱:ILSpy,代碼行數:26,代碼來源:CSharpParser.cs

示例12: case_531

void case_531()
#line 3835 "cs-parser.jay"
{
		var tne = (ATypeNameExpression) yyVals[-3+yyTop];
		if (tne.HasTypeArguments)
			Error_TypeExpected (GetLocation (yyVals[0+yyTop]));

		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new MemberAccess (tne, lt.Value, (int) yyVals[0+yyTop], lt.Location) {
			DotLocation = GetLocation (yyVals[-2+yyTop])
		};		
	  }
開發者ID:kaagati,項目名稱:NRefactory,代碼行數:12,代碼來源:cs-parser.cs

示例13: ResolveStringSwitchMap

		void ResolveStringSwitchMap (ResolveContext ec)
		{
			FullNamedExpression string_dictionary_type;
			if (TypeManager.generic_ienumerable_type != null) {
				MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
					new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc), "Generic", loc);

				string_dictionary_type = new MemberAccess (system_collections_generic, "Dictionary",
					new TypeArguments (
						new TypeExpression (TypeManager.string_type, loc),
						new TypeExpression (TypeManager.int32_type, loc)), loc);
			} else {
				MemberAccess system_collections_generic = new MemberAccess (
					new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc);

				string_dictionary_type = new MemberAccess (system_collections_generic, "Hashtable", loc);
			}

			var ctype = ec.CurrentMemberDefinition.Parent.PartialContainer;
			Field field = new Field (ctype, string_dictionary_type,
				Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED,
				new MemberName (CompilerGeneratedClass.MakeName (null, "f", "switch$map", unique_counter++), loc), null);
			if (!field.Define ())
				return;
			ctype.AddField (field);

			var init = new List<Expression> ();
			int counter = 0;
			Elements.Clear ();
			string value = null;
			foreach (SwitchSection section in Sections) {
				int last_count = init.Count;
				foreach (SwitchLabel sl in section.Labels) {
					if (sl.Label == null || sl.Converted == SwitchLabel.NullStringCase)
						continue;

					value = (string) sl.Converted;
					var init_args = new List<Expression> (2);
					init_args.Add (new StringLiteral (value, sl.Location));
					init_args.Add (new IntConstant (counter, loc));
					init.Add (new CollectionElementInitializer (init_args, loc));
				}

				//
				// Don't add empty sections
				//
				if (last_count == init.Count)
					continue;

				Elements.Add (counter, section.Labels [0]);
				++counter;
			}

			Arguments args = new Arguments (1);
			args.Add (new Argument (new IntConstant (init.Count, loc)));
			Expression initializer = new NewInitialize (string_dictionary_type, args,
				new CollectionOrObjectInitializers (init, loc), loc);

			switch_cache_field = new FieldExpr (field, loc);
			string_dictionary = new SimpleAssign (switch_cache_field, initializer.Resolve (ec));
		}
開發者ID:alisci01,項目名稱:mono,代碼行數:61,代碼來源:statement.cs

示例14: case_432

void case_432()
#line 3222 "cs-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new MemberAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location) {
			DotLocation = GetLocation (yyVals[-2+yyTop])
		};
	  }
開發者ID:kaagati,項目名稱:NRefactory,代碼行數:8,代碼來源:cs-parser.cs

示例15: case_530

void case_530()
#line 3827 "cs-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		
		yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (int) yyVals[0+yyTop], lt.Location) {
			DotLocation = GetLocation (yyVals[-2+yyTop])
		};
	  }
開發者ID:kaagati,項目名稱:NRefactory,代碼行數:9,代碼來源:cs-parser.cs


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