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


C# MemberReferenceExpression类代码示例

本文整理汇总了C#中MemberReferenceExpression的典型用法代码示例。如果您正苦于以下问题:C# MemberReferenceExpression类的具体用法?C# MemberReferenceExpression怎么用?C# MemberReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: FieldReferenceReflectionEmitter

        internal FieldReferenceReflectionEmitter(MemberReferenceExpression memberReferenceExpression,
                                                 Type target,
                                                 MemberInfo member,
                                                 ILGenerator ilGenerator,
                                                 IOpCodeIndexer instructionsIndexer,
                                                 IAstVisitor<ILGenerator, AstNode> visitor,
                                                 List<LocalBuilder> locals,
                                                 bool isSetter = false)
            : base(memberReferenceExpression, target, member, ilGenerator, instructionsIndexer, visitor, locals) {

            FieldReference = MemberReference.Annotation<FieldReference>();
            IsByRef = MemberReference.Parent is DirectionExpression;
            Type = FieldReference.FieldType.GetActualType();
            FieldInfo = FieldReference.GetActualField();
            NonPublic = !((FieldInfo.Attributes & (_publicFieldAttributes)) == _publicFieldAttributes);

            if (isSetter) {
                _emitAction = EmitStoreFieldReference;
                _emitPrivateAction = EmitPrivateStoreFieldReference;
            }
            else {
                _emitAction = EmitLoadFieldReference;
                _emitPrivateAction = EmitPrivateLoadFieldReference;
            }
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:25,代码来源:FieldReferenceReflectionEmitter.cs

示例2: PropertyReferenceReflectionEmitter

        public PropertyReferenceReflectionEmitter(MemberReferenceExpression memberReferenceExpression,
                                                  Type target,
                                                  MemberInfo member,
                                                  ILGenerator ilGenerator,
                                                  IOpCodeIndexer instructionsIndexer,
                                                  IAstVisitor<ILGenerator, AstNode> visitor,
                                                  List<LocalBuilder> locals,
                                                  bool isSetter = false)
            : base(memberReferenceExpression, target, member, ilGenerator, instructionsIndexer, visitor, locals) {

            var propertyInfo = Member as PropertyInfo;

            _isSetter = isSetter;
            _propertyDefinition = MemberReference.Annotation<Cecil.PropertyDefinition>();
            NonPublic = !_propertyDefinition.GetMethod.IsPublic;
            Type = _propertyDefinition.PropertyType.GetActualType();

            if (isSetter) {
                _propertyMethod = propertyInfo.GetSetMethod(NonPublic);
                _emitPrivateAction = EmitPrivateStorePropertyReference;
            }
            else {
                _propertyMethod = propertyInfo.GetGetMethod(NonPublic);
                _emitPrivateAction = EmitPrivateLoadPropertyReference;
            }
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:26,代码来源:PropertyReferenceReflectionEmitter.cs

示例3: EventReferenceReflectionEmitter

 internal EventReferenceReflectionEmitter(MemberReferenceExpression memberReferenceExpression,
                                          Type target,
                                          MemberInfo member,
                                          ILGenerator ilGenerator,
                                          IOpCodeIndexer instructionsIndexer,
                                          IAstVisitor<ILGenerator, AstNode> visitor,
                                          List<LocalBuilder> locals)
     : base(memberReferenceExpression, target, member, ilGenerator, instructionsIndexer, visitor, locals) { }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:8,代码来源:EventReferenceReflectionEmitter.cs

示例4: VisitMemberReferenceExpression

			public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
			{
				if (!IsTargetOfInvocation(memberReferenceExpression)) {
					var mgr = ctx.Resolve (memberReferenceExpression) as MethodGroupResolveResult;
					if (mgr != null)
						UsedMethods.AddRange (mgr.Methods);
				}
				base.VisitMemberReferenceExpression(memberReferenceExpression);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:9,代码来源:ParameterNotUsedIssue.cs

示例5: ToStaticMethodInvocation

        AstNode ToStaticMethodInvocation(InvocationExpression invocation, MemberReferenceExpression memberReference,
		                                 CSharpInvocationResolveResult invocationRR)
        {
            var newArgumentList = invocation.Arguments.Select(arg => arg.Clone()).ToList();
            newArgumentList.Insert(0, memberReference.Target.Clone());
            var newTarget = memberReference.Clone() as MemberReferenceExpression;
            newTarget.Target = new IdentifierExpression(invocationRR.Member.DeclaringType.Name);
            return new InvocationExpression(newTarget, newArgumentList);
        }
开发者ID:porcus,项目名称:NRefactory,代码行数:9,代码来源:ExtensionMethodInvocationToStaticMethodInvocationAction.cs

示例6: VisitMemberReferenceExpression

			public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
			{
				base.VisitMemberReferenceExpression(memberReferenceExpression);
				HandleMemberReference(
					memberReferenceExpression, memberReferenceExpression.Target, memberReferenceExpression.MemberNameToken, memberReferenceExpression.TypeArguments, NameLookupMode.Expression,
					script => {
						script.Replace(memberReferenceExpression, RefactoringAstHelper.RemoveTarget(memberReferenceExpression));
					});
			}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:9,代码来源:RedundantNamespaceUsageIssue.cs

示例7: MultipuleAssignmentEmitter

 internal MultipuleAssignmentEmitter(MemberReferenceExpression memberReferenceExpression,
                                     Expression assignor,
                                     ILGenerator ilGenerator,
                                     IOpCodeIndexer instructionsIndexer,
                                     IAstVisitor<ILGenerator, AstNode> visitor,
                                     List<LocalBuilder> locals)
     : base(memberReferenceExpression, ilGenerator, instructionsIndexer, visitor, locals) {
     _assignorExpression = assignor;
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:9,代码来源:MultipuleAssignmentEmitter.cs

示例8: VisitMemberReferenceExpression

        public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
        {
            var identifierExpression = memberReferenceExpression.Target as IdentifierExpression;
            if (identifierExpression != null && identifierExpression.Identifier == _fromIdentifier)
            {
                memberReferenceExpression.Target = new IdentifierExpression("doc");
            }

            base.VisitMemberReferenceExpression(memberReferenceExpression);
        }
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:10,代码来源:ChangeRootReferenceVisitor.cs

示例9: AbstractMemberReferenceEmitter

 internal AbstractMemberReferenceEmitter(MemberReferenceExpression memberReferenceExpression,
                                         Type target,
                                         MemberInfo member,
                                         ILGenerator ilGenerator,
                                         IOpCodeIndexer instructionsIndexer,
                                         IAstVisitor<ILGenerator, AstNode> visitor,
                                         List<LocalBuilder> locals)
     : base(ilGenerator, instructionsIndexer, visitor, locals) {
     Target = target;
     Member = member;
     MemberReference = memberReferenceExpression;
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:12,代码来源:AbstractMemberReferenceEmitter.cs

示例10: LookupAmbiguousMemberInOtherAssembly

        public void LookupAmbiguousMemberInOtherAssembly()
        {
            _compilationUnit.UsingDirectives.Add(new UsingNamespaceDirective("System"));
            var reference = new MemberReferenceExpression(new IdentifierExpression("Console"), "WriteLine");

            var result = reference.Resolve(_compilationUnit.GetScope());
            Assert.IsInstanceOfType(result, typeof(AmbiguousMemberResolveResult));
            var memberResult = (AmbiguousMemberResolveResult)result;
            Assert.AreEqual("System.Console", memberResult.Member.DeclaringType.FullName);
            Assert.AreEqual("WriteLine", memberResult.Member.Name);
            Assert.IsTrue(memberResult.Candidates.Count > 1);
        }
开发者ID:JerreS,项目名称:AbstractCode,代码行数:12,代码来源:MemberResolutionTests.cs

示例11: VisitObjectCreateExpression

		public override object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
		{
			if (objectCreateExpression.Arguments.Count() == 2) {
				Expression obj = objectCreateExpression.Arguments.First();
				Expression func = objectCreateExpression.Arguments.Last();
				Annotation annotation = func.Annotation<Annotation>();
				if (annotation != null) {
					IdentifierExpression methodIdent = (IdentifierExpression)((InvocationExpression)func).Arguments.Single();
					MethodReference method = methodIdent.Annotation<MethodReference>();
					if (method != null) {
						if (HandleAnonymousMethod(objectCreateExpression, obj, method))
							return null;
						// Perform the transformation to "new Action(obj.func)".
						obj.Remove();
						methodIdent.Remove();
						if (!annotation.IsVirtual && obj is ThisReferenceExpression) {
							// maybe it's getting the pointer of a base method?
							if (method.DeclaringType != context.CurrentType) {
								obj = new BaseReferenceExpression();
							}
						}
						if (!annotation.IsVirtual && obj is NullReferenceExpression && !method.HasThis) {
							// We're loading a static method.
							// However it is possible to load extension methods with an instance, so we compare the number of arguments:
							bool isExtensionMethod = false;
							TypeReference delegateType = objectCreateExpression.Type.Annotation<TypeReference>();
							if (delegateType != null) {
								TypeDefinition delegateTypeDef = delegateType.Resolve();
								if (delegateTypeDef != null) {
									MethodDefinition invokeMethod = delegateTypeDef.Methods.FirstOrDefault(m => m.Name == "Invoke");
									if (invokeMethod != null) {
										isExtensionMethod = (invokeMethod.Parameters.Count + 1 == method.Parameters.Count);
									}
								}
							}
							if (!isExtensionMethod) {
								obj = new TypeReferenceExpression { Type = AstBuilder.ConvertType(method.DeclaringType) };
							}
						}
						// now transform the identifier into a member reference
						MemberReferenceExpression mre = new MemberReferenceExpression();
						mre.Target = obj;
						mre.MemberName = methodIdent.Identifier;
						methodIdent.TypeArguments.MoveTo(mre.TypeArguments);
						mre.AddAnnotation(method);
						objectCreateExpression.Arguments.Clear();
						objectCreateExpression.Arguments.Add(mre);
						return null;
					}
				}
			}
			return base.VisitObjectCreateExpression(objectCreateExpression, data);
		}
开发者ID:stgwilli,项目名称:ILSpy,代码行数:53,代码来源:DelegateConstruction.cs

示例12: VisitMemberReferenceExpression

			public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
			{
				base.VisitMemberReferenceExpression(memberReferenceExpression);
				if (memberReferenceExpression == null || memberReferenceExpression.Target is ThisReferenceExpression)
					// Call within current class scope using 'this' or 'base'
					return;
				var memberResolveResult = context.Resolve(memberReferenceExpression) as MemberResolveResult;
				if (memberResolveResult == null)
					return;
				if (!memberResolveResult.Member.IsStatic)
					return;
				HandleMember(memberReferenceExpression, memberReferenceExpression.Target, memberResolveResult.Member, memberResolveResult.TargetResult);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:13,代码来源:ReferenceToStaticMemberViaDerivedTypeIssue.cs

示例13: VisitMemberReferenceExpression

            public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
            {
                const string typeToUse = "System.Threading.Thread";
                const string methodToFind = "Abort";

                if (_codebaseDeclarations.Any(a => a.Name == memberReferenceExpression.Target.GetIdentifier() && a.IsType(typeToUse)) || memberReferenceExpression.IsReferenceOfTypeFromScope(typeToUse))
                {
                    if (memberReferenceExpression.MemberName == methodToFind)
                    {
                        UnlockWith(memberReferenceExpression);
                    }
                }

                return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:15,代码来源:ThreadMethodschievements.cs

示例14: VisitMemberReferenceExpression

        // fixes bug https://github.com/ashmind/TryRoslyn/issues/7
        // todo: report this to the decompiler guys -- but does not seem like they are reading their queue
        public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
        {
            StartNode(memberReferenceExpression);

            var useParentheses = RequiresParenthesesWhenTargetOfMemberReference(memberReferenceExpression.Target);
            if (useParentheses)
                LPar();
            memberReferenceExpression.Target.AcceptVisitor(this);
            if (useParentheses)
                RPar();

            WriteToken(Roles.Dot);
            WriteIdentifier(memberReferenceExpression.MemberName);
            WriteTypeArguments(memberReferenceExpression.TypeArguments);
            EndNode(memberReferenceExpression);
        }
开发者ID:i3arnon,项目名称:TryRoslyn,代码行数:18,代码来源:DecompiledPseudoCSharpOutputVisitor.cs

示例15: VisitMemberReferenceExpression

 public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
 {
     if(memberReferenceExpression.MemberName == "Length")
     {
         var variableName = memberReferenceExpression.Target.GetIdentifier();
         if(memberReferenceExpression.GetVariablesOfInitializer<ArrayCreateExpression>().Any(a => a.Name == variableName))
         {
             UnlockWith(memberReferenceExpression);
         }
         else if(_codebaseDeclarations.Any(a => a.Name == variableName && a.Initializer is ArrayCreateExpression))
         {
             UnlockWith(memberReferenceExpression);
         }
     }
     return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
 }
开发者ID:jonasswiatek,项目名称:strokes,代码行数:16,代码来源:ArrayLengthPropertyAchievement.cs


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