Permalink
Browse files

fixes issue 2: FileHelper now doesn't blow up when using dynamic clas…

…s creation
  • Loading branch information...
1 parent 7cc19b8 commit 71d3e16171f7627659c210b1bbca2b8530a27613 unknown committed Apr 8, 2010
@@ -36,7 +36,7 @@ public void Write(object t)
/// <param name="errorMode">The error mode.</param>
public FileEngine OnError(ErrorMode errorMode)
{
- engine.ErrorMode = errorMode;
+ engine.ErrorManager.ErrorMode = errorMode;
return this;
}
@@ -75,15 +75,15 @@ private static string NormalizeFilename(string filename)
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);
}
- /// <summary>
- /// Gets or sets the options.
- /// </summary>
- /// <value>The options.</value>
- public RecordOptions Options
- {
- get { return engine.Options; }
- set { engine.Options = value; }
- }
+ ///// <summary>
+ ///// Gets or sets the options.
+ ///// </summary>
+ ///// <value>The options.</value>
+ //public RecordOptions Options
+ //{
+ // get { return engine.RecordType.; }
+ // set { engine.Options = value; }
+ //}
/// <summary>
/// Gets or sets the footer text.
@@ -32,6 +32,9 @@ protected override IEnumerable<Row> DecorateEnumerableForExecution(IOperation op
{
Error(e, "Failed to execute operation {0}", operation);
threadedEnumerator.MarkAsFinished();
+#if DEBUG
+ throw e;
+#endif
}
finally
{
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DC42946E-5972-411C-A061-F2932E49C31F}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -57,7 +57,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedLibs\Boo.Lang.dll</HintPath>
</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>
<HintPath>..\SharedLibs\FileHelpers.dll</HintPath>
</Reference>
@@ -64,7 +64,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedLibs\Boo.Lang.Parser.dll</HintPath>
</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>
<HintPath>..\SharedLibs\FileHelpers.dll</HintPath>
</Reference>
@@ -167,6 +167,8 @@
<Compile Include="SingleThreadedPipelineExecuterTest.cs" />
<Compile Include="SqlBatchOperationFixture.cs" />
<Compile Include="SqlBulkInsertOperationFixture.cs" />
+ <Compile Include="UsingDAL\ImportUsersFromFileDynamic.cs" />
+ <Compile Include="UsingDAL\ReadUsersFromFileDynamic.cs" />
<Compile Include="UsingDAL\ExportUsersToFile.cs" />
<Compile Include="UsingDAL\GetAllUsers.cs" />
<Compile Include="UsingDAL\ImportUsersFromFile.cs" />
@@ -2,11 +2,11 @@ namespace Rhino.Etl.Tests.UsingDAL
{
using Core;
- public class ImportUsersFromFile : EtlProcess
+ public class ImportUsersFromFileDynamic : EtlProcess
{
protected override void Initialize()
{
- Register(new ReadUsersFromFile());
+ Register(new ReadUsersFromFileDynamic());
Register(new SaveToDal());
}
}
@@ -0,0 +1,13 @@
+namespace Rhino.Etl.Tests.UsingDAL
+{
+ using Core;
+
+ public class ImportUsersFromFile : EtlProcess
@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());
+ }
+ }
+}
@@ -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);
+ }
+ }
+ }
+}
@@ -36,5 +36,16 @@ public void CanReadFromFileToDAL()
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);
+ }
}
}
View
Binary file not shown.

0 comments on commit 71d3e16

Please sign in to comment.