-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add feature to intercept property binding (#20)
Add a functionally to intercept the property bind and convert it to primitive value or do something else.
- Loading branch information
1 parent
3ffaba7
commit 45f741f
Showing
48 changed files
with
1,343 additions
and
374 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Spinner.Cache; | ||
using Spinner.Parsers; | ||
using Spinner.Test.Helper.Parses; | ||
using Xunit; | ||
|
||
namespace Spinner.Test.Cache | ||
{ | ||
public class ParserTypeCacheTest | ||
{ | ||
[Fact] | ||
public void TryGet_WhenCalled_ShoudReturnParsedTypeFromCache() | ||
{ | ||
// Arrange | ||
const string key = "key"; | ||
ITypeParse parser = new CacheParser(); | ||
|
||
ParserTypeCache.Add(key, parser); | ||
// Act | ||
var typeCached = ParserTypeCache.TryGet(key, out var typeInCache); | ||
|
||
// Assert | ||
Assert.True(typeCached); | ||
Assert.IsType<CacheParser>(typeInCache); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ public static ConstructorInfo[] GetConstructors() | |
return Type.GetConstructors(); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Spinner.Parsers; | ||
|
||
namespace Spinner.Test.Helper.Parses | ||
{ | ||
internal sealed class CacheParser : ITypeParse | ||
{ | ||
public object Parser(object obj) | ||
{ | ||
return obj; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Spinner.Parsers; | ||
using System.Globalization; | ||
|
||
namespace Spinner.Test.Helper.Parses | ||
{ | ||
internal sealed class DecimalParser : ITypeParse | ||
{ | ||
public object Parser(object obj) | ||
{ | ||
string value = obj.ToString().Insert(2, "."); | ||
return decimal.Parse(value, new CultureInfo("en-US")); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Spinner.Attribute; | ||
using System; | ||
|
||
namespace Spinner.Test.Models | ||
{ | ||
[ObjectMapper(length: 4)] | ||
internal struct NothingDecimal : IEquatable<NothingDecimal> | ||
{ | ||
public NothingDecimal(string value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
[WriteProperty(length: 4, order: 0, paddingChar: ' ')] | ||
public string Value { get; set; } | ||
|
||
public bool Equals(NothingDecimal other) | ||
{ | ||
return Value == other.Value; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(Value); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return obj is NothingDecimal nothingDecimal && Equals(nothingDecimal); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Spinner.Attribute; | ||
using Spinner.Test.Helper.Parses; | ||
using System; | ||
|
||
namespace Spinner.Test.Models | ||
{ | ||
[ObjectMapper(length: 4)] | ||
internal sealed class NothingDecimalReader : IEquatable<NothingDecimalReader> | ||
{ | ||
[ReadProperty(start: 0, length: 4, type: typeof(DecimalParser))] | ||
public decimal Value { get; set; } | ||
|
||
public bool Equals(NothingDecimalReader other) | ||
{ | ||
return Value == other.Value; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(Value); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return obj is NothingDecimalReader nothingDecimalReader && Equals(nothingDecimalReader); | ||
} | ||
} | ||
} |
Oops, something went wrong.