Ejemplo n.º 1
0
        /// <summary>
        /// Events this instance.
        /// </summary>
        /// <returns>ActionResult.</returns>
        public ActionResult Events()
        {
            var resolver = new JsonResolver();
            var evt      = GetEvents();

            return(Content(resolver.Serialize(evt), "application/json"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
        public override string ToString()
        {
            var serializer = new JsonResolver();

            var serializedObject = serializer.Serialize(this);

            return(serializedObject);
        }
        public void ResolveLoadsInformationFromSpecifiedFileTest()
        {
            var sut = new JsonResolver <Config>("localsettings.json");

            var actual = sut.Resolve() as Config;

            actual.Storage.BlobStorage.Should().StartWith("local ");
        }
Ejemplo n.º 4
0
 public static IMvcBuilder AddDxSampleModelJsonOptions(this IMvcBuilder builder, Action <JsonResolver> setupAction = null)
 {
     return(builder.AddJsonOptions(opt => {
         var resolver = new JsonResolver();
         opt.SerializerSettings.ContractResolver = resolver;
         opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
         setupAction?.Invoke(resolver);
     }));
 }
        public void ResolveLoadsInformationFromAppSettingsFileTest()
        {
            var sut = new JsonResolver <Config>();

            var actual = sut.Resolve() as Config;

            actual.Should().NotBeNull();
            actual.Storage.BlobStorage.Should().NotBeNullOrEmpty();
            actual.Storage.Database.Should().NotBeNullOrEmpty();
            actual.Storage.TableStorage.Should().NotBeNullOrEmpty();
            actual.FirstJob.Name.Should().NotBeNullOrEmpty();
            actual.FirstJob.TriggerInSeconds.Should().NotBe(0);
            actual.FirstJob.Trigger.Should().NotBe(TimeSpan.Zero);
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string temp = Configuration["LiveWithPost"];

            Helpers.GenHelper.LiveWithPost = false;
            if (temp.ToUpper() == "Y" || temp.ToUpper() == "YES" || temp.ToUpper() == "TRUE" || temp == "1")
            {
                Helpers.GenHelper.LiveWithPost = true;
            }

            Helpers.GenHelper.FilePath = Configuration["FilePath:LogPath"];

            JsonResolver resolver = new JsonResolver();

#if NETCOREAPP
            Action <MvcNewtonsoftJsonOptions> JsonOptions =
#else
            Action <MvcJsonOptions> JsonOptions =
#endif
                options => {
                options.SerializerSettings.ContractResolver      = resolver;
                options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            };
            services.AddMvc(options => {
                options.EnableEndpointRouting = false;
            })
#if !NETCOREAPP
            .AddJsonOptions(JsonOptions)
#endif
            .SetCompatibilityVersion(CompatibilityVersion.Latest);

#if NETCOREAPP
            services.AddControllers()
            .AddNewtonsoftJson(JsonOptions);
#endif
            // configure basic authentication
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath = loginPath;
            });
            services.AddSingleton <XpoDataStoreProviderService>();
            services.AddSingleton(Configuration);
            services.AddHttpContextAccessor();
            services.AddScoped <SecurityProvider>();
        }