This file contains hidden or 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
/// <reference path="~/Scripts/jasmine/jasmine.js" /> | |
/// <reference path="~/Scripts/angular.js" /> | |
/// <reference path="~/Scripts/angular-mocks.js" /> | |
/// <reference path="~/Scripts/Common/Collections/keyed-collection.js" /> | |
describe('keyed-collection', function () { | |
beforeEach(module('common.collections.keyedCollection')); | |
describe('keyed-collection service', function () { |
This file contains hidden or 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 static class Extensions | |
{ | |
public static void AddOnce<TEntity>( | |
this IDbSet<TEntity> set, | |
Expression<Func<TEntity, object>> identifierExpression, | |
params TEntity[] entities) where TEntity : class | |
{ | |
if (set == null) throw new ArgumentNullException("set"); | |
if (identifierExpression == null) throw new ArgumentNullException("identifierExpression"); | |
if (entities == null) throw new ArgumentNullException("entities"); |
This file contains hidden or 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 properties = { Two:true, Three:1 }; | |
var filters = ['One===true', 'Two===true', 'Three>6', 'Three<6 || Two===true']; | |
var fnString = ''; | |
for(var name in properties) { | |
fnString +='var '+name+'='+properties[name]+';\n'; | |
} | |
console.log(fnString); |
This file contains hidden or 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
namespace MyApp | |
{ | |
public sealed class Int | |
{ | |
public static readonly DependencyProperty AttachedProperty = DependencyProperty.RegisterAttached( | |
"IntAttached", typeof(bool), typeof(Int), null); | |
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached( | |
"Value", typeof(int), typeof(Int), new PropertyMetadata(null, OnAttach)); |
This file contains hidden or 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 class SpecialCamelCasePropertyNamesContractResolver : | |
CamelCasePropertyNamesContractResolver | |
{ | |
protected override JsonDictionaryContract CreateDictionaryContract( | |
Type objectType) | |
{ | |
var contract = base.CreateDictionaryContract(objectType); | |
contract.DictionaryKeyResolver = propertyName => propertyName; |
This file contains hidden or 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 static class ReflectionExtensions | |
{ | |
public static void FindImplementationsInSameAssemblyAs<T>( | |
this Type type, | |
Action<Type, Type> action) | |
{ | |
var assembly = typeof(T).GetTypeInfo().Assembly; | |
var query = | |
from implementationType in assembly.GetTypes() |
This file contains hidden or 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
services.AddDbContext<MyDataContext>( | |
o => o.UseSqlServer(settings.ConnectionString), | |
ServiceLifetime.Scoped, | |
ServiceLifetime.Singleton); | |
services.TryAddSingleton<Func<MyDataContext>>(sp => | |
() => new MyDataContext(sp.GetService<DbContextOptions<MyDataContext>>()) | |
); |
This file contains hidden or 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
import { Injectable, NgZone } from '@angular/core'; | |
@Injectable() | |
export class ScrollService { | |
constructor( | |
private ngZone: NgZone) { | |
} | |
scrollTo(selector: string, focus?: boolean): void { |
This file contains hidden or 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
internal class Program | |
{ | |
static readonly Regex VersionRE = new Regex(@"(\d+\.\d+\.\d+)(\-.*(\-\d+))?"); | |
static void Main(string[] args) | |
{ | |
var app = new CommandLineApplication(); | |
var pack = app.Command("pack", config => | |
{ | |
var versionArg = config.Argument("version", "Semamtic Version to pack e.g. (1.0.0-beta-1)", false); |
This file contains hidden or 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 static class ObservableExtensions | |
{ | |
public static Builder<TBase> SwitchType<TBase>( | |
this IObservable<TBase> observable) | |
{ | |
return new Builder<TBase>(observable); | |
} | |
public class Builder<TBase> | |
{ |