/// <summary> /// Calls the given visitor for the type's component. /// </summary> /// <param name="visitor">Visitor to use.</param> public void Accept(ITypeVisitor visitor) { if (visitor == null) throw new ArgumentNullException("visitor"); visitor.Visit(_type); if (_type.HasSecurityDeclarations) visitor.Visit(_type.SecurityDeclarations); if (_type.HasGenericParameters) visitor.Visit(_type.GenericParameters); if (_type.HasInterfaces) visitor.Visit(_type.Interfaces); if (_type.HasCustomAttributes) visitor.Visit(_type.CustomAttributes); if (_type.HasEvents) visitor.Visit(_type.Events); if (_type.HasFields) visitor.Visit(_type.Fields); if (_type.HasProperties) visitor.Visit(_type.Properties); if (_type.HasMethods) visitor.Visit(_type.Methods); if (_type.HasNestedTypes) visitor.Visit(_type.NestedTypes); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitMemberPointerType(this, quals)); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitUnaryTransformType(this, quals)); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitDependentNameType(this, quals)); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitTemplateParameterSubstitutionType(this, quals)); }
public T Visit <T>(ITypeVisitor <T> visitor) { return(Type.Visit(visitor, Qualifiers)); }
public abstract void Accept(ITypeVisitor visitor);
public abstract T Accept <T>(ITypeVisitor <T> visitor);
/// <summary> /// Extension method that uses the <see cref="TypeCrawler"/> to visit a type with a visitor. /// </summary> /// <param name="self">Instance parameter. Type to be visited.</param> /// <param name="visitor">The visitor to use.</param> public static void Accept(this TypeDefinition self, ITypeVisitor visitor) { if (self == null) throw new InstanceArgumentNullException(); new TypeCrawler(self).Accept(visitor); }
public T Accept <T>(ITypeVisitor <T> visitor) => visitor.VisitFunctionType(this);
public override void Visit(ITypeVisitor visitor) => visitor.Visit(this);
public T Visit <T>(ITypeVisitor <T> visitor) { return(visitor.VisitQualifiedType(this)); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitUnresolvedUsingType(this, quals)); }
/// <summary> /// Walk over a type to create a value. /// </summary> /// <param name="visitor">The type visitor object.</param> /// <param name="type">The type.</param> /// <typeparam name="T">The return type.</typeparam> /// <returns>A value.</returns> public static T ApplyTypeVisitor <T>(ITypeVisitor <T> visitor, Type type) { if (type == BoolType) { return(visitor.VisitBool()); } if (type == ByteType) { return(visitor.VisitByte()); } if (type == ShortType) { return(visitor.VisitShort()); } if (type == UshortType) { return(visitor.VisitUshort()); } if (type == IntType) { return(visitor.VisitInt()); } if (type == UintType) { return(visitor.VisitUint()); } if (type == LongType) { return(visitor.VisitLong()); } if (type == UlongType) { return(visitor.VisitUlong()); } if (IsOptionType(type)) { var t = type.GetGenericArguments()[0]; return(visitor.VisitOption(ty => ApplyTypeVisitor(visitor, ty), t)); } if (IsTupleType(type)) { var tleft = type.GetGenericArguments()[0]; var tright = type.GetGenericArguments()[1]; return(visitor.VisitTuple(ty => ApplyTypeVisitor(visitor, ty), tleft, tright)); } if (IsValueTupleType(type)) { var tleft = type.GetGenericArguments()[0]; var tright = type.GetGenericArguments()[1]; return(visitor.VisitValueTuple(ty => ApplyTypeVisitor(visitor, ty), tleft, tright)); } if (IsIListType(type)) { var t = type.GetGenericArguments()[0]; return(visitor.VisitList(ty => ApplyTypeVisitor(visitor, ty), type, t)); } if (IsIDictionaryType(type)) { var args = type.GetGenericArguments(); var tkey = args[0]; var tvalue = args[1]; return(visitor.VisitDictionary(ty => ApplyTypeVisitor(visitor, ty), type, tkey, tvalue)); } if (IsListType(type) || IsDictionaryType(type)) { throw new InvalidOperationException($"Unsupported object field type: {type}"); } // some class or struct var dict = new Dictionary <string, Type>(); foreach (var field in GetAllFields(type)) { dict[field.Name] = field.FieldType; } foreach (var property in GetAllProperties(type)) { dict[property.Name] = property.PropertyType; } return(visitor.VisitObject(t => ApplyTypeVisitor(visitor, t), type, dict)); }
public abstract object Accept <T>(ITypeVisitor <T> visitor);
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals) { return(visitor.VisitAttributedType(this, quals)); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitPointerType(this, QualifiedPointee.Qualifiers)); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals) { return(visitor.VisitBuiltinType(this, quals)); }
public override object Accept <T>(ITypeVisitor <T> visitor) { return(visitor.Visit(this)); }
public abstract SemanticAtom Accept(ITypeVisitor v);
public override SemanticAtom Accept(ITypeVisitor v) { return(v.Visit(this)); }
public void AcceptTypeVisitor(ITypeVisitor visitor, DB_Type type) { VisitType(type, visitor); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitDependentTemplateSpecializationType(this, quals)); }
public CreateBindings(ITypeVisitor <IWidget> widgetFactory) { Bindings = new List <UIBinding>(); WidgetFactory = widgetFactory; }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitInjectedClassNameType(this, quals)); }
/// <summary> /// Accept a visit from the given visitor for each item /// </summary> internal static void AcceptAll <T, VisitorT, DataT>(this IEnumerable <T> items, ITypeVisitor <VisitorT, DataT> visitor, DataT data) where T : TypeReference { foreach (var x in items) { x.Accept(visitor, data); } }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitPackExpansionType(this, quals)); }
public override TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor) { return(defaultTypeVisitor.Visit(this)); }
public abstract T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers());
public override TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor) { EnsureReferenceType(); return(ReferenceType.Accept(defaultTypeVisitor)); }
public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers()) { return(visitor.VisitTypedefType(this, quals)); }
public abstract TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor);