Ejemplo n.º 1
0
        public IList <string> GetGlobalVariables()
        {
            var masterFiles = new List <string>();

            GetMasterFiles(MasterFolderTypes.Shared, masterFiles);
            GetMasterFiles(MasterFolderTypes.Layouts, masterFiles);

            _viewLoader.Load(_viewPath);
            masterFiles.ToList().ForEach(filePath =>
            {
                var type = filePath.Contains(MasterFolderTypes.Shared.ToString()) ? MasterFolderTypes.Shared : MasterFolderTypes.Layouts;
                _viewLoader.Load(filePath.Substring(filePath.LastIndexOf(type.ToString())));
            });

            var globalVariables = new List <string>();
            var chunkLists      = _viewLoader.GetEverythingLoaded();

            chunkLists.ToList().ForEach(list =>
            {
                var globals = list.Where(chunk => chunk is GlobalVariableChunk);
                globals.ToList().ForEach(globalVar => globalVariables.Add(((GlobalVariableChunk)globalVar).Name));
            });

            return(globalVariables);
        }
Ejemplo n.º 2
0
        public void LoadSimpleFile()
        {
            ExpectGetChunks("home\\simple.spark", new SendLiteralChunk());
            viewFolder.Stub(x => x.HasView("home\\_global.spark")).Return(false);
            viewFolder.Stub(x => x.HasView("Shared\\_global.spark")).Return(false);

            var chunks = loader.Load("home\\simple.spark");

            viewFolder.VerifyAllExpectations();
            syntaxProvider.VerifyAllExpectations();

            Assert.AreEqual(1, chunks.Count());
            Assert.AreEqual(1, loader.GetEverythingLoaded().Count());
        }
Ejemplo n.º 3
0
    public void TestGrid()
    {
        //ViewLoader.Load(panelTran, ViewScheme.Grid, "2:2@test/?video001=RTSP,wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov,1,1,1,1&SubGrid=Grid,,1,1,1,1");
        ViewLoader.Load(panelTran, ViewScheme.Grid, text.text);

        //GridContentData grid = new GridContentData(ViewScheme.Grid, text1.text,2,1,1,1);

        //LayoutData layout2 = new LayoutData();
        //layout2.Name = "Child";
        //layout2.Column = 2;
        //layout2.Row = 2;
        //layout2.views = new GridContentData[1];
        //layout2.views[0] = new GridContentData(ViewScheme.RTSP, "wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", 1, 1, 1, 1);
        //LayoutData layout = new LayoutData();
        //layout.Name = "Main";
        //layout.Column = 2;
        //layout.Row = 2;
        //layout.views = new GridContentData[1];
        //layout.views[0] = new GridContentData(ViewScheme.Grid, layout2, 2, 1, 1, 1);
        //string data = JsonUtility.ToJson(layout);
        //Debug.Log(data);
        //ViewLoader.Load(panelTran, ViewScheme.Grid, data);

        //string uri = @"http://*****:*****@test/?video001=RTSP,wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov,1,1,1,1";
        //Uri test = new Uri(uri);
        //Debug.Log("Name : " + test.UserInfo + " col : " + test.Host + " row : " + test.Port + " query : " + test.Query);
    }
Ejemplo n.º 4
0
        public void BindingProviderIsCalledUsingTheCorrectBindingRequest()
        {
            var bindingProvider = MockRepository.GenerateMock <IBindingProvider>();
            var syntaxProvider  = MockRepository.GenerateStub <ISparkSyntaxProvider>();
            var viewPath        = Path.Combine("Account", "index.spark");
            var folder          = new StubViewFolder {
                Path = viewPath, LastModified = 4
            };

            bindingProvider.Expect(x => x.GetBindings(null))
            .IgnoreArguments()
            .Return(new Binding[0])
            .Callback <BindingRequest>(x => x.ViewFolder == folder && x.ViewPath == viewPath);

            syntaxProvider.Stub(x => x.GetChunks(null, null))
            .IgnoreArguments()
            .Return(new List <Chunk>());
            var viewLoader = new ViewLoader
            {
                ViewFolder      = folder,
                SyntaxProvider  = syntaxProvider,
                BindingProvider = bindingProvider
            };

            viewLoader.Load(viewPath);

            bindingProvider.VerifyAllExpectations();
        }
Ejemplo n.º 5
0
 private IList <Chunk> LoadChunks(string viewPath)
 {
     try
     {
         return(_viewLoader.Load(viewPath) ?? new List <Chunk>());
     }
     catch (CompilerException)
     {
         return(new List <Chunk>());
     }
 }
 private void LoadTemplates(ViewLoader loader, IEnumerable <string> templates, ICollection <IList <Chunk> > chunksLoaded, ICollection <string> templatesLoaded)
 {
     foreach (string str in templates)
     {
         if (templatesLoaded.Contains(str))
         {
             throw new CompilerException(string.Format("Unable to include template '{0}' recusively", templates));
         }
         IList <Chunk> item = loader.Load(str);
         chunksLoaded.Add(item);
         templatesLoaded.Add(str);
     }
 }
Ejemplo n.º 7
0
        public void LoadingEmptyShadeFile()
        {
            var viewFolder = new InMemoryViewFolder
            {
                { Path.Combine("home", "empty.shade"), "" },
            };
            var viewLoader = new ViewLoader {
                SyntaxProvider = new DefaultSyntaxProvider(ParserSettings.DefaultBehavior), ViewFolder = viewFolder
            };
            var chunks     = viewLoader.Load(Path.Combine("home", "empty.shade"));
            var everything = viewLoader.GetEverythingLoaded();

            Assert.AreEqual(1, everything.Count());
        }
Ejemplo n.º 8
0
        public void LoadingPartialInsideNamedSection()
        {
            var viewFolder = new InMemoryViewFolder
            {
                { "home\\index.spark", "<for each='var x in new[]{1,2,3}'><Guts><section:foo><Another/></section:foo></Guts></for>" },
                { "home\\_Guts.spark", "<div><render:foo/></div>" },
                { "home\\_Another.spark", "<p>hello world</p>" }
            };
            var viewLoader = new ViewLoader {
                SyntaxProvider = new DefaultSyntaxProvider(ParserSettings.DefaultBehavior), ViewFolder = viewFolder
            };
            var chunks     = viewLoader.Load("home\\index.spark");
            var everything = viewLoader.GetEverythingLoaded();

            Assert.AreEqual(3, everything.Count());
        }
Ejemplo n.º 9
0
        public void ParametersInCallerBody()
        {
            var viewFolder = new InMemoryViewFolder
                                 {
                                     {"home\\index.spark", "<for each='var x in new[]{1,2,3}'><Guts>${xIndex}</Guts></for>"},
                                     {"home\\_Guts.spark", "<p><render/></p>"}
                                 };
            var loader = new ViewLoader { SyntaxProvider = new DefaultSyntaxProvider(ParserSettings.DefaultBehavior), ViewFolder = viewFolder };

            var chunks = loader.Load("home\\index.spark");

            var detectCode = new DetectCodeExpressionVisitor(null);
            var index = detectCode.Add("xIndex");
            var count = detectCode.Add("xCount");
            detectCode.Accept(chunks);

            Assert.IsTrue(index.Detected);
            Assert.IsFalse(count.Detected);
        }
Ejemplo n.º 10
0
        public void IterationInPartialFile()
        {
            var viewFolder = new InMemoryViewFolder
                                 {
                                     {"home\\index.spark", "<Guts items='new[]{1,2,3}'><section:each>${xIndex}</section:each></Guts>"},
                                     {"home\\_Guts.spark", "<for each='var x in items'><render:each/></for>"}
                                 };
            var loader = new ViewLoader { SyntaxProvider = new DefaultSyntaxProvider(ParserSettings.DefaultBehavior), ViewFolder = viewFolder };

            var chunks = loader.Load("home\\index.spark");

            var detectCode = new DetectCodeExpressionVisitor(null);
            var index = detectCode.Add("xIndex");
            var count = detectCode.Add("xCount");
            detectCode.Accept(chunks);

            Assert.IsTrue(index.Detected);
            Assert.IsFalse(count.Detected);
        }
 private void SetContent(GridContentData[] dataList)
 {
     viewList = dataList;
     for (int i = 0; i < viewList.Length; i++)
     {
         if (!string.IsNullOrEmpty(viewList[i].Path) && viewList[i].Path != "Null")
         {
             Debug.Log(viewList[i].Path);
             viewList[i].View = ViewLoader.Load(transform, viewList[i].Scheme, viewList[i].Path);
         }
         else
         {
             string data = JsonUtility.ToJson(viewList[i].Content);
             Debug.Log(data);
             viewList[i].View = ViewLoader.Load(transform, viewList[i].Scheme, data);
         }
         //ViewLoader.Load(transform,viewList[i]);
         //viewList[i].View = ViewLoader.Load(transform, viewList[i].Scheme);
         //viewList[i].View.Setup(viewList[i].Path);
         //Debug.Log(JsonUtility.ToJson(viewList[i]));
     }
     UpdateLayout();
 }
Ejemplo n.º 12
0
        public void ExpiresWhenFilesChange()
        {
            var viewFolder = new StubViewFolder {
                Path = "home\\changing.spark", LastModified = 4
            };

            var viewLoader = new ViewLoader
            {
                ViewFolder     = viewFolder,
                SyntaxProvider = MockRepository.GenerateStub <ISparkSyntaxProvider>()
            };

            viewLoader.SyntaxProvider
            .Expect(x => x.GetChunks(null, null))
            .IgnoreArguments()
            .Return(new Chunk[0]);

            viewLoader.Load("home\\changing.spark");

            Assert.That(viewLoader.IsCurrent());

            viewFolder.LastModified = 7;
            Assert.That(!viewLoader.IsCurrent());
        }