Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Security Vulnerability not fit for production
            services.AddCors(options =>
            {
                options.AddPolicy("default", policy =>
                {
                    policy.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddControllers()
            .ConfigureApiBehaviorOptions(option =>
            {
                option.SuppressMapClientErrors = true;
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "UL Online Calculator ",
                    Version     = "1",
                    Description = "This API is used to evaluate Mathematical Expression.",
                    Contact     = new OpenApiContact()
                    {
                        Email = "*****@*****.**",
                        Name  = "Kumar Shantanu",
                        Url   = new Uri("http://uk.linkedin.com/in/shaan")
                    },
                    License = new OpenApiLicense()
                    {
                        Name = "MIT License",
                        Url  = new Uri("https://opensource.org/licenses/MIT")
                    }
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            ServiceConfigurationManager.ConfigureAuthentication(services, Configuration);
            ServiceConfigurationManager.ConfigurePersistence(services, Configuration);
            ServiceConfigurationManager.ConfigureServiceLifeTime(services);
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Security Vulnerability not fit for production
            services.AddCors(options =>
            {
                options.AddPolicy("default", policy =>
                {
                    policy.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });
            services.AddControllers();
            services.AddHttpContextAccessor();
            ServiceConfigurationManager.ConfigureAuthentication(services, Configuration);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Publish News ",
                    Version     = "1",
                    Description = "Through this API you can Publish, Read News Articles and many more.",
                    Contact     = new OpenApiContact()
                    {
                        Email = "*****@*****.**",
                        Name  = "Kumar Shantanu",
                        Url   = new Uri("http://uk.linkedin.com/in/shaan")
                    },
                    License = new OpenApiLicense()
                    {
                        Name = "MIT License",
                        Url  = new Uri("https://opensource.org/licenses/MIT")
                    }
                });

                //todo Enable Xml document and get documents from them to Swagger
                //var xmlCommentsFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                //var xmlCommentsFullPath = Path.Combine(AppContext.BaseDirectory, xmlCommentsFile);

                //setupAction.IncludeXmlComments(xmlCommentsFullPath);
            });
            ServiceConfigurationManager.ConfigurePersistence(services, Configuration);
            ServiceConfigurationManager.ConfigureServiceLifeTime(services);
        }
        public static void Configure(ServiceConfiguration config)
        {
            string address = config.BaseAddresses.First().AbsoluteUri;

            ServiceConfigurationManager manager = new ServiceConfigurationManager();

            ContractDescription contract = ContractDescription.GetContract(typeof(IService));
            ServiceEndpoint     endpoint = new ServiceEndpoint(contract, manager.CreateBinding(), new EndpointAddress(address));

            config.AddServiceEndpoint(endpoint);
            //config.AddServiceEndpoint(manager.CreateServiceEndpoint(address));

            config.Description.Behaviors.Add(new ServiceMetadataBehavior {
                HttpGetEnabled = true
            });
            config.Description.Behaviors.Add(new ServiceDebugBehavior {
                IncludeExceptionDetailInFaults = true
            });
        }
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            Trace.TraceInformation("CrmPluginBrokerRole is starting.");

            /// Initialize the ServiceConfigurationManager to retrieve secrets held by an Azure Key Vault
            ServiceConfigurationManager.InitializeSecrets(Constants.AppAuthClientIdSetting, Constants.AppAuthCertThumbprintSetting, TimeSpan.FromMinutes(DefaultSecretTimeoutInMinutes));

            foreach (var topicRegistration in _topicRegistrations)
            {
                topicRegistration.Initialize();
            }

            var started = base.OnStart();

            Trace.TraceInformation("CrmPluginBrokerRole has been started.");

            return(started);
        }