fluent-interface

How do I unit test code that uses a Fluent interface?

I've created a few small fluent interfaces through method chaining. They typically call a number of Repositories that fetch data from webservices / databases. How should I go about unit testing methods that use the fluent interface? Public IEnumberable<Computer> FindComputers(string serialNumber) { return Computers.FindBySerialNu...

Question regarding fluent interface in C#

I have the following class: public class Fluently { public Fluently Is(string lhs) { return this; } public Fluently Does(string lhs) { return this; } public Fluently EqualTo(string rhs) { return this; } public Fluently LessThan(string rhs) { return this; } public Fluently GreaterThan(string rhs)...

Lambda Func<> and Fluent

There are lots of Fluent implementations out there now that work with Lambdas to do things that are quite neat. I'd like to wrap my brain around it so I can start creating some of these things, but I have yet to find an explanation that my brain understands. Consider this simple example of a Person Validator public class PersonValidat...

C# Lambda+Extensions+Fluent - How Would I Do This?

I want to be able to create "Transformation" classes that take a given object, perform a series of transformations on it (i.e. change property values) and keeps track of the transformations performed. The transformation performed will vary based on the properties of the object provided. I want to be able to apply transformation rules (...

Multi-level inheritence with fluent interface in C#

Given the sample console application below: QUESTION #1: Why does .Name() return typeof OranizationBuilder, but .Write() calls CorporationBuilder? QUESTION #2: How to get .Name() to return typeof CorporationBuilder? namespace MyCompany { using System; class Program { static void Main(string[] args) { ...

Issue With Fluent Nhibernate Automapping and Guids / UniqueIdentifiers as Primary Key Fields

I am attempting to use the Fluent-NHibernate automapping functionality (in the latest version of the software) and am running into problems using Guids as the Primary Key fields. If I use integer fields for the primary keys, the tables are generated successfully and all Nhibernate functionality seems to work fine. FYI, I am using NHibern...

Nested Lambda for use with Fluent Interface

Given the following types: class Parent { List<Child> Children {get;set;}} class Child {List<Child> GrandChildren {get;set;}} class Helper<TEntity> {List<string> Properties {get;set;}} And given the following methods on Helper... public Helper AddProps<TEntity, TProp>(Expression<Func<TEntity, TProp>> exp) { this.Properties.Add(...

Persisting complex test data

We are using builder pattern to generate test data. These domain objects have relations between them. Our functional tests require these objects to be persisted. Think about this model: If I want a plain instance of C I do aNew().c().build() If I want it to be persisted I do aNew().c().saveIn(session) If I want an instance of C wit...

Design of an Alternative (Fluent?) Interface for Regular Expressions

I've just seen a huge regex for Java that made me think a little about maintainability of regular expressions in general. I believe that most people - except some badass perl mongers - would agree that regular expressions are hardly maintainable. I was thinking about how this situation could be fixed. So far, the most promising idea I h...

Generic 'TThis' for fluent classes

I'm constructing a fluent interface where I have a base class that contains the bulk of the fluent logic, and a derived class that add some specialized behavior. The problem I'm facing is the return type of the fluent methods in the base class when called from an instance of the derived type. After invoking a method of the base class, on...

Complex Query based on a List

I have a Class like below public class Customer { public virtual int ID { get; set; } public virtual IList<LokalPortalen.Domain.Entity.CustomerLocationType> CustomerLocationTypes { get; set; } public virtual ZipCode ZipCode { get; set; } public Customer() { CustomerLocationTypes = new List<LokalPortalen.Doma...

Fluent Entity Framework Mapping

Hi, Is there any way to perform Fluent EF Mapping like Fluent NHibernate for NHibernate ? ...

Why use a fluent inteface?

When comparing to classic Properties,what's the big gain of using it ? I know the repeating of the instance name is gone,but thats all ? public class PropClass { public Object1 object1 { get; set; } public Object2 object2 { get; set; } } PropClass propClass = new PropClass(); propClass.object1 = o1; propClass.object2 = o2; publi...

How do I get all the key for the components that are currently register in Castle Windsor?

The main question is in the title but here is the background. Since I pick the lazy way to register my components container.Register( AllTypes.Pick().FromAssembly( typeof (MyModelBinder).Assembly).WithService.FirstInterface() ); Now when I try container.AddComponent<CompositionBinder, CompositionBin...

What's a fluent interface?

I recently came across this expression - but reading up on Wikipedia did not clarify it much for me - I still don't get it: What's the point of it How is it used in practice (i.e. how does it benefit a coder in their day to day work/building systems)? [Edit] The Wikipedia article C++ example is overly long, and conflates the discussi...

Generify UI components

I was trying for days to figure out if is possible, I failed but maybe it is be possible(I think it should be possible). Let's say we have a few UI components similar with Swing hierarchies + we will use fluent interfaces Fluent Interfaces: public abstract class Component { ... public abstract Component setName(String name)...

Interface Inheritance: Method does not show up!

I've got an interface inheritance issue that has been vexing me for some time. It doesn't seem to make any sense, and I can only conclude that I'm missing something fundamental. Overview The code below is from part of a fluent interface for our ORM tool. It provides a SQL-like syntax for pulling data from the database. You don't have t...

Fluent interfaces and inheritance in C#

I'll show a problem by example. There is a base class with fluent interface: class FluentPerson { private string _FirstName = String.Empty; private string _LastName = String.Empty; public FluentPerson WithFirstName(string firstName) { _FirstName = firstName; return this; } public FluentPerson Wi...

Fluent Web.Config

Has anyone made an attempt at something like similar to the Fluent-Nhibernate project except for web.config? Is this even plausible? ...

How would i Build a mysql query through a set of PHP OOP methods?

I want to be able to do something like this: $table_object->getRows()->where($wer)->or($or)->orderBy('field', 'DESC'); If i were sure that all the methods will be called each time and in that order, then it would be simple and i can return an instance of the object itself on each method call so that the query gets build and finally ex...