/// <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);
        }
Exemple #2
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitMemberPointerType(this, quals));
 }
Exemple #3
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitUnaryTransformType(this, quals));
 }
Exemple #4
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitDependentNameType(this, quals));
 }
Exemple #5
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitTemplateParameterSubstitutionType(this, quals));
 }
Exemple #6
0
 public T Visit <T>(ITypeVisitor <T> visitor)
 {
     return(Type.Visit(visitor, Qualifiers));
 }
Exemple #7
0
 public abstract void Accept(ITypeVisitor visitor);
Exemple #8
0
 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);
 }
Exemple #10
0
 public T Accept <T>(ITypeVisitor <T> visitor) => visitor.VisitFunctionType(this);
Exemple #11
0
 public override void Visit(ITypeVisitor visitor) => visitor.Visit(this);
Exemple #12
0
 public T Visit <T>(ITypeVisitor <T> visitor)
 {
     return(visitor.VisitQualifiedType(this));
 }
Exemple #13
0
 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));
        }
Exemple #15
0
 public abstract object Accept <T>(ITypeVisitor <T> visitor);
Exemple #16
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals)
 {
     return(visitor.VisitAttributedType(this, quals));
 }
Exemple #17
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitPointerType(this, QualifiedPointee.Qualifiers));
 }
Exemple #18
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals)
 {
     return(visitor.VisitBuiltinType(this, quals));
 }
Exemple #19
0
 public override object Accept <T>(ITypeVisitor <T> visitor)
 {
     return(visitor.Visit(this));
 }
Exemple #20
0
 public abstract SemanticAtom Accept(ITypeVisitor v);
Exemple #21
0
 public override SemanticAtom Accept(ITypeVisitor v)
 {
     return(v.Visit(this));
 }
Exemple #22
0
 public void AcceptTypeVisitor(ITypeVisitor visitor, DB_Type type)
 {
     VisitType(type, visitor);
 }
Exemple #23
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitDependentTemplateSpecializationType(this, quals));
 }
Exemple #24
0
 public CreateBindings(ITypeVisitor <IWidget> widgetFactory)
 {
     Bindings      = new List <UIBinding>();
     WidgetFactory = widgetFactory;
 }
Exemple #25
0
 public override T Visit <T>(ITypeVisitor <T> visitor,
                             TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitInjectedClassNameType(this, quals));
 }
Exemple #26
0
 /// <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);
     }
 }
Exemple #27
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitPackExpansionType(this, quals));
 }
Exemple #28
0
 public override TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor)
 {
     return(defaultTypeVisitor.Visit(this));
 }
Exemple #29
0
 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));
 }
Exemple #31
0
 public override T Visit <T>(ITypeVisitor <T> visitor, TypeQualifiers quals = new TypeQualifiers())
 {
     return(visitor.VisitTypedefType(this, quals));
 }
Exemple #32
0
 public abstract TResult Accept <TResult>(ITypeVisitor <TResult> defaultTypeVisitor);