public void Reset() { Cache.Empty(); UserConfigurations.Reset(); ConstructionFactory.Reset(); ObjectMapperFactory.Reset(); }
private static void ClassInitialize_Api() { _testContext.Properties.Add( "apiDataRows", new Dictionary <BillPaymentsClient, ApiPresets> { { BillPaymentsClientFactory.Create(Config.MerchantSecretKey), new ApiPresets { Bills = new List <BillResponse>(), Refunds = new List <RefundResponse>() } }, { BillPaymentsClientFactory.Create( Config.MerchantSecretKey, null, ObjectMapperFactory.Create <NewtonsoftMapper>() ), new ApiPresets { Bills = new List <BillResponse>(), Refunds = new List <RefundResponse>() } } } ); }
public void Load() { var objectMapper = ObjectMapperFactory.CreateInstance(); try { _settings = objectMapper.ReadValue <Settings>(_fileName); UpdateEffectPatternManager(); //try loading the ELS configuration files, if something goes wrong, disable the els option if (_settings.ColorSettings.ElsEnabled) { _settings.ColorSettings.ElsEnabled = _elsSettingsManager.Load(); } _rage.DisplayPluginNotification("configuration loaded"); _rage.LogTrivial(Settings.ToString()); //initialize/reinitialize the effect devices and color manager _effectsManager.Initialize(); _colorManager.Initialize(_settings); } catch (FileNotFoundException) { _rage.DisplayPluginNotification("configuration file not found, using defaults instead"); LoadDefaults(); } catch (Exception e) { _rage.LogTrivial(e.Message + Environment.NewLine + e.StackTrace); _rage.DisplayPluginNotification("configuration file is not valid, using defaults instead"); LoadDefaults(); } }
public void Dispose() { _isDisposed = true; Cache.Empty(); UserConfigurations.Reset(); ConstructionFactory.Reset(); ObjectMapperFactory.Reset(); }
public MapperContext() { Cache = new CacheSet(); Naming = new NamingSettings(Cache); QualifiedMemberFactory = new QualifiedMemberFactory(this); RootMembersSource = new RootMembersSource(QualifiedMemberFactory); ObjectMapperFactory = new ObjectMapperFactory(Cache); UserConfigurations = new UserConfigurationSet(this); ConstructionFactory = new ComplexTypeConstructionFactory(Cache); ValueConverters = new ConverterSet(UserConfigurations); RuleSets = MappingRuleSetCollection.Default; }
public MapperContext(NamingSettings namingSettings = null) { Cache = new CacheSet(); DataSources = new DataSourceFinder(); NamingSettings = namingSettings ?? new NamingSettings(); RootMembersSource = new RootMembersSource(new RootQualifiedMemberFactory(this)); ObjectMapperFactory = new ObjectMapperFactory(this); ObjectFlattener = new ObjectFlattener(); DerivedTypes = new DerivedTypesCache(); UserConfigurations = new UserConfigurationSet(); ValueConverters = new ConverterSet(); RuleSets = new MappingRuleSetCollection(); }
public void ShouldLoadElsFile() { var elsSettings = new ElsSettings { LightingSettings = new LightingSettings { Extra01 = new ExtraSettings { IsElsControlled = true, AllowEnvLight = true, Color = Color.Blue }, Extra02 = new ExtraSettings { IsElsControlled = true, AllowEnvLight = true, Color = Color.Blue }, Extra03 = new ExtraSettings { IsElsControlled = true, AllowEnvLight = true, Color = Color.Blue }, Extra04 = new ExtraSettings { IsElsControlled = true, AllowEnvLight = true, Color = Color.Red }, Extra05 = new ExtraSettings { IsElsControlled = true, AllowEnvLight = true, Color = Color.Red }, Extra06 = new ExtraSettings { IsElsControlled = true, AllowEnvLight = true, Color = Color.Red } } }; var objectMapper = ObjectMapperFactory.CreateInstance(); var result = objectMapper.ReadValue <ElsSettings>(FILE); Assert.NotNull(result); Assert.Equal(elsSettings, result); }
public static BillPaymentsClient Create( string secretKey, IClient client = null, IObjectMapper objectMapper = null, IFingerprint fingerprint = null ) { return(new BillPaymentsClient( secretKey, new RequestMappingIntercessor( client ?? ClientFactory.Create(), objectMapper ?? ObjectMapperFactory.Create() ), fingerprint ?? FingerprintFactory.Create() )); }
public static IServiceCollection AddMapper(this IServiceCollection services) { AutoMapper.IConfigurationProvider configuration = new MapperConfiguration(config => { config.AddProfile <ApplicationServiceProfile>(); }); services.AddSingleton(configuration); services.AddScoped <IMapper, Mapper>(); var mapperService = services.BuildServiceProvider().GetService <IMapper>(); ObjectMapperFactory.SetObjectMapper(new AutoMapAdapter(mapperService)); return(services); }
internal static void AddMapper(this IServiceCollection services, IObjectMapper objectMapper) { if (objectMapper is null) { objectMapper.AddAutoMapperConfiguration(services, confg => {}); services.AddScoped <IMapper, Mapper>(); var mapperService = services.BuildServiceProvider().GetService <IMapper>(); ObjectMapperFactory.SetObjectMapper(new AutoMapAdapter(mapperService)); return; } ObjectMapperFactory.SetObjectMapper(objectMapper); }
public bool Load() { _rage.LogTrivialDebug("loading ELS configuration files..."); var objectMapper = ObjectMapperFactory.CreateInstance(); _elsVehicleSettings.Clear(); _elsSettings.Clear(); try { foreach (var file in Directory.GetFiles(ElsDirectory, "*.xml")) { _rage.LogTrivialDebug("loading els configuration file " + file); var settings = LoadElsFile(file, objectMapper); _rage.LogTrivialDebug("storing els configuration for vehicle " + settings.Key); _elsSettings.Add(settings.Key, settings.Value); } foreach (var file in Directory.GetFiles(DefaultDirectory, "*.xml")) { _rage.LogTrivialDebug("loading els default configuration file " + file); var settings = LoadElsFile(file, objectMapper); var name = settings.Key; _rage.LogTrivialDebug("storing els default configuration for vehicle " + name); _elsVehicleSettings.Add(_elsSettings.ContainsKey(name) ? new ElsVehicleSettings(name, _elsSettings[name], settings.Value) : new ElsVehicleSettings(name, settings.Value)); } _rage.LogTrivial("ELS configuration files loaded"); return(true); } catch (Exception e) { _rage.LogTrivial(e.Message + Environment.NewLine + e.StackTrace); _rage.DisplayPluginNotification("an error occurred while loading the ELS configuration"); } return(false); }
public Children(IChildren children, bool flag = true) { Name = "Test"; FatherName = "TestFather"; childrenCollection = new ChildrenCollection() { DefaultValue = -1, FullName = "Children Name 1", Enabled = false }; if (children != null) { if (flag) { ///////////////////////////////////////////////////////////////////// //// Using Generic Mapper Configuration /// ///////////////////////////////////////////////////////////////////// var mapper = ObjectMapperFactory.CreateMapper <IChildren, IChildren>(); mapper.Map(children, this); } else { ///////////////////////////////////////////////////////////////////// //// Using Profile Registration Mapper Configuration /// ///////////////////////////////////////////////////////////////////// var config = new MapperConfiguration( cfg => { cfg.CreateMap <Children, Children>() .PreserveReferences(); cfg.CreateMap <ChildrenCollection, ChildrenCollection>() .PreserveReferences(); cfg.CreateMap <ChildrenElements, ChildrenElements>() .PreserveReferences(); }); config.AssertConfigurationIsValid(); var mapper = new Mapper(config); mapper.Map(children, this); } } }
private static void ClassInitialize_Fake() { _testContext.Properties.Add( "fakeDataRows", new Dictionary <BillPaymentsClient, FakeApiPresets>( new[] { new FakeClient(ObjectMapperFactory.Create()), new FakeClient(ObjectMapperFactory.Create <NewtonsoftMapper>()) } .Select(fakeClient => new KeyValuePair <BillPaymentsClient, FakeApiPresets>( BillPaymentsClientFactory.Create(Config.MerchantSecretKey, fakeClient, fakeClient.ObjectMapper), new FakeApiPresets { Client = fakeClient, Bills = new List <BillResponse>(), Refunds = new List <RefundResponse>() } )) ) ); }
public ReadValue() { _objectMapper = ObjectMapperFactory.CreateInstance(); }