CSharpFeeds - All your C# feeds in one place.

Sponsors

Feed: InitializeComponent();

Site: http://initializecomponent.blogspot.com/feeds/posts/default Link: http://initializecomponent.blogspot.com/feeds/posts/default

Sunday, September 12, 2010

A Repository-like façade for Entity Framework – Part II

by Ray Henry via InitializeComponent(); on 9/12/2010 9:35:00 AM

This is the second post in this series. Part 1 The first thing we need to do to enable using our POCOs with EF 4.0 is to decide how we want to handle change tracking and lazy loading of our child collections. For now, let’s take full advantage of EF’s capabilities and allow it to generate the proxies for lazy loading and full change tracking. To do this, there are four requirements: Each POCO must have an empty default constructor. Each property of the POCO must be declared vir ...

[ read more ]

Thursday, September 09, 2010

A Repository-like façade for mocking Entity Framework

by Ray Henry via InitializeComponent(); on 9/9/2010 5:07:00 PM

While I know there are a lot of people in the ALT.NET community who like to mock Enitity Framework, that is not what I am talking about. The objective of this exercise is to develop an Interface that can be used by Business Logic to query and persist data as well as provide and in-memory “mock” for testing or prototyping without a database. The paradigm used is that of object model aggregates typically found in Domain-driven designs (DDD). This is fortunate because it is the model used by EF, ...

[ read more ]

Thursday, May 07, 2009

Authorization Strategies for the Business Layer

by Ray Henry via InitializeComponent(); on 5/7/2009 10:05:00 AM

It's tempting to design a Business Layer that accepts User identity information and attempts to authenticate and authorize the user. However, security is a cross-cutting concern, and as such, should not be intertwined with your business logic. The strategies presented here will extract the authorization component from the business logic and embed it as a separate concern within the Business Layer. I'm going to ignore the authentication function, and focus on determining what authority an authen ...

[ read more ]

Monday, October 06, 2008

Fun with C# 3.0 (#4) - Nullable types and the ?? operator

by Ray Henry via InitializeComponent(); on 10/6/2008 10:23:00 AM

C# has reference types and value types. Reference types are commonly called objects, and variables that are declared to be of a reference type can refer to an object or be null. Value types (int or bool, for example) can be stored in variables that contain the actual value, and therefore can never be null. Sometimes it is useful to have a value type that can have a null value, so this feature has been added to C# 3.0. This feature is implemented using generics and the type System.Nullable<T ...

[ read more ]

Saturday, July 12, 2008

Ninject revisited

by Ray Henry via InitializeComponent(); on 7/12/2008 6:25:00 PM

In a previous post, I looked at Ninject, and based on a cursory look at the documentation, dismissed it as requiring me to decorate my component classes with attributes in order to use multi-parameter constructor injection. Thanks to a comment by ninject's author, Nate Kohari, I found that with a slight configuration change, we can duplicate the behavior of Unity. The proof's in the pudding. Let's see if we can wire up the same components with both Unity and Ninject without having to make any c ...

[ read more ]

Thursday, July 03, 2008

Fun with C# 3.0 (#3) - Lambda expressions

by Ray Henry via InitializeComponent(); on 7/3/2008 11:55:00 AM

The addition of LINQ to C#/.NET has really improved the way that we can handle data in our applications. Here's an example. Suppose we want to write a method to count the number of strings in a list which exceed a certain length. It's not to hard to do with C# 2.0; you iterate over the items, make the comparison, increment a counter and return it. But C# 3.0 makes it simple. When the namespace System.Linq is included in your file, IEnumerable objects get a load of new extension methods. One of ...

[ read more ]

Fun with C# 3.0 (#3) - Lambda expressions

by Ray Henry via InitializeComponent(); on 7/3/2008 11:55:00 AM

The addition of LINQ to C#/.NET has really improved the way that we can handle data in our applications. Here's an example. Suppose we want to write a method to count the number of strings in a list which exceed a certain length. It's not to hard to do with C# 2.0; you iterate over the items, make the comparison, increment a counter and return it. But C# 3.0 makes it simple. When the namespace System.Linq is included in your file, IEnumerable objects get a load of new extension methods. One of ...

[ read more ]

Tuesday, June 24, 2008

Fun with C# 3.0 (#2)

by Ray Henry via InitializeComponent(); on 6/24/2008 6:31:00 PM

This one is a quickie. Auto-implemented properties. It allows you specify the property and have the compiler automatically define a backing private instance member. It is way cool. public class Employee{ public string Name { set; get; } public string Job { set; get; } public int Age { set; get; }} ...

[ read more ]

Fun with C# 3.0 (#2)

by Ray Henry via InitializeComponent(); on 6/24/2008 6:31:00 PM

This one is a quickie. Auto-implemented properties. It allows you specify the property and have the compiler automatically define a backing private instance member. It is way cool. public class Employee{ public string Name { set; get; } public string Job { set; get; } public int Age { set; get; }} ...

[ read more ]

Fun with C# 3.0 (#1)

by Ray Henry via InitializeComponent(); on 6/24/2008 1:47:00 PM

This is the first in a series of posts in which I explore new features of C# 3.0 available in Visual Studio 2008. In this post, I introduce anonymous types and extension methods. An anonymous type is an unnamed class that you can define simply by specifying the values of its properties. These properties are read-only and can be accessed through the usual property accessor syntax. var employee = new { Name = "John Smith", Age = 44, Job = "Manager" };Console.WriteLine(emplo ...

[ read more ]

Fun with C# 3.0 (#1)

by Ray Henry via InitializeComponent(); on 6/24/2008 1:47:00 PM

This is the first in a series of posts in which I explore new features of C# 3.0 available in Visual Studio 2008. In this post, I introduce anonymous types and extension methods. An anonymous type is an unnamed class that you can define simply by specifying the values of its properties. These properties are read-only and can be accessed through the usual property accessor syntax. var employee = new { Name = "John Smith", Age = 44, Job = "Manager" };Console.WriteLine(emplo ...

[ read more ]

Wednesday, June 18, 2008

Configuring and Supplying a Factory with Unity

by Ray Henry via InitializeComponent(); on 6/18/2008 10:08:00 AM

Here is a code-sample which allows the Factory to be Container-dependent, and thus configurable in the container setup code. Notice that I registered the unity instance with itself. If you do not do this, when the Factory is created, Unity will see that a UnityContainer is needed by the constructor and instantiate a new UnityContainer, which will not have the correct configuration. If you have registered the configured unity instance, then it will be supplied to the Factory. Also note that the u ...

[ read more ]

Container Dependency anti-pattern

by Ray Henry via InitializeComponent(); on 6/18/2008 8:48:00 AM

It is good design to minimize the number of dependencies between components in a system. Dependency Injection is used to decouple components from each other. A component should not specify, or require, a particular implementation of a Data Service, Logging Service or any other cross-cutting concern. One solution to this problem is to use a DI container, such as Unity. This localizes all the dependencies in one place, the shell, or configuration point for your application. The components and serv ...

[ read more ]

Tuesday, June 17, 2008

Stupid .NET Tricks #1

by Ray Henry via InitializeComponent(); on 6/17/2008 4:08:00 PM

If you like to Unit Test as much as I do, and you're obsessive about putting your strings in Resources files, it can be kind of tricky to make use of these Resources in your Unit Tests. I'll show you what I mean. You want to unit test the following: public string login(user, pw){ if (!validUser(user, pw)) { return "Invalid User"; }}OK, so we write a test: public void TestInvalidUser(){ MyClass m = new MyClass(); Assert.AreEqual("Invalid User", m.login( ...

[ read more ]

Stupid .NET Tricks #1

by Ray Henry via InitializeComponent(); on 6/17/2008 4:08:00 PM

If you like to Unit Test as much as I do, and you're obsessive about putting your strings in Resources files, it can be kind of tricky to make use of these Resources in your Unit Tests. I'll show you what I mean. You want to unit test the following: public string login(user, pw){ if (!validUser(user, pw)) { return "Invalid User"; }}OK, so we write a test: public void TestInvalidUser(){ MyClass m = new MyClass(); Assert.AreEqual("Invalid User", m.login( ...

[ read more ]

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us