public void GivenISerializeThePropertyBag()
        {
            IJsonSerializerOptionsProvider settingsProvider = ContainerBindings.GetServiceProvider(this.featureContext).GetService <IJsonSerializerOptionsProvider>();

            PropertyBag propertyBag = this.scenarioContext.Get <PropertyBag>();

            this.scenarioContext.Set(JsonSerializer.Serialize(propertyBag, settingsProvider.Instance), "Result");
        }
        public void GivenISerializeAPOCOWith(string value, string time, string nullableTime, string culture, ExampleEnum someEnum)
        {
            var poco = new PocObject {
                SomeCulture = string.IsNullOrEmpty(culture) ? null : CultureInfo.GetCultureInfo(culture), SomeDateTime = DateTimeOffset.Parse(time), SomeNullableDateTime = string.IsNullOrEmpty(nullableTime) ? null : (DateTimeOffset?)DateTimeOffset.Parse(nullableTime), SomeEnum = someEnum, SomeValue = value
            };
            IJsonSerializerOptionsProvider settingsProvider = ContainerBindings.GetServiceProvider(this.featureContext).GetService <IJsonSerializerOptionsProvider>();

            this.scenarioContext.Set(JsonSerializer.Serialize(poco, settingsProvider.Instance), "Result");
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyBag"/> class.
        /// </summary>
        /// <param name="serializerOptionsProvider">The serializer settings provider.</param>
        public PropertyBag(IJsonSerializerOptionsProvider serializerOptionsProvider)
        {
            if (serializerOptionsProvider is null)
            {
                throw new ArgumentNullException(nameof(serializerOptionsProvider));
            }

            this.Properties        = EmptyObject;
            this.SerializerOptions = serializerOptionsProvider.Instance;
        }
コード例 #4
0
 public JsonSerializer(IJsonSerializerOptionsProvider jsonSerializerOptionsProvider)
 {
     _jsonSerializerOptions = jsonSerializerOptionsProvider.Apply(new JsonSerializerOptions());
 }
コード例 #5
0
ファイル: BaseStartup.cs プロジェクト: Woodhds/metrics
 protected BaseStartup(IConfiguration configuration)
 {
     Configuration = configuration;
     JsonSerializerOptionsProvider = new JsonSerializerOptionsProvider();
 }
        public void GivenIDeserializeAPropertyBagFromTheStringHelloWorldNumber(string json)
        {
            IJsonSerializerOptionsProvider settingsProvider = ContainerBindings.GetServiceProvider(this.featureContext).GetService <IJsonSerializerOptionsProvider>();

            this.scenarioContext.Set(JsonSerializer.Deserialize <PropertyBag>(json, settingsProvider.Instance), "Result");
        }
        public void GivenIDeserializeAPOCOWithTheJsonString(string json)
        {
            IJsonSerializerOptionsProvider settingsProvider = ContainerBindings.GetServiceProvider(this.featureContext).GetService <IJsonSerializerOptionsProvider>();

            this.scenarioContext.Set(JsonSerializer.Deserialize <PocObject>(json, settingsProvider.Instance), "Result");
        }