Esempio n. 1
0
        private T CreateEntityManagerCore()
        {
            var compositionProvider = Composition.Provider as ISupportsRecomposition;

            if (compositionProvider != null && compositionProvider.IsRecomposing)
            {
                throw new InvalidOperationException(StringResources.CreatingEntityManagerDuringRecompositionNotAllowed);
            }

            Composition.BuildUp(this);
            EventFns.Subscribe(this);
            EnsureDelegates();
            var manager = CreateEntityManager();

            if (ConnectionOptions.IsDesignTime)
            {
                manager.Fetching +=
                    delegate { throw new InvalidOperationException(StringResources.ManagerTriedToFetchData); };
                manager.Saving +=
                    delegate { throw new InvalidOperationException(StringResources.ManagerTriedToSaveData); };

                if (SampleDataProviders != null)
                {
                    SampleDataProviders.ForEach(p => p.AddSampleData(manager));
                }
            }

            return(manager);
        }
Esempio n. 2
0
        private void PopulateStoreEcs()
        {
            // Create a separate isolated EntityManager
            var manager = CreateEntityManager();

            manager.Options.UseDefaultAuthenticationContext = false;
            manager.AuthenticationContext          = AnonymousAuthenticationContext.Instance;
            manager.DefaultQueryStrategy           = QueryStrategy.CacheOnly;
            manager.DefaultEntityReferenceStrategy = EntityReferenceStrategy.NoLoad;

            if (SampleDataProviders != null)
            {
                SampleDataProviders.ForEach(p => p.AddSampleData(manager));
            }

            _storeEcs = manager.CacheStateManager.GetCacheState();
            // We used the manager just to get the ECS; now clear it out
            manager.Clear();
        }