Skip to content

Instantly share code, notes, and snippets.

public class Car {
protected String BrandName;
public void Go() {
System.out.println("I'm " + BrandName + " and I'm on my way...");
}
}
public class MercedesCar extends Car {
public MercedesCar() {
BrandName = "Mercedes";
return cats.Map<List<CatDTO>>();
// AutoMapper will scan the assemblies passed in for Profile instances and add each to the configuration
Mapper.Initialize(config =>
config.AddProfiles(new[]
{
// Marker types for assemblies
// Only one type from assembly
typeof (BusinessMappingProfile),
typeof (ClassFromSomeOtherAssemblyWithMappings)
}));
public class BusinessMappingProfile : Profile
{
public BusinessMappingProfile()
{
CreateMap<Cat, CatDTO>()
.ReverseMap();
CreateMap<Dog, DogDTO>()
.ReverseMap();
}
@andriybuday
andriybuday / ObjectExtensions.cs
Created November 27, 2016 23:07
ObjectExtensions Map method to abstract AutoMapper Map method
public static class ObjectExtensions
{
public static T Map<T>(this object source)
{
return AutoMapper.Mapper.Map<T>(source);
}
}
#!/bin/bash
CurrentPath=$(pwd)
# a directory where two repositories will get fetched to
SynchLocation="/C/git-synch/"
# bundle file location - typicly on a media that transfers the file (like USB-stick)
BundleLocation="/E/bundlefile.bundle"
# remote location and alias name for repository A
RemoteA="https://github.com/LocationOfRepoA.git"
RepoA="RepoA"
# remote location and alias name for repository B
@andriybuday
andriybuday / 0 - ServiceHost.cs
Last active April 16, 2024 15:58
Microsoft.Extensions.DependencyInjection with OWIN Self-Hosted WebAPI
// ...
using Microsoft.Owin.Hosting;
// ...
public class ServiceHost
{
private IDisposable server = null;
const string baseAddress = "https://*:443";
public void Start()
@andriybuday
andriybuday / UsingEPPlus.cs
Last active February 29, 2016 11:14
Using EPPlus
using (var excelPackage = new ExcelPackage(newFileInfo))
{
var ws = excelPackage.Workbook.Worksheets["Work Sheet Name"];
// do the stuff, here are some examples
var cellRange = ws.Cells[string.Format("{0}{1}:{0}{2}", "A", 2, 4)];
// merging cells
cellRange.Merge = true;
// setting value
cellRange.Value = "Any object that serves as cell value";
@andriybuday
andriybuday / UsingXLSX.js
Created February 29, 2016 10:43
Using XLSX library
// reading workbook from binary contents
var workbook = XLSX.read(excelBinaryContents, {type: 'binary'});
// retrieve properties of workbook (will be needed later)
var wbProps = workbook.Workbook.WBProps;
// get any particular worksheet by name
var worksheet = workbook.Sheets['Work Sheet Name'];
// get any cell
@andriybuday
andriybuday / file-select.hbs
Created February 29, 2016 10:27
file-select component with Ember.JS
<input {{bind-attr accept=fileFilter}} class="file-input-hidden" type="file" />
{{action-button action='pressButton' type=type title=title icon=icon hidden=hidden disabled=disabled visible=visible}}