コード例 #1
0
ファイル: FakeViewEngine.cs プロジェクト: jmptrader/jessica
        public Action<Stream> RenderView(ViewLocation viewLocation, dynamic model)
        {
            if (viewLocation == null)
            {
                return stream => { };
            }

            return stream =>
            {
                var writer = new StreamWriter(stream);
                writer.Write(viewLocation.Contents.ReadToEnd());
                writer.Flush();
            };
        }
コード例 #2
0
ファイル: RazorViewEngine.cs プロジェクト: hoest/GnojEd
        /// <summary>
        /// RenderView method
        /// </summary>
        /// <param name="viewLocation">ViewLocation object</param>
        /// <param name="model">dynamic model object</param>
        /// <returns>Action object</returns>
        public Action<Stream> RenderView(ViewLocation viewLocation, dynamic model)
        {
            return stream => {
            this.ViewLocation = viewLocation;

            if (!this.Cache.ContainsKey(viewLocation.Location)) {
              string template = File.ReadAllText(viewLocation.Location);
              Razor.AddResolver(name => GetTemplate(name));
              Razor.CompileWithAnonymous(template, viewLocation.Location);
              this.Cache.Add(viewLocation.Location, DateTime.Now);
            }

            string result = Razor.Run(model, viewLocation.Location);

            var writer = new StreamWriter(stream);
            writer.Write(result);
            writer.Flush();
              };
        }
コード例 #3
0
 public Action<Stream> RenderView(ViewLocation viewLocation, dynamic model)
 {
     throw new NotImplementedException();
 }