Ejemplo n.º 1
0
        public void TestTrackingScoped()
        {
            // create root container
            var container = new RootContainer();

            // register the dummy test service as scoped
            container.Register <DummyDisposeTracker, DummyDisposeTracker>().AsScoped();

            // resolve tests services (they are different instances due they are resolved from
            // different scope keys)
            var dummyService1 = container.Resolve <DummyDisposeTracker>(scopeKey: null);
            var dummyService2 = container.Resolve <DummyDisposeTracker>(scopeKey: new object());

            // dispose container after usage
            using (container)
            {
                // ensure the services are different creations
                Assert.False(ReferenceEquals(dummyService1, dummyService2),
                             "Expected that resolving using different scopes does not returns the same service.");

                // service null checks
                Assert.NotNull(dummyService1);
                Assert.NotNull(dummyService2);

                // ensure the services are not disposed if the container is not
                Assert.False(dummyService1.IsDisposed, "Expected that a scoped service is not disposed when the container is not disposed.");
                Assert.False(dummyService2.IsDisposed, "Expected that a scoped service is not disposed when the container is not disposed.");
            }

            // ensure the services are disposed by the container
            Assert.True(dummyService1.IsDisposed, "Expected that scoped service is disposed when disposing container (global scope).");
            Assert.True(dummyService2.IsDisposed, "Expected that scoped service is disposed when disposing container (non-global scope).");
        }
Ejemplo n.º 2
0
 private void OnBackRequested(object sender, BackRequestedEventArgs e)
 {
     if (!Dock.OnBackPress() && RootContainer.CanGoBack)
     {
         RootContainer.GoBack();
     }
 }
Ejemplo n.º 3
0
        private void Init()
        {
            Singleton <BroadcastCenter> .Instance.Subscribe("login_completed",
                                                            (sender, args) =>
            {
                RootContainer.Navigate <TimelineActivity>();
                NotificationViewModel.Instance.Init();
            });

            Singleton <BroadcastCenter> .Instance.Subscribe("status_clicked",
                                                            (sender, args) => RootContainer.Navigate <StatusActivity>(args));

            Singleton <BroadcastCenter> .Instance.Subscribe("user_clicked",
                                                            (sender, args) => { RootContainer.Navigate(typeof(UserActivity), args); });

            Singleton <BroadcastCenter> .Instance.Subscribe("status_like", (sender, args) => { });

            Singleton <BroadcastCenter> .Instance.Subscribe("image_clicked",
                                                            (sender, args) => RootContainer.Navigate <ImageActivity>(args));

            Singleton <BroadcastCenter> .Instance.Subscribe("video_clicked",
                                                            (sender, args) => RootContainer.Navigate <VideoActivity>(args));

            RegisterNotification("notification_new_fans", "FollowerCount");
            RegisterNotification("notification_new_mention_at", "MentionStatusCount");
            RegisterNotification("notification_new_mention_comment", "MentionCmtCount");
            RegisterNotification("notification_new_comment", "CmtCount");
            RegisterNotification("notification_new_dm", "DmCount");

            RootContainer.BackStackChanged += RootContainerOnBackStackChanged;
            RootContainer.Navigate(typeof(LoginActivity));
        }
Ejemplo n.º 4
0
        protected override void BindModelBasic()
        {
            ViewModel.AnimeItemDisplayContext = ViewModelLocator.AnimeList.AnimeItemsDisplayContext;

            (RootContainer.GetChildAt(0) as ViewGroup).GetChildAt(0).SetBackgroundResource(_position % 2 == 0
                ? ResourceExtension.BrushRowAlternate1Res
                : ResourceExtension.BrushRowAlternate2LighterRes);

            AnimeCompactItemType.Text  = ViewModel.PureType;
            AnimeCompactItemTitle.Text = ViewModel.Title;

            AnimeCompactItemFavouriteIndicator.Visibility =
                ViewModel.IsFavouriteVisibility ? ViewStates.Visible : ViewStates.Gone;

            AnimeCompactItemTagsButton.Visibility = ViewModel.TagsControlVisibility
                ? ViewStates.Visible
                : ViewStates.Gone;

            AnimeCompactItemGlobalScore.Text = ViewModel.GlobalScoreBind;

            if (string.IsNullOrEmpty(ViewModel.TopLeftInfoBind))
            {
                AnimeCompactItemTopLeftInfo.Visibility = ViewStates.Gone;
            }
            else
            {
                AnimeCompactItemTopLeftInfo.Visibility = ViewStates.Visible;
                AnimeCompactItemTopLeftInfo.Text       = ViewModel.TopLeftInfoBind;
            }


            AnimeCompactItemScoreLabel.Text    = ViewModel.MyScoreBind;
            AnimeCompactItemStatusLabel.Text   = ViewModel.MyStatusBind;
            AnimeCompactItemWatchedButton.Text = ViewModel.MyEpisodesBind;
        }
Ejemplo n.º 5
0
        private void Init()
        {
            MessageCenterDock.RegisterPropertyChangedCallback(VisibilityProperty,
                                                              (sender, e) => { UpdateNavigationBackButton(); });
            Singleton <MessagingCenter> .Instance.Subscribe("login_completed",
                                                            (sender, args) => RootContainer.Navigate <TimelineActivity>());

            Singleton <MessagingCenter> .Instance.Subscribe("status_clicked",
                                                            (sender, args) => RootContainer.Navigate <StatusActivity>(args));

            Singleton <MessagingCenter> .Instance.Subscribe("user_clicked",
                                                            (sender, args) => { RootContainer.Navigate(typeof(UserActivity), args); });

            Singleton <MessagingCenter> .Instance.Subscribe("status_like", (sender, args) => { });

            Singleton <MessagingCenter> .Instance.Subscribe("image_clicked",
                                                            (sender, args) => RootContainer.Navigate <ImageActivity>(args));

            Singleton <MessagingCenter> .Instance.Subscribe("video_clicked",
                                                            (sender, args) => RootContainer.Navigate <VideoActivity>(args));

            Singleton <MessagingCenter> .Instance.Subscribe("request_dock_visible", (sender, args) =>
            {
                if (args is bool boolArgs)
                {
                    Singleton <MessagingCenter> .Instance.Send(this, "dock_visible", boolArgs && MessageCenterDock.Visibility == Visibility.Collapsed && RootContainer.CurrentActivity is TimelineActivity);
                }
            });

            RootContainer.BackStackChanged += RootContainerOnBackStackChanged;
            RootContainer.Navigate(typeof(LoginActivity));
        }
Ejemplo n.º 6
0
        public void TestTrackingTransient()
        {
            // create root container
            var container = new RootContainer();

            // register the dummy test service as transient
            container.Register <DummyDisposeTracker, DummyDisposeTracker>().AsTransient();

            // track disposable transients
            container.TrackDisposableTransients = true;

            // resolve tests services
            var service = container.Resolve <DummyDisposeTracker>();

            // dispose container after usage
            using (container)
            {
                // service null checks
                Assert.NotNull(service);

                // ensure the services are not disposed if the container is not
                Assert.False(service.IsDisposed, "Expected that a transient service is not disposed when the container is not disposed.");
            }

            // ensure the services are disposed by the container
            Assert.True(service.IsDisposed, "Expected that transient service is disposed when disposing container.");
        }
Ejemplo n.º 7
0
        private ILifetimeScope LoadModules()
        {
            var loader = RootContainer.Resolve <IPackageLockLoader>();

            var modulesConfig = RootContainer.Resolve <IOptions <ModulesOptions> >().Value;
            var lockFile      = new FileInfo(Environment.ExpandEnvironmentVariables(modulesConfig.ModulesLockPath));

            if (lockFile.Exists)
            {
                PackagesLock packagesLock;
                try
                {
                    packagesLock = JsonConvert.DeserializeObject <PackagesLock>(File.ReadAllText(lockFile.FullName));
                }
                catch (Exception)
                {
                    return(RootContainer);
                }

                var loadContext = loader.Load(packagesLock).Result;
                if (loadContext.PackagesLoaded)
                {
                    return(RootContainer.BeginLifetimeScope(builder => loadContext.Configure(builder)));
                }
            }

            return(RootContainer);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public VirtualCanvasControl()
        {
            this.rootContainer = new RootContainer(this);
            InitializeComponent();
            this.AllowDrop = true;
            this.SetStyle(ControlStyles.Selectable, true);

            // Connect to root container
            rootContainer.ContainerEvent += OnRootContainerEvent;

            // Forward panel events
            panel.KeyDown           += (sender, e) => OnKeyDown(e);
            panel.KeyUp             += (sender, e) => OnKeyUp(e);
            panel.MouseClick        += (sender, e) => OnMouseClick(e);
            panel.MouseDoubleClick  += (sender, e) => OnMouseDoubleClick(e);
            panel.MouseDown         += (sender, e) => OnMouseDown(e);
            panel.MouseMove         += (sender, e) => OnMouseMove(e);
            panel.MouseUp           += (sender, e) => OnMouseUp(e);
            panel.MouseEnter        += (sender, e) => OnMouseEnter(e);
            panel.MouseLeave        += (sender, e) => OnMouseLeave(e);
            panel.MouseWheel        += (sender, e) => OnMouseWheel(e);
            panel.Click             += (sender, e) => OnClick(e);
            panel.DoubleClick       += (sender, e) => OnDoubleClick(e);
            panel.DragDrop          += (sender, e) => OnDragDrop(e);
            panel.DragEnter         += (sender, e) => OnDragEnter(e);
            panel.DragLeave         += (sender, e) => OnDragLeave(e);
            panel.DragOver          += (sender, e) => OnDragOver(e);
            panel.GiveFeedback      += (sender, e) => OnGiveFeedback(e);
            panel.QueryContinueDrag += (sender, e) => OnQueryContinueDrag(e);

            // Connect to scrollbar events
            hScrollBar.Scroll += (sender, e) => Invalidate();
            vScrollBar.Scroll += (sender, e) => Invalidate();
        }
Ejemplo n.º 9
0
        private void serializeBurstBinary_Click(object sender, EventArgs e)
        {
            // create fake obj
            var obj = RootContainer.CreateFakeRoot();

            // create instance of sharpSerializer
            var settings   = new SharpSerializerBinarySettings(BinarySerializationMode.Burst);
            var serializer = new SharpSerializer(settings);


            // *************************************************************************************
            // For advanced serialization you create SharpSerializer with an overloaded constructor
            //
            //  SharpSerializerBinarySettings settings = createBinarySettings();
            //  serializer = new SharpSerializer(settings);
            //
            // Scroll the page to the createBinarySettings() method for more details
            // *************************************************************************************


            // set the filename
            var filename = "sharpSerializerExample.burst";

            // serialize
            serialize(obj, serializer, filename);
        }
Ejemplo n.º 10
0
        public void MapElements(string code)
        {
            var finder = GetRootElementFinder(code);

            _rootNode = new RootContainer(finder.GetLineNumber());
            _rootNode.SetClasses(GetClassDeclarations(finder));
        }
Ejemplo n.º 11
0
        public void serializeSizeOptimizedBinary_Click(object sender, EventArgs e)
        {
            // create fake obj
            var obj = RootContainer.CreateFakeRoot();

            // create instance of sharpSerializer
            var serializer = new SharpSerializer(true);


            // *************************************************************************************
            // For advanced serialization you create SharpSerializer with an overloaded constructor
            //
            //  SharpSerializerBinarySettings settings = createBinarySettings();
            //  serializer = new SharpSerializer(settings);
            //
            // Scroll the page to the createBinarySettings() method for more details
            // *************************************************************************************


            // set the filename
            var filename = "sharpSerializerExample.sizeOptimized";

            // serialize
            SerializationMessage = serialize(obj, serializer, filename);

            //IKI: iOS UIAlertView
            ShowMessageAlert(this, null);

            return;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Override this to add custom behavior to execute after the application starts.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The args.</param>
        protected override async void OnStartup(object sender, StartupEventArgs e)
        {
            DisplayRootViewFor <TrayIconViewModel>();
            _eventManager = RootContainer.GetInstance <TfsEventManager>();
            await _eventManager.Connect();

            await _eventManager.StartMonitoring();
        }
Ejemplo n.º 13
0
        public void TestChildContainerParentResolve()
        {
            // register service in parent container
            RootContainer.Register <IDummyService, DummyService>();

            // try resolving the service in the parent container from the child container
            Assert.NotNull(ChildContainer.Resolve <IDummyService>());
        }
Ejemplo n.º 14
0
        public KeyboardInput(RootContainer root)
        {
            if (root == null)
            {
                throw new ArgumentException("RootContainer cannot be null", "root");
            }

            Container = root;
        }
Ejemplo n.º 15
0
        public CompositionFixture(Action <CompositionBatch> explicitExports)
        {
            _rootCatalog = new DirectoryCatalog(".", new RegistrationBuilder());
            Scoping      = new CompositionScopingService(_rootCatalog, explicitExports ?? (_ => {}), new[] { TransactionScope.Id });
            RootContainer.ComposeExportedValue <ICompositionScopingService>(Scoping);

            BasicConfigurator.Configure(new Appender());
            RootContainer.ComposeExportedValue <ILog>(LogManager.GetLogger("TESTLOG"));
        }
Ejemplo n.º 16
0
        public override void UpdateDraw()
        {
            CheckEvent();

            RootContainer.UpdateDraw();

            HandleEvent();
            EventQueue.Clear();
            repaintFlag = false;
        }
Ejemplo n.º 17
0
		private async void SwipeToShowList(object sender, SwipedEventArgs e)
		{
			uint duration = 700;

			await Task.WhenAll(
				CartPreviewContainer.FadeTo(1, 500),
				RootContainer.TranslateTo(0, 0, duration, Easing.CubicOut),
				CartContainer.TranslateTo(0, 0, duration, Easing.CubicOut)
			);
		}
Ejemplo n.º 18
0
        public void TestInit()
        {
            _template = new PythonCodeTemplate();
            var code       = _template.TransformText();
            var rootMapper = new RootMapper(new ParserBuilder());

            rootMapper.MapElements(code);
            _mappedRoot = rootMapper.GetMappedItem();
            _mainClass  = (ClassDeclaration)_mappedRoot.ClassDeclarations.FirstOrDefault();
        }
Ejemplo n.º 19
0
        private static void RegisterEvents(ContainerBuilder builder)
        {
            // Event Service registration.
            builder.RegisterKafkaEventBusComponents(
                ServiceName,
                (metadata, bldr) =>
            {
                bldr.RegisterType <EventServicePublishExtender>()
                .WithParameter(new ResolvedParameter(
                                   (p, c) => p.ParameterType == typeof(IEventService),
                                   (p, c) => RootContainer.Resolve <IEventService>()))
                .As <IEventService>()
                .InstancePerLifetimeScope();

                bldr.Register(c => metadata.ToRequestHeaders())
                .InstancePerRequest();
            });

            builder
            .RegisterType <EventSubscriber>()
            .AsSelf()
            .AutoActivate();

            builder
            .RegisterType <EventHandlerLocator>()
            .As <IEventHandlerLocator>()
            .SingleInstance()
            .AutoActivate();

            // Use reflection to register all the IEventHandlers in the Synthesis.GuestService.EventHandlers namespace
            var assembly = Assembly.GetAssembly(typeof(GuestSessionModule));
            var types    = assembly.GetTypes().Where(x => string.Equals(x.Namespace, "Synthesis.GuestService.EventHandlers", StringComparison.Ordinal)).ToArray();

            foreach (var type in types)
            {
                if (!type.IsAbstract && typeof(IEventHandlerBase).IsAssignableFrom(type))
                {
                    builder.RegisterType(type).AsSelf().As <IEventHandlerBase>();
                }
            }

            // register event service for events to be handled for every instance of this service
            builder.RegisterType <SettingsInvalidateCacheEventHandler>().AsSelf();

            builder.RegisterType <EventHandlerLocator>()
            .WithParameter(new ResolvedParameter(
                               (p, c) => p.ParameterType == typeof(IEventServiceConsumer),
                               (p, c) => c.ResolveKeyed <IEventServiceConsumer>(Registration.PerInstanceEventServiceKey)))
            .OnActivated(args => args.Instance.SubscribeEventHandler <SettingsInvalidateCacheEventHandler>("*", EventNames.SettingsInvalidateCache))
            .Keyed <IEventHandlerLocator>(Registration.PerInstanceEventServiceKey)
            .SingleInstance()
            .AutoActivate();
        }
Ejemplo n.º 20
0
        static void BuildWorkHorseConfiguration()
        {
            WorkHorseContainer = RootContainer.CreateChildContainer();

            WorkHorseContainer.RegisterType <EditRepositoriesViewModel>(new PerResolveLifetimeManager());
            WorkHorseContainer.RegisterType <EditBranchViewModel>(new PerResolveLifetimeManager());
            WorkHorseContainer.RegisterType <EditBranchDescriptionViewModel>(new PerResolveLifetimeManager());
            WorkHorseContainer.RegisterType <EditMergeRequestViewModel>(new PerResolveLifetimeManager());
            WorkHorseContainer.RegisterType <EditBranchChangesViewModel>(new PerResolveLifetimeManager());
            WorkHorseContainer.RegisterType <EditMergeRequestTestsViewModel>(new PerResolveLifetimeManager());
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(WorkHorseContainer));
        }
Ejemplo n.º 21
0
 /// <summary>Registers the type mappings with the Unity container.</summary>
 /// <typeparam name="Content">Type from as Content</typeparam>
 public static void RegisterTypeContent <Content>(Func <object> ContentCreator)
 {
     if (BIAUnityContentCreator.ContentsCreator.ContainsKey(typeof(Content)))
     {
         BIAUnityContentCreator.ContentsCreator[typeof(Content)] = ContentCreator;
     }
     else
     {
         BIAUnityContentCreator.ContentsCreator.Add(typeof(Content), ContentCreator);
     }
     RootContainer.RegisterType <BIAUnityContainer <Content> >((LifetimeManager)Activator.CreateInstance(LifetimeManagerType));
 }
Ejemplo n.º 22
0
        public void UpdateScroll()
        {
            HandleScrollInput();
            var scrollVelocitySign = Mathf.Sign(scrollVelocity);

            scrollVelocity = scrollVelocitySign * Mathf.Max(0, Mathf.Abs(scrollVelocity) - scrollFrameDecay);
            scrollY       += scrollVelocity;
            TrimScroll();
            TrimScrollVelocity();
            var rootRT = RootContainer.GetComponent <RectTransform>();

            rootRT.anchoredPosition = new Vector2(0, scrollY);
        }
Ejemplo n.º 23
0
        public void TestChildContainerParentResolveWithOverrideFromParent()
        {
            // allow service overriding from the child container
            ChildContainer.ContainerResolveMode = ContainerResolveMode.ParentFirst;

            // register service in parent container
            RootContainer.Register <IDummyService, DummyService>();

            // register service in child container
            ChildContainer.Register <IDummyService, OtherDummyService>();

            // try resolving the service in the parent container from the child container
            Assert.IsType <DummyService>(ChildContainer.Resolve <IDummyService>());
        }
Ejemplo n.º 24
0
        public void TestTransientRegistration()
        {
            // create root container for test
            using (var container = new RootContainer())
            {
                // register the test service as transient
                container.Register <IDummyService, DummyService>().AsTransient();

                // create two different transient services
                var dummyService1 = container.Resolve <IDummyService>();
                var dummyService2 = container.Resolve <IDummyService>();

                // ensure the services are different creations
                Assert.False(ReferenceEquals(dummyService1, dummyService2),
                             "Expected that transient services do not have the same reference.");
            }
        }
Ejemplo n.º 25
0
        public void TestSingletonRegistration()
        {
            // create root container for test
            using (var container = new RootContainer())
            {
                // register the test service as Singleton
                container.Register <IDummyService, DummyService>().AsSingleton();

                // create two Singleton services (should be the same)
                var dummyService1 = container.Resolve <IDummyService>();
                var dummyService2 = container.Resolve <IDummyService>();

                // ensure the services are the same creations
                Assert.True(ReferenceEquals(dummyService1, dummyService2),
                            "Expected that Singleton services have the same reference.");
            }
        }
Ejemplo n.º 26
0
        protected override void RootContainerInit()
        {
            AnimeListItemAddToListButton.SetOnClickListener(new OnClickListener(view => ViewModel.AddAnimeCommand.Execute(null)));
            AnimeListItemTagsButton.SetOnClickListener(new OnClickListener(OnTagsButtonClick));
            AnimeListItemStatusButton.SetOnClickListener(
                new OnClickListener(view => ShowStatusDialog()));
            AnimeListItemScoreButton.SetOnClickListener(
                new OnClickListener(view => ShowRatingDialog()));

            AnimeListItemIncButton.SetOnClickListener(
                new OnClickListener(view => ViewModel.IncrementWatchedCommand.Execute(null)));
            AnimeListItemDecButton.SetOnClickListener(
                new OnClickListener(view => ViewModel.DecrementWatchedCommand.Execute(null)));

            RootContainer.SetOnLongClickListener(new OnLongClickListener(view => MoreButtonOnClick()));
            RootContainer.SetOnClickListener(new OnClickListener(view => ContainerOnClick()));
            base.RootContainerInit();
        }
Ejemplo n.º 27
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            ApplicationContext.Initialize();
            this.RootVisual = new UserControlContainer();
            if (Application.Current.IsRunningOutOfBrowser)
            {
                Application.Current.CheckAndDownloadUpdateCompleted += (obj, args) =>
                {
                    if (args.UpdateAvailable)
                    {
                        UpdateAvailableWindow.Show(() => Application.Current.MainWindow.Close());
                    }
                    else
                    {
                        var settingsUriString = "Settings.xml";
                        Uri source            = Application.Current.Host.Source;

                        string location;
                        if (Debugger.IsAttached)
                        {
                            location = "http://www.indoorworx.com/IndoorWorx/";// "http://localhost:3415/";
                        }
                        else
                        {
                            location = source.AbsoluteUri.Substring(0, source.AbsoluteUri.IndexOf("ClientBin", StringComparison.OrdinalIgnoreCase));
                        }

                        settingsUriString = String.Concat(location, settingsUriString);

                        Uri settingsUri = new Uri(settingsUriString, UriKind.Absolute);

                        SettingsClient settingsService = new SettingsClient(settingsUri);
                        settingsService.GetSettingsCompleted += this.SettingsService_GetSettingsCompleted;
                        settingsService.GetSettingsAsync();
                    }
                };
                Application.Current.CheckAndDownloadUpdateAsync();
            }
            else
            {
                RootContainer.SwitchControl(new ApplicationInstallerView());
            }
        }
Ejemplo n.º 28
0
        public void TestInconsistenceAfterConstruction()
        {
            var registration1     = new DirectRegistration <DummyService>().AsSingleton();
            var registration2     = new DirectRegistration <DummyService>().AsSingleton();
            var registrations     = new IServiceRegistration[] { registration1, registration2 };
            var multiRegistration = new MultiRegistration(registrations);

            // change the lifetime of a service
            registration1.AsScoped();

            using (var container = new RootContainer())
            {
                container.Register <IDummyService>(multiRegistration);
                var enumerable = container.ResolveAll <IDummyService>();

                // create services
                Assert.Throws <InvalidOperationException>(enumerable.ToArray);
            }
        }
Ejemplo n.º 29
0
        public void serializeXmlButton_Click(object sender, EventArgs e)
        {
            // create fake obj
            var obj = RootContainer.CreateFakeRoot();

            // create instance of sharpSerializer
            // with the standard constructor it serializes to xml
            var serializer = new SharpSerializer();


            // *************************************************************************************
            // For advanced serialization you create SharpSerializer with an overloaded constructor
            //
            //  SharpSerializerXmlSettings settings = createXmlSettings();
            //  serializer = new SharpSerializer(settings);
            //
            // Scroll the page to the createXmlSettings() method for more details
            // *************************************************************************************


            // *************************************************************************************
            // You can alter the SharpSerializer with its settings, you can provide your custom readers
            // and writers as well, to serialize data into Json or other formats.
            //
            // var serializer = createSerializerWithCustomReaderAndWriter();
            //
            // Scroll the page to the createSerializerWithCustomReaderAndWriter() method for more details
            // *************************************************************************************


            // set the filename
            var filename = "sharpSerializerExample.xml";

            // serialize
            SerializationMessage = serialize(obj, serializer, filename);

            //IKI: iOS UIAlertView
            ShowMessageAlert(this, null);


            return;
        }
Ejemplo n.º 30
0
        public void TestScopedRegistration()
        {
            // create root container
            using (var container = new RootContainer())
            {
                // create dummy scope keys
                var globalScope = default(object);
                var myScope     = new object();

                // register the test service as scoped
                container.Register <IDummyService, DummyService>().AsScoped();

                var dummyService1 = container.Resolve <IDummyService>(globalScope);
                var dummyService2 = container.Resolve <IDummyService>(globalScope);
                var dummyService3 = container.Resolve <IDummyService>(myScope);
                var dummyService4 = container.Resolve <IDummyService>(myScope);

                // ensure the created services are not null
                Assert.NotNull(dummyService1);
                Assert.NotNull(dummyService2);
                Assert.NotNull(dummyService3);
                Assert.NotNull(dummyService4);

                Assert.True(ReferenceEquals(dummyService1, dummyService2),
                            "Expected that resolving using the same scope returns the same service. (global scope)");

                Assert.True(ReferenceEquals(dummyService3, dummyService4),
                            "Expected that resolving using the same scope returns the same service. (non-global scope)");

                Assert.False(ReferenceEquals(dummyService1, dummyService3),
                             "Expected that resolving using different scopes does not returns the same service.");

                Assert.False(ReferenceEquals(dummyService2, dummyService4),
                             "Expected that resolving using different scopes does not returns the same service.");

                Assert.False(ReferenceEquals(dummyService1, dummyService4),
                             "Expected that resolving using different scopes does not returns the same service.");

                Assert.False(ReferenceEquals(dummyService2, dummyService3),
                             "Expected that resolving using different scopes does not returns the same service.");
            }
        }
 /// --------------------------------------------------------------------------------
 /// <summary>
 /// Initializes with it the associated root container and database.
 /// </summary>
 ///
 /// <param name="rootContainer">
 /// The root object that this collection is associated with.
 /// </param>
 /// --------------------------------------------------------------------------------
 protected DatabaseObjectsUsingAttributes(RootContainer rootContainer)
     : base(rootContainer)
 {
 }
 /// --------------------------------------------------------------------------------
 /// <summary>
 /// Initializes with it the associated root container and database.
 /// </summary>
 ///
 /// <param name="rootContainer">
 /// The root object that this collection is associated with.
 /// </param>
 /// --------------------------------------------------------------------------------
 protected DatabaseObjectsVolatile(RootContainer rootContainer)
     : base(rootContainer)
 {
     VolatileItemsLoad();
 }
 /// --------------------------------------------------------------------------------
 /// <summary>
 /// Initializes with it the associated root container and database.
 /// </summary>
 ///
 /// <param name="rootContainer">
 /// The root object that this collection is associated with.
 /// </param>
 /// --------------------------------------------------------------------------------
 protected DatabaseObjectsEnumerable(RootContainer rootContainer)
     : base(rootContainer)
 {
 }