Skip to content

Commit

Permalink
Merge branch 'release/first-commit'
Browse files Browse the repository at this point in the history
  • Loading branch information
chyccs committed Mar 12, 2021
2 parents 5f78e96 + 5c66a2a commit 33cee41
Show file tree
Hide file tree
Showing 21 changed files with 1,067 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ChoiSerializer/ChoiSerializer.sln
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 ChoiSerializer/ChoiSerializer/Annotation/MappedForLength.cs
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; }
}
}
}
34 changes: 34 additions & 0 deletions ChoiSerializer/ChoiSerializer/Annotation/MappedForSize.cs
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; }
}
}
}
62 changes: 62 additions & 0 deletions ChoiSerializer/ChoiSerializer/Annotation/MappedForType.cs
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);
//}
}
}
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;
}
}
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
{
}
}
24 changes: 24 additions & 0 deletions ChoiSerializer/ChoiSerializer/ChoiFormatter.cs
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();
}
}
}
9 changes: 9 additions & 0 deletions ChoiSerializer/ChoiSerializer/ChoiSerializer.csproj
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>
Loading

0 comments on commit 33cee41

Please sign in to comment.