Exemplo n.º 1
0
        public void TestInitialise()
        {
            _typeResolver          = new Mock <IOpenApiUmbrellaTypeResolver>();
            _fieldStealer          = new Mock <IStealFieldsFromOpenApiObjectTypesService>();
            _objectsKeyStore       = new Mock <IObjectsProcessingKeyStore>();
            _moduleBuilderProvider = new ModuleBuilderProvider();

            _service = new OpenApiObjectToTypeService(_typeResolver.Object,
                                                      _fieldStealer.Object,
                                                      _moduleBuilderProvider);

            _prop1     = new OpenApiPrimitiveType();
            _prop2     = new OpenApiPrimitiveType();
            _inputType = new OpenApiObjectType()
            {
                Properties = new Dictionary <string, IOpenApiType>()
                {
                    { "FirstProperty", _prop1 },
                    { "SecondProperty", _prop2 }
                }
            };
            _inputDefinitions = new Dictionary <string, IOpenApiType>();
            _name             = Guid.NewGuid().ToString();

            _typeResolver.Setup(s => s.GetType(_service,
                                               _objectsKeyStore.Object,
                                               It.IsAny <OpenApiPrimitiveType>(),
                                               _inputDefinitions,
                                               It.IsAny <string>()))
            .Returns(typeof(int));
        }
Exemplo n.º 2
0
        public void TestInitialise()
        {
            _moduleProvider = new ModuleBuilderProvider();

            _service = new OpenApiEnumToTypeService(_moduleProvider);

            _enumeration = new OpenApiEnumType();
            _name        = Guid.NewGuid().ToString();
        }
Exemplo n.º 3
0
 public void OneTimeSetUp()
 {
     (var assemblyBuilder, var moduleBuilder) = ModuleBuilderProvider.Get();
     proxyProvider        = new ProxyProvider(moduleBuilder);
     jsonSerializer       = new JsonSerializer();
     grobufSerializer     = new GrobufSerializer();
     proxySerializer      = new ProxySerializer(proxyProvider, jsonSerializer);
     this.assemblyBuilder = assemblyBuilder;
 }
Exemplo n.º 4
0
        private static void RegisterOptimizations(IIocContainer container)
        {
            var moduleBuilder = ModuleBuilderProvider.GetModuleBuilder();
            var typeContainer = new TypeGlobalContainer();

            var optimizationPackage = new OptimizationPackage(moduleBuilder, typeContainer);

            container.RegisterSingleton(typeof(IOptimizationPackage), optimizationPackage);
        }
Exemplo n.º 5
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            var filePathFormatService = new FilePathFormattingService();
            var jsonTypeParser        = new OpenApiSpecUmbrellaTypeParser <JsonCatchAllTypeModel>();
            var jsonObjectParser      = new OpenApiSpecObjectParser <JsonCatchAllTypeModel>(jsonTypeParser);
            var yamlTypeParser        = new OpenApiSpecUmbrellaTypeParser <YamlCatchAllTypeModel>();
            var yamlObjectParser      = new OpenApiSpecObjectParser <YamlCatchAllTypeModel>(yamlTypeParser);
            var lastTokenService      = new LastTokenInPathService();
            var enumFromStringService = new EnumFromStringService();
            var shortNameService      = new OpenApiEndpointShortNameService(lastTokenService);

            var moduleBuilderProvider   = new ModuleBuilderProvider();
            var openApiPrimitiveService = new OpenApiPrimitiveToTypeService(new OpenApiEnumToTypeService(moduleBuilderProvider));
            var openApiTypeResolver     = new OpenApiUmbrellaTypeResolver(openApiPrimitiveService,
                                                                          new OpenApiReferenceToTypeService(lastTokenService));
            var openApiObjectToTypeService = new OpenApiObjectToTypeService(openApiTypeResolver,
                                                                            new StealFieldsFromOpenApiObjectTypeService(openApiTypeResolver),
                                                                            moduleBuilderProvider);

            //establish current ps session working directory
            using (var session = PowerShell.Create(RunspaceMode.CurrentRunspace))
            {
                session.AddCommand("get-location");
                _pwd = session.Invoke <PathInfo>()
                       .FirstOrDefault()?.Path;
            }

            _specImportService = new ImportSpecFromFilePathService(filePathFormatService,
                                                                   new JsonFileToOpenApiModelService(jsonObjectParser,
                                                                                                     jsonTypeParser,
                                                                                                     new OpenApiJsonEndpointsParser(jsonTypeParser,
                                                                                                                                    jsonObjectParser,
                                                                                                                                    enumFromStringService),
                                                                                                     shortNameService),
                                                                   new YamlFileToOpenApiModelService(yamlObjectParser,
                                                                                                     yamlTypeParser,
                                                                                                     new OpenApiYamlEndpointsParser(yamlTypeParser,
                                                                                                                                    yamlObjectParser,
                                                                                                                                    enumFromStringService),
                                                                                                     shortNameService),
                                                                   new OpenApiSpecModelToGeneratedTypesService(openApiObjectToTypeService,
                                                                                                               openApiTypeResolver,
                                                                                                               new OpenApiEndpointToEndpointService(openApiTypeResolver,
                                                                                                                                                    openApiPrimitiveService,
                                                                                                                                                    openApiObjectToTypeService)));
        }