Skip to content

Commit

Permalink
fixes issue 2: FileHelper now doesn't blow up when using dynamic clas…
Browse files Browse the repository at this point in the history
…s creation
  • Loading branch information
unknown committed Apr 8, 2010
1 parent 7cc19b8 commit 71d3e16
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Rhino.Etl.Core/Files/FileEngine.cs
Expand Up @@ -36,7 +36,7 @@ public void Write(object t)
/// <param name="errorMode">The error mode.</param> /// <param name="errorMode">The error mode.</param>
public FileEngine OnError(ErrorMode errorMode) public FileEngine OnError(ErrorMode errorMode)
{ {
engine.ErrorMode = errorMode; engine.ErrorManager.ErrorMode = errorMode;
return this; return this;
} }


Expand Down
18 changes: 9 additions & 9 deletions Rhino.Etl.Core/Files/FluentFile.cs
Expand Up @@ -75,15 +75,15 @@ private static string NormalizeFilename(string filename)
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename); return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);
} }


/// <summary> ///// <summary>
/// Gets or sets the options. ///// Gets or sets the options.
/// </summary> ///// </summary>
/// <value>The options.</value> ///// <value>The options.</value>
public RecordOptions Options //public RecordOptions Options
{ //{
get { return engine.Options; } // get { return engine.RecordType.; }
set { engine.Options = value; } // set { engine.Options = value; }
} //}


/// <summary> /// <summary>
/// Gets or sets the footer text. /// Gets or sets the footer text.
Expand Down
3 changes: 3 additions & 0 deletions Rhino.Etl.Core/Pipelines/ThreadPoolPipelineExecuter.cs
Expand Up @@ -32,6 +32,9 @@ protected override IEnumerable<Row> DecorateEnumerableForExecution(IOperation op
{ {
Error(e, "Failed to execute operation {0}", operation); Error(e, "Failed to execute operation {0}", operation);
threadedEnumerator.MarkAsFinished(); threadedEnumerator.MarkAsFinished();
#if DEBUG
throw e;
#endif
} }
finally finally
{ {
Expand Down
4 changes: 2 additions & 2 deletions Rhino.Etl.Core/Rhino.Etl.Core.csproj
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion> <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DC42946E-5972-411C-A061-F2932E49C31F}</ProjectGuid> <ProjectGuid>{DC42946E-5972-411C-A061-F2932E49C31F}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
Expand Down Expand Up @@ -57,7 +57,7 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedLibs\Boo.Lang.dll</HintPath> <HintPath>..\SharedLibs\Boo.Lang.dll</HintPath>
</Reference> </Reference>
<Reference Include="FileHelpers, Version=2.2.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657, processorArchitecture=MSIL"> <Reference Include="FileHelpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedLibs\FileHelpers.dll</HintPath> <HintPath>..\SharedLibs\FileHelpers.dll</HintPath>
</Reference> </Reference>
Expand Down
4 changes: 3 additions & 1 deletion Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
Expand Up @@ -64,7 +64,7 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedLibs\Boo.Lang.Parser.dll</HintPath> <HintPath>..\SharedLibs\Boo.Lang.Parser.dll</HintPath>
</Reference> </Reference>
<Reference Include="FileHelpers, Version=2.2.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657, processorArchitecture=MSIL"> <Reference Include="FileHelpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedLibs\FileHelpers.dll</HintPath> <HintPath>..\SharedLibs\FileHelpers.dll</HintPath>
</Reference> </Reference>
Expand Down Expand Up @@ -167,6 +167,8 @@
<Compile Include="SingleThreadedPipelineExecuterTest.cs" /> <Compile Include="SingleThreadedPipelineExecuterTest.cs" />
<Compile Include="SqlBatchOperationFixture.cs" /> <Compile Include="SqlBatchOperationFixture.cs" />
<Compile Include="SqlBulkInsertOperationFixture.cs" /> <Compile Include="SqlBulkInsertOperationFixture.cs" />
<Compile Include="UsingDAL\ImportUsersFromFileDynamic.cs" />
<Compile Include="UsingDAL\ReadUsersFromFileDynamic.cs" />
<Compile Include="UsingDAL\ExportUsersToFile.cs" /> <Compile Include="UsingDAL\ExportUsersToFile.cs" />
<Compile Include="UsingDAL\GetAllUsers.cs" /> <Compile Include="UsingDAL\GetAllUsers.cs" />
<Compile Include="UsingDAL\ImportUsersFromFile.cs" /> <Compile Include="UsingDAL\ImportUsersFromFile.cs" />
Expand Down
4 changes: 2 additions & 2 deletions Rhino.Etl.Tests/UsingDAL/ImportUsersFromFile.cs
Expand Up @@ -2,11 +2,11 @@ namespace Rhino.Etl.Tests.UsingDAL
{ {
using Core; using Core;


public class ImportUsersFromFile : EtlProcess public class ImportUsersFromFileDynamic : EtlProcess
{ {
protected override void Initialize() protected override void Initialize()
{ {
Register(new ReadUsersFromFile()); Register(new ReadUsersFromFileDynamic());
Register(new SaveToDal()); Register(new SaveToDal());
} }
} }
Expand Down
13 changes: 13 additions & 0 deletions Rhino.Etl.Tests/UsingDAL/ImportUsersFromFileDynamic.cs
@@ -0,0 +1,13 @@
namespace Rhino.Etl.Tests.UsingDAL
{
using Core;

public class ImportUsersFromFile : EtlProcess

This comment has been minimized.

Copy link
@hoffmanc

hoffmanc Apr 21, 2010

looks like i switched the files around by accident. one thing i do like about Java is enforcement of filename/classname consistency

{
protected override void Initialize()
{
Register(new ReadUsersFromFile());
Register(new SaveToDal());
}
}
}
38 changes: 38 additions & 0 deletions Rhino.Etl.Tests/UsingDAL/ReadUsersFromFileDynamic.cs
@@ -0,0 +1,38 @@
using System;
using FileHelpers;
using FileHelpers.RunTime;

namespace Rhino.Etl.Tests.UsingDAL
{
using System.Collections.Generic;
using Core;
using Rhino.Etl.Core.Files;
using Rhino.Etl.Core.Operations;
using System.Linq;

public class ReadUsersFromFileDynamic : AbstractOperation
{
private Type _tblClass;
public ReadUsersFromFileDynamic()
{
var userRecordClassBuilder = new DelimitedClassBuilder("UserRecord","\t");
userRecordClassBuilder.IgnoreFirstLines = 1;
userRecordClassBuilder.AddField("Id", typeof(Int32));
userRecordClassBuilder.AddField("Name", typeof(String));
userRecordClassBuilder.AddField("Email", typeof(String));
_tblClass = userRecordClassBuilder.CreateRecordClass();
}

public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
{
var file = new FileHelperEngine(_tblClass);
//var ary = new[] {"one", "two", "three"};
//var items = from a in ary select a;
var items = file.ReadFile("users.txt");
foreach (object obj in items)
{
yield return Row.FromObject(obj);
}
}
}
}
11 changes: 11 additions & 0 deletions Rhino.Etl.Tests/UsingDAL/UsingDALFixture.cs
Expand Up @@ -36,5 +36,16 @@ public void CanReadFromFileToDAL()


Assert.Equal(5, MySimpleDal.Users.Count); Assert.Equal(5, MySimpleDal.Users.Count);
} }

[Fact]
public void CanReadFromFileToDALDynamic() {
MySimpleDal.Users = new List<User>();
File.WriteAllText("users.txt", expected);

var import = new ImportUsersFromFileDynamic();
import.Execute();

Assert.Equal(5, MySimpleDal.Users.Count);
}
} }
} }
Binary file modified SharedLibs/FileHelpers.dll
Binary file not shown.

0 comments on commit 71d3e16

Please sign in to comment.