.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

New Construct

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
Why are we using new() constraint in the following construct.  I am working on the nopcommerce project.  In general when do we use the new() construct.    public sealed class StaticObjectContextManager<T> : ObjectContextManager<T> where T : ObjectContext, new() { private static T _objectContext; private static object _lockObject = new object(); /// <summary> /// Returns a shared NorthwindObjectContext instance. /// </summary> public override T ObjectContext { get { lock (_lockObject) { if (_objectContext == null) { string connectionString = ObjectContextHelper.GetEntityConnectionString(); _objectContext = Activator.CreateInstance(typeof(T), new object[] { connectionString }) as T; } } return _objectContext; } } }

View Complete Post

More Related Resource Links

Construct Regular Expressions

Hi ,  I need to construct a regular expression for the password textbox which shouldn't accept special characters($,@,!,etc).Even whitespaces,tabs. I tried the below this accepts special characters. Any inputs <asp:RegularExpressionValidator ID="RegEx" runat="server" ControlToValidate="Password" ErrorMessage="Password must be atleast 8 characters and include a number,alphabets upper case and lower case. "ToolTip="Password format is not correct" ValidationExpression="^(?=.{8})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$"> </asp:RegularExpressionValidator>    Regards  Janet

parsing "(?(?\d+-\d+-\d+)\s+...) - Unrecognized grouping construct.


hello everyone

i am trying a regular expression for the FTP Server List Formats (e.g.  drwxr-xr-x 1 ftp ftp 0 Mar 15 2010 .Test Folder11). but my regular expression gives me this error :

parsing "(?(?\d+-\d+-\d+)\s+)(?\d+\:\d+(AM|PM))\s*)(?((?\)|(?\d+))\s*)(?\w+))" - Unrecognized grouping construct.

The original regular expression is :@"(?" + @"(?\d+-\d+-\d+)\s+)" + 

                @"(?\d+\:\d+(AM|PM))\s*)" + 

                @"(?((?\)|(?\d+))\s*)" +


                RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace

                | RegexOptions.Compiled


please suggest some regular expression or solution for this problem.

thanks in advance.

How to construct a regular expression

Hi Everyone, I need to Construct a Regular expression in the below format. AppID: Description AppID: EXP (should be 2-6 chars capital letters) Description: Meaningful name for the form Max Length is 60 chars -No underscore characters are to be used in form names for example the regular expression should be EXP: RequestCreate I have written a Regular expression like this "^([A-Z]{2,6}:\\s){1,60}$"; for Appid and to restrict _ I have written like this ^[^><]+$ individually but how to combine them so that every thing works perfectly.When I join them I am geting error.Thanks for the help.

Unable to construct SerializerProvider on Windows 7(64-Bit machine)

I have an application which is target at any CPU.  Under 32-bit system, it works fine, but on Windows 7(64-bit machine), I have an exception when trying to construct SerializerProvider, which seems trying to read the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WinFX Serializers" and get access is denied error. I do find out that if I build the application target at x86 and run the application as Administrator, it works fine, but that is not I wanted and also restrict to do so.

Does anyone know a solution to this? Thank you in advance.

Organizing SQL query to help construct reporting grids


I'm not sure how to phrase this question, or what I even need to be looking for, but here goes.


I have the following table:

Date (datetime)   | Data (varchar)  | State (varchar)

2010-05-08 12:35:29.998 | Interested in proposal | California
2010-06-08 12:35:29.998 | Interested in proposal | California
2010-06-09 12:35:29.998 | Interested in trial   | Texas
2010-08-08 12:35:29.998 | Interested in demo   | California

What I am trying to do is organize the data into a table to generate reports based on some small criteria (Is it a demo, trial, or proposal they are requesting?). What my goal is to end up with something like this:

State    |  January | February | March | April | ....
Alabama   |  3   |  0   |  2  |  10 | ...
California |  10   |  2   |  0  |  9  | ....

I have a query that does some of this. It can group the data in the following format:

state  |  Total  |  Month
Alabama |  10   |  1
Alabama |   2   |  2
Alabama |   3   |  3

The problem I have, is I can't easily loop through this row-by-row and insert it into a table. I've been looking around and thinking of ways t

How do I programatically construct a data binding?


I am trying to build a custom control that expands on the base TextBlock.  I created a UserControl (NewTextBlock) that contains a Label and TextBlock wrapped within a WrapPanel.  I also added new Dependency Properties (IsRequired, IsNumeric, MinValue, MaxValue) and their validation routines to the NewTextBlock class.  I can now add a NewTextBlock control to the UI and it has a label and new properties.

My problem is setting the binding for the NewTextBlock.  It actually needs to be linked to the internal TextBlock.  How would this be accomplished in C#?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend