本文整理汇总了C#中ICSharpCode.NRefactory.CSharp类的典型用法代码示例。如果您正苦于以下问题:C# ICSharpCode.NRefactory.CSharp类的具体用法?C# ICSharpCode.NRefactory.CSharp怎么用?C# ICSharpCode.NRefactory.CSharp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICSharpCode.NRefactory.CSharp类属于命名空间,在下文中一共展示了ICSharpCode.NRefactory.CSharp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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();
}
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例12: Init
protected internal Init(NRefactory.VariableInitializer variableInitializer, IScope scope, INRefcatoryExpressionVisitor visitor)
: base(scope, visitor) {
NRefactory.Expression initializer = null;
_variableInitializer = variableInitializer;
initializer = variableInitializer.Initializer;
}
示例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);
}
示例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();
}
示例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();
}