static void Main(string[] args) { //setup the servicelocator ServiceLocator locator = ServiceLocator.Instance; locator.AddService(typeof(IFileSystem), new FileSystemWrapper()); locator.AddService(typeof(ProcessSettings), SettingsFactory.CreateProcessSettings()); locator.AddService(typeof(IBuildServiceFacade), new ClientFacade()); locator.AddService(typeof(ILogger), new ConsoleLogger()); bool everythingOk = true; try { locator.GetService <ProcessSettings>().Validate(); } catch (Exception ex) { locator.GetService <ILogger>().Log(ex.Message); everythingOk = false; } if (everythingOk) { _watcher = new SubmitWatcher(); Console.WriteLine("Start watching for submits to process.. Press enter to quit."); _watcher.StartWatching(); } Console.ReadLine(); }
private static ServiceLocator Config() { var sl = new ServiceLocator(); sl.AddService <IOrderService, OrderService>(); sl.AddService <ICustomerService, CustomerService>(); return(sl); }
public void GetService_ReplaceService_ReturnService() { ServiceLocator locator = ServiceLocator.Instance; locator.AddService(typeof(IFileSystem), new FileSystemWrapper()); locator.AddService(typeof(IFileSystem), new FileSystemWrapper()); IFileSystem fs = locator.GetService <IFileSystem>(); Assert.IsNotNull(fs); }
private void Awake() { ServiceLocator.AddService(this); #if UNITY_EDITOR AwakeEditor(); #endif }
public void DeveloperModeIsFalseByDefault() { ServiceLocator.AddService <BaseStorageService>(new StorageService()); var channel = new PersistenceChannel(); Assert.IsFalse(channel.DeveloperMode.Value); }
public void DeveloperModeCanBeModifiedByConfiguration() { ServiceLocator.AddService <BaseStorageService>(new StorageService()); var channel = new PersistenceChannel(); channel.DeveloperMode = true; Assert.IsTrue(channel.DeveloperMode.Value); }
public void WhenSetToTrueChangesTelemetryBufferCapacityToOneForImmediateTransmission() { ServiceLocator.AddService <BaseStorageService>(new StorageService()); var channel = new PersistenceChannel(); channel.DeveloperMode = true; Assert.AreEqual(1, channel.TelemetryBuffer.Capacity); }
public void GetterReturnsTelemetryBufferCapacity() { ServiceLocator.AddService <BaseStorageService>(new StorageService()); var channel = new PersistenceChannel(); channel.TelemetryBuffer.Capacity = 42; Assert.AreEqual(42, channel.MaxTelemetryBufferCapacity); }
public override void Awake() { base.Awake(); LocaleData.Initialize(_LocaleTextAsset); // Add to the service locator ServiceLocator.AddService(typeof(IShooter), this); }
protected override void OnNavigatedTo(NavigationEventArgs e) { MainPageVM mainPageVM = (MainPageVM)this.DataContext; mainPageVM.NavigationService = this.NavigationService; ServiceLocator.AddService <NavigationService>(this.NavigationService); mainPageVM.OnPropertyChanged("LoginStatus"); base.OnNavigatedTo(e); }
public async Task InitializeSetsSdkVersionPropertyOfGivenTelemetry() { ServiceLocator.AddService <IPlatformService>(new PlatformService()); var initializer = new SdkVersionPropertyContextInitializer(); var telemetryContext = new TelemetryContext(); await initializer.Initialize(telemetryContext); Assert.NotNull(telemetryContext.Internal.SdkVersion); }
public void ConstructorAddsExceptionToExceptionPropertyAndExceptionsCollectionProperty() { ServiceLocator.AddService <IPlatformService>(new PlatformService()); Exception constructorException = new Exception("ConstructorException"); var testExceptionTelemetry = new ExceptionTelemetry(constructorException); Assert.Same(constructorException, testExceptionTelemetry.Exception); Assert.Equal(constructorException.Message, testExceptionTelemetry.Exceptions.First().message); }
public void SerializeWritesSingleInnerExceptionOfAggregateExceptionOnlyOnce() { ServiceLocator.AddService <IPlatformService>(new PlatformService()); var exception = new AggregateException("Test Exception", new Exception()); ExceptionTelemetry expected = CreateExceptionTelemetry(exception); var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <ExceptionTelemetry, DataPlatformModel.ExceptionData>(expected); Assert.Equal(2, item.Data.BaseData.Exceptions.Count); }
public void TestInitialize() { ServiceLocator.AddService <IPlatformService>(new PlatformService()); ServiceLocator.AddService <IApplicationService>(new ApplicationService()); this.applicationSettings = new Dictionary <string, object>(); this.platform = new StubPlatform { OnGetApplicationSettings = () => this.applicationSettings, }; PlatformSingleton.Current = this.platform; }
public void Register_Single_Transient_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService <GuidTest>(ServiceType.Transient); var guid1 = serviceLocator.GetService <GuidTest>().Guid; var guid2 = serviceLocator.GetService <GuidTest>().Guid; guid1.ShouldNotBe(guid2); }
public void Register_Keyed_With_Interface_Transient_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService <IGuidTest, GuidTest>("key", ServiceType.Transient); var guid1 = serviceLocator.GetService <IGuidTest>("key").Guid; var guid2 = serviceLocator.GetService <IGuidTest>("key").Guid; guid1.ShouldNotBe(guid2); }
public void EndpointAddressCanBeModifiedByConfiguration() { ServiceLocator.AddService <BaseStorageService>(new StorageService()); var channel = new PersistenceChannel(); Uri expectedEndpoint = new Uri("http://abc.com"); channel.EndpointAddress = expectedEndpoint.AbsoluteUri; Assert.AreEqual(expectedEndpoint, new Uri(channel.EndpointAddress)); }
public void WhenSetToFalseChangesTelemetryBufferCapacityToOriginalValueForBufferedTransmission() { ServiceLocator.AddService <BaseStorageService>(new StorageService()); var channel = new PersistenceChannel(); int originalTelemetryBufferSize = channel.TelemetryBuffer.Capacity; channel.DeveloperMode = true; channel.DeveloperMode = false; Assert.AreEqual(originalTelemetryBufferSize, channel.TelemetryBuffer.Capacity); }
public void Register_Keyed_Factory_Transient_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService("key", ServiceType.Transient, (__) => new GuidTest()); var guid1 = serviceLocator.GetService <GuidTest>("key").Guid; var guid2 = serviceLocator.GetService <GuidTest>("key").Guid; guid1.ShouldNotBe(guid2); }
public void Register_Keyed_With_Interface_Factory_Singleton_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService <IGuidTest>("key", ServiceType.Singleton, (__) => new GuidTest()); var guid1 = serviceLocator.GetService <IGuidTest>("key").Guid; var guid2 = serviceLocator.GetService <IGuidTest>("key").Guid; guid1.ShouldBe(guid2); }
public void Register_Keyed_Single_Singleton_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService <GuidTest>("key", ServiceType.Singleton); var guid1 = serviceLocator.GetService <GuidTest>("key").Guid; var guid2 = serviceLocator.GetService <GuidTest>("key").Guid; guid1.ShouldBe(guid2); }
public void Register_With_Interface_Singleton_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService <IGuidTest, GuidTest>(ServiceType.Singleton); var guid1 = serviceLocator.GetService <IGuidTest>().Guid; var guid2 = serviceLocator.GetService <IGuidTest>().Guid; guid1.ShouldBe(guid2); }
public void Register_With_Interface_Factory_Transient_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService <IGuidTest>(ServiceType.Transient, (__) => new GuidTest()); var guid1 = serviceLocator.GetService <IGuidTest>().Guid; var guid2 = serviceLocator.GetService <IGuidTest>().Guid; guid1.ShouldNotBe(guid2); }
public void Register_Factory_Singleton_Service() { var serviceLocator = new ServiceLocator(); serviceLocator.AddService(ServiceType.Singleton, (__) => new GuidTest()); var guid1 = serviceLocator.GetService <GuidTest>().Guid; var guid2 = serviceLocator.GetService <GuidTest>().Guid; guid1.ShouldBe(guid2); }
public void AddsItselfToTelemetryInitializersToSetSessionIdForAllTelemetryTypes() { ServiceLocator.AddService <IApplicationService>(new ApplicationService()); var module = new SessionTelemetryModule(new StubPlatform(), new StubClock()); var configuration = new TelemetryConfiguration(); configuration.TelemetryChannel = new InMemoryChannel(); module.Initialize(); Assert.Contains(module, TelemetryConfiguration.Active.TelemetryInitializers); }
public void WindowsBootStrapperSettingTheInstrumentationKeyWhenSupplied() { ServiceLocator.AddService <BaseStorageService>(new TestStorageService()); string instrumentationKey = Guid.NewGuid().ToString(); WindowsAppInitializer.InitializeAsync(instrumentationKey, new TelemetryConfiguration() { Collectors = WindowsCollectors.Metadata }).GetAwaiter().GetResult(); Assert.IsFalse(string.IsNullOrEmpty(TelemetryConfiguration.Active.InstrumentationKey)); }
public void ExceptionPropertySetterReplacesExceptionDetailsInExceptionsCollectionProperty() { ServiceLocator.AddService <IPlatformService>(new PlatformService()); Exception constructorException = new Exception("ConstructorException"); var testExceptionTelemetry = new ExceptionTelemetry(constructorException); Exception nextException = new Exception("NextException"); testExceptionTelemetry.Exception = nextException; Assert.Same(nextException, testExceptionTelemetry.Exception); Assert.Equal(nextException.Message, testExceptionTelemetry.Exceptions.First().message); }
public void PassesTelemetryToMemoryBufferChannel() { ServiceLocator.AddService <BaseStorageService>(new StorageService()); var channel = new PersistenceChannel(); var telemetry = new StubTelemetry(); channel.Send(telemetry); IEnumerable <ITelemetry> actual = channel.TelemetryBuffer.Dequeue(); Assert.AreEqual(telemetry, actual.First()); }
private void Awake() { OnBeginConnectingSignal = new Signal(); OnConnectedToMasterSignal = new Signal(); OnDisconnectedFromMasterSignal = new Signal(); OnConnectionFailSignal = new Signal <string>(); OnJoinedRoomSignal = new Signal(); OnAllPlayersConnectedSignal = new Signal(); OnRemoteBoardChangeSignal = new Signal <Seed, int, int>(); OnNewGameStartedSignal = new Signal(); ServiceLocator.AddService <INetworkService>(this); }
public async Task InitializeSetsSdkVersionValueAsAssemblyVersion() { ServiceLocator.AddService <IPlatformService>(new PlatformService()); var initializer = new SdkVersionPropertyContextInitializer(); var telemetryContext = new TelemetryContext(); await initializer.Initialize(telemetryContext); string expectedSdkVersion; expectedSdkVersion = typeof(SdkVersionPropertyContextInitializer).GetTypeInfo().Assembly.GetCustomAttributes <AssemblyFileVersionAttribute>() .First() .Version; Assert.Equal("hockeysdk.uwp:" + expectedSdkVersion, telemetryContext.Internal.SdkVersion); }