Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/SafeMapper/v15/sqlite3/storage.ide
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

using AutoMapper;

public class AutoMapperDateTimeTypeConverter : TypeConverter<string, DateTime>
public class AutoMapperDateTimeTypeConverter : ITypeConverter<string, DateTime>
{
protected override DateTime ConvertCore(string source)
public DateTime Convert(string source, DateTime destination, ResolutionContext context)
{
return System.Convert.ToDateTime(source);
}
Expand Down
40 changes: 23 additions & 17 deletions SafeMapper.Profiler/ProfileConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public override void Execute()
*/
}

private void ProfileConvert<TSource, TDestination>(TSource[] input, CultureInfo formatProvider, Action<int> compareFunc)
private void ProfileConvert<TSource, TDestination>(TSource[] input, CultureInfo formatProvider,
Action<int> compareFunc)
{
var safeMapper = SafeMap.GetConverter<TSource, TDestination>();
var sourceType = typeof(TSource);
Expand All @@ -151,26 +152,31 @@ private void ProfileConvert<TSource, TDestination>(TSource[] input, CultureInfo
var emitMapper = ObjectMapperManager.DefaultInstance.GetMapper<TSource, TDestination>();

//var fFastMapper = fFastMap.MapperFor<TSource, TDestination>();

if (typeof(TDestination) != typeof(string))
AutoMapper.Mapper.Initialize(cfg =>
{
if (typeof(TDestination) == typeof(DateTime) && typeof(TSource) == typeof(string))
{
AutoMapper.Mapper.CreateMap(typeof(TSource), typeof(TDestination)).ConvertUsing(typeof(AutoMapperDateTimeTypeConverter));
}
else
if (typeof(TDestination) != typeof(string))
{
AutoMapper.Mapper.CreateMap<TSource, TDestination>();
if (typeof(TDestination) == typeof(DateTime) && typeof(TSource) == typeof(string))
{
cfg.CreateMap(typeof(TSource), typeof(TDestination))
.ConvertUsing(typeof(AutoMapperDateTimeTypeConverter));
}
else
{
cfg.CreateMap<TSource, TDestination>();
}
}
}

AutoMapper.Mapper.CreateMap<Address, AddressDto>();
AutoMapper.Mapper.CreateMap<AddressDto, Address>();
AutoMapper.Mapper.CreateMap<BenchSource.Int1, BenchDestination.Int1>();
AutoMapper.Mapper.CreateMap<BenchSource.Int2, BenchDestination.Int2>();
cfg.CreateMap<Address, AddressDto>();
cfg.CreateMap<AddressDto, Address>();
cfg.CreateMap<BenchSource.Int1, BenchDestination.Int1>();
cfg.CreateMap<BenchSource.Int2, BenchDestination.Int2>();
});


this.WriteHeader(string.Format("Profiling convert from {0} to {1}, {2} iterations", typeof(TSource).Name,
typeof(TDestination).Name, input.Length));

this.WriteHeader(string.Format("Profiling convert from {0} to {1}, {2} iterations", typeof(TSource).Name, typeof(TDestination).Name, input.Length));

if (compareFunc != null)
{
this.AddResult("Native", compareFunc);
Expand All @@ -188,7 +194,7 @@ private void ProfileConvert<TSource, TDestination>(TSource[] input, CultureInfo
this.AddResult("ValueInjecter",
i =>
{
var result = new TDestination();
var result = new TDestination();
result.InjectFrom(input[i]);
});*/

Expand Down
23 changes: 13 additions & 10 deletions SafeMapper.Profiler/ProfileInvalidConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,23 @@ public override void Execute()
{
}
};

if (typeof(TDestination) != typeof(string))
AutoMapper.Mapper.Initialize(cfg =>
{
if (typeof(TDestination) == typeof(DateTime) && typeof(TSource) == typeof(string))
{
AutoMapper.Mapper.CreateMap(typeof(TSource), typeof(TDestination)).ConvertUsing(typeof(AutoMapperDateTimeTypeConverter));
}
else
if (typeof(TDestination) != typeof(string))
{
AutoMapper.Mapper.CreateMap<TSource, TDestination>();
if (typeof(TDestination) == typeof(DateTime) && typeof(TSource) == typeof(string))
{
cfg.CreateMap(typeof(TSource), typeof(TDestination))
.ConvertUsing(typeof(AutoMapperDateTimeTypeConverter));
}
else
{
cfg.CreateMap<TSource, TDestination>();
}
}
}

AutoMapper.Mapper.CreateMap<Address, AddressDto>();
cfg.CreateMap<Address, AddressDto>();
});

this.WriteHeader(string.Format("Profiling convert from {0} to {1}, {2} iterations", typeof(TSource).Name, typeof(TDestination).Name, input.Length));

Expand Down
35 changes: 35 additions & 0 deletions SafeMapper.Profiler/SafeMapper.Profiler.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<AssemblyName>SafeMapper.Profiler</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>SafeMapper.Profiler</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SafeMapper.Tests.Model\SafeMapper.Tests.Model.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SafeMapper\SafeMapper.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<PackageReference Include="AutoMapper" Version="6.1.1" />
<PackageReference Include="EmitMapper" Version="1.0.0" />
<PackageReference Include="fasterflect" Version="2.1.3" />
<PackageReference Include="FastMapper" Version="1.2.0" />
<PackageReference Include="fFastMapper" Version="0.5.3" />
<PackageReference Include="ServiceStack.Text" Version="4.5.12" />
<PackageReference Include="UniversalTypeConverter" Version="1.0.4" />
<PackageReference Include="ValueInjecter" Version="3.1.1.3" />
<Reference Include="System.Web" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
22 changes: 0 additions & 22 deletions SafeMapper.Profiler/SafeMapper.Profiler.xproj

This file was deleted.

31 changes: 0 additions & 31 deletions SafeMapper.Profiler/project.json

This file was deleted.

64 changes: 64 additions & 0 deletions SafeMapper.StrongName/SafeMapper.StrongName.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>3.0.0</VersionPrefix>
<TargetFrameworks>net45;net451;netstandard2.0</TargetFrameworks>
<AssemblyName>SafeMapper.StrongName</AssemblyName>
<AssemblyOriginatorKeyFile>../SafeMapper.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>SafeMapper.StrongName</PackageId>
<PackageTags>Fast;Object;Mapper;Converter</PackageTags>
<PackageReleaseNotes>https://github.com/unger/SafeMapper</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/unger/SafeMapper</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/unger/SafeMapper</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/unger/SafeMapper</RepositoryUrl>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>

<ItemGroup>
<Compile Remove="..\SafeMapper\obj\**\*" />
<Compile Include="..\SafeMapper\**\*.cs" Exclude="..\SafeMapper\obj\**\*;bin\**;obj\**;**\*.xproj;packages\**" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<DefineConstants>$(DefineConstants);ASYNC</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);COREFX</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.4.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
</ItemGroup>
</Project>
21 changes: 0 additions & 21 deletions SafeMapper.StrongName/SafeMapper.StrongName.xproj

This file was deleted.

80 changes: 0 additions & 80 deletions SafeMapper.StrongName/project.json

This file was deleted.

Loading