Ejemplo n.º 1
0
        public static void Pack(this ICakeContext context, IEnumerable <FileGroupTarget> targets, string outputFile, bool handleZip = false, bool handleNuPkg = false)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var rootDirectory = FileUtil.NormalizePathSeparator(context.Environment.WorkingDirectory.FullPath, true);

            if (File.Exists(outputFile))
            {
                File.Delete(outputFile);
            }

            using (IVirtualFileStorage fs = new VirtualFileStorage(handleZip, handleNuPkg))
            {
                using (var zip = ZipFile.Open(outputFile, ZipArchiveMode.Create))
                {
                    foreach (var t in targets)
                    {
                        foreach (var f in t.IncludedFiles(rootDirectory, fs))
                        {
                            var sourceFile      = Path.Combine(rootDirectory, f.FilePath);
                            var destinationFile = Path.Combine(t.Target.Substring(1), f.FinalFilePath);

                            using (var entry = zip.CreateEntry(destinationFile).Open())
                            {
                                fs.OpenRead(sourceFile).CopyTo(entry);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void reading_file_data_can_be_transparently_done_from_a_zip_file()
 {
     using (var s = new VirtualFileStorage())
     {
         {
             string file = Path.Combine(ZipTestsFolder, "Folder/AnotherTextInFolder.txt");
             string text = ReadText(s, file);
             Assert.That(text == "A");
         }
         {
             string file = Path.Combine(ZipTestsFolder, "Folder/Sub/NewDoc.txt");
             string text = ReadText(s, file);
             Assert.That(text == "NewDoc");
         }
         {
             string file = Path.Combine(ZipTestsFolder, "Folder/FolderHasBeenZipped.zip/ANewTextDocument.txt");
             string text = ReadText(s, file);
             Assert.That(text == "A2");
         }
         {
             string file = Path.Combine(ZipTestsFolder, "Folder/FolderHasBeenZipped.zip/Folder/Sub/NewDoc.txt");
             string text = ReadText(s, file);
             Assert.That(text == "NewDoc");
         }
         {
             string file = Path.Combine(ZipTestsFolder, "src.zip/Bootstrapper/DataServicePackage.cs");
             string text = ReadText(s, file);
             Assert.That(text == "File is DataServicePackage");
         }
     }
 }
Ejemplo n.º 3
0
 public void transparently_enumerating_files_from_a_zip()
 {
     using (var s = new VirtualFileStorage())
     {
         string root   = Path.Combine(ZipTestsFolder, "Folder/FolderHasBeenZipped.zip");
         var    fInZip = s.EnumerateFiles(root).ToList();
         ContainsFolderHasBeenZipped(fInZip, root);
     }
 }
Ejemplo n.º 4
0
        public void transparently_enumerating_files_from_inside_a_zip()
        {
            using (var s = new VirtualFileStorage())
            {
                {
                    string root = Path.Combine(ZipTestsFolder, "Folder/FolderHasBeenZipped.zip/Folder");

                    var fInZip = s.EnumerateFiles(root).ToList();
                    ContainsFolder(fInZip, root, hasFolderHasBeenZipped: false);
                }
                {
                    string root = Path.Combine(ZipTestsFolder, "src.zip/Bootstrapper");

                    var fInZip = s.EnumerateFiles(root).ToList();
                    ContainsBootstrapper(fInZip, root);
                }
            }
        }
Ejemplo n.º 5
0
        public void transparently_enumerating_files_from_a_zip_is_recursive()
        {
            using (var s = new VirtualFileStorage())
            {
                {
                    string root = Path.Combine(ZipTestsFolder, "Folder");

                    var fInFolder = s.EnumerateFiles(root).ToList();
                    ContainsFolder(fInFolder, root, hasFolderHasBeenZipped: true);
                }
                {
                    string root = ZipTestsFolder;

                    var fInFolder = s.EnumerateFiles(root).ToList();
                    ContainsZipTests(fInFolder, root);
                }
            }
        }
Ejemplo n.º 6
0
        public void TestSerialization()
        {
            var c1 = new Entity {
                Name = "c1"
            };

            c1.Set(ComponentTest2.Key, new ComponentTest2 {
                Test3 = 123
            });
            c1.Set(ComponentTest1.Key, new ComponentTest1 {
                Test = 32, Test2 = 40, RefTest2 = c1.Get(ComponentTest2.Key)
            });

            // Convert to data format
            //var convertedEntities = ParameterContainerExtensions.Convert(new[] { c1 });

            // Save to VFS and reload it
            var vfs = new VirtualFileStorage();

            File.Delete("package_scene.dat");

            var packageManager = new PackageManager(vfs);
            //packageManager.CreatePackage("/data/package_scene.dat");
            //convertedEntities.Location = "/data/package_scene.dat/guid_" + Guid.NewGuid();

            var contentManager = new ContentManager(new ContentSerializerContextGenerator(vfs));

            contentManager.RegisterConverter(new EntitySceneConverter());

            var convertedEntities = contentManager.Convert <EntitySceneData, IList <Entity> >(new[] { c1 }, "/data/package_scene.dat/entityscene.hotei");

            contentManager.Save(convertedEntities);

            contentManager = new ContentManager(new ContentSerializerContextGenerator(vfs));
            contentManager.RegisterConverter(new EntitySceneConverter());
            convertedEntities = contentManager.Load <EntitySceneData>(convertedEntities.Location.Url);
            // Convert back to runtime entities
            //var entities = ParameterContainerExtensions.Convert(convertedEntities);
            var entities = contentManager.Convert <IList <Entity>, EntitySceneData>(convertedEntities);
            var c1Copy   = entities[0];

            Assert.AreEqual(c1.Get(ComponentTest1.Key).Test, c1Copy.Get(ComponentTest1.Key).Test);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            EngineContext.Setup();
            EngineContext.RenderSystem = new DefaultRenderSystem();
            EngineContext.RenderSystem.Init(EngineContext.RenderContext);

            var effect = EngineContext.RenderContext.BuildEffect().Using<RenderTargetFeature>().Using<TransformationFeature>().Using<TextureFeature>().Compile();

            var vfs = new VirtualFileStorage();
            vfs.MountFileSystem("/global_data", "..\\deps\\data\\");
            vfs.MountFileSystem("/global_data2", "..\\data\\");
            var packageVfs = vfs.MountPackage("/testpackage", "/global_data/factory3.dat").Result;
            var contentManager = new ContentManager(vfs, packageVfs);
            contentManager.RegisterSerializer(new SimpleContentSerializer<MeshData>());
            contentManager.RegisterSerializer(new TextureSerializer());
            contentManager.RegisterSerializer(new GpuTextureSerializer(EngineContext.RenderContext.GraphicsDevice));

            var meshData = contentManager.Load<MeshData>("/testpackage/guid/" + packageVfs.Objects[2].Header.ObjectId.Guid);
            var effectMesh = new EffectMesh(effect, meshData);
            //effect.InstantiateMesh(effectMesh);
            //effect.UpdateMeshData(effectMesh, meshData);
            //effectMesh.AddRenderQueue();

            var projectionMatrix = Matrix.PerspectiveFovLH((float)Math.PI * 0.5f, 1024.0f / 768.0f, 1.0f, 4000.0f);

            EngineContext.RenderContext.ParameterGroups.Get(TransformationFeature.TransformationGroup).SetAs(TransformationFeature.Projection, projectionMatrix);

            var factoryTexture = (ITexture2D)contentManager.Load<ITexture>("/global_data2/media/factory.png");
            effectMesh.Parameters.Set(TextureFeature.Texture, factoryTexture);

            var world = Matrix.Scaling(0.1f) * Matrix.Translation(new Vector3(-30.0f, -30.0f, 0.0f));
            effectMesh.Parameters.Set(TransformationFeature.World, world);

            var depth = EngineContext.RenderContext.GraphicsDevice.DepthStencilBuffer.New(DepthFormat.Depth32, EngineContext.RenderContext.Width, EngineContext.RenderContext.Height);
            EngineContext.RenderContext.ParameterGroups.GetGroup(RenderTargetFeature.Group).Set(RenderTargetFeature.RenderTarget, EngineContext.RenderContext.RenderTarget);
            EngineContext.RenderContext.ParameterGroups.GetGroup(RenderTargetFeature.Group).Set(RenderTargetFeature.DepthStencil, depth);

            float time = 0.0f;

            while (true)
            {
                var eyeVector = new Vector4(-800.0f * (float)Math.Cos(time), 800.0f * (float)Math.Sin(time), 500.0f, 1.0f);
                time += 0.0001f;
                var viewMatrix = Matrix.LookAtLH(new Vector3(eyeVector.X, eyeVector.Y, eyeVector.Z), new Vector3(0.0f, 0.0f, 50.0f), new Vector3(0.0f, 0.0f, 1.0f));
                EngineContext.RenderContext.ParameterGroups.Get(TransformationFeature.TransformationGroup).SetAs(TransformationFeature.View, viewMatrix);
                
                Scheduler.Step();
                WinFormsHelper.UpdateWindow();
                EngineContext.Render();

                if (Win32Interop._kbhit() != 0)
                {
                    var key = Console.ReadKey(true).KeyChar;
                    switch (key)
                    {
                        default:
                            break;
                    }
                    if (key == 'q')
                        break;
                }
            }
            EngineContext.Stop();

        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            EngineContext.Setup();
            EngineContext.RenderSystem = new DefaultRenderSystem();
            EngineContext.RenderSystem.Init(EngineContext.RenderContext);

            var effect = EngineContext.RenderContext.BuildEffect().Using <RenderTargetFeature>().Using <TransformationFeature>().Using <TextureFeature>().Compile();

            var vfs = new VirtualFileStorage();

            vfs.MountFileSystem("/global_data", "..\\deps\\data\\");
            vfs.MountFileSystem("/global_data2", "..\\data\\");
            var packageVfs     = vfs.MountPackage("/testpackage", "/global_data/factory3.dat").Result;
            var contentManager = new ContentManager(vfs, packageVfs);

            contentManager.RegisterSerializer(new SimpleContentSerializer <MeshData>());
            contentManager.RegisterSerializer(new TextureSerializer());
            contentManager.RegisterSerializer(new GpuTextureSerializer(EngineContext.RenderContext.GraphicsDevice));

            var meshData   = contentManager.Load <MeshData>("/testpackage/guid/" + packageVfs.Objects[2].Header.ObjectId.Guid);
            var effectMesh = new EffectMesh(effect, meshData);
            //effect.InstantiateMesh(effectMesh);
            //effect.UpdateMeshData(effectMesh, meshData);
            //effectMesh.AddRenderQueue();

            var projectionMatrix = Matrix.PerspectiveFovLH((float)Math.PI * 0.5f, 1024.0f / 768.0f, 1.0f, 4000.0f);

            EngineContext.RenderContext.ParameterGroups.Get(TransformationFeature.TransformationGroup).SetAs(TransformationFeature.Projection, projectionMatrix);

            var factoryTexture = (ITexture2D)contentManager.Load <ITexture>("/global_data2/media/factory.png");

            effectMesh.Parameters.Set(TextureFeature.Texture, factoryTexture);

            var world = Matrix.Scaling(0.1f) * Matrix.Translation(new Vector3(-30.0f, -30.0f, 0.0f));

            effectMesh.Parameters.Set(TransformationFeature.World, world);

            var depth = EngineContext.RenderContext.GraphicsDevice.DepthStencilBuffer.New(DepthFormat.Depth32, EngineContext.RenderContext.Width, EngineContext.RenderContext.Height);

            EngineContext.RenderContext.ParameterGroups.GetGroup(RenderTargetFeature.Group).Set(RenderTargetFeature.RenderTarget, EngineContext.RenderContext.RenderTarget);
            EngineContext.RenderContext.ParameterGroups.GetGroup(RenderTargetFeature.Group).Set(RenderTargetFeature.DepthStencil, depth);

            float time = 0.0f;

            while (true)
            {
                var eyeVector = new Vector4(-800.0f * (float)Math.Cos(time), 800.0f * (float)Math.Sin(time), 500.0f, 1.0f);
                time += 0.0001f;
                var viewMatrix = Matrix.LookAtLH(new Vector3(eyeVector.X, eyeVector.Y, eyeVector.Z), new Vector3(0.0f, 0.0f, 50.0f), new Vector3(0.0f, 0.0f, 1.0f));
                EngineContext.RenderContext.ParameterGroups.Get(TransformationFeature.TransformationGroup).SetAs(TransformationFeature.View, viewMatrix);

                Scheduler.Step();
                WinFormsHelper.UpdateWindow();
                EngineContext.Render();

                if (Win32Interop._kbhit() != 0)
                {
                    var key = Console.ReadKey(true).KeyChar;
                    switch (key)
                    {
                    default:
                        break;
                    }
                    if (key == 'q')
                    {
                        break;
                    }
                }
            }
            EngineContext.Stop();
        }