public CustomAttributeDataWrapper(AttributeData a, MetadataLoadContextInternal metadataLoadContext)
        {
            var namedArguments = new List <CustomAttributeNamedArgument>();

            foreach (KeyValuePair <string, TypedConstant> na in a.NamedArguments)
            {
                var member = a.AttributeClass !.GetMembers(na.Key).First();

                MemberInfo memberInfo = member is IPropertySymbol
                    ? new PropertyInfoWrapper((IPropertySymbol)member, metadataLoadContext)
                    : new FieldInfoWrapper((IFieldSymbol)member, metadataLoadContext);

                namedArguments.Add(new CustomAttributeNamedArgument(memberInfo, na.Value.Value));
            }

            var constructorArguments = new List <CustomAttributeTypedArgument>();

            foreach (TypedConstant ca in a.ConstructorArguments)
            {
                constructorArguments.Add(new CustomAttributeTypedArgument(ca.Type.AsType(metadataLoadContext), ca.Value));
            }
            Constructor          = new ConstructorInfoWrapper(a.AttributeConstructor !, metadataLoadContext);
            NamedArguments       = namedArguments;
            ConstructorArguments = constructorArguments;
        }
示例#2
0
 public TypeWrapper(ITypeSymbol namedTypeSymbol, MetadataLoadContextInternal metadataLoadContext)
 {
     _typeSymbol          = namedTypeSymbol;
     _metadataLoadContext = metadataLoadContext;
     _namedTypeSymbol     = _typeSymbol as INamedTypeSymbol;
     _arrayTypeSymbol     = _typeSymbol as IArrayTypeSymbol;
 }
        public static Type AsType(this ITypeSymbol typeSymbol, MetadataLoadContextInternal metadataLoadContext)
        {
            if (typeSymbol == null)
            {
                return(null);
            }

            return(new TypeWrapper(typeSymbol, metadataLoadContext));
        }
示例#4
0
 public ConstructorInfoWrapper(IMethodSymbol ctor, MetadataLoadContextInternal metadataLoadContext)
 {
     _ctor = ctor;
     _metadataLoadContext = metadataLoadContext;
 }
 public static MethodInfo AsMethodInfo(this IMethodSymbol methodSymbol, MetadataLoadContextInternal metadataLoadContext) => (methodSymbol == null ? null : new MethodInfoWrapper(methodSymbol, metadataLoadContext)) !;
 public MemberInfoWrapper(ISymbol member, MetadataLoadContextInternal metadataLoadContext)
 {
     _member = member;
     _metadataLoadContext = metadataLoadContext;
 }
示例#7
0
 public ParameterInfoWrapper(IParameterSymbol parameter, MetadataLoadContextInternal metadataLoadContext)
 {
     _parameter           = parameter;
     _metadataLoadContext = metadataLoadContext;
 }
示例#8
0
 public FieldInfoWrapper(IFieldSymbol parameter, MetadataLoadContextInternal metadataLoadContext)
 {
     _field = parameter;
     _metadataLoadContext = metadataLoadContext;
 }
 public MethodInfoWrapper(IMethodSymbol method, MetadataLoadContextInternal metadataLoadContext)
 {
     _method = method;
     _metadataLoadContext = metadataLoadContext;
 }
 public PropertyInfoWrapper(IPropertySymbol property, MetadataLoadContextInternal metadataLoadContext)
 {
     _property            = property;
     _metadataLoadContext = metadataLoadContext;
 }
示例#11
0
 public AssemblyWrapper(IAssemblySymbol assembly, MetadataLoadContextInternal metadataLoadContext)
 {
     Symbol = assembly;
     _metadataLoadContext = metadataLoadContext;
 }