Пример #1
0
        public void NonSpatialCacheName()
        {
            TRexCaches.NonSpatialCacheName(StorageMutability.Mutable, FileSystemStreamType.Events).Should().Be(TRexCaches.kNonSpatialMutable);
            TRexCaches.NonSpatialCacheName(StorageMutability.Immutable, FileSystemStreamType.Events).Should().Be(TRexCaches.kNonSpatialImmutable);

            TRexCaches.NonSpatialCacheName(StorageMutability.Immutable, FileSystemStreamType.SiteModelMachineElevationChangeMap).Should().Be(TRexCaches.kSiteModelChangeMapsCacheName);
            TRexCaches.NonSpatialCacheName(StorageMutability.Immutable, FileSystemStreamType.SiteModelMachineElevationChangeMap).Should().Be(TRexCaches.kSiteModelChangeMapsCacheName);
        }
Пример #2
0
 public void SiteModelsCacheName()
 {
     TRexCaches.NonSpatialCacheName(StorageMutability.Mutable, FileSystemStreamType.ProductionDataXML).Should().Be(TRexCaches.kSiteModelsCacheMutable);
     TRexCaches.NonSpatialCacheName(StorageMutability.Immutable, FileSystemStreamType.ProductionDataXML).Should().Be(TRexCaches.kSiteModelsCacheImmutable);
 }
Пример #3
0
        /// <summary>
        /// Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex
        /// </summary>
        private static void AddDIEntries()
        {
            DIBuilder.Continue()
            .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))

            //***********************************************
            // Injected factories for non-transacted proxies
            // **********************************************

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)))))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)))))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) =>
            {
                // SiteModel change maps are only maintained on the immutable grid
                if (mutability != StorageMutability.Immutable)
                {
                    return(null);
                }

                return(new StorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType))));
            }))

            //***********************************************
            // Injected factories for transacted proxies
            // **********************************************

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) =>
            {
                // SiteModel change maps are only maintained on the immutable grid
                if (mutability != StorageMutability.Immutable)
                {
                    return(null);
                }

                return(new StorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer()));
            }));
        }
Пример #4
0
        public void AddProxyCacheFactoriesToDI()
        {
            _tagFileBufferQueue = null;

            DIBuilder
            .Continue()

            // Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex

            /////////////////////////////////////////////////////
            // Injected standard storage proxy cache factories
            /////////////////////////////////////////////////////

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer())))

            /////////////////////////////////////////////////////
            // Injected transacted storage proxy cache factories
            /////////////////////////////////////////////////////

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <ITAGFileBufferQueue> >(factory => () =>
            {
                _tagFileBufferQueue ??= new TAGFileBufferQueue();
                return(_tagFileBufferQueue);
            }))

            .Build();

            // Set up a singleton storage proxy for mutable and immutable contexts for tests when there is no Ignite mock available
            var mutableStorageProxy   = new StorageProxy_Ignite_Transactional(StorageMutability.Mutable);
            var immutableStorageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Immutable);

            DIBuilder
            .Continue()

            // Add the factory to create a single storage proxy instance.
            .Add(x => x.AddSingleton <Func <StorageMutability, IStorageProxy> >(factory => mutability => mutability == StorageMutability.Mutable ? mutableStorageProxy : immutableStorageProxy))
            .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))
            .Build();
        }