Monday, February 18, 2008

Enum Utilities

In this article I will discuss some classes I've written to simplify working with enumerations. The primary thrust of these classes is added functionality, but in some cases there are performance improvements as well.

Click here

Download source

The zip file contains:
EnumDefaultValueAttribute.cs
EnumTransmogrifier.cs
LibEnum.cs
build.bat
csc.rsp
EnumDemo1.cs
EnumDemo2.cs
EnumDump.cs
MonthEnum.cs
PolyglotAttribute.cs
WeekdayEnum.cs

Once you extract the files to a directory you should be able to execute build.bat to compile the demo programs. (They are console applications.)

To use the methods in your own projects, simply add the appropriate files.

Sunday, February 17, 2008

Directives in Asp.Net

Directives are used to pass optional settings to the ASP.NET pages and compilers.

Click here to read article.

Tuesday, February 12, 2008

Custom Controls: Extra Property Tab

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Elsehemy.Controls
{
[Designer(typeof(UserControlDesigner))]
[PropertyTab(typeof(ExtraSuperTab),
PropertyTabScope.Component)]
public partial class TestUserControl : UserControl
{
public TestUserControl()
{
InitializeComponent();
}
int _x;

public int XXX
{
get { return _x; }
set { _x = value; }
}
}


public class ExtraSuperTab :
System.Windows.Forms.Design.PropertyTab
{
public override PropertyDescriptorCollection
GetProperties(object component,
Attribute[] attributes)
{
PropertyDescriptor pd =
TypeDescriptor.CreateProperty(
component.GetType(),
"XXX",
typeof(int),
new CategoryAttribute("Super Properties"));

return (
new PropertyDescriptorCollection(
new PropertyDescriptor[]{pd}
));
}

public override string TabName
{
get { return "Super Tab"; }
}

public override System.Drawing.Bitmap Bitmap
{
get
{
return (System.Drawing.Bitmap)System.
Drawing.Image.FromFile(@"C:\icon.jpg");
}
}
}
}




 

And in the control don't forget the attribute

[PropertyTab(typeof(ExtraSuperTab),
PropertyTabScope.Component)]
public partial class TestUserControl : UserControl
 
Via Amr Elsehemy's Blog





Sunday, February 10, 2008

How to use delegates to remove duplicated code

Click Here

Static Extension Methods

DateTime d = DateTime.Yesterday();
//...
public static DateTime Yesterday<this DateTime>()
{
return DateTime.Today.AddDays(-1);
}
 


Via Mabstrerama

Tuesday, February 05, 2008

101 Design Patterns & Tips for Developers

Full guide for developer how to create your application in the using   a "design patterns", that include next parts:

  • Creational Patterns
  • Structural Patterns
  • Behavioral Patterns
  • Composing Methods of Refactoring
  • Moving Features Between Objects
  • Organizing Data
  • Simplifying Conditional Expressions
  • Making Method Calls Simpler
  • Dealing with Generalization
  • Big Refactorings

Click here to read.