Пример #1
0
        public LogRendererShould()
        {
            _converters = BuildConvertersCollection();

            _logWriter = new Mock <ILogWriter>();
            _logWriter
            .Setup(writer => writer.Write(It.IsAny <LogContext>(), It.IsAny <JsonObject>()))
            .Callback(_logWriteCallback);

            var provider = new DependencyCollection()
                           .AddLogs()
                           .AddLogWriter(_logWriter.Object)
                           .BuildProvider();

            _logger = provider.GetRequired <ILogger <LogRendererShould> >();
        }
Пример #2
0
        public SettingsProviderShould()
        {
            _converters = BuildConvertersCollection();

            _property       = "property";
            _propertyValue  = JsonValue.True;
            _nestedProperty = "nested";
            _nestedValue    = (JsonObject)_converters.Get <BigObject>().Write(Fixture.Create <BigObject>());
            _out            = new JsonObject
            {
                [_property]       = _propertyValue,
                [_nestedProperty] = _nestedValue
            };

            _source   = BuildSource();
            _settings = new SettingsProvider(new[] { _source.Object }, _converters);
        }
Пример #3
0
    public static void GetConverterElement()
    {
        // Get the Web application configuration.
        System.Configuration.Configuration configuration =
            WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

        // Get the external JSON section.
        ScriptingJsonSerializationSection jsonSection =
            (ScriptingJsonSerializationSection)configuration.GetSection(
                "system.web.extensions/scripting/webServices/jsonSerialization");

        //Get the converters collection.
        ConvertersCollection converters =
            jsonSection.Converters;

        if ((converters != null) && converters.Count > 0)
        {
            // Get the first registered converter.
            Converter converterElement = converters[0];
        }
    }