本文整理汇总了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;
}
}
示例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;
}
}
示例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) { }
示例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);
}
示例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);
}
示例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));
});
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}