This post originated from an RSS feed registered with .NET Buzz
by James Avery.
Original Post: Extensibility?
Feed Title: .Avery Blog
Feed URL: /blog/Install/BlogNotConfiguredError.aspx
Feed Description: .NET and everything nice
Latest .NET Buzz Posts
Latest .NET Buzz Posts by James Avery
Latest Posts From .Avery Blog
Advertisement
Let's say you want to change the list of regular expressions normally displayed in the RegexTypeEditor, is this code a good sign? (Reflector is good)
private object [] get_CannedExpressions (){ object [] objArray1 ; if (RegexEditorDialog .cannedExpressions == null ) { objArray1 = new object [15 ]; objArray1 [0 ] = SR .GetString ("RegexCanned_Custom" ); objArray1 [1 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_SocialSecurity" ), @"\d{3}-\d{2}-\d{4}" ); objArray1 [2 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_USPhone" ), @"((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}" ); objArray1 [3 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_Zip" ), @"\d{5}(-\d{4})?" ); objArray1 [4 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_Email" ), @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ); objArray1 [5 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_URL" ), @"http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" ); objArray1 [6 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_FrZip" ), @"\d{5}" ); objArray1 [7 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_FrPhone" ), @"(0( \d|\d ))?\d\d \d\d(\d \d| \d\d )\d\d" ); objArray1 [8 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_DeZip" ), @"(D-)?\d{5}" ); objArray1 [9 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_DePhone" ), @"((\(0\d\d\) |(\(0\d{3}\) )?\d )?\d\d \d\d \d\d|\(0\d{4}\) \d \d\d-\d\d?)" ); objArray1 [10 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_JpnZip" ), @"\d{3}(-(\d{4}|\d{2}))?" ); objArray1 [11 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_JpnPhone" ), @"(0\d{1,4}-|\(0\d{1,4}\) ?)?\d{1,4}-\d{4}" ); objArray1 [12 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_PrcZip" ), @"\d{6}" ); objArray1 [13 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_PrcPhone" ), @"(\(\d{3}\)|\d{3}-)?\d{8}" ); objArray1 [14 ] = new RegexEditorDialog .CannedExpression (SR .GetString ("RegexCanned_PrcSocialSecurity" ), @"\d{18}|\d{15}" ); RegexEditorDialog .cannedExpressions = objArray1 ; } return RegexEditorDialog .cannedExpressions ;} Basically you would have to create a new Type Editor which inherits from this one, then create a new control which inherits from the RegexValidator and then add an attribute targeting your new type editor. Obviously not built with extension in mind, unless I am missing something.
-James
Read: Extensibility?