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 class FooController : Controller | |
{ | |
private readonly IViewFactory viewFactory; | |
public FooController(IViewFactory viewFactory) { this.viewFactory = viewFactory; } | |
public IActionResult Index() | |
{ | |
var viewModel = viewFactory.Create<CreateFooViewModel>(); | |
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 class CharacterController : Controller | |
{ | |
/*[...]*/ | |
public IActionResult Profile(int id) | |
{ | |
/*[...]*/ | |
var viewModel = viewFactory.Build<int, CharacterProfileViewModelBuilder>(id); | |
return View(viewModel); | |
} | |
} |
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 static class IServiceCollectionExtensions | |
{ | |
public static IServiceCollection ConnectImplementations<TService>(this IServiceCollection services, Assembly assembly)where TService : class | |
{ | |
return services.ConnectImplementations(typeof (TService), assembly); | |
} | |
public static IServiceCollection ConnectImplementations(this IServiceCollection services, Type serviceType, Assembly assembly) | |
{ | |
if (!serviceType.IsInterface) throw new ArgumentException($"{nameof(serviceType)} must be an interface"); |
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
module.exports = { | |
paths: { | |
public: "wwwroot", | |
watched: ["wwwroot/javascripts", "wwwroot/stylesheets"] | |
}, | |
npm: { | |
styles: { | |
"bootstrap": ["dist/css/bootstrap.css"], | |
"font-awesome": ["css/font-awesome.css"], | |
"animate.css": ["animate.css"] |
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 class ModelStateTransferValue | |
{ | |
public string Key { get; set; } | |
public string AttemptedValue { get; set; } | |
public object RawValue { get; set; } | |
public ICollection<string> ErrorMessages { get; set; } = new List<string>(); | |
} | |
public static class ModelStateHelper | |
{ |
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 class AutoMapperModule : Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
builder.Register(c => new MapperConfiguration(config => { config.AddProfiles(GetType().Assembly); })).AsSelf().SingleInstance(); | |
builder.Register(c => c.Resolve<MapperConfiguration>().CreateMapper(c.Resolve)).As<IMapper>().InstancePerLifetimeScope(); | |
} | |
} |
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 class GenericHandlersModule : Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
builder.RegisterType<CreateCommandHandler<Foo, CreateFooCommand>>().As<IRequestHandler<CreateFooCommand, bool>>(); | |
builder.RegisterType<DeleteCommandHandler<Foo, DeleteFooCommand>>().As<IRequestHandler<DeleteFooCommand, bool>>(); | |
builder.RegisterType<ListQueryHandler<Foo, ListFooQuery>>().As<IRequestHandler<ListFooQuery, IEnumerable<Foo>>>(); | |
builder.RegisterType<UpdateCommandHandler<Foo, UpdateFooCommand>>().As<IRequestHandler<UpdateFooCommand, bool>>(); | |
} | |
} |
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
// Component definition (holds information about template and view model) | |
class ClickCounterComponent extends Component { | |
constructor(name: string, viewModel: ViewModelClass) { | |
super(name, viewModel, template) | |
} | |
} | |
// Actual view model (This separation allows us to reuse view models for components) | |
class ClickCounterViewModel extends ViewModel { | |
public count: ko.Observable<number> = ko.observable<number>(0); |
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
# Dependencies: {:saxy, "~> 1.2"}, {:sax_map, "~> 0.2"}, {:benchee, "~> 1.0"} | |
# | |
# Samples | |
# | |
simple = """ | |
<?xml version="1.0"?> | |
<?xml-stylesheet href="catalog.xsl" type="text/xsl"?> | |
<catalog> |
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
defmodule CounterCache do | |
@moduledoc """ | |
This module provides a way of generating embedded schemas that contain the definition of cached fields. | |
A module is automatically created for each and contains the definition values passed in the list. | |
By accessing the generated module, those fields can be queried from the schema that contains them. | |
# Usage | |
- Add `use CounterCache` to your module. | |
- Invoke `counter_cache_field` inside your schema definition: |
OlderNewer