public void Should_get_empty_configuration() { var configurationStore = new ConfigurationStore().Initialize(); var root = configurationStore.Get<string>("/"); Assert.AreEqual("null", root); }
static void SetupGamespy(ConfigurationStore mapConfig) { mapConfig.CreateMap<GamespyServerQueryResult, Server>() .ForMember(x => x.IsDedicated, opt => opt.ResolveUsing(src => GetValueWithFallback(src, "dedicated", "ds").TryInt() == 1)) .ForMember(x => x.NumPlayers, opt => opt.ResolveUsing(src => src.GetSettingOrDefault("numplayers").TryInt())) .ForMember(x => x.MaxPlayers, opt => opt.ResolveUsing(src => src.GetSettingOrDefault("maxplayers").TryInt())) .ForMember(x => x.Difficulty, opt => opt.ResolveUsing(src => GetValueWithFallback(src, "difficulty", "diff").TryInt())) .ForMember(x => x.GameState, opt => opt.ResolveUsing(src => src.GetSettingOrDefault("gameState").TryInt())) .ForMember(x => x.VerifySignatures, opt => opt.ResolveUsing(src => GetValueWithFallback(src, "verifySignatures", "verSig").TryInt())) .ForMember(x => x.SvBattleye, opt => opt.ResolveUsing(src => GetValueWithFallback(src, "sv_battleye", "be").TryInt())) .ForMember(x => x.ReqBuild, opt => opt.ResolveUsing(src => src.GetSettingOrDefault("reqBuild").TryIntNullable())) .ForMember(x => x.PasswordRequired, opt => opt.ResolveUsing(src => src.GetSettingOrDefault("password").TryInt() > 0)) .ForMember(x => x.Mission, opt => opt.ResolveUsing(src => src.GetSettingOrDefault("mission"))) .ForMember(x => x.Island, opt => opt.ResolveUsing(src => CapitalizeString(src.GetSettingOrDefault("mapname")))) .ForMember(x => x.GameType, opt => opt.ResolveUsing(src => { var str = CapitalizeString(src.GetSettingOrDefault("gametype")); return string.IsNullOrWhiteSpace(str) ? "Unknown" : str; })) .ForMember(x => x.GameName, opt => opt.ResolveUsing(src => src.GetSettingOrDefault("gamename"))) .ForMember(x => x.GameVer, opt => opt.ResolveUsing(src => GetVersion(src.GetSettingOrDefault("gamever")))) .ForMember(x => x.Signatures, opt => opt.ResolveUsing(src => GetValueWithFallback(src, "signatures", "sig").TrySplit(';'))) .AfterMap(GamespyAfterMap); }
public async Task DeleteTest() { await(await ConfigStore.DeleteAsync()).WaitForCompletionResponseAsync(); ConfigurationStore configurationStore = await ResGroup.GetConfigurationStores().GetIfExistsAsync(ConfigurationStoreName); Assert.IsNull(configurationStore); }
public ReportController(IMessageQueueProvider queueProvider, IAdoNetUnitOfWork unitOfWork, ConfigurationStore configStore) { _unitOfWork = unitOfWork; _configStore = configStore; _messageQueue = queueProvider.Open("Reports"); }
private static void RegisterTypes(ContainerBuilder builder) { builder.RegisterType <AutorizationService>().As <IAutorizationService>(); builder.RegisterType <SystemMembershipService>().As <ISystemMembershipService>(); builder.RegisterType <FormAutentificationService>().As <IFormAutentificationService>(); builder.RegisterType <CrudPostService>().As <ICrudPostService>(); builder.Register(ctx => new UmbracoContextWrapper(Umbraco.Web.UmbracoContext.Current)).As <IUmbracoContextWrapper>().InstancePerLifetimeScope(); builder.Register(ctx => ApplicationContext.Current.Services.MemberService).As <IMemberService>().InstancePerLifetimeScope(); builder.RegisterInstance(ApplicationContext.Current.Services.ContentService).As <IContentService>(); builder.RegisterInstance(ApplicationContext.Current.Services.MediaService).As <IMediaService>(); builder.Register(c => { var s = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); s.CreateMap <Umbraco.Web.PublishedContentModels.Post, Models.PostViewModel>() .ForMember(l => l.PostText, opt => opt.MapFrom(l => l.PostText)) .ForMember(l => l.PostDate, opt => opt.MapFrom(l => l.PostDate)) .ForMember(l => l.MemberID, opt => opt.MapFrom(l => l.MemberID)) .ForMember(l => l.PostImage, opt => opt.Ignore()); return(s); }).As <IConfigurationProvider>().SingleInstance(); builder.RegisterType <MappingEngine>().As <IMappingEngine>(); }
private static void MapProducts(ConfigurationStore mapperConfig) { mapperConfig.CreateMap<Product, ProductModel>() .ForMember(d => d.Id, opt => opt.MapFrom(s => s.ProductID)) .ReverseMap(); mapperConfig.CreateMap<ProductModelCreateRequest, Product>() .ForMember(d => d.ProductID, opt => opt.MapFrom(s => s.Id)) .ReverseMap(); mapperConfig.CreateMap<Product, ProductModelResponse>() .ForMember(d => d.Id, opt => opt.MapFrom(s => s.ProductID)) .ForMember(d => d.LastModifiedDate, opt => opt.MapFrom(s => s.ModifiedDate)) .ForMember(d => d.ParentProductCategoryID, opt => opt.MapFrom(s => s.ProductCategory.ParentProductCategoryID)) .ForMember(d => d.CategoryName, opt => opt.MapFrom(s => s.ProductCategory.Name)) .ForMember(d => d.CatalogDescription, opt => opt.MapFrom(s => s.ProductType.CatalogDescription)) .ForMember(d => d.ProductTypeName, opt => opt.MapFrom(s => s.ProductType.Name)) .ReverseMap(); mapperConfig.CreateMap<ProductCategoryModel, ProductCategory>() .IgnorePropertiesThatHaveNotBeenSet() .ReverseMap(); mapperConfig.CreateMap<ProductModelUpdateRequest, Product>() .IgnorePropertiesThatHaveNotBeenSet() .ReverseMap(); }
public void ShouldMapToNewISet() { new PlatformSpecificMapperRegistryOverride().Initialize(); var config = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); config.CreateMap <SourceWithIEnumerable, TargetWithISet>() .ForMember(dest => dest.Stuff, opt => opt.MapFrom(src => src.Stuff.Select(s => s.Value))); config.AssertConfigurationIsValid(); var engine = new MappingEngine(config); var source = new SourceWithIEnumerable { Stuff = new[] { new TypeWithStringProperty { Value = "Microphone" }, new TypeWithStringProperty { Value = "Check" }, new TypeWithStringProperty { Value = "1, 2" }, new TypeWithStringProperty { Value = "What is this?" } } }; var target = engine.Map <SourceWithIEnumerable, TargetWithISet>(source); }
public void AddOrUpdate(UpdateOwnerInput input) { var config = new ConfigurationStore(new TypeMapFactory(), AutoMapper.Mappers.MapperRegistry.Mappers); var mapper = new MappingEngine(config); config.CreateMap<OwnerDto, Owner>().ConstructUsing(model => { if (model.Id == 0) { Owner toAdd = new Owner(); _ownerRepository.Insert(toAdd); return toAdd; } else { return _ownerRepository.Get(model.Id); } }); config.CreateMap<OwnerLandPropertyDto, LandProperty>().ConstructUsing(model => { return _landPropertyRepository.Get(model.Id); }); try { mapper.Map<OwnerDto, Owner>(input.OwnerToUpdate); } catch (Exception e) { throw e; } }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the value to convert into an instance of <see cref="ConfigurationStore" />.</param> /// <returns> /// an instance of <see cref="ConfigurationStore" />, or <c>null</c> if there is no suitable conversion. /// </returns> public static object ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return(null); } try { ConfigurationStore.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); } catch { // Unable to use JSON pattern } try { return(new ConfigurationStore { Properties = ConfigurationStorePropertiesTypeConverter.ConvertFrom(sourceValue.Properties), }); } catch { } return(null); }
public void should_retry_when_initialisation_fails_until_successful() { const int failCount = 2; var builder = new FailingConfigurationBuilder(failCount); var store = new ConfigurationStore(builder.Build); Configuration configuration1; for (var i = 0; i < failCount; i++) { try { configuration1 = store.Configuration; Assert.Fail("Exception should be thrown on first 2 attempts to initialise configuration"); } catch { } } configuration1 = store.Configuration; var configuration2 = store.Configuration; Assert.IsNotNull(configuration1); Assert.AreSame(configuration1, configuration2); Assert.AreEqual(3, builder.AttemptedBuildCount); Assert.AreEqual(1, builder.BuildCount); }
private static IConfigurationProvider CreateMapperConfiguration() { var result = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); result.AllowNullCollections = true; result.CreateMap <D.ScrumTeam, ScrumTeam>(); result.CreateMap <D.Observer, TeamMember>() .ForMember(m => m.Type, mc => mc.ResolveUsing((D.Observer o) => o.GetType().Name)); result.CreateMap <D.Message, Message>() .Include <D.MemberMessage, MemberMessage>() .Include <D.EstimationResultMessage, EstimationResultMessage>() .ForMember(m => m.Type, mc => mc.MapFrom(m => m.MessageType)); result.CreateMap <D.MemberMessage, MemberMessage>(); result.CreateMap <D.EstimationResultMessage, EstimationResultMessage>(); result.CreateMap <KeyValuePair <D.Member, D.Estimation>, EstimationResultItem>() .ForMember(i => i.Member, mc => mc.MapFrom(p => p.Key)) .ForMember(i => i.Estimation, mc => mc.MapFrom(p => p.Value)); result.CreateMap <D.EstimationParticipantStatus, EstimationParticipantStatus>(); result.CreateMap <D.Estimation, Estimation>() .ForMember(e => e.Value, mc => mc.ResolveUsing(e => e.Value.HasValue && double.IsPositiveInfinity(e.Value.Value) ? Estimation.PositiveInfinity : e.Value)); result.AssertConfigurationIsValid(); return(result); }
private void MapIdentifiers(ConfigurationStore map) { map.CreateMap<Documents.AccountIdentifier, AccountIdentifier>() .ForMember(x => x.Account, m => m.ResolveUsing(ToAccount)); map.CreateMap<Documents.Pattern, IPattern>() .ConvertUsing(ToPattern); map.CreateMap<AmountPattern, Documents.Pattern>() .ConvertUsing(ToPattern); map.CreateMap<AmountRangePattern, Documents.Pattern>() .ConvertUsing(ToPattern); map.CreateMap<DayOfMonthPattern, Documents.Pattern>() .ConvertUsing(ToPattern); map.CreateMap<FieldPattern, Documents.Pattern>() .ConvertUsing(ToPattern); map.CreateMap<CompositePattern, Documents.Pattern>() .ForMember(x => x.Name, m => m.UseValue("Composite")) .ForMember(x => x.Child, m => m.MapFrom(p => p)); map.CreateMap<AccountIdentifier, Documents.AccountIdentifier>(); }
// For Direct3D, who fails to center the window on startup. private void CenterWindowAndSetTitle() { var windowBounds = Window.ClientBounds; var displayMode = GraphicsDevice.Adapter.CurrentDisplayMode; Window.Position = new Point((displayMode.Width - windowBounds.Width) / 2, (displayMode.Height - windowBounds.Height) / 2); var config = ConfigurationStore.Get <MainAppConfig>(); string songTitle; if (ConfigurationStore.TryGetValue <BeatmapLoaderConfig>(out var scoreLoaderConfig)) { songTitle = scoreLoaderConfig.Data.Title; } else { songTitle = null; } var appCodeName = ApplicationHelper.CodeName; var windowTitle = config.Data.Window.Title; if (!string.IsNullOrWhiteSpace(songTitle)) { windowTitle = songTitle + " - " + windowTitle; } if (!string.IsNullOrWhiteSpace(appCodeName)) { windowTitle = windowTitle + " (\"" + appCodeName + "\")"; } Window.Title = windowTitle; }
/// <summary> /// Used to setup AutoMapper /// </summary> /// <param name="additionalProfiles">These profiles will override any existing mappings in an additive manner. Base and ProjectTo are applied automatically.</param> /// <exception cref="AutoMapperConfigurationException">Thrown the mapping configuration is invalid - check the logs</exception> public static void InitializeMappers(params Profile[] additionalProfiles) { if (!hasInitialized) { hasInitialized = true; } else { throw new AutoMapperConfigurationException("InitializeMappers should only be called once during the lifetime of an application."); } // Setup Mapper Mapper.AddProfile(Api); if (additionalProfiles != null) { foreach (Profile additionalProfile in additionalProfiles) { Mapper.AddProfile(additionalProfile); } } // Verify Mapper configuration Mapper.AssertConfigurationIsValid(); // Setup ProjectToMapper ConfigurationStore getAllConfig = CreateConfiguration(); ApiProjectToMapper = CreateMapper(getAllConfig); getAllConfig.AddProfile(Api); getAllConfig.AddProfile(ApiProjectTo); }
public void Build(Action <ContainerRegistrar> action, ConfigurationStore configStore) { var builder = new ContainerRegistrar(); //need to invoke first to allow plug-ins to override default behavior. action(builder); builder.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly()); builder.RegisterService(CreateUnitOfWork, Lifetime.Scoped); builder.RegisterService(CreateTaskInvoker, Lifetime.Singleton); builder.RegisterService(CreateConnection, Lifetime.Transient); RegisterBuiltInComponents(builder); RegisterQueues(builder); builder.RegisterService(x => Container, Lifetime.Singleton); builder.RegisterService(x => x); builder.RegisterService(CreateAnalysisDbContext); builder.RegisterInstance(configStore); builder.RegisterType(typeof(IConfiguration <>), typeof(ConfigWrapper <>), Lifetime.Transient); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); builder.RegisterService(x => configStore.Load <BaseConfiguration>()); var ioc = builder.Build(); DependencyResolver.SetResolver(new GriffinDependencyResolver(ioc)); GlobalConfiguration.Configuration.DependencyResolver = new GriffinWebApiDependencyResolver2(ioc); Container = new GriffinContainerAdapter(ioc); }
/// <summary> /// Creates a new instance of <see cref="CheckForNotificationsToSend" />. /// </summary> /// <param name="notificationsRepository">To load notification configuration</param> /// <param name="userRepository">To load user info</param> public CheckForNotificationsToSend(INotificationsRepository notificationsRepository, IUserRepository userRepository, ConfigurationStore configStore) { _notificationsRepository = notificationsRepository; _userRepository = userRepository; _configStore = configStore; }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Get", "{controller}/{id}", new { action = "Get" }, new { id = @"\d+" } ); routes.MapRoute( "Save", "{controller}/", new { action = "Save" }, new { httpMethod = new HttpMethodConstraint("POST") } ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); var config = ConfigurationStore.Get(); config.RegisterVendorized("application/vnd.company.com+xml", new Driver(new XmlSerializer(), new XmlHypermediaInjector(), new XmlDeserializer())); }
public TransportMongo(string tempDir, string url) { if (!FileSystemHelper.SafeDeleteDirectory(tempDir)) { Debug.WriteLine("failed delete temp dir"); } var pcktsDir = Path.Combine(tempDir, "pckts"); var tempPcktsDir = Path.Combine(tempDir, "tmp_pckts"); this._packetManager = new PacketManager(new PacketManagerSettings(pcktsDir, tempPcktsDir)); var transportSettings = new TransportSettings() { PacketSizeLimits = new SendMessageSizeLimits { Min = 0, Max = 1 * 1024 * 1024, //Max = 100, } }; var agentInfoService = new TransportAgentInfoService(new RealComputerIdentityProvider()); this.TransportClient = new TransportClient(agentInfoService, _packetManager); var cnfsDir = Path.Combine(tempDir, "conf"); var tempcnfsDir = Path.Combine(tempDir, "conf_pckts"); var confStore = new ConfigurationStore(cnfsDir, tempcnfsDir); confStore.Subscribe(new TestOnConfigUpdate()); this.SenderWorker = new TransportSenderWorker(_packetManager, agentInfoService, confStore, url, transportSettings, new SendStateStore()); CancellationTokenSource cs = new CancellationTokenSource(); }
// This actually should be OnGotContext protected override void OnLoadContents() { // Handle scaling var s = ConfigurationStore.Get <ScalingConfig>(); var t = ScaleResults; var baseScaling = s.Data.Base; var viewport = Game.GraphicsDevice.Viewport; var xRatio = viewport.Width / baseScaling.X; var yRatio = viewport.Height / baseScaling.Y; var ty = typeof(ScalingConfig.ScalingConfigData); var props = ty.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (var prop in props) { if (prop.PropertyType == typeof(Vector2)) { var source = (Vector2)prop.GetValue(s.Data); var scaled = Resize(source, xRatio, yRatio); prop.SetValue(t, scaled); } else if (prop.PropertyType == typeof(ScalingConfig.SizableScaling)) { var source = (ScalingConfig.SizableScaling)prop.GetValue(s.Data); var scaled = Resize(source, xRatio, yRatio); prop.SetValue(t, scaled); } } ScaledRatio = new Vector2(xRatio, yRatio); base.OnLoadContents(); }
public void AddOrUpdate(GetMortgageInput input) { var config = new ConfigurationStore(new TypeMapFactory(), AutoMapper.Mappers.MapperRegistry.Mappers); var mapper = new MappingEngine(config); config.CreateMap<MortgageDto, Mortgage>().ConstructUsing(model => { if (model.Id == 0) { Mortgage toAdd = new Mortgage(); _mortgageRepository.Insert(toAdd); return toAdd; } else { return _mortgageRepository.Get(model.Id); } }).ForMember(x => x.LandProperty, o => o.Ignore()); try { mapper.Map<MortgageDto, Mortgage>(input.MortgageToUpdate); } catch (Exception e) { throw e; } }
public void DeviceReadyForReturn(RepositoryMonitorEvent e) { var job = (Job)e.Entity; var emailConfig = new ConfigurationStore(e.Database).DeserializeConfiguration(); var messageConfig = emailConfig.MessageConfig.First(z => z.EmailMessageType == MessageType.DeviceReadyForCollection); var user = UserService.GetUser(job.UserId); if (!job.DeviceReadyForReturn.HasValue || !messageConfig.EmailAlertEnabled || user.EmailAddress == null) { return; } //Send Collection Email try { Internal.Email.SendEmailMessage(user, messageConfig, job); //Insert note into job log if email has been sent successfully e.Database.JobLogs.Add(new JobLog { Job = job, Comments = $"# Collection Email Sent.\r\n Collection email sent to {user.DisplayName}", TechUser = e.Database.Users.Find(UserService.CurrentUserId), Timestamp = DateTime.Now }); e.Database.SaveChanges(); } catch (Exception message) { throw new Exception(message.ToString()); } }
public static Dictionary <string, string> DiscloseInformation(DiscoDataContext Database, Job Job, OrganisationAddress Address, User TechUser) { var config = new ConfigurationStore(Database); string serialNumberMessage; if (Job.Device.HasAlternateSerialNumber(out serialNumberMessage)) { serialNumberMessage += " [Acer SNID]"; } else { serialNumberMessage = Job.DeviceSerialNumber; } return(new Dictionary <string, string>() { { "LWT Customer Entity Id", config.CustomerEntityId }, { "LWT Customer Username", config.CustomerUsername }, { "Contact Name", TechUser.DisplayName }, { "Contact Company", Address.Name }, { "Contact Address", Address.Address }, { "Contact Suburb", Address.Suburb }, { "Contact Postcode", Address.Postcode }, { "Contact Phone", TechUser.PhoneNumber }, { "Contact Email", TechUser.EmailAddress }, { "Device Serial Number", serialNumberMessage }, { "Device Product Description", String.Format("{0} {1}", Job.Device.DeviceModel.Manufacturer, Job.Device.DeviceModel.Model) }, { "Device Room Location", String.Format("Customer Job Id: {0}", Job.Id) } }); }
public async Task GetTest() { ConfigurationStore configurationStore = await ConfigStore.GetAsync(); Assert.IsTrue(ConfigurationStoreName.Equals(configurationStore.Data.Name)); Assert.IsTrue(configurationStore.Data.PublicNetworkAccess == PublicNetworkAccess.Disabled); }
public void Start() { _log.Submit(LogLevel.Info, "Starting configuration store"); ConfigurationStore.Start(); _log.Submit(LogLevel.Info, "Configuration store started "); _log.Submit(LogLevel.Info, "Starting Data Manager"); DataManager.Start(); _log.Submit(LogLevel.Info, "Data Manager started"); _log.Submit(LogLevel.Info, "Setting up environment"); // inject UploadPackage.PackageDAO = DataManager.PackageDAO; DownloadPackage.PackageDAO = DataManager.PackageDAO; DownloadPackage.FileStore = DataManager.FileStore; PackageDetails.PackageDAO = DataManager.PackageDAO; PackageDetails.FileStore = DataManager.FileStore; DeletePackage.PackageDAO = DataManager.PackageDAO; DeletePackage.FileStore = DataManager.FileStore; FindPackage.PackageDAO = DataManager.PackageDAO; Search.PackageDAO = DataManager.PackageDAO; _log.Submit(LogLevel.Info, "Environment setup finished"); _log.Submit(LogLevel.Info, "Starting Nuget server"); OwinHost.Start(ConfigurationStore.ServerPort.Value, ConfigurationStore.ApiKey.Value); _log.Submit(LogLevel.Info, "Nuget server started"); }
public void Should_not_notify_after_deregistration() { var configurationStore = new ConfigurationStore().Initialize(); const string config1 = "{child1:{field1:1,field2:2},child2:{field1:99,field2:98}}"; const string config2 = "{child1:{field1:3,field2:2},child2:{field1:99,field2:98}}"; configurationStore.UpdateConfiguration(config1); var child1Field1Value = 0; var registration = configurationStore.Register("/child1/field1", (int v) => child1Field1Value = v); Assert.AreEqual(1, child1Field1Value); configurationStore.UpdateConfiguration(config2); Assert.AreEqual(3, child1Field1Value); registration.Dispose(); configurationStore.UpdateConfiguration(config1); Assert.AreEqual(3, child1Field1Value); Assert.AreEqual(1, configurationStore.Get <int>("/child1/field1")); }
public void Should_parse_path() { var configurationStore = new ConfigurationStore().Initialize(); configurationStore.UpdateConfiguration("{child1:{field1:1,field2:2},child2:{field1:99,field2:98}}"); var root = configurationStore.Get <TestClassB>("/"); var child1 = configurationStore.Get <TestClassA>("/child1"); var child2 = configurationStore.Get <TestClassA>("/child2"); Assert.IsNotNull(root); Assert.IsNotNull(root.Child1); Assert.IsNotNull(root.Child2); Assert.AreEqual(1, root.Child1.Field1); Assert.AreEqual(2, root.Child1.Field2); Assert.AreEqual(99, root.Child2.Field1); Assert.AreEqual(98, root.Child2.Field2); Assert.IsNotNull(child1); Assert.AreEqual(1, child1.Field1); Assert.AreEqual(2, child1.Field2); Assert.IsNotNull(child2); Assert.AreEqual(99, child2.Field1); Assert.AreEqual(98, child2.Field2); }
public ServerConnection(string url) { using(Log.Scope("ServerConnection constructor")) { Log.Debug("connecting to {0}", url); try { if(_instance != null) { _instance.Dispose(); _instance = null; } } catch { } if(url == null) throw new ArgumentNullException("url"); _url = url; this.Server = new LPSClientShared.LPSServer.Server(url); this.Server.CookieContainer = CookieContainer; this.cached_datasets = new Dictionary<string, DataSet>(); _instance = this; resource_manager = new ResourceManager(this); configuration_store = new ConfigurationStore(); } }
protected override void SetIssuerSpecificTokenValidationParameters(TokenValidationParameters validationParameters) { if (!string.IsNullOrWhiteSpace(ConfigurationStore.GetRoleClaimType())) { validationParameters.RoleClaimType = ConfigurationStore.GetRoleClaimType(); } }
public void Build(Action <ContainerRegistrar> action, ConfigurationStore configStore) { var builder = new ContainerRegistrar(); builder.RegisterComponents(Lifetime.Scoped, Assembly.GetExecutingAssembly()); builder.RegisterService(CreateConnection, Lifetime.Scoped); builder.RegisterService(CreateTaskInvoker, Lifetime.Singleton); builder.RegisterInstance(Startup.ConnectionFactory); action(builder); RegisterBuiltInComponents(builder); RegisterQueues(builder); builder.RegisterService(x => Container, Lifetime.Singleton); builder.RegisterService(x => x); builder.RegisterConcrete <AnalysisDbContext>(); builder.RegisterInstance(configStore); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); var ioc = builder.Build(); DependencyResolver.SetResolver(new GriffinDependencyResolver(ioc)); GlobalConfiguration.Configuration.DependencyResolver = new GriffinWebApiDependencyResolver2(ioc); Container = new GriffinContainerAdapter(ioc); }
public static bool ValidateEnvironment(DiscoDataContext Database, Controller controller, User TechUser) { // Validate Configuration var config = new ConfigurationStore(Database); if (string.IsNullOrWhiteSpace(config.CustomerEntityId)) { controller.ModelState.AddModelError(string.Empty, "LWT Customer Entity Id is Required (See LWT Plugin Configuration)"); } if (string.IsNullOrWhiteSpace(config.CustomerUsername)) { controller.ModelState.AddModelError(string.Empty, "LWT Customer Username is Required (See LWT Plugin Configuration)"); } // Validate TechUser Email Address if (string.IsNullOrEmpty(TechUser.EmailAddress)) { controller.ModelState.AddModelError(string.Empty, "LWT Requires a Technician Email Address (Update your Email Address in Active Directory)"); } if (string.IsNullOrEmpty(TechUser.PhoneNumber)) { controller.ModelState.AddModelError(string.Empty, "LWT Requires a Technician Phone Number (Update your Telephone Number in Active Directory)"); } return(controller.ModelState.IsValid); }
public TransportBootstrap Init(string tempDir) { if (!FileSystemHelper.SafeDeleteDirectory(tempDir)) { Debug.WriteLine("failed delete temp dir"); } var pcktsDir = Path.Combine(tempDir, "pckts"); var tempPcktsDir = Path.Combine(tempDir, "tmp_pckts"); var packetManager = new PacketManager(new PacketManagerSettings(pcktsDir, tempPcktsDir)); var transportSettings = new TransportSettings() { PacketSizeLimits = new SendMessageSizeLimits { Min = 0, Max = TransportConstants.DefaultMaxClientPacketSize, } }; string url = "http://localhost:5002/dhu/transport/exchange"; this.transportClient = new TransportClient(packetManager, transportSettings); var agentInfoService = new TransportAgentInfoService(new RealComputerIdentityProvider()); var cnfsDir = Path.Combine(tempDir, "conf"); var tempcnfsDir = Path.Combine(tempDir, "conf_pckts"); var confStore = new ConfigurationStore(cnfsDir, tempcnfsDir); confStore.Subscribe(new TestOnConfigUpdate()); this.senderWorker = new TransportSenderWorker(packetManager, agentInfoService, confStore, url, transportSettings, new SendStateStore()); return(this); }
public void should_not_initialise_configuration_and_session_factory_until_accessed() { var builder = new TestConfigurationBuilder(); var store = new ConfigurationStore(builder.Build); Assert.AreEqual(0, builder.BuildCount); }
protected override void OnLoadContents() { base.OnLoadContents(); var game = Game.ToBaseGame(); _basicEffect = new BasicEffect(game.GraphicsDevice); game.EffectManager.RegisterSingleton(_basicEffect); // Hack: register note effect list NoteEffects.Effects[(int)NoteType.Floor] = _basicEffect; NoteEffects.Effects[(int)NoteType.Long] = _basicEffect; NoteEffects.Effects[(int)NoteType.Arc] = _basicEffect; NoteEffects.Effects[(int)NoteType.Sky] = _basicEffect; var beatmap = Game.FindSingleElement <BeatmapLoader>()?.Beatmap; if (beatmap != null) { _beatmap = new VisualBeatmap(game.GraphicsDevice, beatmap, _stageMetrics); } var config = ConfigurationStore.Get <TrackDisplayConfig>(); _panelTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.PanelTexture); _trackLaneDividerTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.TrackLaneDividerTexture); _skyInputTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.SkyInputTexture); _noteTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteTexture); _noteHoldTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteHoldTexture); _noteHoldHighlightedTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteHoldHighlightedTexture); _noteSkyTexture = ContentHelper.LoadTexture(game.GraphicsDevice, config.Data.NoteSkyTexture); var metrics = _stageMetrics; { _trackRectangle = new TexturedRectangle(game.GraphicsDevice); _trackRectangle.SetVerticesXY(new Vector2(-metrics.HalfTrackFullWidth, -metrics.TrackLength * 0.1f), new Vector2(metrics.TrackFullWidth, metrics.TrackLength * 1.1f), new Color(Color.White, 0.9f), 0, 0); } { _finishLineRectangle = new TexturedRectangle(game.GraphicsDevice); _finishLineRectangle.SetVerticesXY(new Vector2(-metrics.HalfTrackInnerWidth, metrics.FinishLineY - metrics.FinishLineHeight / 2), new Vector2(metrics.TrackInnerWidth, metrics.FinishLineHeight), new Color(Color.MediumPurple, 0.9f), 0.02f); } { _laneDividerRectangles = new TexturedRectangle[3]; for (var i = 1; i < 4; ++i) { _laneDividerRectangles[i - 1] = new TexturedRectangle(game.GraphicsDevice); var left = i * metrics.TrackInnerWidth / 4 - metrics.LaneDividerWidth / 2 - metrics.HalfTrackInnerWidth; var origin = new Vector2(left, 0); var size = new Vector2(metrics.LaneDividerWidth, metrics.TrackLength); _laneDividerRectangles[i - 1].SetVerticesXY(origin, size, new Color(Color.Lavender, 0.9f), 0.01f); } } { _skyInputRectangle = new TexturedRectangle(game.GraphicsDevice); _skyInputRectangle.SetVerticesXZ(new Vector2(-metrics.SkyInputWidth / 2, metrics.SkyInputZ - metrics.SkyInputTallness / 2), new Vector2(metrics.SkyInputWidth, metrics.SkyInputTallness), Color.White, metrics.FinishLineY); } }
protected override void OnUpdate(GameTime gameTime) { base.OnUpdate(gameTime); var syncTimer = Game.ToBaseGame().FindSingleElement <SyncTimer>(); if (syncTimer == null) { throw new InvalidOperationException(); } var now = syncTimer.CurrentTime.TotalSeconds; var config = ConfigurationStore.Get <SongTitleConfig>(); var appearStages = config.Data.Animation.Appear; var reappearStages = config.Data.Animation.Reappear; var s1t1 = appearStages.Enter + appearStages.FadeIn; var s1t2 = s1t1 + appearStages.Hold; var s1t3 = s1t2 + appearStages.FadeOut; var s2t1 = reappearStages.Enter + reappearStages.FadeIn; var s2t2 = s2t1 + reappearStages.Hold; var s2t3 = s2t2 + reappearStages.FadeOut; if (!(appearStages.Enter <= now && now <= s1t3) && !(reappearStages.Enter <= now && now <= s2t3)) { Opacity = 0; return; } float opacity = 0; if (!appearStages.FadeIn.Equals(0) && now <= s1t1) { opacity = (float)(now - appearStages.Enter) / (float)appearStages.FadeIn; } else if (!appearStages.Hold.Equals(0) && now <= s1t2) { opacity = 1; } else if (!appearStages.FadeOut.Equals(0) && now <= s1t3) { opacity = 1 - (float)(now - s1t2) / (float)appearStages.FadeOut; } else if (!reappearStages.FadeIn.Equals(0) && now <= s2t1) { opacity = (float)(now - reappearStages.Enter) / (float)reappearStages.FadeIn; } else if (!reappearStages.Hold.Equals(0) && now <= s2t2) { opacity = 1; } else if (!reappearStages.FadeOut.Equals(0) && now <= s2t3) { opacity = 1 - (float)(now - s2t2) / (float)reappearStages.FadeOut; } Opacity = opacity; }
/// <summary> /// Creates a new instance of <see cref="InviteUserHandler" />. /// </summary> /// <param name="invitationRepository">Store invitations</param> /// <param name="userRepository">To load inviter and invitee</param> /// <param name="applicationRepository">Add pending member</param> public InviteUserHandler(IInvitationRepository invitationRepository, IUserRepository userRepository, IApplicationRepository applicationRepository, ConfigurationStore configStore) { _invitationRepository = invitationRepository; _userRepository = userRepository; _applicationRepository = applicationRepository; _configStore = configStore; }
private void MapAccount(ConfigurationStore map) { map.CreateMap<Documents.Account, Account>() .ForMember(x => x.Id, m => m.ResolveUsing(GetEntityId)); map.CreateMap<Account, Documents.Account>() .ForMember(x => x.Id, m => m.ResolveUsing(GetRavenId)); }
public IMappingEngine Build() { var map = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); foreach (var provider in _providers) provider.RegisterTypeMaps(map); return new MappingEngine(map); }
public async Task DeleteTest() { await ConfigStore.DeleteAsync(true); ConfigurationStore configurationStore = await ResGroup.GetConfigurationStores().GetIfExistsAsync(ConfigurationStoreName); Assert.IsNull(configurationStore); }
public async Task Get() { #region Snippet:Managing_ConfigurationStores_GetAConfigurationStore ConfigurationStore configurationStore = await resourceGroup.GetConfigurationStores().GetAsync("myApp"); Console.WriteLine(configurationStore.Data.Name); #endregion }
public void RegisterTypeMaps(ConfigurationStore map) { MapAccount(map); MapTransaction(map); MapIdentifiers(map); MapBudget(map); MapImport(map); }
public void ConfigureStructureMap(ConfigurationStore configStore) { For<ConfigurationStore>().Singleton().Use(configStore); For<IConfigurationProvider>().Use(x => x.GetInstance<ConfigurationStore>()); For<IConfiguration>().Use(x => x.GetInstance<ConfigurationStore>()); For<IMappingEngine>().Use<MappingEngine>(); For<ITypeMapFactory>().Use<TypeMapFactory>(); }
void CreateGameMap(ConfigurationStore config) { config.CreateMap<InstalledState, GameDataModel>(); config.CreateMap<GameMetaData, GameDataModel>(); config.CreateMap<Game, GameDataModel>() .AfterMap(AfterGameDataModelMap); CreateGameSettingsMap(config); }
private void MapBudget(ConfigurationStore map) { map.CreateMap<Budget, Documents.Budget>() .ForMember(x => x.AccountId, m => m.MapFrom(x => x.RealAccount.Id)); map.CreateMap<Documents.Budget, Budget>() .ForMember(x => x.RealAccount, m => m.ResolveUsing(x => new Account { Id = x.AccountId })) .ForMember(x => x.BudgetAccount, m => m.ResolveUsing(x => new Account { Id = x.BudgetAccountId })); }
public static IMappingEngine CreateEngine(Profile mappingProfile) { ConfigurationStore store = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); store.AssertConfigurationIsValid(); MappingEngine engine = new MappingEngine(store); store.AddProfile(mappingProfile); return engine; }
IConfigurationProvider CreateConfig() { var config = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); config.SetupConverters(); CreateProfileMap(config); CreateDlcMap(config); CreateGameMap(config); config.Seal(); return config; }
public BaseController() : base() { AnonymousManagersProvider = new ManagersProvider(); IPlatformSpecificMapperRegistry platformSpecificRegistry = PlatformAdapter.Resolve<IPlatformSpecificMapperRegistry>(true); platformSpecificRegistry.Initialize(); var store = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); _mapper = new MappingEngine(store); }
public void ConfigurationStore_should_return_correct_type() { var configStore = new ConfigurationStore(); configStore.Mapping<ITest, Test>(); var a = configStore._pairings.Count; var obj = Locator.Resolve<ITest>(configStore._pairings); string hi = obj.Hi(); }
public static MappingEngine CreateMappingEngine() { var mapperConfig = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.AllMappers()); new ProductMapper().ConfigureMap(mapperConfig); new CustomerMapper().ConfigureMap(mapperConfig); var mapper = new MappingEngine(mapperConfig); Mapper.AssertConfigurationIsValid(); return mapper; }
public void Should_get_value_configuration() { var validator = new Validator { IsValid = true }; var configurationStore = new ConfigurationStore().Initialize(validator); const int testValue = 76534; configurationStore.UpdateConfiguration(testValue.ToString()); var root = configurationStore.Get<int>("/"); Assert.AreEqual(testValue, root); }
public void Should_get_object_configuration() { var configurationStore = new ConfigurationStore().Initialize(); configurationStore.UpdateConfiguration("{field1:1,field2:2}"); var root = configurationStore.Get<TestClassA>("/"); Assert.IsNotNull(root); Assert.AreEqual(1, root.Field1); Assert.AreEqual(2, root.Field2); }
private void MapImport(ConfigurationStore map) { map.CreateMap<ImportResult, Documents.ImportResult>() .ForMember(x => x.Id, m => m.ResolveUsing(x => string.Concat("imports/", x.Id))); map.CreateMap<Documents.ImportResult, ImportResult>() .ForMember(x => x.Id, m => m.ResolveUsing(x => x.Id == null ? "0" : x.Id.Split('/').Last())); ; map.CreateMap<Transaction, ImportedTransaction>() .ForMember(x => x.TransactionId, m => m.MapFrom(x => x.Id)) .ForMember(x => x.Id, m => m.MapFrom(x => x.Reference)); }
public void AddOrUpdate(UpdateLandPropertyInput input) { var config = new ConfigurationStore(new TypeMapFactory(), AutoMapper.Mappers.MapperRegistry.Mappers); var mapper = new MappingEngine(config); config.CreateMap<LandPropertyDto, LandProperty>().ConstructUsing(model => { if (model.Id == 0) { LandProperty toAdd = new LandProperty(); _landPropertyRepository.InsertAsync(toAdd); return toAdd; } else { return _landPropertyRepository.Get(model.Id); } }); config.CreateMap<LandPropertyOwnerDto, Owner>().ConstructUsing(model => { return _ownerRepository.Get(model.Id); }); config.CreateMap<MortgageDto, Mortgage>().ConstructUsing(model => { if (model.MortgageIdentifier > 0 && model.Id == 0) { Mortgage toAdd = new Mortgage(); _mortgageRepository.Insert(toAdd); return toAdd; } else if (model.Id > 0) { return _mortgageRepository.Get(model.Id); } else { return null; } }).ForMember(x => x.LandProperty, o => o.Ignore()); try { mapper.Map<LandPropertyDto, LandProperty>(input.LandPropToUpdate); } catch (Exception e) { throw e; } }
public void Should_get_array_configuration() { var validator = new Validator { IsValid = true }; var configurationStore = new ConfigurationStore().Initialize(validator); configurationStore.UpdateConfiguration("[3,2,1]"); var root = configurationStore.Get<int[]>("/"); Assert.AreEqual(3, root.Length); Assert.AreEqual(3, root[0]); Assert.AreEqual(2, root[1]); Assert.AreEqual(1, root[2]); }
void CreateGameSettingsMap(ConfigurationStore config) { config.CreateMap<GameSettings, GameSettingsDataModel>() .Include<RealVirtualitySettings, RealVirtualityGameSettingsDataModel>() .Include<Homeworld2Settings, HomeWorld2SettingsDataModel>() .Include<GTAVSettings, GTAVSettingsDataModel>(); config.CreateMap<RealVirtualitySettings, RealVirtualityGameSettingsDataModel>() .Include<ArmaSettings, ArmaSettingsDataModel>(); config.CreateMap<Arma2FreeSettings, Arma2OriginalChildSettingsDataModel>(); config.CreateMap<ArmaSettings, ArmaSettingsDataModel>() .Include<Arma2OaSettings, Arma2OaSettingsDataModel>(); config.CreateMap<ArmaSettings, Arma2OriginalChildSettingsDataModel>(); config.CreateMap<Arma2OaSettings, Arma2OaSettingsDataModel>() .Include<Arma3Settings, Arma3SettingsDataModel>() .Include<Arma2CoSettings, Arma2CoSettingsDataModel>(); config.CreateMap<Arma2CoSettings, Arma2CoSettingsDataModel>() .ForMember(x => x.Arma2Free, opt => opt.Ignore()) .ForMember(x => x.Arma2Original, opt => opt.Ignore()) .AfterMap(AfterCoMap); config.CreateMap<Arma3Settings, Arma3SettingsDataModel>(); config.CreateMap<Homeworld2Settings, HomeWorld2SettingsDataModel>(); config.CreateMap<GTAVSettings, GTAVSettingsDataModel>(); config.CreateMap<GameSettingsDataModel, GameSettings>() .Include<RealVirtualityGameSettingsDataModel, RealVirtualitySettings>() .Include<HomeWorld2SettingsDataModel, Homeworld2Settings>() .Include<GTAVSettingsDataModel, GTAVSettings>(); config.CreateMap<RealVirtualityGameSettingsDataModel, RealVirtualitySettings>() .Include<ArmaSettingsDataModel, ArmaSettings>(); config.CreateMap<ArmaSettingsDataModel, ArmaSettings>() .Include<Arma2OaSettingsDataModel, Arma2OaSettings>(); config.CreateMap<Arma2OaSettingsDataModel, Arma2OaSettings>() .Include<Arma3SettingsDataModel, Arma3Settings>() .Include<Arma2CoSettingsDataModel, Arma2CoSettings>(); config.CreateMap<Arma3SettingsDataModel, Arma3Settings>(); config.CreateMap<Arma2CoSettingsDataModel, Arma2CoSettings>() .ForMember(x => x.Arma2Free, opt => opt.Ignore()) .ForMember(x => x.Arma2Original, opt => opt.Ignore()) .AfterMap(AfterCoRevMap); config.CreateMap<Arma2OriginalChildSettingsDataModel, ArmaSettings>(); config.CreateMap<Arma2OriginalChildSettingsDataModel, Arma2FreeSettings>(); config.CreateMap<HomeWorld2SettingsDataModel, Homeworld2Settings>(); config.CreateMap<GTAVSettingsDataModel, GTAVSettings>(); }
public void GetAllCustomers_MissingMappingConfiguration_AutoMapperMappingException() { //Arrange var configurationStore = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); IMappingEngine mappingEngine = new MappingEngine(configurationStore); IStorage storage = new MemoryStorage(); ICustomerRepository customerRepository = new CustomerRepository(mappingEngine, storage); //Act IEnumerable<CustomerDomain> actualCustomers = customerRepository.GetAllCustomers(); //Assert Mapper.AssertConfigurationIsValid(); CollectionAssert.AreEqual(GetExpectedCustomers().ToList(), actualCustomers.ToList()); }
internal override void ConfigureMap(ConfigurationStore mapperConfig) { mapperConfig.CreateMap<CustomerModel, Customer>() .ReverseMap(); mapperConfig.CreateMap<Customer, CustomerModelResponse>() .ForMember(d => d.Surname, opt => opt.MapFrom(s => s.LastName)) .ReverseMap(); mapperConfig.CreateMap<CustomerAddressModel, CustomerAddress>() .ReverseMap(); mapperConfig.CreateMap<AddressModel, Address>() .ReverseMap(); }
public void Should_load_app_settings() { var configurationStore = new ConfigurationStore().Initialize(); var source = new ConfigurationManagerSource(configurationStore).Initialize(); source.LoadConfiguration(); var value1 = configurationStore.Get<string>("appSettings/key1"); var value2 = configurationStore.Get<string>("appSettings/key2"); var testInt = configurationStore.Get<int>("appSettings/testInt"); Assert.AreEqual("value1", value1); Assert.AreEqual("value2", value2); Assert.AreEqual(54, testInt); }
static MappingEngine CreateMapper() { var mappingConfig = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); mappingConfig.SetupConverters(); mappingConfig.CreateMap<Bundle, CustomCollection>() .ForMember(x => x.Name, opt => opt.MapFrom(src => src.GetFullName())) .ForMember(x => x.RequiredMods, opt => opt.MapFrom(src => src.GetRequiredClient())) .ForMember(x => x.OptionalMods, opt => opt.MapFrom(src => src.GetOptionalClient())); mappingConfig.CreateMap<CustomCollection, Bundle>() .ForMember(x => x.Name, opt => opt.ResolveUsing(src => PackageHelper.Packify(src.Name))) .ForMember(x => x.FullName, opt => opt.ResolveUsing(src => src.Name)) .ForMember(x => x.RequiredClients, opt => opt.ResolveUsing(src => src.RequiredMods)) .ForMember(x => x.OptionalClients, opt => opt.ResolveUsing(src => src.OptionalMods)); mappingConfig.Seal(); return new MappingEngine(mappingConfig); }
/// <summary> /// Initializes the mapping engine. /// </summary> /// <returns></returns> public static IMappingEngine Initialize() { // Initialize PlatformAdapter .Resolve<IPlatformSpecificMapperRegistry>() .Initialize(); var config = new ConfigurationStore( new TypeMapFactory(), MapperRegistry.Mappers); // Maps config.CreateMap<DatabaseRegistration, DatabaseItemViewModel>(); // Done return new MappingEngine(config); }
public JsonMapper() { var configurationStore = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); this.mapper = new MappingEngine(configurationStore); configurationStore.CreateMap<Feature, JsonFeature>() .ForMember(t => t.FeatureElements, opt => opt.ResolveUsing(s => s.FeatureElements)) .AfterMap( (sourceFeature, targetFeature) => { foreach (var featureElement in targetFeature.FeatureElements.ToArray()) { featureElement.Feature = targetFeature; } }); configurationStore.CreateMap<Example, JsonExample>(); configurationStore.CreateMap<Keyword, JsonKeyword>(); configurationStore.CreateMap<Scenario, JsonScenario>() .ForMember(t => t.Feature, opt => opt.Ignore()); configurationStore.CreateMap<ScenarioOutline, JsonScenarioOutline>() .ForMember(t => t.Feature, opt => opt.Ignore()); configurationStore.CreateMap<Step, JsonStep>(); configurationStore.CreateMap<Table, JsonTable>(); configurationStore.CreateMap<TestResult, JsonTestResult>().ConstructUsing(ToJsonTestResult); configurationStore.CreateMap<TableRow, JsonTableRow>() .ConstructUsing(row => new JsonTableRow(row.Cells.ToArray())); configurationStore.CreateMap<IFeatureElement, IJsonFeatureElement>().ConvertUsing( sd => { var scenario = sd as Scenario; if (scenario != null) { return this.mapper.Map<JsonScenario>(scenario); } var scenarioOutline = sd as ScenarioOutline; if (scenarioOutline != null) { return this.mapper.Map<JsonScenarioOutline>(scenarioOutline); } throw new ArgumentException("Only arguments of type Scenario and ScenarioOutline are supported."); }); }