Esempio n. 1
0
        private static NSerializer GetSerializerAs(FieldFormatterType type, FieldAccessType accessType,
                                                   DateFormatType dateFormatType, bool withNulls)
        {
            var currentDirectory = Directory.GetParent(Directory.GetCurrentDirectory());
            var config           = new Dictionary <string, object>
            {
                { ConfigurationManager.MetadataDirKey, Path.Combine(currentDirectory.Parent?.Parent?.ToString(), "Resources") },
                { ConfigurationManager.IncludeNullValuesKey, withNulls },
                { ConfigurationManager.FieldFormattingMethodKey, type.ToString() },
                { ConfigurationManager.FieldAccessTypeKey, accessType.ToString() },
                { ConfigurationManager.DateFormatKey, dateFormatType.ToString() }
            };

            var configurationProvider = new MockConfigurationProvider(config);
            var environment           = new MockEnvironment();
            var cache = new MockCache();

            return(NSerializerBuilder.Build()
                   .WithCache(cache)
                   .WithConfigurationProvider(configurationProvider)
                   .WithEnvironment(environment)
                   .Get());
        }
Esempio n. 2
0
 public FieldFormatter(FieldFormatterType type)
 {
     _formatterType = type;
 }