• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# NRefactory.CSharp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FiltertConstructorStatements

        private static NRefactory.ConstructorDeclaration FiltertConstructorStatements(NRefactory.ConstructorDeclaration constructorDeclaration, Type baseType) {
            var block = new NRefactory.BlockStatement();

            foreach (var statement in constructorDeclaration.Body.Statements) {
                var expression = statement as NRefactory.ExpressionStatement;

                if (expression != null) {
                    if (expression.Expression is NRefactory.AssignmentExpression) {
                        continue;
                    }

                    var invocation = expression.Expression as NRefactory.InvocationExpression;

                    block.Add(statement.Clone());

                    if (invocation != null && invocation.HasAnnotationOf<Cecil.MethodReference>()) {
                        var methodReference = invocation.Annotation<Cecil.MethodReference>();

                        if (methodReference.Name.Equals(".ctor") && methodReference.DeclaringType.GetActualType().Equals(baseType)) {
                            block.AddReturnStatement(new NRefactory.ThisReferenceExpression());
                            constructorDeclaration.Body = block;
                            break;
                        }
                    }
                }
                else {
                    block.Add(statement.Clone());
                }
            }

            return constructorDeclaration;
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:32,代码来源:DynamicTypeBuilder.cs


示例2: Index

        protected internal Index(NRefactory.IndexerExpression indexerExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
            : base(scope, visitor) {
            bool isAssignment = false;
            PropertyReference propertyReference = null;

            _indexerExpression = indexerExpression;
            isAssignment = IsAssignment();
            Target = indexerExpression.Target.AcceptVisitor(Visitor, ParentScope);
            TryGetArguments();

            if (indexerExpression.HasAnnotationOf<PropertyReference>(out propertyReference)) {
                var propertyInfo = Target.Type.GetProperty(propertyReference.Name);

                InternalType = propertyInfo.PropertyType;
                _indexer = propertyInfo;
            }
            else {
                _isArrayIndex = true;
                var targetType = Target.Type;

                if (targetType.HasElementType) {
                    targetType = Target.Type.GetElementType();
                }

                InternalType = targetType;
                _methodCall = _isAssignment ? Expression.ArrayAccess : (Func<Expression, IEnumerable<Expression>, Expression>)Expression.ArrayAccess;
            }
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:28,代码来源:Index.cs


示例3: ArrayCreation

        protected internal ArrayCreation(NRefactory.ArrayCreateExpression arrayCreateExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
            : base(scope, visitor) {
            
            _arrayCreateExpression = arrayCreateExpression;
            _isJaggeedArray = IsJaggedArray();
            _isVector = IsVector();
            InternalType = GetArrayType();

            if (InternalType.GetArrayRank() == 1 && !_isJaggeedArray) {
                if (TryGetOneDimensionalArrayBounds()) {
                    BuildEmptyOneDimensionalArray();
                }
                else {
                    BuildOneDimensionalArray();
                }
            }
            else {
                if (TryGetBounds()) {
                    BuildEmptyMultiDimensionalArray();
                }
                else {
                    BuildMultiDimensionalArrayAccess();
                }
            }
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:25,代码来源:ArrayCreation.cs


示例4: Switch

 protected internal Switch(NRefactory.SwitchStatement switchStatement, IScope scope, INRefcatoryExpressionVisitor visitor)
     : base(scope, visitor) {
     _switchStatement = switchStatement;
     SwitchValue = switchStatement.Expression.AcceptVisitor(Visitor, scope);
     BuildSwitchCases();
     InternalType = TypeSystem.Void;
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:Switch.cs


示例5: New

        protected internal New(NRefactory.ObjectCreateExpression objectCreation, IScope scope, INRefcatoryExpressionVisitor visitor)
            : base(scope, visitor) {
            
            _objectCreation = objectCreation;

            if (!objectCreation.Type.IsNull) {
                InternalType = objectCreation.Type.AcceptVisitor(Visitor, ParentScope).Type;

                if (objectCreation.Initializer != null) {
                    if (objectCreation.Arguments.Count == 2) {
                        Expression expression;
                        NRefactory.Expression @this = objectCreation.Arguments.First();
                        NRefactory.Expression func = objectCreation.Arguments.Last();

                        if (TryHandleAnonymousMethod(@this, func as NRefactory.InvocationExpression, out expression)) {
                            Expression = expression;
                            return;
                        }
                    }

                    if (objectCreation.Initializer != NRefactory.ArrayInitializerExpression.Null) {
                        Expression = objectCreation.Initializer.AcceptVisitor(Visitor, ParentScope);
                        return;
                    }
                }

                Expression = BuildConstructor();
            }
            else {
                Expression = HandleAnonymousType();
            }
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:32,代码来源:New.cs


示例6: Direction

 protected internal Direction(NRefactory.DirectionExpression directionExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
     : base(scope, visitor) {
     _directionExpression = directionExpression;
     IdentifierParameter = directionExpression.Expression.AcceptVisitor(Visitor, scope) as Identifier;
     _outParameter = ParentScope.Find(IdentifierParameter.Name);
     InternalType = IdentifierParameter.Type;
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:Direction.cs


示例7: CaseLabel

 protected internal CaseLabel(NRefactory.CaseLabel caseLabel, IScope scope, INRefcatoryExpressionVisitor visitor)
     : base(scope, visitor) {
     var expression = caseLabel.Expression;
     _caseLabel = caseLabel;
     DefaultValue = expression.AcceptVisitor(Visitor, ParentScope);
     InternalType = DefaultValue.Type;
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:CaseLabel.cs


示例8: Identifier

 protected internal Identifier(NRefactory.IdentifierExpression identifierExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
     : base(scope, visitor) {
     _identifierExpression = identifierExpression;
     Expression = scope.Find(_identifierExpression.Identifier);
     InternalType = Expression.Type;
     Name = _identifierExpression.Identifier;
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:Identifier.cs


示例9: Invocation

        protected internal Invocation(NRefactory.InvocationExpression invocationExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
            : base(scope, visitor) {
            
            var methodReference = invocationExpression.Annotation<Mono.Cecil.MethodReference>();

            _invocationExpression = invocationExpression;

            if (methodReference != null) {
                MethodInfo methodInfo = null;
                Member = methodInfo = methodReference.GetActualMethod<MethodInfo>();

                if (IsInitializeArray(methodInfo)) {
                    var first = _invocationExpression.Arguments.First().AcceptVisitor(Visitor, ParentScope);
                    var invocation = _invocationExpression.Arguments.Last() as NRefactory.InvocationExpression;
                    var second = invocation.Arguments.First();
                    var memberReference = invocationExpression.Target as NRefactory.MemberReferenceExpression;
                    var target = memberReference.Target as NRefactory.TypeReferenceExpression;
                    var type = target.Type.GetActualType();
                    var parameters = methodReference.Parameters;
                    return;
                }
            }

            BuildInvocation();
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:25,代码来源:Invocation.cs


示例10: MappedInvocation

        public MappedInvocation(NRefactory.ConstructorDeclaration ctor, MethodDefinition baseCtor) {
            var parameterTypes = new List<Type>();
            var ctorType = ctor.GetActualType();

            _parameters = ctor.Parameters
                              .Select((p, i) => {
                                  return new Parameter(p.Name, p.GetActualType(), i);
                              })
                              .ToArray();

            _parameterDeclarations = ctor.Parameters.ToArray();
            _visitor.VisitConstructorDeclaration(ctor, null);
            _outParameters = new List<Parameter>();
            parameterTypes = new List<Type>();

            _parameters.ForEach((p, i) => {
                var type = p.Type;

                if (_visitor.Contains(p.Name)) {
                    if (!type.IsByRef) {
                        type = type.MakeByRefType();
                        p = new Parameter(p.Name, type, p.Location);
                    }

                    _outParameters.Add(p);
                }

                parameterTypes.Add(type);
            });

            VerifyUniqueness(ctorType, parameterTypes);
            Parameters = parameterTypes.ToArray();
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:33,代码来源:MappedInvocation.cs


示例11: NamedExpression

 protected internal NamedExpression(NRefactory.NamedExpression namedExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
     : base(scope, visitor) {
     Name = namedExpression.Identifier;
     _namedExpression = namedExpression;
     Expression = _namedExpression.Expression.AcceptVisitor(Visitor, ParentScope);
     InternalType = Expression.Type;
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:NamedExpression.cs


示例12: Init

        protected internal Init(NRefactory.VariableInitializer variableInitializer, IScope scope, INRefcatoryExpressionVisitor visitor)
            : base(scope, visitor) {
            NRefactory.Expression initializer = null;

            _variableInitializer = variableInitializer;
            initializer = variableInitializer.Initializer;
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:Init.cs


示例13: ConstructorBlock

 public static ConstructorBlock ConstructorBlock(NRefactory.BlockStatement blockStatement,
                                                 ParameterExpression contextParameter,
                                                 IScope scope,
                                                 INRefcatoryExpressionVisitor visitor,
                                                 IEnumerable<ParameterExpression> parameters = null,
                                                 IEnumerable<ParameterExpression> baseConstructorParameters = null) {
     return new ConstructorBlock(blockStatement, contextParameter, parameters: parameters, scope: scope, visitor: visitor, baseConstructorParameters: baseConstructorParameters);
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:8,代码来源:AstExpression.cs


示例14: Block

        protected internal Block(NRefactory.BlockStatement blockStatement, IScope scope, INRefcatoryExpressionVisitor visitor, IEnumerable<ParameterExpression> parameters = null)
            : base(scope, visitor) {

            _blockStatement = blockStatement;
            InternalType = ResolveType(blockStatement);
            Parameters = parameters;
            BuildExpressions();
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:8,代码来源:Block.cs


示例15: AnonymousType

        protected internal AnonymousType(NRefactory.AnonymousTypeCreateExpression anonymousTypeCreateExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
            : base(scope, visitor) {
            var typeInformation = anonymousTypeCreateExpression.Annotation<TypeInformation>();

            _anonymousTypeCreateExpression = anonymousTypeCreateExpression;
            _initializers = _anonymousTypeCreateExpression.Initializers.Select(i => i.AcceptVisitor(Visitor, ParentScope));
            InternalType = typeInformation.InferredType.GetActualType();
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:8,代码来源:AnonymousType.cs


示例16: Base

        protected internal Base(NRefactory.BaseReferenceExpression baseReferenceExpression, IScope scope, INRefcatoryExpressionVisitor visitor)
            : base(scope, visitor) {
            var memberReference = baseReferenceExpression.Parent.Annotation<Mono.Cecil.MemberReference>();

            _baseReferenceExpression = baseReferenceExpression;
            Context = RootScope.Context.Expression;
            InternalType = memberReference != null ? memberReference.DeclaringType.GetActualType() : Context.Type;
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:8,代码来源:Base.cs


示例17: MethodBlock

        public MethodBlock(NRefactory.BlockStatement blockStatement, IScope scope, INRefcatoryExpressionVisitor visitor, IEnumerable<ParameterExpression> parameters = null)
            : base(blockStatement, parameters: parameters, scope: scope, visitor: visitor) {
            var registry = RootScope.BranchingRegistry;

            if (registry.HasReturnLabel) {
                AddReturnLabelExpression();
            }
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:8,代码来源:MethodBlock.cs


示例18: GetOutParameters

        internal IEnumerable<Parameter> GetOutParameters(NRefactory.ConstructorDeclaration ctor) {
            var mapped = _mappedInvocations.FirstOrDefault(m => m.CanMapTo(ctor));

            if (mapped != null) {
                return mapped.OutParameters;
            }

            return null;
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:9,代码来源:DynamicProxy.cs


示例19: ReduceEvent

        private Expression ReduceEvent(NRefactory.AssignmentExpression assignmentExpression) {
            ExpressionType expressionType;

            if (!Enum.TryParse<ExpressionType>(assignmentExpression.Operator.ToString(), out expressionType)) {
                throw new InvalidOperationException("Event registration must have an add/subtract operator");
            }

            return AstExpression.Event(Expression, Member as EventInfo, expressionType, ParentScope, Visitor);
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:9,代码来源:MemberReference.cs


示例20: ResolveConstructor

        private static NRefactory.ConstructorDeclaration ResolveConstructor(NRefactory.ConstructorDeclaration constructorDeclaration, Type baseType, ILGenerator iLGenerator, List<Cil.Instruction> instructions) {
            ConstructorEmitterVisitor constructorEmitter = null;

            constructorDeclaration = FiltertConstructorStatements(constructorDeclaration, baseType);
            constructorEmitter = new ConstructorEmitterVisitor(constructorDeclaration, new InstructionsIndexer(instructions));
            constructorDeclaration.AcceptVisitor(constructorEmitter, iLGenerator);

            return constructorDeclaration;
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:9,代码来源:DynamicTypeBuilder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICSharpContextActionDataProvider类代码示例发布时间:2022-05-24
下一篇:
C# ICSharpCode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap