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
public void Main() | |
{ | |
var config = new MapperConfiguration(cfg => | |
{ | |
cfg.CreateProjection<Product, ProductArticle>() | |
.ForMember(d => d.Price, o => o.MapFrom(source => source.Articles.Where(x => x.IsDefault && x.NationId == 1 && source.ECommercePublished).FirstOrDefault())); | |
cfg.CreateProjection<ProductArticle, ProductModel>(); | |
cfg.CreateProjection<Article, PriceModel>() | |
.ForMember(d => d.RegionId, o => o.MapFrom(s => s.NationId)); | |
}); |
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
using ... | |
static void Main(string[] args) | |
{ | |
var x = (Microsoft.Office.Interop.Excel._Application) Marshal.GetActiveObject("Excel.Application"); | |
x.ChartDataPointTrack = false; | |
MapperRegistry.Mappers.Add(new ComObjectMapper()); | |
var config = new MapperConfiguration(c => c.CreateMap<Microsoft.Office.Interop.Excel._Application, App>()); | |
config.AssertConfigurationIsValid(); | |
var mapper = config.CreateMapper(); |
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
using static Expression; | |
public static class Extensions | |
{ | |
public static IMappingExpression<TSource, TDestination> Flatten<TSource, TDestination, TSourceMember>( | |
this IMappingExpression<TSource, TDestination> map, | |
Expression<Func<TSource, TSourceMember>> source) | |
{ | |
var innerSourceProperties = | |
from sp in typeof(TSourceMember).GetProperties() |
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
static void Main(string[] args) | |
{ | |
var config = new MapperConfiguration(c => | |
{ | |
c.CreateMap<Model, Dto>(); | |
c.CreateMap<Item, ItemDto>(); | |
}); | |
config.AssertConfigurationIsValid(); | |
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
var configurationExpression = new MapperConfigurationExpression(); | |
configurationExpression.RemoveUnusedFeatures(); | |
configurationExpression.AddProfile<MyMappings>(); | |
var config = new MapperConfiguration(configurationExpression); | |
class MyMappings : Profile | |
{ | |
public MyMappings() | |
{ | |
this.RemoveUnusedFeatures(); | |
} |
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
using System; | |
using System.Threading; | |
using System.Collections.Concurrent; | |
using System.Diagnostics; | |
namespace UiPath.CoreIpc.Tests | |
{ | |
public class GuiLikeSyncContext : SynchronizationContext | |
{ | |
private readonly BlockingCollection<(SendOrPostCallback Callback, object State)> _workQueue = new BlockingCollection<(SendOrPostCallback, object)>(); |
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
static void Main(string[] args) | |
{ | |
Mapper.Initialize(cfg => | |
{ | |
cfg.AddProfile<MyMapperProfile>(); | |
}); | |
Mapper.AssertConfigurationIsValid(); | |
new[]{new OrderDTO{ customer = new customer { ID = 1, name = "john" }}}.AsQueryable().ProjectTo<Order>().Dump(); | |
} | |
public class Order |
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
void Main() | |
{ | |
Mapper.Initialize(cfg => | |
{ | |
cfg.CreateMap<Source, Destination>().ForMember(dest => dest.ValuesCount, opt => opt.MapFrom(s=>s.Value1+s.Value2)); | |
cfg.CreateMap<SourceItem, DestItem>(); | |
}); | |
Mapper.AssertConfigurationIsValid(); | |
//Mapper.Configuration.BuildExecutionPlan(typeof(Source), typeof(Destination)).ToReadableString().Dump(); | |
var expression = Mapper.Configuration.ResolveTypeMap(typeof(Source), typeof(Destination)).PropertyMaps.Last().CustomMapExpression; |
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
public void Main() | |
{ | |
var config = new MapperConfiguration(cfg => { | |
cfg.CreateMissingTypeMaps = false; | |
cfg.CreateMap<DateTimeDetails, PickupDetails>().ForMember(dest => dest.time, opt => opt.MapFrom(src => src)); | |
cfg.CreateMap<DateTime?, DateString>().ConvertUsing(src => new DateString { Value = src.HasValue ? src.Value.ToString("yyyyMMdd") : String.Empty}); | |
cfg.CreateMap<DateTimeDetails, TimeString>() | |
.ForMember(dest => dest.timeZoneOffset, opt => opt.MapFrom(src => src.TimeZoneOffset.ToString())) | |
.ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.Time)); | |
}); |
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
void Main() | |
{ | |
Mapper.Initialize(cfg=> | |
{ | |
cfg.CreateMap<object, bool>().ConvertUsing(o=>o!=null); | |
cfg.RecognizeDestinationPostfixes("Specified"); | |
}); | |
Mapper.AssertConfigurationIsValid(); | |
NewerOlder