Skip to content

Instantly share code, notes, and snippets.

View lbargaoanu's full-sized avatar

Lucian Bargaoanu lbargaoanu

View GitHub Profile
static void Main(string[] args)
{
// Setup Mapper config
var config = new MapperConfiguration(c =>
{
c.DisableConstructorMapping();
c.CreateMap<RoleDTO, Role>();
c.CreateMap<UserDTO, User>()
static void Main(string[] args)
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<IBaseUserDto, IBaseUserEntity>()
.ForMember(d=>d.Name, opt => opt.Ignore());
cfg.CreateMap(typeof(BaseUserDto<>), typeof(BaseUserEntity<>));
cfg.CreateMap(typeof(ConcreteUserDto), typeof(ConcreteUserEntity))
Result StackTrace:
at System.Collections.Generic.SortedSet`1..ctor(IEnumerable`1 collection, IComparer`1 comparer)
at NuGet.Commands.UnresolvedMessages.<GetSourceInfoForIdAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Commands.UnresolvedMessages.<GetSourceInfosForIdAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
void Main()
{
DirectoryLocker.Create(@"C:\X");
DirectoryLocker.Create(@"C:\X");
}
public static class DirectoryLocker
{
private static ConcurrentDictionary<string, FileStream> _lockFiles = new ConcurrentDictionary<string, FileStream>();
static void Main(string[] args)
{
var config = new MapperConfiguration(cfg =>
{
//cfg.CreateMissingTypeMaps = false;
cfg.CreateMap<DTO_Object, EntityClass>().ForMember(s => s.DynamicFields,
o => o.MapFrom(s => s.DynamicFields.Select(m => m.Id)));
});
config.AssertConfigurationIsValid();
var mapper = config.CreateMapper();
static void Main()
{
Mapper.Initialize(cfg=>
{
cfg.CreateMap<Player, PlayerDto>()
.ForMember(d=>d.TeamIds, o=>o.MapFrom(s=>s.Teams.Select(t=>t.Id).ToList()))
.ForMember(d=>d.FullName, o=>o.MapFrom(s=>s.Name + " " +s.LastName));
});
Mapper.AssertConfigurationIsValid();
using(var connection = new SQLiteConnection("data source=test"))
var source = @"C:\Users\lucian.bargaoanu\AppData\Local\Packages\Microsoft.WindowsFeedbackHub_8wekyb3d8bbwe\LocalState\{3e013fe7-2abf-493f-9d14-8c96bd350762}.txt";
var afterBackSlashIndex = source.LastIndexOf('\\') + 1;
var s = new StringBuilder(source)
.Remove(afterBackSlashIndex, source.Length - afterBackSlashIndex)
.Replace('\\', '/');
s.ToString().Dump();
namespace Source
{
public class Instance
{
public Type Type { get; set; }
public object Definition { get; set; }
}
public sealed class Class : Instance
{
static void Main(string[] args)
{
int Count = 20;
var sum = 0.0;
for(int i=0;i<Count;i++){
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Entity1, EntityDTO1>().ReverseMap();
cfg.CreateMap<Entity2, EntityDTO2>().ReverseMap();
cfg.CreateMap<Entity3, EntityDTO3>().ReverseMap();
static void Main(string[] args)
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Library, LibraryDto>();
});
using(var context = new TestContext())
{
context.Libraries.ProjectTo<LibraryDto>().Dump();