Exemplo n.º 1
0
        public void TryReplace <T>(BehaviorGraph graph, string fileName)
        {
            var file = graph.Files.FindFiles(FileSet.Shallow(fileName))
                       .FirstOrDefault(x => x.Provenance.EqualsIgnoreCase("application"));

            if (file != null)
            {
                var template = new Template
                {
                    FilePath = file.Path,
                    RootPath = file.Path,
                    ViewPath = Path.GetFileName(file.Path)
                };

                var descriptor = new ViewDescriptor <Template>(template)
                {
                    ViewModel = typeof(T)
                };

                var sparkDescriptor = new SparkDescriptor(descriptor.Template)
                {
                    ViewModel = typeof(T)
                };

                var view = new SparkViewToken(sparkDescriptor);

                var chain = graph.Behaviors.Single(x => x.ResourceType() == typeof(T));
                chain.Output.ClearAll();
                chain.Output.Writers.AddToEnd(new SpecialView <T>(view));
            }
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            var root = AppDomain.CurrentDomain.BaseDirectory;
            _template = new Template(Path.Combine(root, "Views", "Home", "Home.spark"), root, TemplateConstants.HostOrigin);

            _descriptor = new SparkDescriptor(_template)
            {
                Namespace = String.Join(".", new[] {GetType().Name, "Views", "Home"}),
                ViewModel = typeof (ProductModel)
            };

            _template.Descriptor = _descriptor;

            _token = new SparkViewToken(_descriptor);
        }
Exemplo n.º 3
0
        protected override void beforeEach()
        {
            _call       = ActionCall.For <SampleEndpoint>(e => e.Get(new SampleInput()));
            _descriptor = newDescriptor();

            _token = new SparkViewToken(_call, _descriptor, "Sample", "Sample");
            _token.Descriptors.Add(_descriptor);

            _views = new ViewBag(new List <IViewToken> {
                _token
            });

            MockFor <ISparkDescriptorVisitorRegistry>()
            .Expect(r => r.VisitorsFor(Arg <ActionCall> .Is.NotNull))
            .Return(new List <ISparkDescriptorVisitor>());
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            var root = AppDomain.CurrentDomain.BaseDirectory;

            _template = new Template(Path.Combine(root, "Views", "Home", "Home.spark"), root, FubuSparkConstants.HostOrigin);

            _descriptor = new ViewDescriptor(_template)
            {
                Namespace = String.Join(".", new[] { GetType().Name, "Views", "Home" }),
                ViewModel = typeof(ProductModel)
            };

            _template.Descriptor = _descriptor;

            _token = new SparkViewToken(_descriptor);
        }