Generic EventArgs<T>

יום שלישי, נובמבר 18, 2008

A good way for passing data with EventArgspublic class EventArgs<TValue1> : EventArgs { public TValue1 Value1 { get; set; } public EventArgs(TValue1 value1) { Value1 = value1; } } Should you want to pass 2 valuespublic class EventArgs<TValue1, TValue2> : EventArgs<TValue1> { public TValue2 Value2 { get; set; } public EventArgs(TValue1 value1, TValue2 value2) : base(value1) { Value2 = value2; ...
תגיות: , , ,
אין תגובות

Extension Methods: IDataReader.GetValue<T>

יום שני, נובמבר 17, 2008

A convenient solution to get value from IDataReader field./// <summary> /// Gets the reader field value. /// </summary> /// <typeparam name="TField">The type of the field.</typeparam> /// <param name="reader">The reader.</param> /// <param name="fieldName">Name of the field.</param> /// <returns></returns> public static TField GetValue<TField>(this IDataReader reader, string fieldName) { //Guard if (string.IsNullOrEmpty(fieldName)) throw new ArgumentException("fieldName"); return (TField)reader.GetValue(reader.GetOrdinal(fieldName)); } Usage:IDataReader reeader = _database.ExecuteReader(command); if (reader.Read()) { int productId = reader.GetValue<int>("ProductId"); }
תגיות: , , ,
4 תגובות

Start Detached AddIn

יום שני, אוגוסט 18, 2008

This Addin add new option to the debug menu for each project (When right clicking from Solution  Explorer).   Features Starts a new instance for the selected project. In case the project is not executable, a dialog is popped asking the user what to do.   Requirements Microsoft .NET Framework 2.0 Visual Studio 2008     For more information click here.   Download Version 1.0.0
6 תגובות

SmartClient: Changing the Projects File System Structure

יום רביעי, יולי 2, 2008

When creating a new smart client project by GAT (Guidance Automation Toolkit) the projects structure hierarchy on the file system is also created by the GAT. Suppose I move the projects to another location on the file system and to and include this projects in different solution, then, I try to add a new BusinessModule, I will get the following exception:   Microsoft.Practices.RecipeFramework.ValueProviderException: An exception occurred during the binding of reference or execution of recipe CreateBusinessModuleCS. Error was: An error happened while calling the value provider or evaluating the default value of argument ShellProject.   The SmartClient searches for...
4 תגובות

LINQ To SQL – Performing Inner Join Queries

יום ראשון, פברואר 24, 2008

Its amazing how simple it is to create inner join queries with LINQ.   Assuming you have the AdventureWorks Database installed.   public void GetEmployeeByID(int employeeID) { AdventureWorksDataContext aw = new AdventureWorksDataContext(); aw.Log = Console.Out; var entities = from e in aw.Employees join ea in aw.EmployeeAddresses on e.EmployeeID equals ea.EmployeeID ...
תגיות: , ,
אין תגובות

LINQ To SQL – Get the SQL text query

Usually when we perform a LINQ Query on a SQL table, we don't see the actual query. Assuming you have the AdventureWorks Database installed. To see the query text, use the Log method: aw.Log = Console.Out   public List<Employee> GetEmployees() { AdventureWorksDataContext aw = new AdventureWorksDataContext(); var employees = from emps in aw.Employees select emps; aw.Log = Console.Out; return...
תגיות: , ,
אין תגובות

JOY, Visual Studio 2008 JavaScript Inteliscence Support

יום רביעי, דצמבר 5, 2007

Yet, another great feature in Visual Studio 2008. JavaScript Inteliscence This is wonderful, i can finally write JavaScript prototypes and see them in the Inteliscence. It was so hard to write Object Oriented in VS2005 because of no Inteliscence support.   To see this in action, first, I've created a new JS file called JScript.js, within i created a new class called Test(). Then i created 2 new prototypes function under Test() called DoSomthing1() and DoSomthing2().   Then i created a new instance of Test(), and here you can see my methods under the Test class.     Even more, when i created a new ASPX file, and...
תגיות: ,
אין תגובות

LINQ – Handling Legacy Code

יום שלישי, דצמבר 4, 2007

LINQ is for queries, no doubt about it. Yet - we can do some interesting thins with LINQ, and not just queries. For example, we all deal sometimes with legacy code inherited from some old project - so here some interesting ways to handle this code with few simple lambda expressions.   For this example, I will use this Employee class: public class Employee { public Employee(string firstName) { this._firstName = firstName; ...
תגיות: , , ,
2 תגובות

WCF – IIS Integrated Security

Usually when we developing a WCF service in Intranet environment, we need to enable users to authenticate on IIS with there login credentials - Integrated Security.   Assuming we using basicHttpBinding and we host the service library on IIS web site, This can be accomplished by the following settings: <bindings> <basicHttpBinding> <binding name="basicHttpBindingConfig"> <security mode="TransportCredentialOnly"> <transport...
תגיות: , ,
אין תגובות

WCF – Binding and Security

יום שני, דצמבר 3, 2007

How do we know which binding to use and when? How do we know which security schema goes with our selected binding configuration?   There's allot of considerations with the binding configuration: Is there IIS involved. Are we going to use IIS Integrated Security. Are we going to use net.tcp binding?   There's also security issues we need to address: How we going to secure our services communication. Do we use the...
תגיות: , , ,
אין תגובות