Skip to content

Instantly share code, notes, and snippets.

View lbargaoanu's full-sized avatar

Lucian Bargaoanu lbargaoanu

View GitHub Profile
namespace Scheduler
{
using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.Collections.Generic;
public static class UIJobScheduler
{
static readonly List<Job> jobs = new List<Job>();
namespace Scheduler
{
using System;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
public static class JobScheduler
{
static readonly LinkedList<Job> jobs = new LinkedList<Job>();
@lbargaoanu
lbargaoanu / EventsList.cs
Created March 4, 2017 17:29
A way to communicate between threads using events. Based on SynchronizationContext.
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
namespace Common
{
public void Main()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Source, Destination>();
cfg.CreateMap<object, DataRow>().ConvertUsing((s, d)=>
{
foreach(var item in Mapper.Map<IDictionary<string, object>>(s))
{
d[item.Key] = item.Value;
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()
void Main()
{
Mapper.Initialize(x =>
{
x.CreateMap<Origin, OriginContract>();
x.CreateMap<OriginContract, Origin>();
x.CreateMap<State, StateContract>();
x.CreateMap<StateContract, State>();
});
static void Main(string[] args)
{
MapperConfiguration config = new MapperConfiguration(c =>
{
c.CreateMap<UserViewModel, ApplicationUsers>().ConvertUsing<UserConvertor>();
});
var mapper = config.CreateMapper();
var user = new UserViewModel
{
Email = "[email protected]",
#include "stdafx.h"
#include <iostream>
#include <functional>
#include <tuple>
#include <utility>
#include <vector>
class IActiveObject {
public:
void Post(std::function<void(void)> handler)
public static void Main()
{
Mapper.Initialize(a => a.AddProfile<TestProfile>());
var mapSource = new SourceTestModel { SourceDetailTestProperty = 5, SourceBaseTestProperty = 10, UseFirstModel = true };
var expectedResult = new FirstTargetTestModel { DetailTestProperty = 5, BaseTestProperty = 10 };
Mapper.Map<ITestDetail>(mapSource).Dump();
}
$typeMapDestination.Foos = .Block(
System.Collections.Generic.List`1[Benchmark.Flattening.ComplexTypeMapper+Foo] $collectionDestination,
System.Collections.Generic.List`1[Benchmark.Flattening.ComplexTypeMapper+Foo] $passedDestination) {
$passedDestination = .If ($dest == null) {
.Default(System.Collections.Generic.List`1[Benchmark.Flattening.ComplexTypeMapper+Foo])
} .Else {
$typeMapDestination.Foos
};
$collectionDestination = .If ($passedDestination != null) {
$passedDestination