本文整理汇总了C#中ICSharpCode.NRefactory.Ast.MemberReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# MemberReferenceExpression类的具体用法?C# MemberReferenceExpression怎么用?C# MemberReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberReferenceExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了MemberReferenceExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: add_Invocation
//, AstExpression expression)
public static InvocationExpression add_Invocation(this BlockStatement blockStatement, string typeName, string methodName, params object[] parameters)
{
if (methodName.valid().isFalse())
return null;
Expression memberExpression = null;
if (typeName.valid())
memberExpression = new MemberReferenceExpression(new IdentifierExpression(typeName), methodName);
else
memberExpression = new IdentifierExpression(methodName);
var memberReference = new InvocationExpression(memberExpression);
if (parameters != null)
{
var arguments = new List<Expression>();
foreach (var parameter in parameters)
if (parameter is Expression)
arguments.add(parameter as Expression);
else
arguments.add(new PrimitiveExpression(parameter, parameter.str()));
memberReference.Arguments = arguments;
}
blockStatement.append(memberReference.expressionStatement());
return memberReference;
}
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:29,代码来源:InvocationExpression_ExtensionMethods.cs
示例2: GenerateCode
public override void GenerateCode(List<AbstractNode> nodes, IList items)
{
TypeReference stringReference = new TypeReference("System.String", true);
MethodDeclaration method = new MethodDeclaration {
Name = "ToString",
Modifier = Modifiers.Public | Modifiers.Override,
TypeReference = stringReference,
};
method.Body = new BlockStatement();
Expression target = new MemberReferenceExpression(new TypeReferenceExpression(stringReference),
"Format");
InvocationExpression methodCall = new InvocationExpression(target);
StringBuilder formatString = new StringBuilder();
formatString.Append('[');
formatString.Append(currentClass.Name);
for (int i = 0; i < items.Count; i++) {
formatString.Append(' ');
formatString.Append(codeGen.GetPropertyName(((FieldWrapper)items[i]).Field.Name));
formatString.Append("={");
formatString.Append(i);
formatString.Append('}');
}
formatString.Append(']');
methodCall.Arguments.Add(new PrimitiveExpression(formatString.ToString(), formatString.ToString()));
foreach (FieldWrapper w in items) {
methodCall.Arguments.Add(new MemberReferenceExpression(new ThisReferenceExpression(), w.Field.Name));
}
method.Body.AddChild(new ReturnStatement(methodCall));
nodes.Add(method);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:30,代码来源:ToStringCodeGenerator.cs
示例3: add_MemberReference
//, AstExpression expression)
public static MemberReferenceExpression add_MemberReference(this BlockStatement blockStatement, string memberName, string className)
{
var identifier = new IdentifierExpression(memberName);
var memberReference = new MemberReferenceExpression(identifier, className);
blockStatement.append(memberReference.expressionStatement());
return memberReference;
}
开发者ID:pusp,项目名称:o2platform,代码行数:8,代码来源:MemberReferenceExpression_ExtensionMethods.cs
示例4: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
base.VisitTypeDeclaration(typeDeclaration, data); // visit methods
typeDeclaration.Attributes.Clear();
typeDeclaration.BaseTypes.Clear();
// add constructor accepting the wrapped object and the field holding the object
FieldDeclaration fd = new FieldDeclaration(null, // no attributes
new TypeReference(typeDeclaration.Name),
Modifiers.Private);
fd.Fields.Add(new VariableDeclaration("wrappedObject"));
typeDeclaration.AddChild(fd);
typeDeclaration.Name += "Wrapper";
if (typeDeclaration.Type == ClassType.Interface) {
typeDeclaration.Type = ClassType.Class;
typeDeclaration.Name = typeDeclaration.Name.Substring(1);
}
ConstructorDeclaration cd = new ConstructorDeclaration(typeDeclaration.Name,
Modifiers.Public,
new List<ParameterDeclarationExpression>(),
null);
cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference,
"wrappedObject"));
// this.wrappedObject = wrappedObject;
Expression fieldReference = new MemberReferenceExpression(new ThisReferenceExpression(),
"wrappedObject");
Expression assignment = new AssignmentExpression(fieldReference,
AssignmentOperatorType.Assign,
new IdentifierExpression("wrappedObject"));
cd.Body = new BlockStatement();
cd.Body.AddChild(new ExpressionStatement(assignment));
typeDeclaration.AddChild(cd);
for (int i = 0; i < typeDeclaration.Children.Count; i++) {
object child = typeDeclaration.Children[i];
if (child is MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration)child;
if (method.Parameters.Count == 0 &&
(method.Name.StartsWith("Is") || method.Name.StartsWith("Get")))
{
// replace the method with a property
PropertyDeclaration prop = new PropertyDeclaration(method.Modifier,
method.Attributes,
method.Name,
null);
prop.TypeReference = method.TypeReference;
prop.GetRegion = new PropertyGetRegion(method.Body, null);
typeDeclaration.Children[i] = prop;
}
}
}
return null;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:55,代码来源:WrapperGeneratorVisitor.cs
示例5: MethodOnThisReferenceInvocation
public void MethodOnThisReferenceInvocation()
{
// InitializeComponents();
MemberReferenceExpression field = new MemberReferenceExpression(new ThisReferenceExpression(), "InitializeComponents");
InvocationExpression invocation = new InvocationExpression(field, new List<Expression>());
object output = invocation.AcceptVisitor(new CodeDomVisitor(), null);
Assert.IsTrue(output is CodeMethodInvokeExpression);
CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output;
Assert.AreEqual("InitializeComponents", mie.Method.MethodName);
Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression);
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:11,代码来源:InvocationExpressionTest.cs
示例6: VisitMemberReferenceExpression
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
{
if (memberReferenceExpression.TargetObject is IdentifierExpression)
{
var identifier = (IdentifierExpression) memberReferenceExpression.TargetObject;
if (identifier.Identifier == "array" && memberReferenceExpression.MemberName == "Length")
UnlockWith(memberReferenceExpression);
}
return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:12,代码来源:ArrayLengthPropertyAchievement.cs
示例7: InvocationOfStaticMethod
public void InvocationOfStaticMethod()
{
// System.Drawing.Color.FromArgb();
MemberReferenceExpression field = new MemberReferenceExpression(new IdentifierExpression("System"), "Drawing");
field = new MemberReferenceExpression(field, "Color");
field = new MemberReferenceExpression(field, "FromArgb");
InvocationExpression invocation = new InvocationExpression(field, new List<Expression>());
object output = invocation.AcceptVisitor(new CodeDomVisitor(), null);
Assert.IsTrue(output is CodeMethodInvokeExpression);
CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output;
Assert.AreEqual("FromArgb", mie.Method.MethodName);
Assert.IsTrue(mie.Method.TargetObject is CodeTypeReferenceExpression);
Assert.AreEqual("System.Drawing.Color", (mie.Method.TargetObject as CodeTypeReferenceExpression).Type.BaseType);
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:14,代码来源:InvocationExpressionTest.cs
示例8: ModifyLambdaForSelect
private static INode ModifyLambdaForSelect(ParenthesizedExpression parenthesizedlambdaExpression,
MemberReferenceExpression target)
{
var parentInvocation = target.TargetObject as InvocationExpression;
if(parentInvocation != null)
{
var parentTarget = parentInvocation.TargetObject as MemberReferenceExpression;
if(parentTarget != null && parentTarget.MemberName == "GroupBy")
{
return new CastExpression(new TypeReference("Func<IGrouping<dynamic,dynamic>, dynamic>"), parenthesizedlambdaExpression, CastType.Cast);
}
}
return new CastExpression(new TypeReference("Func<dynamic, dynamic>"), parenthesizedlambdaExpression, CastType.Cast);
}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:14,代码来源:TransformDynamicLambdaExpressions.cs
示例9: VisitMemberReferenceExpression
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
{
foreach (var forbidden in Members.Where(x => x.Names.Contains(memberReferenceExpression.MemberName)))
{
var identifierExpression = GetTarget(memberReferenceExpression);
if(forbidden.TypeAliases.Contains(identifierExpression) == false)
continue;
var text = QueryParsingUtils.ToText(memberReferenceExpression);
throw new InvalidOperationException(string.Format(forbidden.Error, text));
}
return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:14,代码来源:ThrowOnInvalidMethodCalls.cs
示例10: VisitMemberReferenceExpression
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
{
var identifierExpression = memberReferenceExpression.TargetObject as IdentifierExpression;
if (identifierExpression == null || identifierExpression.Identifier != identifier)
return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
var indexerExpression = new IndexerExpression(
memberReferenceExpression.TargetObject,
new List<Expression> { new PrimitiveExpression(memberReferenceExpression.MemberName, memberReferenceExpression.MemberName) });
ReplaceCurrentNode(indexerExpression);
indexerExpression.Parent = memberReferenceExpression.Parent;
return indexerExpression;
}
开发者ID:sirrocco,项目名称:rhino-divandb,代码行数:15,代码来源:TransformVisitor.cs
示例11: GenerateCode
public override void GenerateCode(List<AbstractNode> nodes, IList items)
{
ConstructorDeclaration ctor = new ConstructorDeclaration(currentClass.Name, Modifiers.Public, null, null);
ctor.Body = new BlockStatement();
foreach (FieldWrapper w in items) {
string parameterName = codeGen.GetParameterName(w.Field.Name);
ctor.Parameters.Add(new ParameterDeclarationExpression(ConvertType(w.Field.ReturnType),
parameterName));
Expression left = new MemberReferenceExpression(new ThisReferenceExpression(), w.Field.Name);
Expression right = new IdentifierExpression(parameterName);
Expression expr = new AssignmentExpression(left, AssignmentOperatorType.Assign, right);
ctor.Body.AddChild(new ExpressionStatement(expr));
}
nodes.Add(ctor);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:ConstructorCodeGenerator.cs
示例12: VisitMemberReferenceExpression
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
{
if (memberReferenceExpression.MemberName == "Abort")
{
if (memberReferenceExpression.TargetObject is IdentifierExpression)
{
var id = (IdentifierExpression)memberReferenceExpression.TargetObject;
if (threadVars.Contains(id.Identifier))
{
UnlockWith(memberReferenceExpression);
}
}
}
return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:16,代码来源:ThreadMethodschievements.cs
示例13: VisitMemberReferenceExpression
public override object VisitMemberReferenceExpression(MemberReferenceExpression fieldReferenceExpression, object data)
{
ResolveResult fieldRR = base.VisitMemberReferenceExpression(fieldReferenceExpression, data) as ResolveResult;
if (vbMyFormsClass != null && IsReferenceToInstanceMember(fieldRR)) {
TypeResolveResult trr = Resolve(fieldReferenceExpression.TargetObject) as TypeResolveResult;
if (trr != null && trr.ResolvedClass != null) {
foreach (IProperty p in vbMyFormsClass.Properties) {
if (p.ReturnType.FullyQualifiedName == trr.ResolvedClass.FullyQualifiedName) {
fieldReferenceExpression.TargetObject = MakeFieldReferenceExpression("My.MyProject.Forms." + p.Name);
}
}
}
}
return null;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:17,代码来源:VBNetToCSharpConvertVisitorWithMyFormsSupport.cs
示例14: VisitMemberReferenceExpression
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
{
IdentifierExpression id = memberReferenceExpression.TargetObject as IdentifierExpression;
if (id != null) {
if (id.Identifier == "System" || id.Identifier == currentClass) {
ReplaceCurrentNode(new IdentifierExpression(memberReferenceExpression.MemberName));
return null;
}
if (id.Identifier.StartsWith("System.")) {
id.Identifier = id.Identifier.Replace("System.", "");
return null;
}
}
// we can't always remove "this", the field name might conflict with a parameter/local variable
// if (memberReferenceExpression.TargetObject is ThisReferenceExpression) {
// ReplaceCurrentNode(new IdentifierExpression(memberReferenceExpression.MemberName));
// return null;
// }
return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
}
开发者ID:almazik,项目名称:ILSpy,代码行数:20,代码来源:SimplifyTypeReferences.cs
示例15: SimpleNonInvocationExpression
//.........这里部分代码省略.........
#line 1676 "VBNET.ATG"
pexpr = new TypeReferenceExpression(new TypeReference(val, true));
break;
}
case 139: {
lexer.NextToken();
#line 1677 "VBNET.ATG"
pexpr = new ThisReferenceExpression();
break;
}
case 144: case 145: {
#line 1678 "VBNET.ATG"
Expression retExpr = null;
if (la.kind == 144) {
lexer.NextToken();
#line 1679 "VBNET.ATG"
retExpr = new BaseReferenceExpression();
} else if (la.kind == 145) {
lexer.NextToken();
#line 1680 "VBNET.ATG"
retExpr = new ClassReferenceExpression();
} else SynErr(258);
Expect(16);
IdentifierOrKeyword(
#line 1682 "VBNET.ATG"
out name);
#line 1682 "VBNET.ATG"
pexpr = new MemberReferenceExpression(retExpr, name);
break;
}
case 117: {
lexer.NextToken();
Expect(16);
Identifier();
#line 1684 "VBNET.ATG"
type = new TypeReference(t.val ?? "");
#line 1686 "VBNET.ATG"
type.IsGlobal = true;
#line 1687 "VBNET.ATG"
pexpr = new TypeReferenceExpression(type);
break;
}
case 148: {
ObjectCreateExpression(
#line 1688 "VBNET.ATG"
out expr);
#line 1688 "VBNET.ATG"
pexpr = expr;
break;
}
case 81: case 93: case 204: {
#line 1690 "VBNET.ATG"
CastType castType = CastType.Cast;
if (la.kind == 93) {
lexer.NextToken();
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:67,代码来源:Parser.cs
示例16: VisitMemberReferenceExpression
public sealed override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) {
this.BeginVisit(memberReferenceExpression);
object result = this.TrackedVisitMemberReferenceExpression(memberReferenceExpression, data);
this.EndVisit(memberReferenceExpression);
return result;
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:6,代码来源:NodeTrackingAstVisitor.cs
示例17: TrackedVisitMemberReferenceExpression
public virtual object TrackedVisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) {
return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:3,代码来源:NodeTrackingAstVisitor.cs
示例18: VisitMemberReferenceExpression
public virtual object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) {
throw new global::System.NotImplementedException("MemberReferenceExpression");
}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:3,代码来源:NotImplementedAstVisitor.cs
示例19: GenerateCode
protected override IEnumerable<string> GenerateCode (INRefactoryASTProvider astProvider, string indent, List<IBaseMember> includedMembers)
{
StringBuilder format = new StringBuilder ();
format.Append ("[");
format.Append (Options.EnclosingType.Name);
format.Append (": ");
int i = 0;
foreach (IMember member in includedMembers) {
if (i > 0)
format.Append (", ");
format.Append (member.Name);
format.Append ("={");
format.Append (i++);
format.Append ("}");
}
format.Append ("]");
MethodDeclaration methodDeclaration = new MethodDeclaration ();
methodDeclaration.Name = "ToString";
methodDeclaration.TypeReference = DomReturnType.String.ConvertToTypeReference ();
methodDeclaration.Modifier = ICSharpCode.NRefactory.Ast.Modifiers.Public | ICSharpCode.NRefactory.Ast.Modifiers.Override;
methodDeclaration.Body = new BlockStatement ();
MemberReferenceExpression formatReference = new MemberReferenceExpression (new TypeReferenceExpression (methodDeclaration.TypeReference), "Format");
List<Expression> arguments = new List<Expression> ();
arguments.Add (new PrimitiveExpression (format.ToString ()));
foreach (IMember member in includedMembers) {
arguments.Add (new IdentifierExpression (member.Name));
}
methodDeclaration.Body.AddChild (new ReturnStatement (new InvocationExpression (formatReference, arguments)));
yield return astProvider.OutputNode (this.Options.Dom, methodDeclaration, indent);
}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:33,代码来源:ToStringGenerator.cs
示例20: GetTarget
private static string GetTarget(MemberReferenceExpression memberReferenceExpression)
{
var identifierExpression = memberReferenceExpression.TargetObject as IdentifierExpression;
if(identifierExpression!=null)
return identifierExpression.Identifier;
var mre = memberReferenceExpression.TargetObject as MemberReferenceExpression;
if(mre != null)
return GetTarget(mre) + "." + mre.MemberName;
return null;
}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:12,代码来源:ThrowOnInvalidMethodCalls.cs
注:本文中的ICSharpCode.NRefactory.Ast.MemberReferenceExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论