fluent-interface

Castle Interceptors With Fluent Interface

廉价感情. 提交于 2019-11-28 06:31:31
问题 I'm trying to get an interceptor I've written to work, but for some reason it doesn't seem to be instantiating the interceptor when I request my components. I'm doing something like this (forgive me if this doesn't quite compile, but you should get the idea): container.Register( Component.For<MyInterceptor>().LifeStyle.Transient, AllTypes.Pick().FromAssembly(...).If(t => typeof(IView).IsAssignableFrom(t)). Configure(c => c.LifeStyle.Is(LifestyleType.Transient).Named(...). Interceptors(new

MEF Plugins and EF CodeFirst - How?

青春壹個敷衍的年華 提交于 2019-11-28 03:36:29
Background: We have a project with many modules. We're using EntityFramework 4.2 with FluentAPI (CodeFirst). There is a central project named Diverto.ORM.EntityFramework.SQLServer which contains partial classes that build the context using the FluentAPI (and which has references to every other project on the solution). Recently we received a request from the customer to implement many other features and the solution will need several other projects. Some of these projects will come from another system (Human Resources) and some will be created. The core of the existing solution is a Finance

101 tutorial for setting up nhibernate? [closed]

独自空忆成欢 提交于 2019-11-28 03:11:59
I am looking for a tutorial on setting up nhibernate. There seems to be few out there, but most are either written in gibberish, or are on an extremely ancient release. Any good resources, possibly even the inclusion of fluent or a code configured install? if you're interested in screencasts, checkout the summer of nhibernate tutorials. They're an execllent way to get up and running Jon Limjap The NHibernate FAQ has everything you need (from blog post 1, that is) including step-by-step discussions on setting up NHibernate. The samples are quite recent, with the blog only starting March 2008.

Tips for writing fluent interfaces in C# 3

爷,独闯天下 提交于 2019-11-28 03:06:23
I'm after some good tips for fluent interfaces in C#. I'm just learning about it myself but keen to hear what others think outside of the articles I am reading. In particular I'm after: when is fluent too much? are there any fluent patterns? what is in C# that makes fluent interfaces more fluent (e.g. extension methods) is a complex fluent interface still a fluent one? refactoring to arrive at a fluent interface or refactoring an existing fluent interface any good examples out there that you have worked with or could recommend? If you could post one tip or thought, or whatever per post. I want

Conditional Builder Method Chaining Fluent Interface

戏子无情 提交于 2019-11-28 02:46:23
I was wondering what would be the best way to implement a .When condition in a fluent interface using method chaining in a Builder object? For instance how would I implement the .WithSkill() and .When() methods in the following example: var level = 5; var ninja = NinjaBuilder .CreateNinja() .Named("Ninja Boy") .AtLevel(level) .WithShurikens(10) .WithSkill(Skill.HideInShadows) .When(level > 3) .Build() Update - A sample solution can be found here . What I'd do is have NinjaBuilder keep the operations as a list of delegates, rather than applying them, and only apply them when .Build is called.

Self bound generic type with fluent interface and inheritance

社会主义新天地 提交于 2019-11-28 01:52:40
I am using a fluent interface with inheritance. I declared the base class Constructor protected so you cant create a Foo<Bar> which would result in a ClassCastException on calling add(). But i am having trouble with the static method that returns a new Foo instance. public class Foo<T extends Foo<T>> // if i change to extends Foo i only get warnings { public static Foo<Foo> createFoo() // <-- error { return new Foo<Foo>(); // <-- error } protected Foo() {} public T add() { //... return (T)this; } } public class Bar extends Foo<Bar> { public Bar sub() { //... return this; } } This is mostly an

Understanding of How to Create a Fluent Interface

别来无恙 提交于 2019-11-27 23:46:35
Hi i'm trying to understand how i could build a readable and also error preventing Fluent-API without to much restriction for the User to hold it simple let's say we want to change the following class to be fluent public class Car { public int Gallons { get; private set; } public int Tons { get; private set; } public int Bhp { get; private set; } public string Make { get; private set; } public string Model { get; private set; } public Car(string make, string model) { Make = make; Model = model; } public void WithHorsePower(int bhp) { Bhp = bhp; return this; } public void WithFuel(int gallons)

EF Code First 4.1 - How to configure one to many relationship with default

谁说胖子不能爱 提交于 2019-11-27 22:29:43
问题 I have a Customer entity which references a collection of Addresses. The complication here is that I want to be able to identify a particular address as the default address. If possible I would like to hold the FK of the default address in the Customer table. This seems more elegant than having a column in the addresses table to identify the default. I am having difficulty with the fluent API in terms of defining this relationship. When I run the following code I get an exception which says:

Difference between .WithMany() and .WithOptional()?

血红的双手。 提交于 2019-11-27 18:47:58
Below are two similar fluent API configurations: WithMany() modelBuilder.Entity<Country>() .HasRequired(cou => cou.Currency) .WithMany() .WillCascadeOnDelete(false); WithOptional() modelBuilder.Entity<Country>() .HasRequired(cou => cou.Currency) .WithOptional() .WillCascadeOnDelete(false); What I am trying to express here is: Every Country requires a concrete Currency , but a Currency can be assigned to zero, one or many Countries. Which of the above statements would I have to use? Or in other words: What exactly is the difference between .WithMany() and .WithOptional() operators? If your

Fluent interfaces and inheritance in C++

故事扮演 提交于 2019-11-27 18:26:26
问题 I'd like to build a base (abstract) class (let's call it type::base ) with some common funcionality and a fluent interface, the problem I'm facing is the return type of all those methods class base { public: base(); virtual ~base(); base& with_foo(); base& with_bar(); protected: // whatever... }; Now I could make subtypes, e.g.: class my_type : public base { public: myType(); // more methods... }; The problem comes when using those subtypes like this: my_type build_my_type() { return my_type(