Skip to content

Commit

Permalink
very minor tweak to FlatFileReader so you can pass in the encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Jun 30, 2010
1 parent f5f433a commit aff2eaa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FubuCore/Binding/FlatFileReader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Text;
using FubuCore.Util;
using Microsoft.Practices.ServiceLocation;

Expand All @@ -19,7 +20,7 @@ public void ReadFile(FlatFileRequest<T> request)
{
using (var stream = new FileStream(request.Filename, FileMode.Open, FileAccess.Read))
{
var reader = new StreamReader(stream);
var reader = new StreamReader(stream, request.Encoding);
var headers = reader.ReadLine();
if (headers.IsEmpty()) return;

Expand Down
7 changes: 7 additions & 0 deletions src/FubuCore/Binding/FlatFileRequest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using System;
using System.Text;

namespace FubuCore.Binding
{
public class FlatFileRequest<T>
{
public FlatFileRequest()
{
Encoding = Encoding.Default;
}

public Action<T> Callback { get; set; }
public Func<IRequestData, T> Finder { get; set; }
public string Filename { get; set; }
public string Concatenator { get; set; }
public Encoding Encoding { get; set; }
}
}
4 changes: 4 additions & 0 deletions src/FubuMVC.UI/Extensibility/IContentExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public interface IContentExtension<T> where T : class
IEnumerable<object> GetExtensions(IFubuPage<T> page);
}



public class LambdaExtension<T> : IContentExtension<T> where T : class
{
private readonly Func<IFubuPage<T>, object> _func;
Expand Down Expand Up @@ -52,6 +54,8 @@ public void Register<T>(IContentExtension<T> extension) where T : class
shelfFor<T>().Add(string.Empty, extension);
}

// Deep in the bowells of FubuMVC, this is the actual code that writes extensions
// into a FubuPage
private static void apply<T>(IEnumerable<IContentExtension<T>> extensions, IFubuPage<T> page) where T : class
{
var writer = page.ServiceLocator.GetInstance<IOutputWriter>();
Expand Down

0 comments on commit aff2eaa

Please sign in to comment.