Created
November 27, 2012 20:38
-
-
Save JefClaes/4156855 to your computer and use it in GitHub Desktop.
Generic FlatFileReader draft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace TestReader | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var reader = new GenericReader<Header, Data, Trailer> (); | |
var composite = reader.Read(); | |
Console.WriteLine(composite.Data.SomeProperty); | |
Console.ReadLine(); | |
} | |
} | |
public class GenericReader<THeader, TData, TTrailer> | |
where THeader : new() | |
where TData : new() | |
where TTrailer : new() | |
{ | |
public GenericComposite<THeader, TData, TTrailer> Read() | |
{ | |
var composite = new GenericComposite<THeader, TData, TTrailer>(); | |
composite.Header = new THeader(); | |
composite.Data = new TData(); | |
composite.Trailer = new TTrailer(); | |
return composite; | |
} | |
} | |
public class GenericComposite<THeader, TData, TTrailer> | |
{ | |
public THeader Header { get; set; } | |
public TData Data { get; set; } | |
public TTrailer Trailer { get; set; } | |
} | |
public class Header { | |
public string SomeProperty { get { return "SomeProperty"; } } | |
} | |
public class Data { | |
public string SomeProperty { get { return "SomeProperty"; } } | |
} | |
public class Trailer { | |
public string SomeProperty { get { return "SomeProperty"; } } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment