Skip to content

Instantly share code, notes, and snippets.

[HttpGet("GetAllCommandHandlers")]
public async Task<IEnumerable<string>> GetAllCommandHandlers()
{
var genericType = typeof(ICommandHandler<>);
var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
.Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition().Equals(genericType)))
.Select(x => $"{x.FullName}.{x.Name}").ToList();
var genericTypeWithResult = typeof(ICommandHandler<,>);
var typesWithresult = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
public static class DateTimeExtentions
{
public static string ToDateTimeHighPrecision(this DateTime source)
{
return source.ToString("MM/dd/yyyy h:mm:ss.fff tt");
}
}
@Zabaa
Zabaa / ApplicationBuilder.cs
Last active April 16, 2018 14:45
Fluent Builder
using System;
using System.Collections.Generic;
namespace FunWithPatterns.Builder
{
public class ApplicationBuilder
{
private string _name;
private string _sureName;
private DateTime _birthDate;
@Zabaa
Zabaa / javascript.json
Last active November 5, 2017 18:30
React Redux component vscode snippet
{
"ReactReduxComponent": {
"prefix": "rrcomp",
"body": [
"import React, { PropTypes } from 'react';\r",
"import { connect } from 'react-redux';\r",
"import { bindActionCreators } from 'redux';\r",
"\r",
"class ${1:ReactComponent} extends React.Component {\r",
" constructor(props, context) {\r",
@Zabaa
Zabaa / DirectReport.sql
Created September 13, 2017 15:43
CTE Example
WITH DirectReports (ManagerID, EmployeeID, Title, Level)
AS
(
-- Anchor member definition
SELECT e.ManagerID, e.EmployeeID, e.Title,
0 AS Level
FROM dbo.MyEmployees AS e
WHERE e.ManagerID IS NULL
UNION ALL
-- Recursive member definition
namespace editors {
export function getEditorClasses(): FactoryConstructor[] {
let list = [];
Object.keys(this).forEach(name => {
let obj = this[name];
if (obj.prototype instanceof editors.Factory) {
list.push(obj);
}
// 3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <ctime>
using namespace std;
class Figura
{
class Program
{
static void Main(string[] args)
{
Foo foo = new Foo();
var setValue = BuildSet<Foo, string>("Bar.Name");
var getValue = BuildGet<Foo, string>("Bar.Name");
setValue(foo, "abc");
Console.WriteLine(getValue(foo));
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RequiredIfEmptyAttribute : ValidationAttribute, IClientValidatable
{
private readonly string[] _dependentProperties;
public RequiredIfEmptyAttribute(params string[] dependentPropertieses)
{
_dependentProperties = dependentPropertieses;
}
public class Permutation
{
public static IEnumerable<string> GetPermutations(string s)
{
if (s.Length > 1)
return from ch in s
from permutation in GetPermutations(s.Remove(s.IndexOf(ch), 1))
select string.Format("{0}{1}", ch, permutation);
else