public AttributeBaseAst _VisitAttributeBase(AttributeBaseAst attributeBaseAst) { var @switch = new Dictionary <Type, Func <AttributeBaseAst, AttributeBaseAst> > { { typeof(AttributeAst), (ab) => { return((AttributeBaseAst)VisitAttribute(ab as AttributeAst)); } }, { typeof(TypeConstraintAst), (ab) => { return((AttributeBaseAst)VisitTypeConstraint(ab as TypeConstraintAst)); } } }; return(@switch[attributeBaseAst.GetType()](attributeBaseAst)); }
public System.Object VisitAttributedExpression(System.Management.Automation.Language.AttributedExpressionAst attributedExpressionAst) { IScriptExtent mappedExtent = MapExtent(attributedExpressionAst.Extent); AttributeBaseAst mappedAttribute = _VisitAttributeBase(attributedExpressionAst.Attribute); ExpressionAst mappedChild = _VisitExpression(attributedExpressionAst.Child); return(new AttributedExpressionAst(mappedExtent, mappedAttribute, mappedChild)); }
private bool IsAttributeOfType(AttributeBaseAst attributeAst, Type type) { var arrayType = attributeAst.TypeName as ArrayTypeName; if (arrayType != null) { return(arrayType.ElementType.GetReflectionType() == type); } return(attributeAst.TypeName.GetReflectionType() == type); }
public static AttributedExpressionAst Update( this AttributedExpressionAst ast, AttributeBaseAst attribute = null, ExpressionAst child = null) { return(new AttributedExpressionAst( ast.Extent, attribute?.Clone() ?? ast.Attribute.Clone(), child?.Clone() ?? ast.Child.Clone())); }
private bool IsParameterAttribute(AttributeBaseAst attributeBaseAst) { return(attributeBaseAst.TypeName.GetReflectionType().Name.Equals("ParameterAttribute")); }