public AttributeInstantiator(WellKnownSymbols wellKnownSymbols)
        {
            this.wellKnownSymbols = wellKnownSymbols;

            this.lookup = new Dictionary <INamedTypeSymbol, Parser>(19, SymbolEqualityComparer.Default);
            Add(this.wellKnownSymbols.AllowAnyStatusCodeAttribute, this.ParseAllowAnyStatusCodeAttribute);
            Add(this.wellKnownSymbols.BaseAddressAttribute, this.ParseBaseAddressAttribute);
            Add(this.wellKnownSymbols.BasePathAttribute, this.ParseBasePathAttribute);
            Add(this.wellKnownSymbols.PathAttribute, this.ParsePathAttribute);
            Add(this.wellKnownSymbols.QueryAttribute, this.ParseQueryAttribute);
            Add(this.wellKnownSymbols.SerializationMethodsAttribute, this.ParseSerializationMethodsAttribute);
            Add(this.wellKnownSymbols.RawQueryStringAttribute, this.ParseRawQueryStringAttribute);
            Add(this.wellKnownSymbols.BodyAttribute, this.ParseBodyAttribute);
            Add(this.wellKnownSymbols.HeaderAttribute, this.ParseHeaderAttribute);
            Add(this.wellKnownSymbols.HttpRequestMessagePropertyAttribute, this.ParseHttpRequestMessagePropertyAttribute);
            Add(this.wellKnownSymbols.QueryMapAttribute, this.ParseQueryMapAttribute);
            Add(this.wellKnownSymbols.RequestAttribute, this.ParseRequestAttribute);
            Add(this.wellKnownSymbols.DeleteAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new DeleteAttribute(), s => new DeleteAttribute(s)));
            Add(this.wellKnownSymbols.GetAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new GetAttribute(), s => new GetAttribute(s)));
            Add(this.wellKnownSymbols.HeadAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new HeadAttribute(), s => new HeadAttribute(s)));
            Add(this.wellKnownSymbols.OptionsAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new OptionsAttribute(), s => new OptionsAttribute(s)));
            Add(this.wellKnownSymbols.PostAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new PostAttribute(), s => new PostAttribute(s)));
            Add(this.wellKnownSymbols.PutAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new PutAttribute(), s => new PutAttribute(s)));
            Add(this.wellKnownSymbols.TraceAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new TraceAttribute(), s => new TraceAttribute(s)));
            Add(this.wellKnownSymbols.PatchAttribute, (x, s, d) => this.ParseRequestAttributeSubclass(x, s, d, () => new PatchAttribute(), s => new PatchAttribute(s)));


            void Add(INamedTypeSymbol?symbol, Parser func)
            {
                if (symbol != null)
                {
                    this.lookup[symbol] = func;
                }
            }
        }
        public RoslynImplementationFactory(Compilation compilation)
        {
            this.compilation = compilation;
            this.symbolsDiagnosticReporter = new DiagnosticReporter();
            this.wellKnownSymbols          = new WellKnownSymbols(compilation, this.symbolsDiagnosticReporter);
            this.attributeInstantiator     = new AttributeInstantiator(this.wellKnownSymbols);
            this.emitter = new Emitter(this.wellKnownSymbols);

            // Catch any symbols errors from just instantiating WellKnownSymbols
            this.symbolsDiagnostics.UnionWith(this.symbolsDiagnosticReporter.Diagnostics);
        }
Esempio n. 3
0
 public RoslynTypeAnalyzer(
     Compilation compilation,
     INamedTypeSymbol namedTypeSymbol,
     WellKnownSymbols wellKnownSymbols,
     AttributeInstantiator attributeInstantiator,
     DiagnosticReporter diagnosticReporter)
 {
     this.compilation           = compilation;
     this.namedTypeSymbol       = namedTypeSymbol;
     this.wellKnownSymbols      = wellKnownSymbols;
     this.attributeInstantiator = attributeInstantiator;
     this.diagnosticReporter    = diagnosticReporter;
 }