Failing test

Jul 1, 2010 at 8:02 AM

Hello

Value injecter seems like exact mapper that i need but i encountered one problem, here is small test that i think should pass, but it dosen't

Snippet

public class Boo
{
public string Id { getset; }
public int Boo1Id { getset; }
public Boo Boo1 { getset; }
}

public class FlatBoo
{
public int Boo1Id { getset; }
}

[Test]
public void AnotherUnflatTest()
{
var flat = new FlatBoo { Boo1Id = 5 };
var boo = new Boo();

boo.InjectFrom<UnflatLoopValueInjection>(flat);

boo.Boo1Id.IsEqualTo(5);
boo.Boo1.IsEqualTo(null);
boo.Boo1.Id.IsEqualTo(null);
}

value injecter initializes Boo1 inside boo. can value injecter check for type before unflatting?
Coordinator
Jul 1, 2010 at 10:04 AM
Edited Jul 1, 2010 at 10:05 AM
Hello
I know there are some issues with the unflattening but we are going to change it's behaviour shortly,
the main problem is when you have something like this:
one side:
FooBarName
and on the other side
Foo.BarName
Foo.Bar.Name
FooBar.Name

what I think to do now is to inject the value in all 3 props

also the UnflatLoopValueInjection is gonna inject the values from source to target with same type

if you need from one type to another (e.g. string to int) extend the UnflatLoopValueInjection<T1,T2>
Cheers,

Omu,
Jul 1, 2010 at 10:40 AM

Hi again,

what you think about checking types before unflatting, i mean if u have

one side:

int FooBarName

other side:

int Foo.BarName
string Foo.Bar.Name
string FooBar.Name

then only inject value to int Foo.BarName (ofcorse if no UnflatLoopValueInjection<T1,T2> specified). and both Foo.Bar() and FooBar() should stay null

Another proposal would be to let user specify in what order unflatting works and should it inject to all mathed places or only to first?

e.g.  if we have FooBarName

thne user could specify should search order be liek:

Foo.Bar.Name, Foo.BarName, FooBarName

or vice versa:

FooBarName, Foo.BarName, Foo.Bar.Name

Coordinator
Jul 1, 2010 at 10:46 AM

well, yes that's how is working, the types are being checked to be the same with the UnflatLoopValueInjection and to be T1 and T2 with the UnflatLoopValueInjection<T1,T2>

and probably the user is going to specify (by using a different injection or something like that)

Cheers,

Omu

Jul 1, 2010 at 11:42 AM
o wrote:

well, yes that's how is working, ..

currently it checks types only in the end, look at my test:

one side:

int Boo1Id

other side

string Id

int Boo1Id

Boo Boo1

 

and after injecting :

var flat = new FlatBoo { Boo1Id = 5 };
var boo = new Boo();

boo.InjectFrom<UnflatLoopValueInjection>(flat);

boo has this values:

{
Id = null Boo1Id = 0 Boo1 = {
Id = null
Boo1Id = 0
Boo1 = null
}
}

it instantiates boo.Boo1 and dont check that boo.Boo1.Id is of type string and Boo1Id is int. if it would check for type then boo would be
 {
   Id = null
Boo1Id = 5
Boo1 = null
}

 

Coordinator
Jul 1, 2010 at 12:34 PM
Edited Jul 1, 2010 at 12:39 PM

yes, I now this :) I was saying about setting the value at the end, anyways I'm going to change this really soon

Jul 1, 2010 at 2:45 PM

this would be great, until new release i will probably change some prop names so that they wont collapse, dirty workaround for now.

Coordinator
Jul 5, 2010 at 2:58 PM
Edited Jul 5, 2010 at 2:59 PM

ok :), you can stop doing workarounds and download the new release 1.9.3, now everything is 100% ok,

when flatting from
Foo.Bar.Name
FooBar.Name
FooBarName
to
FooBarName
the value of the first one (Foo.Bar.Name) will be taken and set into the FooBarName

and when unflatting from

FooBarName
to
Foo.Bar.Name
FooBar.Name
FooBarName

the value of the FooBarName will be set to all targets

that's the default behaviour but now it is very to easy to create your own flatloopinjection does the stuff different
I actually don't think than anybody will ever have this need or even this situation but still, it is possible 

also, now you can flat/unflat from

fooBar32_helloworld to foo.Bar32._hello.world

no requirement for PascalCase anymore

cya

Omu

Jul 5, 2010 at 3:15 PM

thats cool, i will defenetly try out new valueinjecter.

thx for such quick response to my problem, dont know if this was only my problem or this new features was on their way erlier, anyway thx again for such quick "feature adding" :)

Coordinator
Jul 5, 2010 at 3:26 PM
it was on their way but you made it go faster :)
Jul 14, 2010 at 3:57 PM

just tried new value injecter, it's working great !