-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,067 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.852 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChoiSerializer", "ChoiSerializer\ChoiSerializer.csproj", "{5090CEE5-6850-4D61-8F6B-5875302F97E1}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "Example\Example.csproj", "{E4D665E2-DEC0-46A4-B8D4-70E907A1E358}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5090CEE5-6850-4D61-8F6B-5875302F97E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5090CEE5-6850-4D61-8F6B-5875302F97E1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5090CEE5-6850-4D61-8F6B-5875302F97E1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5090CEE5-6850-4D61-8F6B-5875302F97E1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E4D665E2-DEC0-46A4-B8D4-70E907A1E358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E4D665E2-DEC0-46A4-B8D4-70E907A1E358}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E4D665E2-DEC0-46A4-B8D4-70E907A1E358}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E4D665E2-DEC0-46A4-B8D4-70E907A1E358}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {DFCFE196-88F3-4F95-AA16-BE8CA71D1F6A} | ||
EndGlobalSection | ||
EndGlobal |
34 changes: 34 additions & 0 deletions
34
ChoiSerializer/ChoiSerializer/Annotation/MappedForLength.cs
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,34 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace ChoiSerializer.Annotation | ||
{ | ||
public delegate int ValueToLengthConvertDelegate(object value); | ||
|
||
public class MappedForLength : SerializerBaseAttribute | ||
{ | ||
public string Target { get; set; } | ||
|
||
public ValueToLengthConvertDelegate ValueConverterDelegate { get; set; } | ||
|
||
private string valueConverter = ""; | ||
|
||
public string ValueConverter | ||
{ | ||
set | ||
{ | ||
valueConverter = value; | ||
var arguments = value.Split('.'); | ||
var assembly = Assembly.GetEntryAssembly(); | ||
Type callerType = null; | ||
foreach (var type in assembly.ExportedTypes) | ||
{ | ||
if (type.Name.Equals(arguments[0])) | ||
callerType = type; | ||
} | ||
ValueConverterDelegate = (ValueToLengthConvertDelegate)Delegate.CreateDelegate(typeof(ValueToLengthConvertDelegate), callerType, arguments[1]); | ||
} | ||
get { return valueConverter; } | ||
} | ||
} | ||
} |
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,34 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace ChoiSerializer.Annotation | ||
{ | ||
public delegate int ValueToSizeConvertDelegate(object value); | ||
|
||
public class MappedForSize : SerializerBaseAttribute | ||
{ | ||
public string Target { get; set; } | ||
|
||
public ValueToSizeConvertDelegate ValueConverterDelegate { get; set; } | ||
|
||
private string valueConverter = ""; | ||
|
||
public string ValueConverter | ||
{ | ||
set | ||
{ | ||
valueConverter = value; | ||
var arguments = value.Split('.'); | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
Type callerType = null; | ||
foreach (var type in assembly.ExportedTypes) | ||
{ | ||
if (type.Name.Equals(arguments[0])) | ||
callerType = type; | ||
} | ||
ValueConverterDelegate = (ValueToSizeConvertDelegate)Delegate.CreateDelegate(typeof(ValueToSizeConvertDelegate), callerType, arguments[1]); | ||
} | ||
get { return valueConverter; } | ||
} | ||
} | ||
} |
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,62 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace ChoiSerializer.Annotation | ||
{ | ||
public delegate Type ValueToTypeConvertDelegate(object value); | ||
|
||
public class MappedForType : SerializerBaseAttribute | ||
{ | ||
public string Target { get; set; } | ||
|
||
public ValueToTypeConvertDelegate ValueConverterDelegate { get; set; } | ||
|
||
private string valueConverter = ""; | ||
|
||
public string ValueConverter | ||
{ | ||
set | ||
{ | ||
valueConverter = value; | ||
var arguments = value.Split('.'); | ||
var assembly = Assembly.GetEntryAssembly(); | ||
Type callerType = null; | ||
foreach (var type in assembly.ExportedTypes) | ||
{ | ||
if (type.Name.Equals(arguments[0])) | ||
callerType = type; | ||
} | ||
ValueConverterDelegate = (ValueToTypeConvertDelegate)Delegate.CreateDelegate(typeof(ValueToTypeConvertDelegate), callerType, arguments[1]); | ||
} | ||
get { return valueConverter; } | ||
} | ||
|
||
//private int GetLengthOfTarget(string valueConverter, object fieldValue) | ||
//{ | ||
// var arguments = valueConverter.Split('.'); | ||
// var assembly = Assembly.GetCallingAssembly(); | ||
// Type callerType = null; | ||
// foreach (var type in assembly.ExportedTypes) | ||
// { | ||
// if (type.Name.Equals(arguments[0])) | ||
// callerType = type; | ||
// } | ||
// ValueToLengthConvertDelegate valueConverterDelegate = (ValueToLengthConvertDelegate)Delegate.CreateDelegate(typeof(ValueToLengthConvertDelegate), callerType, arguments[1]); | ||
// return valueConverterDelegate(fieldValue); | ||
//} | ||
|
||
//private Type GetTypeOfTarget(string valueConverter, object fieldValue) | ||
//{ | ||
// var arguments = valueConverter.Split('.'); | ||
// var assembly = Assembly.GetEntryAssembly(); | ||
// Type callerType = null; | ||
// foreach (var type in assembly.ExportedTypes) | ||
// { | ||
// if (type.Name.Equals(arguments[0])) | ||
// callerType = type; | ||
// } | ||
// ValueToTypeConvertDelegate valueConverterDelegate = (ValueToTypeConvertDelegate)Delegate.CreateDelegate(typeof(ValueToTypeConvertDelegate), callerType, arguments[1]); | ||
// return valueConverterDelegate(fieldValue); | ||
//} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
ChoiSerializer/ChoiSerializer/Annotation/SerializableCulumn.cs
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,9 @@ | ||
namespace ChoiSerializer.Annotation | ||
{ | ||
public class SerializableCulumn : SerializerBaseAttribute | ||
{ | ||
public int Index { get; set; } | ||
|
||
public int Length { get; set; } = 0; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
ChoiSerializer/ChoiSerializer/Annotation/SerializerBaseAttribute.cs
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,9 @@ | ||
using System; | ||
|
||
namespace ChoiSerializer.Annotation | ||
{ | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public class SerializerBaseAttribute : Attribute | ||
{ | ||
} | ||
} |
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,24 @@ | ||
using System.IO; | ||
using System.Runtime.Serialization; | ||
|
||
namespace ChoiSerializer | ||
{ | ||
public class ChoiFormatter : IFormatter | ||
{ | ||
public SerializationBinder Binder { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } | ||
|
||
public StreamingContext Context { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } | ||
|
||
public ISurrogateSelector SurrogateSelector { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } | ||
|
||
public object Deserialize(Stream serializationStream) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public void Serialize(Stream serializationStream, object graph) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} | ||
} |
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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<ApplicationIcon /> | ||
<Win32Resource /> | ||
</PropertyGroup> | ||
|
||
</Project> |
Oops, something went wrong.