Beispiel #1
0
        public static Dictionary <string, StructPropertyConverter <T> > ActivateStructPropertyConverters <T>(
            IConvertersCollection converters)
            where T : struct
        {
            var ownerType  = Typeof <T> .Raw;
            var properties = ownerType.GetProperties();

            var propertyConverters = new Dictionary <string, StructPropertyConverter <T> >(
                properties.Length,
                StringUtils.IgnoreCaseComparer);

            foreach (var property in properties)
            {
                if (IgnoreAttribute.IsDefined(property))
                {
                    continue;
                }

                var converter         = converters.Get(property.PropertyType);
                var propertyConverter = new StructPropertyConverter <T>(ownerType, property, converter);

                propertyConverters.Add(property.Name, propertyConverter);
            }

            return(propertyConverters);
        }
Beispiel #2
0
        public StructConverter(IConvertersCollection converters) : base(false)
        {
            var type = Typeof <T> .Raw;

            _activator = Expression.Lambda <Func <T> >(Expression.New(type)).Compile();

            _properties = SerializationUtils.ActivateStructPropertyConverters <T>(converters);
        }
Beispiel #3
0
 public ComponentsConverter(
     IConvertersCollection converters,
     IComponentFactory componentFactory,
     SourceDescriptions descriptions)
 {
     _converters       = converters;
     _componentFactory = componentFactory;
     _descriptions     = descriptions;
 }
Beispiel #4
0
        public SettingsProvider(ISettingsSource[] sources, IConvertersCollection converters)
        {
            _configuration  = new JsonObject();
            _converters     = converters;
            _sectionBuilder = BuildSection;
            _sources        = sources;

            Reload();
        }
Beispiel #5
0
        public JsonFileSource(IConvertersCollection converters, SourceDescriptions descriptions, string path)
            : base(converters, descriptions)
        {
            if (!File.Exists(path))
            {
                throw Error.FileNotFound(path);
            }

            _path = path;
        }
Beispiel #6
0
            public Enumerator(
                IConvertersCollection converters,
                SourceDescriptions descriptions,
                JsonTokenizer tokenizer)
            {
                _converters   = converters;
                _descriptions = descriptions;
                _tokenizer    = tokenizer;

                Current = null !;
            }
Beispiel #7
0
        protected CollectionConverter(IConvertersCollection converters)
        {
            Contract = Typeof <TCollection> .Raw;

            _converters          = converters;
            _elementConverter    = converters.Get <TElement>();
            _elementType         = Typeof <TElement> .Raw;
            _elementTypeNullable = _elementType.IsClass
                ? new Func <TElement, bool>(reference => reference == null)
                : notReference => false;
        }
Beispiel #8
0
        public Configuration(IConvertersCollection converters = null, IConfigurationSource[] sources = null)
        {
            if (sources == null)
            {
                sources = Array.Empty <IConfigurationSource>();
            }

            _cache      = new Dictionary <string, object>();
            _converters = converters ?? new ConvertersCollection(CultureInfo.InvariantCulture);
            _sources    = sources;

            Reload();
        }
Beispiel #9
0
        public EntityState(
            IActorContext actors,
            IActorFactory actorFactory,
            IAssetContext assets,
            IConvertersCollection converters,
            SourceDescriptions descriptions)
        {
            Actors = actors;
            Assets = assets;

            _actorFactory = actorFactory;
            _converters   = converters;
            _descriptions = descriptions;
        }
Beispiel #10
0
        public LogProviderShould()
        {
            _logWriter = new Mock <ILogWriter>();
            _logWriter
            .Setup(writer => writer.Write(It.IsAny <LogContext>(), It.IsAny <JsonObject>()))
            .Callback(_logWriteCallback);

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

            _converters = dependencyProvider.GetRequired <IConvertersCollection>();
            _logger     = dependencyProvider.GetRequired <ILogger <LogProviderShould> >();
            _sender     = typeof(LogProviderShould);
        }
Beispiel #11
0
        public LoggerShould(ITestOutputHelper output) : base(output)
        {
            _logEnricher   = new Mock <ILogEnricher>();
            _logWriter     = new Mock <ILogWriter>();
            _testLogWriter = new TestLogWriter();

            var provider = new DependencyCollection()
                           .AddLogging()
                           .AddJsonConverter() // for register IConvertersCollection
                           .AddDefaultLogEnrichers()
                           .AddLogWriter(_testLogWriter)
                           .AddLogWriter(_logWriter.Object)
                           .AddLogWriter <ConsoleLogWriter>()
                           .AddLogEnricher(_logEnricher.Object)
                           .AddLogEnricher <TestLogEnricher>()
                           .BuildProvider();

            _convertersCollection = provider.GetRequiredService <IConvertersCollection>();
            _logger = provider.GetRequiredService <ILogger <LoggerShould> >();
        }
Beispiel #12
0
 public RenderersCollection(IConvertersCollection converters)
 {
     _arrayRendererBuilder = BuildArrayRenderer;
     _converters           = converters;
     _rendererBuilder      = BuildRenderer;
 }
Beispiel #13
0
 public JsonObjectShould()
 {
     _converters = BuildConvertersCollection();
 }
Beispiel #14
0
 public ListConverter(IConvertersCollection converters) : base(converters)
 {
 }
Beispiel #15
0
 protected JsonSource(IConvertersCollection converters, SourceDescriptions descriptions)
 {
     _converters   = converters;
     _descriptions = descriptions;
 }
Beispiel #16
0
 internal JConverter(IConvertersCollection converters)
 {
     Converters = converters;
 }
Beispiel #17
0
 public ObjectConverterShould()
 {
     _converters = BuildConvertersCollection();
     _converter  = _converters.Get <Boo>();
 }
Beispiel #18
0
 public JsonStreamSource(IConvertersCollection converters, SourceDescriptions descriptions, Stream stream)
     : base(converters, descriptions)
 {
     _stream = stream;
 }
Beispiel #19
0
 public JConverter(CultureInfo culture = null)
 {
     _converters = new ConvertersCollection(culture ?? CultureInfo.InvariantCulture);
 }
Beispiel #20
0
 public static T Read <T>(this IConvertersCollection converters, JsonData json)
 {
     return(converters.Get <T>().Read(json));
 }
Beispiel #21
0
 public static JsonData Write <T>(this IConvertersCollection converters, T data)
 {
     return(converters.Get <T>().Write(data));
 }
Beispiel #22
0
 public JsonDataShould()
 {
     _converters = BuildConvertersCollection();
 }
Beispiel #23
0
 public ArrayConverter(IConvertersCollection converters) : base(converters)
 {
 }
Beispiel #24
0
 public IdConverter(IConvertersCollection converters, SourceDescriptions descriptions)
 {
     _descriptions    = descriptions;
     _intConverter    = converters.Get <int>();
     _stringConverter = converters.Get <string>();
 }
 public RendererCollection(IConvertersCollection converters = null)
 {
     _converters = converters ?? new ConvertersCollection(CultureInfo.InvariantCulture);
     _renderers  = new Dictionary <string, Renderer>();
     _lock       = new object();
 }
Beispiel #26
0
 public ConvertersCollectionShould()
 {
     _converters = BuildConvertersCollection();
 }
Beispiel #27
0
 public JsonFileStore(IConvertersCollection converters, string path)
 {
     _converters = converters;
     _path       = path;
 }
Beispiel #28
0
 internal JConverter(IConvertersCollection convertersCollection)
 {
     _converters = convertersCollection;
 }
Beispiel #29
0
 public JsonObjectShould(ITestOutputHelper output) : base(output)
 {
     _converters = new ConvertersCollection(CultureInfo.InvariantCulture);
 }
Beispiel #30
0
        public ArrayRenderer(string[] arguments, IFormatter formatter, LocalList <Type> argumentTypes, IConvertersCollection converters)
            : base(formatter)
        {
            var argumentConverters = new IJsonConverter[argumentTypes.Length];

            for (var i = 0; i < argumentTypes.Length; i++)
            {
                argumentConverters[i] = converters.Get(argumentTypes[i]);
            }

            _arguments  = arguments;
            _converters = argumentConverters;
        }