示例#1
0
            public IViewFile GetViewSource(string path)
            {
                var lang = ParseLanguagePath(path);

                if (lang == null)
                {
                    return(_viewFolder.GetViewSource(path));
                }

                var detected = PathVariations(lang).First(x => _viewFolder.HasView(x));

                return(_viewFolder.GetViewSource(detected ?? lang.Path));
            }
示例#2
0
 private static LocateResult Result(IViewFolder viewFolder, string path)
 {
     return(new LocateResult
     {
         Path = path,
         ViewFile = viewFolder.GetViewSource(path)
     });
 }
 private static LocateResult Result(IViewFolder viewFolder, string path)
 {
     return new LocateResult
     {
         Path = path,
         ViewFile = viewFolder.GetViewSource(path)
     };
 }
        private static string ReadContents(IViewFolder adapter, string path)
        {
            Assert.That(adapter.HasView(path), Is.True);
            var source = adapter.GetViewSource(path);
            var stream = source.OpenViewStream();
            var reader = new StreamReader(stream);

            return(reader.ReadToEnd());
        }
 static string ReadToEnd(IViewFolder viewFolder, string path)
 {
     using (var stream = viewFolder.GetViewSource(path).OpenViewStream())
     {
         using (var reader = new StreamReader(stream))
         {
             return(reader.ReadToEnd());
         }
     }
 }
示例#6
0
        public IViewFile GetViewSource(string path)
        {
            var adjusted = Adjust(path);

            if (adjusted == null)
            {
                throw new FileNotFoundException("File not found", path);
            }
            return(_viewFolder.GetViewSource(adjusted));
        }
示例#7
0
        public override IEnumerable<Binding> GetBindings(IViewFolder viewFolder)
        {
            if (viewFolder.HasView("bindings.xml") == false)
                return new Binding[0];

            var file = viewFolder.GetViewSource("bindings.xml");
            using (var stream = file.OpenViewStream())
            {
                using (var reader = new StreamReader(stream))
                {
                    return LoadStandardMarkup(reader);
                }
            }
        }
示例#8
0
        public override IEnumerable <Binding> GetBindings(IViewFolder viewFolder)
        {
            if (viewFolder.HasView("bindings.xml") == false)
            {
                return(new Binding[0]);
            }

            var file = viewFolder.GetViewSource("bindings.xml");

            using (var stream = file.OpenViewStream())
            {
                using (var reader = new StreamReader(stream))
                {
                    return(LoadStandardMarkup(reader));
                }
            }
        }
示例#9
0
        protected SourceContext CreateSourceContext(string viewPath, IViewFolder viewFolder)
        {
            var viewSource = viewFolder.GetViewSource(viewPath);

            if (viewSource == null)
                throw new FileNotFoundException("View file not found", viewPath);

            using (var stream = viewSource.OpenViewStream())
            {
                string fileName = viewPath;
                if (stream is FileStream)
                    fileName = ((FileStream) stream).Name;

                using (TextReader reader = new StreamReader(stream))
                {
                    return new SourceContext(reader.ReadToEnd(), viewSource.LastModified, fileName);
                }
            }
        }
        public static SourceContext CreateSourceContext(string viewPath, IViewFolder viewFolder)
        {
            SourceContext context;
            IViewFile     viewSource = viewFolder.GetViewSource(viewPath);

            if (viewSource == null)
            {
                throw new FileNotFoundException("View file not found", viewPath);
            }
            using (Stream stream = viewSource.OpenViewStream())
            {
                string fileName = viewPath;
                if (stream is FileStream)
                {
                    fileName = ((FileStream)stream).Name;
                }
                using (TextReader reader = new StreamReader(stream))
                {
                    context = new SourceContext(reader.ReadToEnd(), viewSource.LastModified, fileName);
                }
            }
            return(context);
        }
示例#11
0
 private static string ReadContents(IViewFolder adapter, string path)
 {
     Assert.That(adapter.HasView(path), Is.True);
     var source = adapter.GetViewSource(path);
     var stream = source.OpenViewStream();
     var reader = new StreamReader(stream);
     return reader.ReadToEnd();
 }
 static string ReadToEnd(IViewFolder viewFolder, string path)
 {
     using (var stream = viewFolder.GetViewSource(path).OpenViewStream())
     {
         using (var reader = new StreamReader(stream))
         {
             return reader.ReadToEnd();
         }
     }
 }
 public IViewFile GetViewSource(string path)
 {
     return(_base.GetViewSource(Convert(path)));
 }