Пример #1
0
        void ApplyRouteRule(StaticFile staticFile, Site site, string outputDirectory)
        {
            RouteRule routeRule = site.GetRoutingRuleFor(staticFile.Item);
            string    route     = routeRule.ApplyTo(staticFile, site);

            staticFile.Path = outputDirectory + route;
        }
Пример #2
0
        public void StaticFileAsync()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            // pack files
            Assert.True(Engine.File.Pack("../../Core/TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test1         = null;
            StaticFile test2         = null;
            StaticFile test3         = null;
            StaticFile test4         = null;
            StaticFile testCache     = null;
            StaticFile testPack1     = null;
            StaticFile testPack2     = null;
            StaticFile testPack3     = null;
            StaticFile testPack4     = null;
            StaticFile testPackCache = null;

            var task1 = Task.Run(() => {
                test1     = StaticFile.Create("../../Core/TestData/IO/test.txt");
                test3     = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
                testPack1 = StaticFile.Create("test.txt");
                testPack3 = StaticFile.Create("全角 テスト.txt");
                testCache = StaticFile.Create("../../Core/TestData/IO/test.txt");
            });

            var task2 = Task.Run(() => {
                test2         = StaticFile.Create("../../Core/TestData/IO/space test.txt");
                test4         = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
                testPack2     = StaticFile.Create("space test.txt");
                testPack4     = StaticFile.Create("全角 テスト.txt");
                testPackCache = StaticFile.Create("space test.txt");
            });

            task1.Wait();
            task2.Wait();

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(test2, null);
            Assert.AreNotEqual(test3, null);
            Assert.AreNotEqual(test4, null);
            Assert.AreNotEqual(testCache, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(testPack2, null);
            Assert.AreNotEqual(testPack3, null);
            Assert.AreNotEqual(testPack4, null);
            Assert.AreNotEqual(testPackCache, null);

            Assert.AreEqual(test1.Size, testPack1.Size);
            Assert.AreEqual(test1.Size, testPack1.Size);
            Assert.AreEqual(test2.Size, testPack2.Size);
            Assert.AreEqual(test3.Size, testPack3.Size);
            Assert.AreEqual(test4.Size, testPack4.Size);

            Engine.Terminate();
        }
Пример #3
0
        public void Zenkaku()
        {
            var tc = new TestCore();

            tc.Init();

            // pack files
            Assert.True(Engine.File.Pack("TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            StaticFile test1     = null;
            StaticFile test2     = null;
            StaticFile testPack1 = null;
            StaticFile testPack2 = null;

#if !CI
            test1     = StaticFile.Create("TestData/IO/全角 テスト.txt");
            test2     = StaticFile.Create("TestData/IO/全角 テスト.txt");
            testPack1 = StaticFile.Create("全角 テスト.txt");
            testPack2 = StaticFile.Create("全角 テスト.txt");

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(test2, null);
            Assert.AreNotEqual(testPack2, null);
            Assert.AreNotEqual(test1.Size, 0);
            Assert.AreNotEqual(testPack1.Size, 0);
            Assert.AreNotEqual(test2.Size, 0);
            Assert.AreNotEqual(testPack2.Size, 0);
#endif

            tc.End();
        }
Пример #4
0
        static void Main(string[] args)
        {
            // Altseed を初期化します。
            if (!Engine.Initialize("Serialization", 640, 480, new Configuration()))
            {
                return;
            }

            // シリアライズ結果を保存するファイルのパス
            var path = "SerializeSample.bin";

            // StaticFileを生成。
            var file1 = StaticFile.Create(@"TestData\IO\test.txt");

            // fileをシリアライズします。
            Serialize(path, file1);

            // シリアライズされたfileをデシリアライズします。
            var file2 = (StaticFile)DeSerialize(path);

            // バイト配列をUTF8として、string型に変換します。
            var text1 = Encoding.UTF8.GetString(file1.Buffer);
            var text2 = Encoding.UTF8.GetString(file2.Buffer);

            // テキストをコンソールに出力します。
            Console.WriteLine("text1 : {0}", text1);
            Console.WriteLine("text2 : {0}", text2);

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Пример #5
0
        public void Zenkaku()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            // pack files
            Assert.True(Engine.File.Pack("../../Core/TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            StaticFile test1     = null;
            StaticFile test2     = null;
            StaticFile testPack1 = null;
            StaticFile testPack2 = null;

            test1     = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
            test2     = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
            testPack1 = StaticFile.Create("全角 テスト.txt");
            testPack2 = StaticFile.Create("全角 テスト.txt");

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(test2, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(testPack2, null);

            Assert.AreNotEqual(test1.Size, 0);
            Assert.AreNotEqual(test2.Size, 0);
            Assert.AreNotEqual(testPack1.Size, 0);
            Assert.AreNotEqual(testPack2.Size, 0);

            Engine.Terminate();
        }
Пример #6
0
 public static void HandleBlobChange(StaticFile obj, MethodReturnEventArgs <Blob> e, Blob oldBlob, Blob newBlob)
 {
     if (oldBlob != null && newBlob != oldBlob)
     {
         throw new InvalidOperationException("Changing blob on static files is not allowed");
     }
     e.Result = newBlob;
 }
Пример #7
0
 public static void HandleBlobChange(StaticFile obj, MethodReturnEventArgs<Blob> e, Blob oldBlob, Blob newBlob)
 {
     if (oldBlob != null && newBlob != oldBlob)
     {
         throw new InvalidOperationException("Changing blob on static files is not allowed");
     }
     e.Result = newBlob;
 }
Пример #8
0
 /// <summary>
 /// This is the Obtain function. You can use it to get the cached/saved data.
 /// </summary>
 /// <param name="s">Type of the StaticFile that you want to retrieve from the cache.</param>
 public string Obtain(StaticFile s)
 {
     if (_map.TryGetValue(s, out var v))
     {
         return(v);
     }
     log.Error(string.Format("Static file of type {0} not found/cached, returning nothing...", s.ToString()));
     return("");
 }
Пример #9
0
            public void SetUp()
            {
                expected   = "Trust No One";
                staticFile = new StaticFile(CreateFakeItem());
                site       = CreateFakeSite();

                routeRule = new RouteRule("*", (ruleContext) => {
                    return(expected);
                });
            }
Пример #10
0
            public void SetUp()
            {
                actionInvoked = false;
                staticFile    = new StaticFile(CreateFakeItem());
                site          = CreateFakeSite();

                compileRule = new CompileRule("*", (ruleContext) => {
                    actionInvoked = true;
                });
            }
Пример #11
0
        private static StaticFile CopyStaticFile(StaticFile file)
        {
            var folder = Path.GetDirectoryName(file.OutputPath);

            Directory.CreateDirectory(folder);

            File.Copy(file.SourcePath, file.OutputPath, true);

            return(file);
        }
Пример #12
0
			public void SetUp()
			{
				actionInvoked = false;
				staticFile = new StaticFile(CreateFakeItem());
				site = CreateFakeSite();
				
				compileRule = new CompileRule("*", (ruleContext) => {
					actionInvoked = true;
				});
			}
Пример #13
0
			public void SetUp()
			{
				expected = "Trust No One";
				staticFile = new StaticFile(CreateFakeItem());
				site = CreateFakeSite();
				
				routeRule = new RouteRule("*", (ruleContext) => {
					return expected;
				});
			}
Пример #14
0
        public bool GetIsExistLatestFile(StaticFile staticFile)
        {
            bool ret = EffekseerNativePINVOKE.IO_GetIsExistLatestFile(swigCPtr, StaticFile.getCPtr(staticFile));

            if (EffekseerNativePINVOKE.SWIGPendingException.Pending)
            {
                throw EffekseerNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public void TestSaveToFile_FileWithNullContent_1FileSaved()
        {
            const string FolderName = "FolderNameTest";
            const string FileName   = "FileNameTest";

            StaticFile.SaveToFile(FolderName, FileName, null);

            Assert.IsTrue(File.Exists(Path.Combine(FolderName, FileName)));

            RemoveFileFromFolder(FolderName, FileName);
        }
Пример #16
0
        public StaticFile LoadIPCFile(string path)
        {
            global::System.IntPtr cPtr = EffekseerNativePINVOKE.IO_LoadIPCFile(swigCPtr, path);
            StaticFile            ret  = (cPtr == global::System.IntPtr.Zero) ? null : new StaticFile(cPtr, true);

            if (EffekseerNativePINVOKE.SWIGPendingException.Pending)
            {
                throw EffekseerNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Пример #17
0
        /// <summary>
        /// 2.0 文件下载
        /// </summary>
        /// <returns></returns>
        public FileResult DownLoadFile()
        {
            int fileId = Convert.ToInt32(Request["fileId"]);  //文件Id

            IBLL.IStaticFileService fileService = OperateHelper.Current.serviceSession.StaticFileService;
            StaticFile file = fileService.GetEntity(fileId);

            WebClient webClient = new WebClient();

            byte[] downStream = webClient.DownloadData(file.FileOnLineURL);

            return(File(downStream, "application/octet-stream", file.FileRawName));
        }
Пример #18
0
        public string GetPublicMediaUrl(string storeId, Guid mediaId)
        {
            if (this.StoreId == storeId)
            {
                StaticFile file = GetFileList().Where(f => f.Id == mediaId).FirstOrDefault();
                if (file != null)
                {
                    return(file.DownloadUrl);
                }
            }

            return(null);
        }
Пример #19
0
        public void CreateStaticFile()
        {
            if (System.IO.Directory.Exists("tmp"))
            {
                System.IO.Directory.Delete("tmp", true);
            }

            System.IO.Directory.CreateDirectory("tmp");
            foreach (var i in Enumerable.Range(0, 1000))
            {
                System.IO.File.Copy("../../Core/TestData/IO/test.txt", "tmp/test" + i + ".txt");
            }
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);

            Assert.NotNull(font);

            var node = new TextNode()
            {
                Font = font, Text = ""
            };

            Engine.AddNode(node);

            var tasks = new List <Task <StaticFile> >();

            foreach (var i in Enumerable.Range(0, 1000))
            {
                tasks.Add(StaticFile.CreateAsync("tmp/test" + i + ".txt"));
            }

            while (Engine.DoEvents())
            {
                node.Text = $"Static File: {tasks.Count(obj => obj.IsCompleted)}/{tasks.Count()}";
                Assert.True(Engine.Update());

                if (tasks.All(obj => obj.IsCompleted))
                {
                    break;
                }
            }

            foreach (var i in Enumerable.Range(0, 1000))
            {
                Assert.AreEqual(tasks[0].Result.Size, tasks[i].Result.Size);
            }

            Engine.Terminate();
        }
Пример #20
0
        public void StaticFileBase()
        {
            var tc = new TestCore();

            tc.Init();

            // pack files
            Assert.True(Engine.File.Pack("TestData/IO/", "pack.pack"));
            Assert.True(Engine.File.PackWithPassword("TestData/IO/pack/", "password.pack", "altseed"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create("TestData/IO/test.txt"), null);
            Assert.False(test.IsInPackage);
            StaticFile testPack = null;

            Assert.AreNotEqual(testPack = StaticFile.Create("test.txt"), null);
            Assert.True(testPack.IsInPackage);
            Assert.AreEqual(test.Size, testPack.Size);

            // add package
            Assert.True(Engine.File.AddRootPackageWithPassword("password.pack", "altseed"));

            // clear cache
            Engine.Resources.Clear();

            StaticFile testPack2 = null;

            Assert.AreNotEqual(testPack2 = StaticFile.Create("test.txt"), null);
            Assert.True(testPack2.IsInPackage);
            Assert.AreNotEqual(testPack, testPack2);
            Assert.AreNotEqual(testPack.Size, testPack2.Size);

            // create static file, and compare no-package and package with password
            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create("TestData/IO/pack/test.txt"), null);
            Assert.AreEqual(test3.Size, testPack2.Size);
            Assert.AreEqual(test3.Size, testPack2.Size);

            tc.End();
        }
Пример #21
0
        public void UtilityStaticFile()
        {
            StaticFile file = StaticFile.Create("~/collar.ashx", "js/collar.js");

            Assert.IsNotNull(file);
            Assert.IsFalse(string.IsNullOrEmpty(file.Hash));
            Assert.IsTrue(file.Url.StartsWith("/collar.ashx", StringComparison.OrdinalIgnoreCase));
            Assert.AreEqual("text/javascript", file.ContentType);

            file = StaticFile.Create("~/collar.ashx", "img/logo-header.png");
            Assert.IsNotNull(file);
            Assert.AreEqual("image/png", file.ContentType);

            file = StaticFile.Create("~/collar.ashx", "index.xslt");
            Assert.IsNotNull(file);
            Assert.AreEqual("text/html", file.ContentType);
        }
Пример #22
0
        void ExecuteFilters(StaticFile staticFile, Site site)
        {
            foreach (var filterName in staticFile.FilterNameQueue)
            {
                IFilter filter = filterFactory.CreateFilter(filterName);

                string source    = staticFile.GetLastSnapShot();
                var    arguments = new Dictionary <string, object> {
                    { "configuration", site.Configuration as IDictionary <string, object> },
                    { "item", staticFile.Item.Meta }
                };

                string result = filter.Execute(source, arguments);

                staticFile.CreateSnapShot(result);
            }
        }
Пример #23
0
        public void StaticFileBase()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            // pack files
            Assert.True(Engine.File.Pack("../../Core/TestData/IO/", "pack.pack"));
            Assert.True(Engine.File.PackWithPassword("../../Core/TestData/IO/pack/", "password.pack", "altseed"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create("../../Core/TestData/IO/test.txt"), null);
            Assert.False(test.IsInPackage);
            StaticFile testPack = null;

            Assert.AreNotEqual(testPack = StaticFile.Create("test.txt"), null);
            Assert.True(testPack.IsInPackage);
            Assert.AreEqual(test.Size, testPack.Size);

            // add package
            Assert.True(Engine.File.AddRootPackageWithPassword("password.pack", "altseed"));

            // clear cache
            Engine.Resources.Clear();

            StaticFile testPack2 = null;

            Assert.AreNotEqual(testPack2 = StaticFile.Create("test.txt"), null);
            Assert.True(testPack2.IsInPackage);
            Assert.AreNotEqual(testPack, testPack2);
            Assert.AreNotEqual(testPack.Size, testPack2.Size);

            // create static file, and compare no-package and package with password
            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create("../../Core/TestData/IO/pack/test.txt"), null);
            Assert.AreEqual(test3.Size, testPack2.Size);
            Assert.AreEqual(test3.Size, testPack2.Size);

            Engine.Terminate();
        }
Пример #24
0
        void ExecuteLayoutFilter(StaticFile staticFile, Site site)
        {
            if (staticFile.Layout != null)
            {
                var layoutRule = site.GetLayoutRuleFor(staticFile.Layout);

                IFilter filter    = filterFactory.CreateFilter(layoutRule.FilterName);
                var     arguments = new Dictionary <string, object> {
                    { "configuration", site.Configuration as IDictionary <string, object> },
                    { "layout", staticFile.Layout.Meta },
                    { "item", staticFile.Item.Meta },
                    { "content", staticFile.GetLastSnapShot() }
                };

                string result = filter.Execute(staticFile.Layout.Content, arguments);

                staticFile.CreateSnapShot(result);
            }
        }
Пример #25
0
        static void Main(string[] args)
        {
            // Altseed を初期化します。
            if (!Engine.Initialize("StaticFile", 640, 480, new Configuration()))
            {
                return;
            }

            // ファイルを読み込みます。
            var staticFile = StaticFile.Create(@"TestData\IO\test.txt");

            // バイト配列をUTF8として、string型に変換します。
            var text = Encoding.UTF8.GetString(staticFile.Buffer);

            // コンソールに出力します。
            Console.WriteLine(text);

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Пример #26
0
        public void StaticFileCache()
        {
            var tc = new TestCore();

            tc.Init();

            var path = System.IO.Path.GetFullPath("TestData/IO/AltseedPink.png");

            Assert.True(Engine.File.Exists(path));
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create(path), null);

            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create(path), null);

            Engine.Log.Info(LogCategory.Engine, $"{test.selfPtr}/{test3.selfPtr}");
            Engine.Log.Info(LogCategory.Engine, Engine.Resources.GetResourcesCount(ResourceType.StaticFile).ToString());
            tc.End();
        }
Пример #27
0
        public void StaticFileCache()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()
            {
                FileLoggingEnabled = true, LogFileName = "cache.txt", ConsoleLoggingEnabled = true
            }));

            var path = System.IO.Path.GetFullPath("../../Core/TestData/IO/AltseedPink.png");

            Assert.True(Engine.File.Exists(path));
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create(path), null);

            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create(path), null);

            Engine.Log.Info(LogCategory.Engine, $"{test.selfPtr}/{test3.selfPtr}");
            Engine.Log.Info(LogCategory.Engine, Engine.Resources.GetResourcesCount(ResourceType.StaticFile).ToString());
            Engine.Terminate();
        }
Пример #28
0
 public static void UploadCanExecReason(StaticFile obj, MethodReturnEventArgs<string> e)
 {
     e.Result = "Changing blob on static files is not allowed";
 }
Пример #29
0
 public static void UploadCanExec(StaticFile obj, MethodReturnEventArgs<bool> e)
 {
     e.Result = obj.Blob == null;
 }
Пример #30
0
 public static void UploadCanExecReason(StaticFile obj, MethodReturnEventArgs <string> e)
 {
     e.Result = "Changing blob on static files is not allowed";
 }
Пример #31
0
        public void PortalConosle(string name)
        {
            StaticFile.ConsoleLine(name);

            StaticFile.ConsoleLine(name, "other");
        }
Пример #32
0
        public void StaticFileAsync()
        {
            var tc = new TestCore();

            tc.Init();

            // pack files
            Assert.True(Engine.File.Pack("TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test1 = null;
            StaticFile test2 = null;

#if !CI
            StaticFile test3 = null;
            StaticFile test4 = null;
#endif
            StaticFile testCache = null;
            StaticFile testPack1 = null;
            StaticFile testPack2 = null;
#if !CI
            StaticFile testPack3 = null;
            StaticFile testPack4 = null;
#endif
            StaticFile testPackCache = null;

            var task1 = Task.Run(() =>
            {
                test1 = StaticFile.Create("TestData/IO/test.txt");
#if !CI
                test3 = StaticFile.Create("TestData/IO/全角 テスト.txt");
#endif
                testPack1 = StaticFile.Create("test.txt");
#if !CI
                testPack3 = StaticFile.Create("全角 テスト.txt");
#endif
                testCache = StaticFile.Create("TestData/IO/test.txt");
            });

            var task2 = Task.Run(() =>
            {
                test2 = StaticFile.Create("TestData/IO/space test.txt");
#if !CI
                test4 = StaticFile.Create("TestData/IO/全角 テスト.txt");
#endif
                testPack2 = StaticFile.Create("space test.txt");
#if !CI
                testPack4 = StaticFile.Create("全角 テスト.txt");
#endif
                testPackCache = StaticFile.Create("space test.txt");
            });

            task1.Wait();
            task2.Wait();

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(test2, null);
#if !CI
            Assert.AreNotEqual(test3, null);
            Assert.AreNotEqual(test4, null);
#endif
            Assert.AreNotEqual(testCache, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(testPack2, null);
#if !CI
            Assert.AreNotEqual(testPack3, null);
            Assert.AreNotEqual(testPack4, null);
#endif
            Assert.AreNotEqual(testPackCache, null);

            Assert.AreEqual(test1.Size, testPack1.Size);
            Assert.AreEqual(test2.Size, testPack2.Size);
#if !CI
            Assert.AreEqual(test3.Size, testPack3.Size);
            Assert.AreEqual(test4.Size, testPack4.Size);
#endif
            tc.End();
        }
Пример #33
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StaticFile obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Пример #34
0
		void ExecuteFilters(StaticFile staticFile, Site site)
		{
			foreach (var filterName in staticFile.FilterNameQueue) {
				IFilter filter = filterFactory.CreateFilter(filterName);
				
				string source = staticFile.GetLastSnapShot();
				var arguments = new Dictionary<string, object> {
					{ "configuration", site.Configuration as IDictionary<string, object> },
					{ "item", staticFile.Item.Meta }
				};
				
				string result = filter.Execute(source, arguments);
				
				staticFile.CreateSnapShot(result);
			}
		}
Пример #35
0
		void ApplyCompileRule(StaticFile staticFile, Site site)
		{
			CompileRule compileRule = site.GetCompilationRuleFor(staticFile.Item);
			compileRule.ApplyTo(staticFile, site);
		}
Пример #36
0
		void ApplyRouteRule(StaticFile staticFile, Site site, string outputDirectory)
		{
			RouteRule routeRule = site.GetRoutingRuleFor(staticFile.Item);
			string route = routeRule.ApplyTo(staticFile, site);
			staticFile.Path = outputDirectory + route;
		}
Пример #37
0
 public static void UploadCanExec(StaticFile obj, MethodReturnEventArgs <bool> e)
 {
     e.Result = obj.Blob == null;
 }
Пример #38
0
        public void CreateStaticFile()
        {
            if (System.IO.Directory.Exists("tmp"))
            {
                System.IO.Directory.Delete("tmp", true);
            }

            System.IO.Directory.CreateDirectory("tmp");
            foreach (var i in Enumerable.Range(0, 1000))
            {
                System.IO.File.Copy("TestData/IO/test.txt", "tmp/test" + i + ".txt");
            }
            var tc = new TestCore();

            tc.Init();

            var font = Font.LoadDynamicFont("TestData/Font/mplus-1m-regular.ttf", 64);

            Assert.NotNull(font);

            var node = new TextNode()
            {
                Font = font, FontSize = 80, Text = ""
            };

            Engine.AddNode(node);

            // TODO : improve performance
            int  itemnum = 100;
            bool dogc    = true;

            var tasks = new List <Task <StaticFile> >();

            foreach (var i in Enumerable.Range(0, itemnum))
            {
                if (i % 10 == 0 && dogc)
                {
                    Thread.Sleep(10);
                    Assert.True(Engine.Update());
                }

                tasks.Add(StaticFile.CreateAsync("tmp/test" + i + ".txt"));
            }

            while (Engine.DoEvents())
            {
                node.Text = $"Static File: {tasks.Count(obj => obj.IsCompleted)}/{tasks.Count()}";
                Assert.True(Engine.Update());

                if (tasks.All(obj => obj.IsCompleted))
                {
                    break;
                }
            }

            foreach (var i in Enumerable.Range(0, itemnum))
            {
                Assert.AreEqual(tasks[0].Result.Size, tasks[i].Result.Size);
            }

            tc.End();
        }
Пример #39
0
 public DynamicStaticFile(DocumentFile activeDocument, StaticFile file)
     : base(file)
 {
 }
Пример #40
0
		void ExecuteLayoutFilter(StaticFile staticFile, Site site)
		{
			if (staticFile.Layout != null) {
				var layoutRule = site.GetLayoutRuleFor(staticFile.Layout);
			
				IFilter filter = filterFactory.CreateFilter(layoutRule.FilterName);
				var arguments = new Dictionary<string, object> {
					{ "configuration", site.Configuration as IDictionary<string, object> },
					{ "layout", staticFile.Layout.Meta },
					{ "item", staticFile.Item.Meta },
					{ "content", staticFile.GetLastSnapShot() }
				};
			
				string result = filter.Execute(staticFile.Layout.Content, arguments);
			
				staticFile.CreateSnapShot(result);
			}
		}