コード例 #1
0
ファイル: Shell.cs プロジェクト: raimu/kephas
 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}.");
 }
コード例 #2
0
ファイル: AmbientServicesTest.cs プロジェクト: raimu/kephas
 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);
 }
コード例 #3
0
ファイル: AmbientServicesTest.cs プロジェクト: raimu/kephas
 public void CompositionContainer_cannot_set_null()
 {
     var ambientServices = new AmbientServices();
     Assert.That(() => ambientServices.RegisterService<ICompositionContext>(null), Throws.InstanceOf<Exception>());
 }
コード例 #4
0
ファイル: AmbientServices.cs プロジェクト: raimu/kephas
 /// <summary>
 /// Initializes static members of the <see cref="AmbientServices"/> class.
 /// </summary>
 static AmbientServices()
 {
     Instance = new AmbientServices();
 }
コード例 #5
0
 public void CompositionContainer_cannot_set_null()
 {
     var ambientServices = new AmbientServices();
     ambientServices.CompositionContainer = null;
 }
コード例 #6
0
        /// <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;
        }