private void NotifyAppStarted(AmbientServices ambientServices) { var elapsed = (TimeSpan)((dynamic)ambientServices).Elapsed; var appManifest = ambientServices.CompositionContainer.GetExport<IAppManifest>(); Console.WriteLine(); Console.WriteLine($"Application '{appManifest.AppId} V{appManifest.AppVersion}' started. Elapsed: {elapsed:c}."); }
public void CompositionContainer_works_fine_when_explicitely_set() { var ambientServices = new AmbientServices(); var mockContainer = Mock.Create<ICompositionContext>(); mockContainer.Arrange(c => c.TryGetExport<ICompositionContext>(null)).Returns((ICompositionContext)null); ambientServices.RegisterService(mockContainer); var noService = ambientServices.CompositionContainer.TryGetExport<ICompositionContext>(); Assert.IsNull(noService); }
public void CompositionContainer_cannot_set_null() { var ambientServices = new AmbientServices(); Assert.That(() => ambientServices.RegisterService<ICompositionContext>(null), Throws.InstanceOf<Exception>()); }
/// <summary> /// Initializes static members of the <see cref="AmbientServices"/> class. /// </summary> static AmbientServices() { Instance = new AmbientServices(); }
public void CompositionContainer_cannot_set_null() { var ambientServices = new AmbientServices(); ambientServices.CompositionContainer = null; }
/// <summary> /// Initializes a new instance of the <see cref="AmbientServicesBuilder"/> class. /// </summary> /// <param name="ambientServices">The ambient services.</param> public AmbientServicesBuilder(AmbientServices ambientServices) { Contract.Requires(ambientServices != null); this.AmbientServices = ambientServices; }