public void TransformPhaseGetsAllDocuments() { // Given TestDocument a1 = new TestDocument("a1"); TestDocument b1 = new TestDocument("b1"); TestDocument b2 = new TestDocument("b2"); TestDocument c1 = new TestDocument("c1"); TestDocument d1 = new TestDocument("d1"); TestDocument d2 = new TestDocument("d2"); ConcurrentDictionary <string, ImmutableArray <IDocument> > documents = new ConcurrentDictionary <string, ImmutableArray <IDocument> >(StringComparer.OrdinalIgnoreCase); IPipelineCollection pipelines = new PipelineCollection(); PipelinePhase phaseA = GetPipelineAndPhase("A", Phase.Transform, pipelines, documents, new[] { a1 }); PipelinePhase phaseB = GetPipelineAndPhase("B", Phase.Transform, pipelines, documents, new[] { b1, b2 }, phaseA); PipelinePhase phaseC = GetPipelineAndPhase("C", Phase.Transform, pipelines, documents, new[] { c1 }, phaseB); PipelinePhase phaseD = GetPipelineAndPhase("D", Phase.Transform, pipelines, documents, new[] { d1, d2 }); PipelineOutputs documentCollection = new PipelineOutputs(documents, phaseC, pipelines); // When IDocument[] result = documentCollection.ToArray(); // Then result.ShouldBe(new[] { a1, b1, b2, c1, d1, d2 }, true); }
public void ThrowsForNonDependentPipelineDuringProcessPhase() { // Given TestDocument a1 = new TestDocument("a1"); TestDocument b1 = new TestDocument("b1"); TestDocument b2 = new TestDocument("b2"); TestDocument c1 = new TestDocument("c1"); TestDocument d1 = new TestDocument("d1"); TestDocument d2 = new TestDocument("d2"); ConcurrentDictionary <string, ImmutableArray <IDocument> > documents = new ConcurrentDictionary <string, ImmutableArray <IDocument> >(StringComparer.OrdinalIgnoreCase); IPipelineCollection pipelines = new PipelineCollection(); PipelinePhase phaseA = GetPipelineAndPhase("A", Phase.Process, pipelines, documents, new[] { a1 }); PipelinePhase phaseB = GetPipelineAndPhase("B", Phase.Process, pipelines, documents, new[] { b1, b2 }, phaseA); PipelinePhase phaseC = GetPipelineAndPhase("C", Phase.Process, pipelines, documents, new[] { c1 }, phaseB); PipelinePhase phaseD = GetPipelineAndPhase("D", Phase.Process, pipelines, documents, new[] { d1, d2 }); PipelineOutputs documentCollection = new PipelineOutputs(documents, phaseC, pipelines); // When, Then Should.Throw <InvalidOperationException>(() => documentCollection.FromPipeline("D")); }
private static TagContainer SetupDIContainer(Options options, out GraphicsDevice graphicsDevice) { var diContainer = new TagContainer(); diContainer.AddTag(options); var graphicsDeviceOptions = new GraphicsDeviceOptions() { Debug = true, HasMainSwapchain = false, PreferDepthRangeZeroToOne = true, PreferStandardClipSpaceYDirection = true, }; graphicsDevice = options.Backend switch { ZZMapsGraphicsBackend.Vulkan => GraphicsDevice.CreateVulkan(graphicsDeviceOptions), ZZMapsGraphicsBackend.D3D11 => GraphicsDevice.CreateD3D11(graphicsDeviceOptions), _ => throw new InvalidOperationException($"Unknown backend {options.Backend}") }; diContainer.AddTag(graphicsDevice); diContainer.AddTag(graphicsDevice.ResourceFactory); var pipelineCollection = new PipelineCollection(graphicsDevice); pipelineCollection.AddShaderResourceAssemblyOf <zzre.materials.ModelStandardMaterial>(); pipelineCollection.AddShaderResourceAssemblyOf <MapStandardMaterial>(); diContainer.AddTag(pipelineCollection); var resourcePools = options.ResourcePath .Select(dirInfo => new FileResourcePool(dirInfo.FullName) as IResourcePool); resourcePools = resourcePools.Concat(options.PAK .Select(fileInfo => new PAKParallelResourcePool(fileInfo.FullName))); var combinedResourcePool = new CombinedResourcePool(resourcePools.Reverse().ToArray()); diContainer.AddTag <IResourcePool>(combinedResourcePool); diContainer.AddTag <IAssetLoader <Texture> >(new RefCachedAssetLoader <Texture>( new TextureAssetLoader(diContainer))); diContainer.AddTag <IAssetLoader <ClumpBuffers> >(new RefCachedAssetLoader <ClumpBuffers>( new ClumpAssetLoader(diContainer))); var mappedDb = new MappedDB(); for (int i = 1; i <= 6; i++) { using var tableStream = combinedResourcePool.FindAndOpen($"Data/_fb0x0{i}.fbs"); if (tableStream == null) { continue; } var table = new Table(); table.Read(tableStream); mappedDb.AddTable(table); } diContainer.AddTag(mappedDb); return(diContainer); }
/// <summary> /// Builds a PipelineProvider /// </summary> /// <returns>Returns a immutable PipelineProvider</returns> public IPipelineProvider Build() { var pipelineCollection = new PipelineCollection <IPipeline>(); var asyncPipelineCollection = new PipelineCollection <IPipelineAsync>(); var cancellablePipelineCollection = new PipelineCollection <ICancellablePipelineAsync>(); foreach (var item in _pipelineBuilderCollection) { var pipeline = item.Build(); pipelineCollection.Add(pipeline); } foreach (var item in _asyncPipelineBuilderCollection) { var pipeline = item.Build(); asyncPipelineCollection.Add(pipeline); } foreach (var item in _cancellablePipelineBuilderCollection) { var pipeline = item.Build(); cancellablePipelineCollection.Add(pipeline); } return(new PipelineProvider( pipelineCollection, asyncPipelineCollection, cancellablePipelineCollection )); }
private static void Main(string[] args) { System.Array.ForEach(PreloadAssemblies, n => System.Reflection.Assembly.Load(n)); System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; var window = VeldridStartup.CreateWindow(new WindowCreateInfo { X = 100, Y = 100, WindowWidth = 1024 * 3 / 2, WindowHeight = 768 * 3 / 2, WindowTitle = "Zanzarah" }); var graphicsDevice = VeldridStartup.CreateGraphicsDevice(window, new GraphicsDeviceOptions { PreferDepthRangeZeroToOne = true, PreferStandardClipSpaceYDirection = true, SyncToVerticalBlank = true, Debug = true }, GraphicsBackend.Direct3D11); var pipelineCollection = new PipelineCollection(graphicsDevice); pipelineCollection.AddShaderResourceAssemblyOf <Program>(); var windowContainer = new WindowContainer(graphicsDevice); var resourcePool = new CombinedResourcePool(new IResourcePool[] { #if DEBUG new PAKResourcePool(new FileStream(@"C:\dev\zanzarah\Resources\DATA_0.PAK", FileMode.Open, FileAccess.Read)), new FileResourcePool(@"C:\dev\zanzarah\") #else new PAKResourcePool(new FileStream(Path.Combine(Environment.CurrentDirectory, "..", "Resources", "DATA_0.PAK"), FileMode.Open, FileAccess.Read)), new FileResourcePool(Path.Combine(Environment.CurrentDirectory, "..")) #endif });
public void ThrowsForDuplicateNameWithDifferentCase() { // Given PipelineCollection pipelines = new PipelineCollection(); pipelines.Add("Foo"); // When, Then Assert.Throws <ArgumentException>(() => pipelines.Add("foo")); }
public Mediator( GetService getService, PipelineCollection <IPipeline> pipelineCollection, PipelineCollection <IAsyncPipeline> asyncPipelineCollection, PipelineCollection <ICancellablePipeline> cancellablePipelineCollection) { GetService = getService; _pipelineCollection = pipelineCollection; _asyncPipelineCollection = asyncPipelineCollection; _cancellablePipelineCollection = cancellablePipelineCollection; }
public void ThrowsForDuplicateName() { // Given Engine engine = new Engine(); PipelineCollection pipelines = new PipelineCollection(engine); pipelines.Add("Foo"); // When, Then Assert.Throws <ArgumentException>(() => pipelines.Add("Foo")); }
public void ThrowsForEmptyPipeline() { // Given ConcurrentDictionary <string, ImmutableArray <IDocument> > documents = new ConcurrentDictionary <string, ImmutableArray <IDocument> >(StringComparer.OrdinalIgnoreCase); IPipelineCollection pipelines = new PipelineCollection(); PipelinePhase phase = GetPipelineAndPhase("A", Phase.Transform, pipelines, documents, Array.Empty <IDocument>()); PipelineOutputs documentCollection = new PipelineOutputs(documents, phase, pipelines); // When, Then Should.Throw <ArgumentException>(() => documentCollection.FromPipeline(string.Empty)); }
public void DoesNotThrowForCurrentPipelineDuringTransform() { // Given ConcurrentDictionary <string, ImmutableArray <IDocument> > documents = new ConcurrentDictionary <string, ImmutableArray <IDocument> >(StringComparer.OrdinalIgnoreCase); IPipelineCollection pipelines = new PipelineCollection(); PipelinePhase phase = GetPipelineAndPhase("A", Phase.Transform, pipelines, documents, Array.Empty <IDocument>()); PipelineOutputs documentCollection = new PipelineOutputs(documents, phase, pipelines); // When, Then Should.NotThrow(() => documentCollection.FromPipeline("A")); }
public void ThrowsForCurrentPipelineDuringProcess() { // Given ConcurrentDictionary <string, ImmutableArray <IDocument> > documents = new ConcurrentDictionary <string, ImmutableArray <IDocument> >(StringComparer.OrdinalIgnoreCase); IPipelineCollection pipelines = new PipelineCollection(); PipelinePhase phase = GetPipelineAndPhase("A", Phase.Process, pipelines, documents, Array.Empty <IDocument>()); PipelineOutputs documentCollection = new PipelineOutputs(documents, phase, pipelines); // When, Then Should.Throw <InvalidOperationException>(() => documentCollection.FromPipeline("A")); }
public void ReturnsTrueForDifferentCase() { // Given PipelineCollection pipelines = new PipelineCollection(); pipelines.Add("Test"); // When bool contains = pipelines.ContainsKey("test"); // Then Assert.IsTrue(contains); }
public void AutoGeneratesNameForNullOrEmpty(string name) { // Given PipelineCollection pipelines = new PipelineCollection(); pipelines.Add("First"); // When pipelines.Add(name); // Then Assert.AreEqual("Pipeline 2", pipelines.Values.Skip(1).First().Name); }
public void ThrowsIfInputPhase() { // Given ConcurrentDictionary <string, ImmutableArray <IDocument> > documents = new ConcurrentDictionary <string, ImmutableArray <IDocument> >(StringComparer.OrdinalIgnoreCase); IPipelineCollection pipelines = new PipelineCollection(); PipelinePhase phase = GetPipelineAndPhase("A", Phase.Input, pipelines, documents, Array.Empty <IDocument>()); phase.Pipeline.Isolated = true; PipelineOutputs documentCollection = new PipelineOutputs(documents, phase, pipelines); // When, Then Should.Throw <InvalidOperationException>(() => documentCollection.ToArray()); }
private void AddDataToPipelineInfo(ref PipelineInfo pipeInfo) { CacheManager cacheManager = null; MessageManager msgManager = null; //Need to add Payment Processor Pipeline collection PipelineBase creditCardPipelineProcessor = new CommerceServer.Core.Runtime.Pipelines.OrderPipeline("CreditCardProcessor", Constants.creditCardPaymentProcessortPcfFilePath, false, Constants.LogFilePath + "\\CreditCard.log", true); PipelineCollection pipeCollection = new PipelineCollection(); pipeCollection.Add("CreditCardProcessor", creditCardPipelineProcessor); pipeInfo["pipelines"] = pipeCollection; try { //Create the Cachemanager object cacheManager = new CacheManager(); //Create the Messagemanager object msgManager = new MessageManager(); AddMessagesToMessageManager(msgManager, CultureInfo.CurrentUICulture.ToString(), 1033); AddMessagesToMessageManager(msgManager, "en-US", 1033); //Set the components in the dictionary ConfigureMarketingSystem(pipeInfo, cacheManager); ConfigureOrderSystem(pipeInfo, cacheManager); ConfigureCatalogSystem(pipeInfo); pipeInfo["MessageManager"] = msgManager; pipeInfo["CommerceResources"] = resources; pipeInfo["cachemanager"] = cacheManager; //Need to explicitly specify the Discount cache name when running in non-ASP.Net environment pipeInfo.DiscountsCacheName = "Discounts"; } finally { if (cacheManager != null) { Marshal.ReleaseComObject(cacheManager); } if (msgManager != null) { Marshal.ReleaseComObject(msgManager); } } }
PipelineCollection CreateIncomingPipelines() { PipelineCollection pipelineCollection; if (settings.GetOrDefault <bool>("Endpoint.SendOnly")) { pipelineCollection = new PipelineCollection(Enumerable.Empty <TransportReceiver>()); } else { var pipelines = BuildPipelines().ToArray(); pipelineCollection = new PipelineCollection(pipelines); } return(pipelineCollection); }
public MediatorBuilder() { _pipelineCollection = new PipelineCollection <IPipeline>(); _asyncPipelineCollection = new PipelineCollection <IAsyncPipeline>(); _cancellablePipelineCollection = new PipelineCollection <ICancellablePipeline>(); }
public Engine() { _pipelines = new PipelineCollection(this); }
public Engine() { _config = new Config(this); _pipelines = new PipelineCollection(this); }
static Task StartPipelines(PipelineCollection pipelineCollection) { return(pipelineCollection.Start()); }