tag:blogger.com,1999:blog-78732876088099722742024-02-07T04:12:06.786+01:00Sebastian TalamoniI am R&D Manager of GenWise Studio (www.genwise.com) and will use this BLOG to make technical comments.Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-7873287608809972274.post-81517980777465159492010-08-23T11:56:00.002+02:002010-08-23T12:07:13.404+02:00Silverlight4 + RIA services : DomainDataSource not found.I've started to review Silverlight4 + RIA services and got some minor problem following some of the videos/website.<br /><br />Specifically I could not find the DomainDataSource.<br /><br />While watching <a href="http://www.silverlight.net/learn/videos/all/net-ria-services-intro/">this great video by Tim Heuer</a> I got stuck when he starts talking about the DomainDataSource.<br /><br />Assembly: System.Widows.Controls.DomainServices.dll<br /><br />For some reason DomainDataSource was not in the toolbox. Furthermore, I could not even find it neither on Add new reference dialog nor in the GAC.<br /><br />If found that assembly at: <br />C:\Program Files (x86)\Microsoft SDKs\RIA Services\v1.0\Libraries\Silverlight<br /><br />So this post might save you some searching minutes..Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-91039896108137123322009-10-26T15:01:00.003+01:002009-10-26T15:08:44.509+01:00Microsoft Security Essentials and SourceGear VaultLately I've been having problems using Source Gear Vault version 4.1.4<br />I've never had any problem like this with Vault so i started thinking what did I install on the last days. The answer was Microsoft Security Essentials.<br /><br />I was getting this ugly error message:<br />Getting latest version of files<br /><span style="font-size:85%;">Local file update for $/MyFile.cs failed: System.UnauthorizedAccessException: Access to the path 'C:\Users\genwise\AppData\Local\Temp\tmpC692.tmp' is denied.<br />at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)<br />at System.IO.File.Delete(String path)<br />at VCDiff.VCDiff.Apply()<br />at VaultClientOperationsLib.WorkingFolder.UpdateHiddenFileContentsFromDelta(VaultClientFile file, String deltaFile, Int64 baseVersion, Int64 targetVersion, UInt32 targetCRC, Int64 targetSize)<br />at VaultClientOperationsLib.UpdateThread.ProcessCommand(UpdateThreadCommand command, UpdateThreadCommandResult& outputResult)</span><br /><br />Luckily they guys at Microsoft included a nice option to exclude certain files and folders. Thanks to this I was able to get rid of this problem ( I am not a security export so i hope I didn't open a Pandora Box with this change..)<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMP6EmO5PHVLs1Sh5QkLjmz-VkGr8SltJPXCgYI_I4dJgAbDL4TvqcdkDonGdUKg-f-22GeAZP6tM0hHRly_uPuNtGskMov8OBnNYPdls5hMMAgHvRUhbEPsM_cOJlDy_NWksAa3B4fgob/s1600-h/Microsoft+Security+Essentials+and+Vault.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 311px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMP6EmO5PHVLs1Sh5QkLjmz-VkGr8SltJPXCgYI_I4dJgAbDL4TvqcdkDonGdUKg-f-22GeAZP6tM0hHRly_uPuNtGskMov8OBnNYPdls5hMMAgHvRUhbEPsM_cOJlDy_NWksAa3B4fgob/s400/Microsoft+Security+Essentials+and+Vault.jpg" alt="" id="BLOGGER_PHOTO_ID_5396909871154495506" border="0" /></a>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com155tag:blogger.com,1999:blog-7873287608809972274.post-56998105537930250912009-10-11T13:09:00.003+02:002009-10-11T13:31:50.012+02:00IIS 64bits and Oracle 32bits<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;font-family:arial,sans-serif;font-size:100%;" ><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre;">At the office we have new i7 machines with 64bit OS.<br />I've spent 2hs to find a solution to this problem so it's worth blogging about it.<br /><br />I had a DNN site using my own BOLayer which in turn used Oracle (10.2)<br /><br />I was getting this error on IIS : "the provider is not compatible with the version of Oracle client"<br /><br />Tried almost everything until I've noticed a nice option in the IIS Application pool advance settings:<br />"Enable 32-Bit Applications" which weirdly enough was configured as false (default value).<br /><br /></span></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwNNC2RQ-HnCePsf1nNa1BiLnZQCADwHIAuIqhZyO7xpWYjyZuC_OAGENgQ58eYCn9hQOtVOl_YxaHqJ8bdbQzZpmD3VgwIAmN7fg2wIBgwItUk5HGK9iXPU812-6UgtOxB5GKMR7NSOZO/s1600-h/IIs+32bits.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 83px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwNNC2RQ-HnCePsf1nNa1BiLnZQCADwHIAuIqhZyO7xpWYjyZuC_OAGENgQ58eYCn9hQOtVOl_YxaHqJ8bdbQzZpmD3VgwIAmN7fg2wIBgwItUk5HGK9iXPU812-6UgtOxB5GKMR7NSOZO/s400/IIs+32bits.jpg" alt="" id="BLOGGER_PHOTO_ID_5391303594758205954" border="0" /></a><br /><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;font-family:arial,sans-serif;font-size:100%;" ><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre;"><br /><br /></span></span><span style="font-size:100%;"><br /></span>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-17503255776824322302009-10-08T09:45:00.009+02:002009-10-09T08:27:51.003+02:00Google Translate API for .NET 0.3We use localization in some of our WPF projects and I was wondering how easy would be to integrate the Google Translate API. I must say it has been unbelievable easy to use it! Check the code below:<br /><br /><div style="background: white none repeat scroll 0% 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"> <pre style="margin: 0px;"><br /></pre></div> <div style="background: white none repeat scroll 0% 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"> <pre style="margin: 0px;"><span style="color: blue;">using</span> Google.API.Translate;</pre> <pre style="margin: 0px;"><span style="color: blue;">using</span> NUnit.Framework;</pre> <pre style="margin: 0px;"> </pre> <pre style="margin: 0px;"><span style="color: blue;">namespace</span> GoogleTranslation</pre> <pre style="margin: 0px;">{</pre> <pre style="margin: 0px;"> [<span style="color: rgb(43, 145, 175);">TestFixture</span>]</pre> <pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: rgb(43, 145, 175);">GoogleTransationFixture</span></pre> <pre style="margin: 0px;"> {</pre> <pre style="margin: 0px;"> [<span style="color: rgb(43, 145, 175);">Test</span>]</pre> <pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> TranslateTest()</pre> <pre style="margin: 0px;"> {</pre> <pre style="margin: 0px;"> <span style="color: blue;">var</span> client = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">TranslateClient</span>(<span style="color: rgb(163, 21, 21);">"test"</span>);</pre> <pre style="margin: 0px;"> <span style="color: blue;">var</span> result = client.Translate(<span style="color: rgb(163, 21, 21);">"casa"</span>, <span style="color: rgb(43, 145, 175);">Language</span>.Spanish, <span style="color: rgb(43, 145, 175);">Language</span>.Dutch);</pre> <pre style="margin: 0px;"> <span style="color: rgb(43, 145, 175);">Assert</span>.IsNotEmpty(result);</pre> <pre style="margin: 0px;"> <span style="color: rgb(43, 145, 175);">Assert</span>.AreEqual(<span style="color: rgb(163, 21, 21);">"huis"</span>, result);</pre> <pre style="margin: 0px;"> }</pre> <pre style="margin: 0px;"> }</pre> <pre style="margin: 0px;">}</pre> </div>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-81451767175620685902009-02-26T13:19:00.004+01:002009-02-26T13:39:39.550+01:00Creating RibbonTab programaticallyI've spent several hours on this issue so it's worth document it just in case it might help someone out there...<div><br /></div><div>When using CWPF (aka Prism) in combintation with the RibbonControlsLibrary I was having a weird problem that my RibbonTabs created "inside" the Prism Modules where loosing it's bindign context and therefore the icon/text was gone (the 2nd time).</div><div><br /></div><div><div><br /></div><div>Both <a href="http://bartekszafko.pl/2008/11/29/en-wpf-ribbon-in-prism-applications/">Bartek Szafko</a> and<a href="http://blog.joachim.at/?p=44"> Joachim Kerschbaumer</a> articles explain very nicely how to create adapter to be able to use RibbonTabs inside CWPF. I am not going to talk about that in this entry so please read them before in case you are just starting with the RibbonControlsLibrary .</div><div><br /></div><div>My problem is that each of the RibbonTabs created inside CWPF IModule is also driven by a ViewModel. </div><div><br /></div><div><div> public partial class DynamicTab </div><div> {</div><div> public DynamicTabVM ViewModel { get; private set; }</div><div><br /></div><div> public DynamicTab()</div><div> {</div><div> InitializeComponent();</div><div> DataContext = ViewModel= new DynamicTabVM();</div><div> }</div><div><br /></div></div><div>The technique of re-attaching the RibbonTab works fine if there is no databinding or it's using static resources.</div><div><br /></div><div>In my scenario all the RibbonButtons have a Bindingg against an ICommand in the viewModel.</div><div> </div><div><div><r:ribbongroup></r:ribbongroup></div><div>When "switching" between Ribbon Tabs --> the DataContext was gone for the "dynamic" RibbonTab. <br /></div></div><div><br /></div><div>I COULD not solve the problem by changing the binding to RelativeSource. Probably this is because I am new to WPF binding and the IDE (vs.net 2008) does not really help at all here.<br /></div><div><br /></div><div><br /></div><div><div> private void AddDynamicTabs()</div><div> {</div><div> //Create the Tab.</div><div> var dynamicTab = new DynamicTab();</div><div><br /></div><div> // The tab DataContext is the ViewModel.</div><div> var vm = (DynamicTabVM) dynamicTab.DataContext;</div><div><br /></div><div> // Take the included ribbon tab.</div><div> RibbonTab tab = dynamicTab.DynamicRibbonTab;</div><div> </div><div> // Disconnect from container</div><div> dynamicTab.Content = null;</div><div><br /></div><div> // Re-assign the DataContext</div><div> tab.DataContext = vm;</div><div><br /></div><div><br /></div><div> foreach (var group in tab.Groups)</div><div> {</div><div> group.DataContext = vm;</div><div><br /></div><div> foreach (var control in group.Controls)</div><div> {</div><div> if (control is RibbonButton)</div><div> {</div><div> (control as RibbonButton).DataContext = vm;</div><div> }</div><div> // TODO : Applies to more controls.. We are currently using RibbonButton.</div><div> }</div><div> }</div><div><br /></div><div> MyRibbon.Tabs.Add(tab);</div><div><br /></div><div> // This is needed to be able to view the NEW tab using the correct Style/Skin.</div><div> MyRibbon.InvalidateVisual();</div><div><br /></div><div> }<br /></div><div><br /></div><div><br /></div><div><div>You can <a href="http://www.genwise.com/download/stalamoni/RibbonTabExample.rar">download </a>the Example code.</div><div><br /></div><div>The example is not actually using CWPF and therefore this code should be included in the Adapter. </div></div></div><div><br /></div><div><br /></div><div><br /></div></div>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com41tag:blogger.com,1999:blog-7873287608809972274.post-22988603071635573092008-11-06T22:15:00.003+01:002008-11-06T23:06:57.087+01:00VSCT Designer<div>Long time since my last entry, I have just moved and have been extremely busy / chaotic during the last weeks. Back online now.</div><div><br /></div><div>I've found the following tool this seems very interesting for anybody working with DSL or VSX: </div><div>http://www.codeplex.com/VSCTDesigner<br /></div><div><br /></div><div>I did have a little problem with adding bitmaps and therefore I've created the following <a href="http://www.codeplex.com/VSCTDesigner/Thread/View.aspx?ThreadId=39374">post in the Codeplex website</a>.</div>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-2899793514151394042008-07-09T17:25:00.005+02:002008-07-09T17:38:17.688+02:00How to copy hibernate.config to the VSTS Output Folder?VSTS is now included by default in the standard/professional version of vs.net 2008. Until now i was using NUnit + TestDriver.net, etc.<br /><br />I've decided to test VSTS and found 1 big problem : my nhibernate.config file was not copied to the output directory of the test output folder. I was expecting this to be automatically since I've set the "Always Copy" in the build property for the file.<br /><br />Doing some basic Google searches I've noticed I am not the only guy having this problem.<br /><br />The solution is to open the "localtestrun.testrunconfig" file which is added automatically to the solution by VSTS, go to "Deployment" and then add the file you want to deploy/copy.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjev96IKvxfqt07OUX3zEED6Mwe6jwLbsrChrvcosUFbbIdCE2DUXKbBBWNkOBa-bhFckCafkEpX986mjwwXPFjay-jIN-IWZrDrWhGA_LPVOBOMsdVub8gFJb5lzzjbjkehVxsW2Ai_5An/s1600-h/localtestrun.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjev96IKvxfqt07OUX3zEED6Mwe6jwLbsrChrvcosUFbbIdCE2DUXKbBBWNkOBa-bhFckCafkEpX986mjwwXPFjay-jIN-IWZrDrWhGA_LPVOBOMsdVub8gFJb5lzzjbjkehVxsW2Ai_5An/s400/localtestrun.jpg" alt="" id="BLOGGER_PHOTO_ID_5221037134514143970" border="0" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br />Once this is done, the hibernate.config file copied every time we run a test. This can be seen in the image below. VSTS creates 1 output folder for each test run.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP-7V3Ty1Kk3ZpDLp-Vq1RSJ_tXpAOt3-_uPa6hB3ci3_7OqFD61d6BbgRm2zuw4BMBq8QKpUmqUpyNXLpZNhX4hbV2wsJk5h69JANPoU0Edy-Vhx41lBpvK6_04ANeygdKmsPSFjUFFJS/s1600-h/Filesystem.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP-7V3Ty1Kk3ZpDLp-Vq1RSJ_tXpAOt3-_uPa6hB3ci3_7OqFD61d6BbgRm2zuw4BMBq8QKpUmqUpyNXLpZNhX4hbV2wsJk5h69JANPoU0Edy-Vhx41lBpvK6_04ANeygdKmsPSFjUFFJS/s400/Filesystem.jpg" alt="" id="BLOGGER_PHOTO_ID_5221037133781597458" border="0" /></a>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com1tag:blogger.com,1999:blog-7873287608809972274.post-65503942259581860132008-06-28T09:04:00.010+02:002008-06-30T12:26:50.758+02:00Code Generation 2008 : more than just contentThe conference is now over.<br /><br />Besides the fact of being a very good conference, one the most important things is that during the conference I've met wonderful people. Not only we had a lot of fun together but also we discussed some very interest topics.<br /><br /><a href="http://pjmolina.com/en/">Pedro Molina</a> , me , Alejandro Silva and <a href="http://weblogs.asp.net/gmilano/default.aspx">Gaston Milano</a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrBEVera2TJ_NswQ73U28qBuJ9Mx3JEdGOQLKUFU59SQ4puLuQrz99LJycfAB6MRJ3z1FrvzsYJgaKW3wKJjDgI9lROuh737O2GIU1so89hocTEtlG8B9Bo9P6bOwemBAh2u3ukXDrK2r1/s1600-h/DSCN0020.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrBEVera2TJ_NswQ73U28qBuJ9Mx3JEdGOQLKUFU59SQ4puLuQrz99LJycfAB6MRJ3z1FrvzsYJgaKW3wKJjDgI9lROuh737O2GIU1so89hocTEtlG8B9Bo9P6bOwemBAh2u3ukXDrK2r1/s400/DSCN0020.JPG" alt="" id="BLOGGER_PHOTO_ID_5216826788232453394" border="0" /></a><br />It's was amazing to see how much we had in common and how much effort we had wasted trying to solve all of us the same stuff. We are working in our little isolated island without having ways to correctly shared/reuse some of the common concepts in our tools/products.<br /><br />Besides there deep technical knowledge and wonderful ideas, the most important thing was that we had a lot of fun together.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkiZdbsD208e2VpC0m2t_YSLuPooKO8Mt7Lp49zAEQ8OrGhnex_2EnZfsdZrwlSFacVb1KESAKQN7rzyWgsmOBJ7t_gkDLnwGI-6XwlCgo9FGEBKd5N6iwEw1H_vlko12T_oh3gG5SnhJx/s1600-h/DSCN0003.JPG"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkiZdbsD208e2VpC0m2t_YSLuPooKO8Mt7Lp49zAEQ8OrGhnex_2EnZfsdZrwlSFacVb1KESAKQN7rzyWgsmOBJ7t_gkDLnwGI-6XwlCgo9FGEBKd5N6iwEw1H_vlko12T_oh3gG5SnhJx/s400/DSCN0003.JPG" alt="" id="BLOGGER_PHOTO_ID_5216832820697449698" border="0" /></a>Another person which I was very pleased to met from Microsoft was <a href="http://blogs.msdn.com/jmprieur/">Jean-Marc Prieur</a> (picture, and yes, the guy in the background is <a href="http://blogs.msdn.com/stevecook/">Steve Cook</a>).<br /><br />He was "<span style="font-weight: bold;">extremely</span>" helpful, always open to new ideas , listened far beyond the extend of his responsibility, stayed "after" the conference to keep listening.<br />"<span style="font-weight: bold;">Chapeau</span>!!!".<br /><br />Later during next week I will write down more stuff related to my point of view of some very specific stuff I've learn.Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com2tag:blogger.com,1999:blog-7873287608809972274.post-30054042146550289702008-06-23T18:31:00.007+02:002008-06-23T19:45:24.629+02:00DSL : Model References (Backplane)A couple of months ago I've wrote this <a href="http://forums.msdn.microsoft.com/en/vsx/thread/689204d4-2e17-4a28-aefa-62735a98e766/">MSDN Forum post</a> where I was a little bit confused (and surprised) with the way of solving DSL Model References.<br /><br />Edward Bakker finally found out that in Rosario the VSX team is actually giving a standard solution for this problem. Here is a <a href="http://www.edwardbakker.nl/PermaLink,guid,bf9c3dc3-501e-4f1a-b178-de01f10ea070.aspx">detail BLOG entry</a> about his findings, which I found very interesting.<br /><br />What I wonder is when (and package into what product? I hope/think it should be the SDK), this improvement will be available.I've tried to google based on "Microsoft.VisualStudio.ToolIntegration.Backplane.dll" and Edward's blog was the only result.<br /><br />I will try to find this information in <a href="http://www.codegeneration.net/conference/index.php">Code Generation conference</a> which I will be attending this week.Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com1tag:blogger.com,1999:blog-7873287608809972274.post-34087727646486850332008-04-08T10:50:00.004+02:002008-04-08T12:04:21.249+02:00ObjectDataSource : Manually controlling the sorting expression.By default the GenWise ASP.NET Templates uses the object datasource SortParamterName. When that property is used , the objectdatasource will manipulate internally the sort expression (change to asc , desc) .<br /><br /><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 269</span> <asp:><span style="color: rgb(43, 145, 175);">ObjectDataSource</span> runat=<span style="color: rgb(163, 21, 21);">"server"</span> ID=<span style="color: rgb(163, 21, 21);">"ObjectDataSource1"</span> TypeName=<span style="color: rgb(163, 21, 21);">"BOLayer.CustomerFactory"</span></asp:></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 270</span> SelectCountMethod=<span style="color: rgb(163, 21, 21);">"Count"</span> EnablePaging=<span style="color: rgb(163, 21, 21);">"True"</span> UpdateMethod=<span style="color: rgb(163, 21, 21);">"Save"</span> DeleteMethod=<span style="color: rgb(163, 21, 21);">"Delete"</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 271</span> SortParameterName=<span style="color: rgb(163, 21, 21);">"pSortExpression"</span> MaximumRowsParameterName=<span style="color: rgb(163, 21, 21);">"pMaxResult"</span> StartRowIndexParameterName=<span style="color: rgb(163, 21, 21);">"pFirstResult"</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 272</span> SelectMethod=<span style="color: rgb(163, 21, 21);">"GetAll"</span>></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 273</span> <selectparameters></selectparameters></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 274</span> <asp:><span style="color: rgb(43, 145, 175);">Parameter</span> Name=<span style="color: rgb(163, 21, 21);">"pSortExpression"</span>></asp:><span style="color: rgb(43, 145, 175);">Parameter</span>></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 275</span> <asp:><span style="color: rgb(43, 145, 175);">Parameter</span> Name=<span style="color: rgb(163, 21, 21);">"pCriteria"</span>></asp:><span style="color: rgb(43, 145, 175);">Parameter</span>></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 276</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 277</span> <deleteparameters></deleteparameters></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 278</span> <asp:><span style="color: rgb(43, 145, 175);">Parameter</span> Name=<span style="color: rgb(163, 21, 21);">"CustomerID"</span>></asp:><span style="color: rgb(43, 145, 175);">Parameter</span>></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 279</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 280</span> <span style="color: rgb(43, 145, 175);">ObjectDataSource</span>></pre> </div><br /><br />For more advanced sorting scenarios you might want to manually control what's passed to the pSortExpression method parameter. This can be done in the following way :<br /><br />Subscribe to the ObjectDataSource Selecting method (genwise does that automatically)<br /><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 44</span> ObjectDataSource1.Selecting += <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">ObjectDataSourceSelectingEventHandler</span>(ObjectDataSource1_Selecting);<br /><br /><br /><br /></pre><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 253</span> <span style="color:blue;">protected</span> <span style="color:blue;">void</span> ObjectDataSource1_Selecting(<span style="color:blue;">object</span> pSender, <span style="color: rgb(43, 145, 175);">ObjectDataSourceSelectingEventArgs</span> pEventArgs)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 254</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 255</span> <span style="color:blue;">if</span> (pEventArgs.ExecutingSelectCount)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 256</span> pEventArgs.InputParameters.Remove(<span style="color: rgb(163, 21, 21);">"pSortExpression"</span>);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 257</span> <span style="color:blue;">else</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 258</span> pEventArgs.InputParameters[<span style="color: rgb(163, 21, 21);">"pSortExpression"</span>] = _newSortExpression;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 259</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 260</span> pEventArgs.InputParameters[<span style="color: rgb(163, 21, 21);">"pCriteria"</span>] = Browse1_GetCriteria();</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 261</span> }</pre> </div> <pre style="margin: 0px;"><br /><span style="font-size:130%;">Where does _newSortExpression come from ? </span><br /><br /><br /></pre><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 198</span> <span style="color:blue;">string</span> _newSortExpression = <span style="color:blue;">null</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 199</span> <span style="color:blue;">protected</span> <span style="color:blue;">void</span> Browse1_Sorting(<span style="color:blue;">object</span> pSender, <span style="color: rgb(43, 145, 175);">GridViewSortEventArgs</span> pEventArgs)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 200</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 201</span> <span style="color:green;">// Calls this method to adapt the sort syntax (required for Composite sorting).</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 202</span> _newSortExpression = <span style="color: rgb(43, 145, 175);">WebUtils</span>.SortExpressionTransformer(pEventArgs);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 203</span> pEventArgs.Cancel = <span style="color:blue;">true</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 204</span> }</pre> </div> <pre style="margin: 0px;"><br /></pre> </div><br />SortExpression Tranformer takes the ObjectDataSource parameters and manipulates them to make them compatible with the GenWise Factories sorting syntax.<br /><br />Below is the code of this method:<br /><br /><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 63</span> <span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">string</span> SortExpressionTransformer(<span style="color: rgb(43, 145, 175);">GridViewSortEventArgs</span> pEventArgs)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 64</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 65</span> <span style="color:blue;">if</span> (pEventArgs == <span style="color:blue;">null</span>) <span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">ArgumentNullException</span>(<span style="color: rgb(163, 21, 21);">"pEventArgs"</span>);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 66</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 67</span> <span style="color:blue;">if</span> (pEventArgs.SortDirection == <span style="color: rgb(43, 145, 175);">SortDirection</span>.Ascending)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 68</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 69</span> <span style="color:blue;">return</span> pEventArgs.SortExpression;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 70</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 71</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 72</span> <span style="color:blue;">string</span> newSortExpression = pEventArgs.SortExpression;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 73</span> <span style="color:blue;">string</span> DESC = <span style="color: rgb(163, 21, 21);">" DESC"</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 74</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 75</span> <span style="color:blue;">if</span> (pEventArgs.SortDirection == <span style="color: rgb(43, 145, 175);">SortDirection</span>.Descending)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 76</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 77</span> <span style="color:blue;">if</span> (pEventArgs.SortExpression.Contains(<span style="color: rgb(163, 21, 21);">","</span>))</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 78</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 79</span> <span style="color:green;">// Case : We have a composite sorting ( Field1,Field2) </span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 80</span> newSortExpression = <span style="color:blue;">string</span>.Empty;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 81</span> <span style="color:blue;">string</span>[] sortParts = pEventArgs.SortExpression.Split(<span style="color: rgb(163, 21, 21);">','</span>);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 82</span> <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i <> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 83</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 84</span> <span style="color:blue;">string</span> sortPart = sortParts[i];</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 85</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 86</span> <span style="color:blue;">int</span> sortDirectionIndex = sortPart.IndexOf(DESC);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 87</span> <span style="color:blue;">bool</span> isDescending = (sortDirectionIndex > -1);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 88</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 89</span> <span style="color:blue;">string</span> property = sortPart;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 90</span> <span style="color:blue;">if</span> (isDescending)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 91</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 92</span> <span style="color:green;">// sta : udpate templates.</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 93</span> <span style="color:green;">//property = sortPart.Substring(0, (sortPart.Length - sortDirectionIndex + 1));</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 94</span> property = sortPart.Substring(0, (sortPart.Length - sortDirectionIndex + 1 + DESC.Length));</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 95</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 96</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 97</span> <span style="color:blue;">if</span> (i > 0) newSortExpression += <span style="color: rgb(163, 21, 21);">","</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 98</span> newSortExpression += property;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 99</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 100</span> <span style="color:green;">// Only add the DESC to all except the last (Last one will be controlled automatically by the object datasource.</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 101</span> <span style="color:blue;">if</span> (!isDescending)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 102</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 103</span> <span style="color:blue;">if</span> (i < (sortParts.Length - 1))</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 104</span> newSortExpression += DESC ;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 105</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 106</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 107</span> pEventArgs.SortExpression = newSortExpression;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 108</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 109</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 110</span> <span style="color:blue;">return</span> newSortExpression;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 111</span> }</pre> </pre></div>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com1tag:blogger.com,1999:blog-7873287608809972274.post-33102507962093216892008-04-07T09:13:00.006+02:002008-04-07T09:25:45.674+02:00GenWise generated project added to vs.net solution using Source control.Several customers have asked me how they can integrate an existing GenWise project into their vs.net solutions. To be more specific, GenWise already generates 100% compatible project files, so what's the problem?<br /><br />Well, If you want to add the generated project into an existing solution and at the same time you can to keep that solution in source safe ( or in sourcegear vault which I use and recommend) then you might hit some little problems.<br /><br /><span style="font-weight: bold;">Problem #1 :</span> Every time you regenerate the project is seen as a "new" project for the solution.<br />The reason behind this is that when you add the project to the solution the .proj file is modified with specific source control information + and ID (Guid) is given, etc.<br />To solve this problem you can "copy/paste" this information from the "modified" version of the project file INTO the GenWise project, so when you re-generate you don't loose this info .<br /><br />Click on the image to enlarge an example for the solution to problem #1.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSucIECx5IEJZIiPN9RA7p5ejMhhML5NGht40WxcBs-YzZ-tudIPU2k6lD2_2_M_y6oS-rRWOPtiJam09D0ry5B91F38BXnziE1MtIc-slTLFsC-Ep4X2MDbGa4HJqlh7f6OUsuiE7QcrN/s1600-h/MsBuild+Project+file.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSucIECx5IEJZIiPN9RA7p5ejMhhML5NGht40WxcBs-YzZ-tudIPU2k6lD2_2_M_y6oS-rRWOPtiJam09D0ry5B91F38BXnziE1MtIc-slTLFsC-Ep4X2MDbGa4HJqlh7f6OUsuiE7QcrN/s400/MsBuild+Project+file.jpg" alt="" id="BLOGGER_PHOTO_ID_5186398800790859922" border="0" /></a><br /><br /><br /><span style="font-weight: bold;">Problem #2 :</span> After you have added the project to a source control provider ( vss or vault) all the files will be automatically read-only (by default) so you need to explicity do a complete project check out before you use the regenerate options from GenWise.Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com1tag:blogger.com,1999:blog-7873287608809972274.post-5668748440314167082008-02-07T22:25:00.000+01:002008-02-07T23:06:32.274+01:00Custom Security MembershipProvider & Login attempts (MaxInvalidPasswordAttempts)The Problem : Have a limit on the amount of possible logins when using a Custom provider.<br /><br />Let's say that you write your own MembershipProvider (quite common if you want to use your own object model ..)<br /><br /><div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 11</span> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: rgb(43, 145, 175);">MyMemberShipProvider</span> : System.Web.Security.<span style="color: rgb(43, 145, 175);">MembershipProvider</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 12</span> {</pre> </div> <br />Like many other articles explain, the most important Method is ValidateUser.<br />What very people often "forget"to mention is that all other features are not present in your provider. For example, the MaxInvalidPasswordAttempts is a property that you can set it to any number but nothing is going to happen.<br /><br /><span style="font-weight: bold; font-style: italic;">In a Nutshell : you need to implement it yourself. </span><br /><br />What I am showning below is a quite simple version but it's proves the point.<br /><br /><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"><pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 180</span> <span style="color:blue;">public</span> <span style="color:blue;">override</span> System.<span style="color: rgb(43, 145, 175);">Boolean</span> ValidateUser(System.<span style="color: rgb(43, 145, 175);">String</span> pUsername, System.<span style="color: rgb(43, 145, 175);">String</span> pPassword)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 181</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 182</span> <span style="color:blue;">if</span> (pUsername.Equals(<span style="color: rgb(163, 21, 21);">"demo"</span>) && pPassword.Equals(<span style="color: rgb(163, 21, 21);">"demo"</span>))</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 183</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 184</span> <span style="color:blue;">return</span> LoginSuccess();</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 185</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 186</span> <span style="color:blue;">return</span> LoginFailed();</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 187</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 188</span> }</pre> </div><br />LoginFailed() will basically return false but also it would do the check if another attempt should be granted or not:<br /><br /><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 211</span> <span style="color:blue;">private</span> <span style="color:blue;">bool</span> LoginFailed()</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 212</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 213</span> <span style="color:green;">//WebFailureAuditEvent.Raise(WebEventCodes.AuditFormsAuthenticationFailure);</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 214</span> LoginFailuresCount++;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 215</span> <span style="color:blue;">if</span> (LoginFailuresCount >= <span style="color:blue;">this</span>.MaxInvalidPasswordAttempts)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 216</span> <span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">Exception</span>(<span style="color: rgb(163, 21, 21);">"OK, that's it. Bye Bye"</span>);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 217</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 218</span> <span style="color:blue;">return</span> <span style="color:blue;">false</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 219</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 220</span> }</pre> </div><br /><br /><pre style="margin: 0px;"><span style="color:green;"><br /></span></pre>You need to keep track of how many login failures :<br /><br /><div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 197</span> <span style="color:blue;">protected</span> <span style="color:blue;">int</span> LoginFailuresCount</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 198</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 199</span> <span style="color:blue;">get</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 200</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 201</span> <span style="color:blue;">if</span> (<span style="color: rgb(43, 145, 175);">HttpContext</span>.Current.Session[<span style="color: rgb(163, 21, 21);">"Failures"</span>] == <span style="color:blue;">null</span>)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 202</span> <span style="color:blue;">return</span> 0;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 203</span> <span style="color:blue;">return</span> (<span style="color:blue;">int</span>)<span style="color: rgb(43, 145, 175);">HttpContext</span>.Current.Session[<span style="color: rgb(163, 21, 21);">"Failures"</span>];</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 204</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 205</span> <span style="color:blue;">set</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 206</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 207</span> <span style="color: rgb(43, 145, 175);">HttpContext</span>.Current.Session[<span style="color: rgb(163, 21, 21);">"Failures"</span>] = <span style="color:blue;">value</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 208</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 209</span> }<br /><br /></pre> </div><br />In the commented line where I was trying to Raise the "<span style="color:green;">WebFailureAuditEvent</span>", I read somewhere that I was a good idea to raise it but could not find any reference or example. If anybody knows how to do it --> please let me know.<br /><br />Note: An improvement to this model would be to support "PasswordAttemptWindow" which in this case I did not implement.<br /><br />Note: New Browser == new Session so it's not really state-of-the-art security technique it's a basicSebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com17tag:blogger.com,1999:blog-7873287608809972274.post-68951842190660453372008-01-17T16:53:00.000+01:002008-01-17T17:26:46.261+01:00DSL - How to use DesignVerbs with shapes?Although I've previously wrote<a href="http://stalamoni.blogspot.com/2007/12/adding-menu-to-dsl-using-vsnet-2008-sdk.html"> in this post</a> about how you could add Menu Commands to shapes, I am still searching for alternative (maybe better?) approaches for exposing commands from my domain classes.<br /><br /><span style="font-style: italic;">Why? Because the other way is too complex (too many steps) and I have many actions/commands.</span><br /><br />Every time you click on a shape, a PropertyGrid is used to expose the ShapeProperties + DomainProperties (yes, they are merged in the PropertyGrid).<br /><br />So, one natural approach would be to think "Why not add DesignVerbs as done for Custom Controls?". <a href="http://forums.microsoft.com/msdn/showpost.aspx?postid=2581053&siteid=1#2581053&SiteID=1">This question</a> was asked in the msdn forum with null replied (until now ;) )<br /><br />What I did was combined <a href="http://blogs.crankygoblin.com/blogs/geoff.appleby/archive/2005/06/16/64688.aspx">the idea from Geoff Appleby</a> with a Custom partial class for each shape (off course only for the ones you need some special command/verb).<br /><br />This is how the final solution looks like:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZdBDW7LEJtKzUqLEa5AhREIr6PxmKWRod3AuAGK4K73SlBoDMpx8TmEnHBRnxnPFW2xBcIBwN2GtZ-DSsipRcQTG5m9lQMce9n1pSS_7p3pBugEw__ONA2GW0fibgNTX4vOu6Gnv-5dRl/s1600-h/DSL+DesignVerbs.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZdBDW7LEJtKzUqLEa5AhREIr6PxmKWRod3AuAGK4K73SlBoDMpx8TmEnHBRnxnPFW2xBcIBwN2GtZ-DSsipRcQTG5m9lQMce9n1pSS_7p3pBugEw__ONA2GW0fibgNTX4vOu6Gnv-5dRl/s400/DSL+DesignVerbs.jpg" alt="" id="BLOGGER_PHOTO_ID_5156478459992942274" border="0" /></a><br />As you can see, "My Custom Action" and "Synchronize" are my exposed Actions/Commands. Here is the code that defines what to show:<br /><br /><span style="color: rgb(0, 0, 153);"> </span><span style="color: rgb(0, 0, 153);font-size:85%;" >public DesignerVerbCollection Verbs<br /> {<br /> get {<br /> DesignerVerbCollection verbs = new DesignerVerbCollection();<br /> verbs.Add( new DesignerVerb("My Custom Action", new EventHandler(ExecuteAction1) ));<br /> verbs.Add(new DesignerVerb("Synchronize", new EventHandler(Synchronize)));<br /> return verbs;<br /> }<br />}<br /><br /> private void Synchronize(object sender, EventArgs e)<br /> {<br /> ExampleElement element = this.ModelElement as ExampleElement;<br /> if ( element == null ) return;<br /> MessageBox.Show("Action 1 was executed on model Element:" + element.Name);<br /> }<br /></span><br />Off course it's not only that since you need to also implement 2 interfaces:<br /><br /><span style="color: rgb(51, 0, 153);font-size:85%;" > public partial class ExampleShape : DslDiagrams::NodeShape, IComponent, IVerbsHost<br /> {<br /><br /> private ISite _site;<br /><br /> public ISite Site<br /> {<br /> get<br /> {<br /> if (_site == null)<br /> _site = new VerbSite(this, new VerbMenuCommandService(this));<br /> return _site;<br /> }<br /> set { _site = value; }<br /> }<br /><br />public interface IVerbsHost { DesignerVerbCollection Verbs { get; }}<br /></span><br />Drop me an e-mail if you are interested in the complete source code ( blogger does not have file upload i think.. need to check..)<br /><br /><span style="font-weight: bold; font-style: italic; color: rgb(153, 0, 0);">TODO : Next I would like to combine both techniques be able to access this design verbs not only from the PropertyGrid but also from the Shape's right mouse and DSL Explorer. </span>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com20tag:blogger.com,1999:blog-7873287608809972274.post-74748286753561799802008-01-15T17:11:00.001+01:002008-01-15T17:31:26.987+01:00Cleaning "old" DSL LanguagesIf you are , like me, new to DSLs you will end up creating many DSL projects. ;)<br /><br />After a while your "New Item" dialog will end up looking really crowded.<br /><br />Don't ask me why but the "Reset the Microsoft Visual Studio 2008 Experimental hive" option does not seem to work on all cases, and I still have several old dsl languages which won't go away. ( Note: I guess that the reset option by design will not mess us local user's document as explained below)<br /><br />First, I've tried , with no success, to follow <a href="http://geeks.ms/blogs/elbruno/archive/2007/12/05/dsl-limpiando-un-entorno-quot-sucio-quot-de-dsls.aspx">the tip from "El Bruno"</a> (spanish blog) .<br /><br /><span style="font-weight: bold;"><span style="font-size:100%;">What's the solution ?</span><br /><br /></span>You need to "remove"all the zip files in the following directories:<br /><br /><span style="font-size:85%;">C:\Users\<yourusername><yourusername>\Documents\Visual Studio 2008\My Exported Templates</yourusername></span><br /><span style="font-size:85%;"><yourusername>C:\Users\<yourusername></yourusername></yourusername><yourusername></span><yourusername><yourusername><span style="font-size:85%;">\Documents\Visual Studio 2008\Templates\ItemTemplates\CSharp\1033</span></yourusername></yourusername><br /><yourusername><yourusername><span style="font-size:85%;">C:\Users\<yourusername>\Documents\Visual Studio 2008\Templates\ItemTemplates\VisualBasic\1033</span></yourusername></yourusername><br /><yourusername style="font-style: italic;"><yourusername><br />Note: On every DSLPackage build , a new file <yourdsl>.zip will be created and placed on that directory. So before trying to open your DSL make sure you build the project first.</yourdsl></yourusername></yourusername>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com1tag:blogger.com,1999:blog-7873287608809972274.post-19382335623159155912008-01-09T15:48:00.000+01:002008-01-09T17:04:04.224+01:00Text Templating (tt) : calling custom methodThe simplest re-usability technique inside .tt files would be to call a class method.<br /><br />Below there is an example of how to achieve this:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU1v_f_7F5COmhS9T7ZhbMG1WDNbjwqjl6sb84D7i2IvcYavSI1iIO3OryaSl12J7secSb3vxz9PTdUF0VnjKU6ejLquogvlDSi75WW7gVuhwlpRRaZ-W7-QKPntMUcuyA2VL9mLZ3L9rd/s1600-h/text+templating+-+custom+method.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU1v_f_7F5COmhS9T7ZhbMG1WDNbjwqjl6sb84D7i2IvcYavSI1iIO3OryaSl12J7secSb3vxz9PTdUF0VnjKU6ejLquogvlDSi75WW7gVuhwlpRRaZ-W7-QKPntMUcuyA2VL9mLZ3L9rd/s400/text+templating+-+custom+method.jpg" alt="" id="BLOGGER_PHOTO_ID_5153490468424984226" border="0" /></a><br />It's important to notice that this syntax has changed because long time ago you could have seen it as <#! , otherwise look at this <a href="http://blogs.msdn.com/garethj/archive/2005/04/07/marchtexttemplatingsyntax.aspx">old post from Gareth</a>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-37741205288343946912008-01-09T14:01:00.001+01:002008-01-09T17:05:49.968+01:00Text Templating (.tt) ValidationDSL supports a nice validation model for the Domain classes/model.<br /><br />But what about the Text Templating requirements?<br /><br />This are validations that apply only to a specific generation task. Let's say if have a property named DotNetType. It could be that this property does not affect generation of [t1] but I need this property for [t2]. For this cases, you will need to somehow validate in the (tt) Template itself.<br /><p></p><p><br /><em>Note: You could argue (please don't) that the example below is a bad example, I know but there are still some other real cases.</em></p><h3>The 'correct' way<br /></h3><ul><li> <div>This page actually shows what's the correct technique<br /><a href="http://msdn2.microsoft.com/en-us/library/bb126597.aspx">How to: Generate Errors and Warnings from Text Templates</a><br /><br /></div> </li></ul><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiNnf_HceHw1jCgvBemUYM4aDVwcojGYRhi2DNMtRiBY7NG2ddiha1TKD712FFNQnG2Vl6IGneEVNBEpXAv73bebKyh-EeeoSiW-z3LhnTRrUGATPsgxaxDG53inmAFQY6PHcVbYwTtzzq/s1600-h/text+templating++-+validation.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiNnf_HceHw1jCgvBemUYM4aDVwcojGYRhi2DNMtRiBY7NG2ddiha1TKD712FFNQnG2Vl6IGneEVNBEpXAv73bebKyh-EeeoSiW-z3LhnTRrUGATPsgxaxDG53inmAFQY6PHcVbYwTtzzq/s400/text+templating++-+validation.jpg" alt="" id="BLOGGER_PHOTO_ID_5153506991164171954" border="0" /></a><br /><br /><br /><br /><p><br /></p><p><br /></p><p><br />I must say that before finding out that I've tried this 2 other options:<br /></p><ul><li>Raise an exception (hard but work since it's integrated with the Error list as shown below):</li></ul><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnkZcsm3G72buNEy_DqBcA7rf-6xpgypo8vcxkkQrhJNNhq1SdbcLt70ZfbN-D3XJIQrn14m3l8RD1GfQg4GGUNOHAWeT2BBV_hFfPlZW3T94QMfHTcUrNURf4Hd9LdBK2NQZwFlOnLN7q/s1600-h/ttValidation_2.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnkZcsm3G72buNEy_DqBcA7rf-6xpgypo8vcxkkQrhJNNhq1SdbcLt70ZfbN-D3XJIQrn14m3l8RD1GfQg4GGUNOHAWeT2BBV_hFfPlZW3T94QMfHTcUrNURf4Hd9LdBK2NQZwFlOnLN7q/s400/ttValidation_2.jpg" alt="" id="BLOGGER_PHOTO_ID_5153480121848768130" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5KIYbkX64mziBKo06pSare9inwUn8zQaRkLWwVVAjhNNn-omdIGpBNzOdwPx4n52BRoeZ-Sy6T_o0Vt1z24OQYnRAsJgK4KUVrd9pwgfAjiUSQfDvyTGVabFOL5fj1LbvE-eXxxl2UTZ_/s1600-h/ttValidation_3.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5KIYbkX64mziBKo06pSare9inwUn8zQaRkLWwVVAjhNNn-omdIGpBNzOdwPx4n52BRoeZ-Sy6T_o0Vt1z24OQYnRAsJgK4KUVrd9pwgfAjiUSQfDvyTGVabFOL5fj1LbvE-eXxxl2UTZ_/s400/ttValidation_3.jpg" alt="" id="BLOGGER_PHOTO_ID_5153480126143735442" border="0" /></a><p></p><p></p><p></p><ul><li>Just add a comment to the output file (this is not always possible ( example : asp.net template based controls like GridView don't support XML comment inside their tpl tags..)<br /></li></ul><h3><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiayzIlrJpv62iCc9Q2RRv7_5XP7UHPxYhmS1MxS95UZ5LPjqIfBHJY-KxUjluhjpcLeodP-9KMrtiBevvMaP8KdvuMnm2-pNP1RMdsKHKJI0qDj0ksjYeOl5nZ-voDJspAwpLOhYNztd5/s1600-h/ttValidation_1.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiayzIlrJpv62iCc9Q2RRv7_5XP7UHPxYhmS1MxS95UZ5LPjqIfBHJY-KxUjluhjpcLeodP-9KMrtiBevvMaP8KdvuMnm2-pNP1RMdsKHKJI0qDj0ksjYeOl5nZ-voDJspAwpLOhYNztd5/s400/ttValidation_1.jpg" alt="" id="BLOGGER_PHOTO_ID_5153480121848768114" border="0" /></a><br /></h3>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-91424336604954899772007-12-28T07:05:00.001+01:002007-12-28T10:47:09.963+01:00Adding a Menu to a DSL (vs.net 2008 SDK + VSCT file)<span xmlns=""><p>It's just strange that something so simple is not integrated as part of the basic features of the DSL tools themselves. Furthermore, the only DSL book I have it shows old code (refers to the old ctc file), the document in the vs.net 2008 SDK shows the same problem, etc.<br /></p><p>The "closest" example I've found is this one: <a href="http://elbruno.com/blogs/elbruno/archive/2007/09/25/dsl-como-agregar-un-menu-personalizado.aspx">El Bruno</a> (Spanish) but unfortunately, this is also based on CTC file and not using the new VSCT example. I must admit that with the new VSCT file it's easier than the previously CTC file.<br /></p><p>All the BLOG's I found showed vs.net 2005 examples all using the old ctc file.<br /></p><p>I first tried to use Clarius SFT (Software Factories Toolkit) which probably would have been a better options but I could not install it ( VS.NET 2008 RTM , can't install old GAX extensions…so SFT would also fail to install). <a href="http://www.clariusconsulting.net/blogs/vga/archive/2007/06/06/AddingCommandsToDslUsingSFT.aspx">Victor Garcia Aprea</a> had exactly <a href="http://www.clariusconsulting.net/blogs/vga/archive/2007/06/06/AddingCommandsToDslUsingSFT.aspx">the same problem</a> as looks like I share <a href="http://www.clariusconsulting.net/blogs/vga/archive/2007/06/06/AddingCommandsToDslUsingSFT.aspx">his point</a> of view about how obscure adding a menu could be.<br /></p><p>This msdn page: <a href="http://msdn2.microsoft.com/en-us/library/bb458025.aspx">VSCT Samples in C#</a> showed me the missing link: How to define the command Guid's and ID's.<br /></p><p><span style="color: rgb(31, 73, 125);"><strong><span style="font-size:130%;">Step#1: Modify Commands.vsct</span><br /> </strong></span></p><ul><li>Project = DSLPackage<br /></li><li>Open Commands.vsct<br /></li><li>Add Symbols ( Guid + ID)</li><ul><li class="MsoNormal" style=""><span style="" lang="EN-US">Please remmember that the commands ID and GUID need to be unique not only in your project but in your whole vs.net environment. I’ve created by accident 2 projects which shared the same ID and I was getting the wrong text.<o:p></o:p></span></li></ul></ul> <ul><li>Add Commands</li></ul></span> <!-- {\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 Commands\cf1 \cf4 package\cf1 =\cf0 "\cf1 guidPkg\cf0 "\cf1 >\par ??\tab \par ?? <\cf3 Buttons\cf1 >\par ?? <\cf3 Button\cf1 \cf4 guid\cf1 =\cf0 "\cf1 cmdImportDbSchemaGUID\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 cmdImportDbSchemaID\cf0 "\cf1 \cf4 priority\cf1 =\cf0 "\cf1 0x0902\cf0 "\cf1 \cf4 type\cf1 =\cf0 "\cf1 Button\cf0 "\cf1 >\par ?? <\cf3 Parent\cf1 \cf4 guid\cf1 =\cf0 "\cf1 guidCmdSet\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 grpidContextMain\cf0 "\cf1 />\par ?? <\cf3 Strings\cf1 >\par ?? <\cf3 CanonicalName\cf1 >\cf0 cmdImportDbSchema\cf1 </\cf3 CanonicalName\cf1 >\par ?? <\cf3 ButtonText\cf1 >\cf0 Import from Database Schema\cf1 </\cf3 ButtonText\cf1 >\par ?? <\cf3 ToolTipText\cf1 >\cf0 Use this option to create the domain from an existing Database Schema\cf1 </\cf3 ToolTipText\cf1 >\par ?? </\cf3 Strings\cf1 >\par ?? </\cf3 Button\cf1 >\par ?? \par ?? <\cf3 Button\cf1 \cf4 guid\cf1 =\cf0 "\cf1 cmdImportClassesGUID\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 cmdImportClassesID\cf0 "\cf1 \cf4 priority\cf1 =\cf0 "\cf1 0x0902\cf0 "\cf1 \cf4 type\cf1 =\cf0 "\cf1 Button\cf0 "\cf1 >\par ?? <\cf3 Parent\cf1 \cf4 guid\cf1 =\cf0 "\cf1 guidCmdSet\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 grpidContextMain\cf0 "\cf1 />\par ?? <\cf3 Strings\cf1 >\par ?? <\cf3 CanonicalName\cf1 >\cf0 cmdImportClasses\cf1 </\cf3 CanonicalName\cf1 >\par ?? <\cf3 ButtonText\cf1 >\cf0 Import from Existing Classes\cf1 </\cf3 ButtonText\cf1 >\par ?? </\cf3 Strings\cf1 >\par ?? </\cf3 Button\cf1 >\par ?? </\cf3 Buttons\cf1 >\par ?? </\cf3 Commands\cf1 >\par ??\tab \par ?? <\cf3 Symbols\cf1 >\par ?? <\cf3 GuidSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportDbSchemaGUID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 \{EC120F9A-9E7F-469d-8D61-F4E2A97E5725\}\cf0 "\cf1 >\par ?? <\cf3 IDSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportDbSchemaID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 0x810\cf0 "\cf1 ></\cf3 IDSymbol\cf1 >\par ?? </\cf3 GuidSymbol\cf1 >\par ??\par ?? <\cf3 GuidSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportClassesGUID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 \{EC120F9A-9E7F-469d-8D61-F4E2A97E5726\}\cf0 "\cf1 >\par ?? <\cf3 IDSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportClassesID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 0x811\cf0 "\cf1 ></\cf3 IDSymbol\cf1 >\par ?? </\cf3 GuidSymbol\cf1 >\par ?? </\cf3 Symbols\cf1 >\par ??</\cf3 CommandTable\cf1 >} --><span style="color: rgb(0, 0, 102);font-size:100%;" ><span style="font-weight: bold;">Example modified VSCT File<br /><br /></span></span><!-- {\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 Commands\cf1 \cf4 package\cf1 =\cf0 "\cf1 guidPkg\cf0 "\cf1 >\par ??\tab \par ?? <\cf3 Buttons\cf1 >\par ?? <\cf3 Button\cf1 \cf4 guid\cf1 =\cf0 "\cf1 cmdImportDbSchemaGUID\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 cmdImportDbSchemaID\cf0 "\cf1 \cf4 priority\cf1 =\cf0 "\cf1 0x0902\cf0 "\cf1 \cf4 type\cf1 =\cf0 "\cf1 Button\cf0 "\cf1 >\par ?? <\cf3 Parent\cf1 \cf4 guid\cf1 =\cf0 "\cf1 guidCmdSet\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 grpidContextMain\cf0 "\cf1 />\par ?? <\cf3 Strings\cf1 >\par ?? <\cf3 CanonicalName\cf1 >\cf0 cmdImportDbSchema\cf1 </\cf3 CanonicalName\cf1 >\par ?? <\cf3 ButtonText\cf1 >\cf0 Import from Database Schema\cf1 </\cf3 ButtonText\cf1 >\par ?? <\cf3 ToolTipText\cf1 >\cf0 Use this option to create the domain from an existing Database Schema\cf1 </\cf3 ToolTipText\cf1 >\par ?? </\cf3 Strings\cf1 >\par ?? </\cf3 Button\cf1 >\par ?? \par ?? <\cf3 Button\cf1 \cf4 guid\cf1 =\cf0 "\cf1 cmdImportClassesGUID\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 cmdImportClassesID\cf0 "\cf1 \cf4 priority\cf1 =\cf0 "\cf1 0x0902\cf0 "\cf1 \cf4 type\cf1 =\cf0 "\cf1 Button\cf0 "\cf1 >\par ?? <\cf3 Parent\cf1 \cf4 guid\cf1 =\cf0 "\cf1 guidCmdSet\cf0 "\cf1 \cf4 id\cf1 =\cf0 "\cf1 grpidContextMain\cf0 "\cf1 />\par ?? <\cf3 Strings\cf1 >\par ?? <\cf3 CanonicalName\cf1 >\cf0 cmdImportClasses\cf1 </\cf3 CanonicalName\cf1 >\par ?? <\cf3 ButtonText\cf1 >\cf0 Import from Existing Classes\cf1 </\cf3 ButtonText\cf1 >\par ?? </\cf3 Strings\cf1 >\par ?? </\cf3 Button\cf1 >\par ?? </\cf3 Buttons\cf1 >\par ?? </\cf3 Commands\cf1 >\par ??\tab \par ?? <\cf3 Symbols\cf1 >\par ?? <\cf3 GuidSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportDbSchemaGUID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 \{EC120F9A-9E7F-469d-8D61-F4E2A97E5725\}\cf0 "\cf1 >\par ?? <\cf3 IDSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportDbSchemaID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 0x810\cf0 "\cf1 ></\cf3 IDSymbol\cf1 >\par ?? </\cf3 GuidSymbol\cf1 >\par ??\par ?? <\cf3 GuidSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportClassesGUID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 \{EC120F9A-9E7F-469d-8D61-F4E2A97E5726\}\cf0 "\cf1 >\par ?? <\cf3 IDSymbol\cf1 \cf4 name\cf1 =\cf0 "\cf1 cmdImportClassesID\cf0 "\cf1 \cf4 value\cf1 =\cf0 "\cf1 0x811\cf0 "\cf1 ></\cf3 IDSymbol\cf1 >\par ?? </\cf3 GuidSymbol\cf1 >\par ?? </\cf3 Symbols\cf1 >\par ??</\cf3 CommandTable\cf1 >} --> <style type="text/css"> .cf { font-family: Courier New; font-size: 10pt; color: black; background: white; } .cl { margin: 0px; } .cln { color: #2b91af; } .cb1 { color: blue; } .cb2 { color: #a31515; } .cb3 { color: red; }</style> <div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 18</span> <span style="color:blue;"><</span><span style="color: rgb(163, 21, 21);">Commands</span><span style="color:blue;"> </span><span style="color:red;">package</span><span style="color:blue;">=</span>"<span style="color:blue;">guidPkg</span>"<span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 19</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 20</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Buttons</span><span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 21</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Button</span><span style="color:blue;"> </span><span style="color:red;">guid</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportDbSchemaGUID</span>"<span style="color:blue;"> </span><span style="color:red;">id</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportDbSchemaID</span>"<span style="color:blue;"> </span><span style="color:red;">priority</span><span style="color:blue;">=</span>"<span style="color:blue;">0x0902</span>"<span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>"<span style="color:blue;">Button</span>"<span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 22</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Parent</span><span style="color:blue;"> </span><span style="color:red;">guid</span><span style="color:blue;">=</span>"<span style="color:blue;">guidCmdSet</span>"<span style="color:blue;"> </span><span style="color:red;">id</span><span style="color:blue;">=</span>"<span style="color:blue;">grpidContextMain</span>"<span style="color:blue;">/></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 23</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Strings</span><span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 24</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">CanonicalName</span><span style="color:blue;">></span>cmdImportDbSchema<span style="color:blue;"><!--</span--><span style="color: rgb(163, 21, 21);">CanonicalName</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 25</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">ButtonText</span><span style="color:blue;">></span>Import from Database Schema<span style="color:blue;"><!--</span--><span style="color: rgb(163, 21, 21);">ButtonText</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 26</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">ToolTipText</span><span style="color:blue;">></span>Use this option to create the domain from an existing Database Schema<span style="color:blue;"><!--</span--><span style="color: rgb(163, 21, 21);">ToolTipText</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 27</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">Strings</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 28</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">Button</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 29</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 30</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Button</span><span style="color:blue;"> </span><span style="color:red;">guid</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportClassesGUID</span>"<span style="color:blue;"> </span><span style="color:red;">id</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportClassesID</span>"<span style="color:blue;"> </span><span style="color:red;">priority</span><span style="color:blue;">=</span>"<span style="color:blue;">0x0902</span>"<span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>"<span style="color:blue;">Button</span>"<span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 31</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Parent</span><span style="color:blue;"> </span><span style="color:red;">guid</span><span style="color:blue;">=</span>"<span style="color:blue;">guidCmdSet</span>"<span style="color:blue;"> </span><span style="color:red;">id</span><span style="color:blue;">=</span>"<span style="color:blue;">grpidContextMain</span>"<span style="color:blue;">/></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 32</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Strings</span><span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 33</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">CanonicalName</span><span style="color:blue;">></span>cmdImportClasses<span style="color:blue;"><!--</span--><span style="color: rgb(163, 21, 21);">CanonicalName</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 34</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">ButtonText</span><span style="color:blue;">></span>Import from Existing Classes<span style="color:blue;"><!--</span--><span style="color: rgb(163, 21, 21);">ButtonText</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 35</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">Strings</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 36</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">Button</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 37</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">Buttons</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 38</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">Commands</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 39</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 40</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">Symbols</span><span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 41</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">GuidSymbol</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportDbSchemaGUID</span>"<span style="color:blue;"> </span><span style="color:red;">value</span><span style="color:blue;">=</span>"<span style="color:blue;">{EC120F9A-9E7F-469d-8D61-F4E2A97E5725}</span>"<span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 42</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">IDSymbol</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportDbSchemaID</span>"<span style="color:blue;"> </span><span style="color:red;">value</span><span style="color:blue;">=</span>"<span style="color:blue;">0x810</span>"<span style="color:blue;">><!--</span--><span style="color: rgb(163, 21, 21);">IDSymbol</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 43</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">GuidSymbol</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 44</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 45</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">GuidSymbol</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportClassesGUID</span>"<span style="color:blue;"> </span><span style="color:red;">value</span><span style="color:blue;">=</span>"<span style="color:blue;">{EC120F9A-9E7F-469d-8D61-F4E2A97E5726}</span>"<span style="color:blue;">></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 46</span> <span style="color:blue;"> <</span><span style="color: rgb(163, 21, 21);">IDSymbol</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>"<span style="color:blue;">cmdImportClassesID</span>"<span style="color:blue;"> </span><span style="color:red;">value</span><span style="color:blue;">=</span>"<span style="color:blue;">0x811</span>"<span style="color:blue;">><!--</span--><span style="color: rgb(163, 21, 21);">IDSymbol</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 47</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">GuidSymbol</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 48</span> <span style="color:blue;"> <!--</span--><span style="color: rgb(163, 21, 21);">Symbols</span><span style="color:blue;">></span></span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 49</span> <span style="color:blue;"><!--</span--><span style="color: rgb(163, 21, 21);">CommandTable</span><span style="color:blue;">></span></span></pre> </div><br /><span xmlns=""><span style="color: rgb(31, 73, 125);"><strong><span style="font-size:130%;">Step#2: Modify Package version</span></strong></span></span><br /><ul><li>Locate the Package.tt , file , edit</li><li>Increment the version number (2nd parameter) as shown below</li></ul><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtw1-D5DlVGRxuyXVUG5-yud3w6fKssEuTJDu4nvcvH-UbP5aRbmFoD_y9MnSocaoCL3lQ2YoohzU1U4o8QXHodfa1iYbCCgsAA704ocksyjawL4c1WctzwdTR7NU35Wntlf9W4ERDEuGb/s1600-h/package.tt"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtw1-D5DlVGRxuyXVUG5-yud3w6fKssEuTJDu4nvcvH-UbP5aRbmFoD_y9MnSocaoCL3lQ2YoohzU1U4o8QXHodfa1iYbCCgsAA704ocksyjawL4c1WctzwdTR7NU35Wntlf9W4ERDEuGb/s400/package.tt" alt="" id="BLOGGER_PHOTO_ID_5148926013405996626" border="0" /></a><br /><span xmlns=""><span style="color: rgb(31, 73, 125);"><strong><span style="font-size:130%;">Step#3: Search for "your" CommandSet class</span></strong></span></span> <ul type="disc"><li class="MsoNormal" style=""><span style="" lang="EN-US">Search in your DSL Solution (DslPackage project) for the text<span style=""> </span></span>“DslShell::CommandSet”<span style="line-height: 115%;" lang="EN-US"><span style="color: rgb(43, 145, 175);"></span></span></li><li class="MsoNormal" style=""><span style="line-height: 115%;" lang="EN-US"><span style="color: rgb(43, 145, 175);"></span></span><span><span>You should notice that’s found 1 time in the CommandSet.cs<br /></span></span></li><li class="MsoNormal" style=""><span><span>If you now find the references for that found class (in this case DomainDesignCommandSetBase ) but in your project will be named differently. You should find that it’s derived + made partial to allow customization</span></span><br /></li></ul><span style="font-size:85%;"><span style="" lang="EN-US"></span></span><span xmlns=""><span style="color: rgb(31, 73, 125);"><strong><span style="font-size:130%;">Step#4: Customize your specific CommandSet<br /></span></strong></span></span><ul type="disc"><li class="MsoNormal" style=""><span style="" lang="EN-US">(optional) Create a folder to hold your own customized classes<o:p></o:p></span></li><li class="MsoNormal" style=""><span style="" lang="EN-US">Create a partial class (as shown below) <o:p></o:p></span></li></ul> <div style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 1</span> <span style="color:blue;">using</span> System;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 2</span> <span style="color:blue;">using</span> System.Collections.Generic;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 3</span> <span style="color:blue;">using</span> System.Linq;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 4</span> <span style="color:blue;">using</span> System.Text;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 5</span> <span style="color:blue;">using</span> System.ComponentModel.Design;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 6</span> <span style="color:blue;">using</span> Microsoft.VisualStudio.Modeling.Shell;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 7</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 8</span> <span style="color:blue;">namespace</span> GenWise.VsNet.DomainDesign.DslPackage</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 9</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 10</span> <span style="color:blue;">internal</span> <span style="color:blue;">partial</span> <span style="color:blue;">class</span> DomainDesignCommandSet : DomainDesignCommandSetBase</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 11</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 12</span> <span style="color:green;">// Note: Here you need to repeat the code from the VSCT .</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 13</span> <span style="color:green;">// I could not find an easy way of re-using the Symbols from the vsct</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 14</span> <span style="color:blue;">public</span> <span style="color: rgb(43, 145, 175);">Guid</span> dbImportSchemaGuid = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">Guid</span>(<span style="color: rgb(163, 21, 21);">"EC120F9A-9E7F-469d-8D61-F4E2A97E5725"</span>);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 15</span> <span style="color:blue;">public</span> <span style="color:blue;">const</span> <span style="color:blue;">int</span> dbImportSchemaID = 0x810;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 16</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 17</span> <span style="color:blue;">public</span> <span style="color: rgb(43, 145, 175);">Guid</span> dbImportClassesGuid = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">Guid</span>(<span style="color: rgb(163, 21, 21);">"EC120F9A-9E7F-469d-8D61-F4E2A97E5726"</span>);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 18</span> <span style="color:blue;">public</span> <span style="color:blue;">const</span> <span style="color:blue;">int</span> dbImportClassesID = 0x811;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 19</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 20</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 21</span> <span style="color:blue;">protected</span> <span style="color:blue;">override</span> <span style="color: rgb(43, 145, 175);">IList</span><menucommand> GetMenuCommands()</menucommand></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 22</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 23</span> <span style="color: rgb(43, 145, 175);">IList</span><menucommand> commands = <span style="color:blue;">base</span>.GetMenuCommands();</menucommand></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 24</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 25</span> <span style="color:green;">// You need to create a new command and add it to</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 26</span> <span style="color:green;">// the commands collection.</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 27</span> DynamicStatusMenuCommand cmdImportDbSchema =</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 28</span> <span style="color:blue;">new</span> DynamicStatusMenuCommand(</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 29</span> <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">EventHandler</span>(OnPopUpMenuDisplayAction),</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 30</span> <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">EventHandler</span>(OnPopUpMenuClick),</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 31</span> <span style="color:blue;">new</span> CommandID(dbImportSchemaGuid, dbImportSchemaID));</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 32</span> commands.Add(cmdImportDbSchema);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 33</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 34</span> <span style="color:green;">// You need to create a new command and add it to</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 35</span> <span style="color:green;">// the commands collection.</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 36</span> DynamicStatusMenuCommand cmdImportClasses =</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 37</span> <span style="color:blue;">new</span> DynamicStatusMenuCommand(</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 38</span> <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">EventHandler</span>(OnPopUpMenuDisplayAction),</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 39</span> <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">EventHandler</span>(OnPopUpMenuClick),</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 40</span> <span style="color:blue;">new</span> CommandID(dbImportClassesGuid, dbImportClassesID));</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 41</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 42</span> commands.Add(cmdImportClasses);</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 43</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 44</span> <span style="color:blue;">return</span> commands;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 45</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 46</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 47</span><br /><br /></pre></div><pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 56</span> <span style="color:blue;">internal</span> <span style="color:blue;">void</span> OnPopUpMenuDisplayAction(<span style="color:blue;">object</span> sender, <span style="color: rgb(43, 145, 175);">EventArgs</span> e)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 57</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 58</span> MenuCommand command = sender <span style="color:blue;">as</span> MenuCommand;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 59</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 60</span> <span style="color:blue;">foreach</span> (<span style="color:blue;">object</span> selectedObject <span style="color:blue;">in</span> <span style="color:blue;">this</span>.CurrentSelection)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 61</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 62</span> <span style="color:blue;">if</span> (selectedObject <span style="color:blue;">is</span> ClassDiagram)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 63</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 64</span> <span style="color:green;">// The popmenu command is always visible</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 65</span> command.Visible = <span style="color:blue;">true</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 66</span> command.Enabled = <span style="color:blue;">true</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 67</span> <span style="color:blue;">return</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 68</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 69</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 70</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 71</span> <span style="color:green;">// The popmenu command is always visible</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 72</span> command.Visible = <span style="color:blue;">false</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 73</span> command.Enabled = <span style="color:blue;">false</span>;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 74</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 75</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 76</span> <span style="color:blue;">internal</span> <span style="color:blue;">void</span> OnPopUpMenuClick(<span style="color:blue;">object</span> sender, <span style="color: rgb(43, 145, 175);">EventArgs</span> e)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 77</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 78</span> MenuCommand command = sender <span style="color:blue;">as</span> MenuCommand;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 79</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 80</span> <span style="color: rgb(43, 145, 175);">StringBuilder</span> sb = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">StringBuilder</span>();</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 81</span> <span style="color:blue;">foreach</span> (<span style="color:blue;">object</span> selectedObject <span style="color:blue;">in</span> <span style="color:blue;">this</span>.CurrentSelection)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 82</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 83</span> sb.AppendLine(<span style="color: rgb(163, 21, 21);">"Selected Shape: "</span> + selectedObject.ToString());</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 84</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 85</span> <span style="color:green;">// the Current selection will hold your "shape" class, so if you are interested</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 86</span> <span style="color:green;">// in getting the Model Class you need to use the ModelElement Property as shown below.</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 87</span> <span style="color:blue;">if</span> (selectedObject <span style="color:blue;">is</span> ClassShape)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 88</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 89</span> ModelClass modelClass = (ModelClass)(selectedObject <span style="color:blue;">as</span> ClassShape).ModelElement;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 90</span> sb.AppendLine(<span style="color: rgb(163, 21, 21);">"*** Related Domain Class: "</span> + modelClass.ToString());</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 91</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 92</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 93</span> <span style="color:blue;">if</span> (selectedObject <span style="color:blue;">is</span> ClassDiagram)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 94</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 95</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 96</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 97</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 98</span> System.Windows.Forms.MessageBox.Show(sb.ToString());</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 99</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 100</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 101</span> }</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 102</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 103</span> </pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 104</span> }</pre><br /><p class="MsoNormal"><b style=""><u><span style="" lang="EN-US">Step #5 : Transform Templates + Test It<o:p></o:p></span></u></b></p> <ul type="disc"><li class="MsoNormal" style=""><span style="" lang="EN-US">Ok, finally, you can now transform templates + run + test it. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="" lang="EN-US">You should see the following in your diagram:<o:p></o:p></span></li></ul><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd56G6wO_7kaz_vWFiQxSfhzbst897YGOfaxEsc2xwXaTnsZOqpfkZUs6hdt6Pk9v6kD-2w_BEu0cxY-b8kR3YuSD89yh2OICakahPhDLHMwIF5O1P6LbCmrBh_JcI3wzuZ-dX1rfNmLsQ/s1600-h/DSL+Menu+Command.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd56G6wO_7kaz_vWFiQxSfhzbst897YGOfaxEsc2xwXaTnsZOqpfkZUs6hdt6Pk9v6kD-2w_BEu0cxY-b8kR3YuSD89yh2OICakahPhDLHMwIF5O1P6LbCmrBh_JcI3wzuZ-dX1rfNmLsQ/s400/DSL+Menu+Command.png" alt="" id="BLOGGER_PHOTO_ID_5148927692738209378" border="0" /></a><br /><span xmlns=""><br /></span><span xmlns=""><span style="color: rgb(31, 73, 125);"><strong><span style="font-size:130%;">How to access the Related Domain Object (given a shape)?</span></strong></span></span><br /><span xmlns=""><br /></span><pre style="margin: 0px;"> <span style="color:green;">// the Current selection will hold your "shape" class, so if you are interested</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> </span> <span style="color:green;">// in getting the Model Class you need to use the ModelElement Property as shown below.</span></pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 87</span> <span style="color:blue;">if</span> (selectedObject <span style="color:blue;">is</span> ClassShape)</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 88</span> {</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 89</span> ModelClass modelClass = (ModelClass)(selectedObject <span style="color:blue;">as</span> ClassShape).ModelElement;</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 90</span> sb.AppendLine(<span style="color: rgb(163, 21, 21);">"*** Related Domain Class: "</span> + modelClass.ToString());</pre> <pre style="margin: 0px;"><span style="color: rgb(43, 145, 175);"> 91</span> }</pre><br /><br /><span xmlns=""><span style="color: rgb(31, 73, 125);"><strong><span style="font-size:130%;">How to control visibility of the Command?</span></strong></span></span><br />Look at lines 56 - 74 from the previous code, it clearly shows how you can based on a condition, enable or disable the command.Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com8tag:blogger.com,1999:blog-7873287608809972274.post-12314363414282517822007-12-21T17:23:00.000+01:002008-01-03T11:23:55.410+01:00NHibernate and WinForms article (1st draft)As I've mentioned before, I am trying to create a Article for using NHibernate with Windows Forms (WinForms).<br /><br />Both the article and the example project are not finished (it's work in progress) but I can't wait any longer , and therefore decided to share and get some initial feedback / reactions.<br /><br /><ul><li><span style=""><a href="http://www.genwise.com/Download/Articles/NHibernateWinForms.zip">Download Article + Example Application</a> <a href="http://www.genwise.com/Download/Articles/NHibernateWinForms.zip"><span style=""></span></a><o:p></o:p></span></li></ul>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com120tag:blogger.com,1999:blog-7873287608809972274.post-3438576914043248862007-12-19T16:53:00.000+01:002007-12-20T10:26:07.889+01:00Warning : Renaming a DSL --> old name still used in .tt filesIf you manually rename the DSL File ( DSLDefinition.dsl ) to something else you will notice that your project will not work anymore giving several weird error messages.<br /><br />The Solution is to manually also change all the .tt files that are still referencing the old name.<br /><br />Default Name : DslDefinition.dsl<br /><br />Search for this name and you will find that all the .tt files are still referencing the old name.<br /><br /><#@ Dsl processor="DslDirectiveProcessor" requires="fileName='..\DslDefinition.dsl'" #><br /><#@ include file="Dsl\ConnectionBuilder.tt" #>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com1tag:blogger.com,1999:blog-7873287608809972274.post-38766905995639068472007-12-17T18:12:00.000+01:002007-12-20T10:26:52.675+01:00WinForms inheritance workaroundI've started some days ago with a simple mini-guide for creating Windows Forms Applications with NHibernate. It's not finished yet but what's interesting because I wanted to have visual inheritance in my application + using Generics. I initially thought that this should not be a problem but i was wrong.<br /><br />After adding Generics support to my Forms + creating abstract Form , the Designer stopped working with one of those "ugly design-time errors" , which BTW are very nicely shown in vs.net 2008.<br />So my conclusion is : neither vs.net 2005 nor vs.net 2008 can easily support Generics + USer Control (or forms) inheritance (they both share this same "bug" / limitation ).<br /><br />Luckily I found this workaournd from <a href="http://blogs.infosupport.com/blogs/frankb/archive/2007/04/28/Lack-of-support-for-generic-base-classes-in-Windows-Forms-designer.aspx?CommentPosted=true#commentmessage">Frank Bakker</a> .I could work-around and create a common/base UserControl for my Business Object UI.<br /><br />Code Example:<br /><br />public partial class ProductFormUC : ProductFormUCDummy<br /> {<br /> public ProductFormUC() : base()<br /> {<br /> InitializeComponent();<br /> }<br /><br /> public ProductFormUC(int pProductID) : this()<br /> {<br /> Product product = this.Repository.ProductDAO.Fetch(pProductID);<br /> if (product == null)<br /> throw new Exception("Not Found : was it deleted? improve this case");<br /><br /> SetCurrentBO(product);<br /><br /> categoryBindingSource.DataSource = this.Repository.CategoriesDAO.GetAll();<br /> categoryBindingSource.DataMember = "CategoryName";<br /><br /> productBindingSource.DataSource = product;<br /><br /> }<br /><br /> }<br /><br /><span style="color: rgb(255, 0, 0); font-weight: bold;">This "intermediate" class makes the trick : </span><br /> public partial class ProductFormUCDummy : BaseBOFormUC<product><br /> {<br /> protected override IDAO<product> DAO<br /> {<br /> get { return this.Repository.ProductDAO; }<br /> }<br /><br /> }</product></product>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com2tag:blogger.com,1999:blog-7873287608809972274.post-74203958983426398092007-08-22T11:49:00.000+02:002007-08-22T11:53:39.124+02:00GenWise : Source Code SynchronizationIn the last couple of projects we've noticed that we where loosing some "precious" time synchronizing code back from a VS.NET solution into the GenWise project system. <p class="MsoNormal">Although we have an integrated Source Editor, our users are constantly switching to VS.NET for debugging purposes. Sometimes while debugging, it’s needed to change code to test again, etc.</p><p class="MsoNormal">We have now created a feature to automatically synchronize those changes back to the project system.</p><p class="MsoNormal">This is a time save feature and allows to combine both worlds better.</p><p class="MsoNormal">We have not yet decided in what version we are going to include this feature.<br /></p>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com1tag:blogger.com,1999:blog-7873287608809972274.post-66262610800854223532007-08-16T13:09:00.001+02:002007-08-16T13:11:42.151+02:00Fenix ASP.NET Generation == goodbyeFenix was my first ASP.NET Generation templates. It was implemented as a Template chain inside the Clarion IDE.<br />Now it's time to say bye-bye to Fenix and finally put all our efforts in GenWise.<br /><br />If you wanna read more about it :<br /><ul><li><a href="http://www.genwise.com/newsletter/Fenix/newsletter.html">Fenix NewsLetter</a><br /></li><li><a href="http://www.genwise.com/Company/FenixforFree/tabid/227/Default.aspx">GenWise Download Page</a> </li></ul>Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-39321308678849005012007-06-25T11:50:00.000+02:002007-06-25T15:17:01.802+02:00NHibernate ILifecycle vs Validation ModelAfter reading this excellent article :<br />http://20.targetprocess.com/2006/08/entity-life-cycle-in-nhibernate.html<br /><br />I finally understood why our <a href="http://www.genwise.com/documentation/index.html?validation_model.html">Validation model</a> was not hitting on Updates!<br />I thought it was some-kind-of-bug but it was definitively not so.<br /><br />Since we just have released GenWise v1.09<br /> --> this topic will be included in the next version of the Templates.Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-71248334256381133172007-05-30T17:29:00.000+02:002007-05-30T18:46:15.991+02:00Intersystem Cache NHibernate Driver/DialectFor a project we had to use Intersystem's Cache.<br /><br />I've create the NHibernate Dialect and Driver (based on the Java version as a source).<br /><br />I don't really know where to post this files so here they go : <a href="http://www.genwise.com/LinkClick.aspx?link=NHibernate+Intersystems+Cache.zip&tabid=76&mid=736">Download NHibernate Cache Driver/Dialect.</a><br /><br />I now need to learn:<br />* Where to post so this get's added to Nhibernate.<br />* Before that step : are there any tests for new dialects (should i write them, how? )<br /><br /><span style="font-weight: bold;">My tests show 1 problem:</span><br />When trying to create a parameterized query using system.guid as parameter type i get this exception: CacheException : Type out of range: System.Guid<br /><br />Failures:<br />1) Standard_BoLayer.Tests.Email_AddressesTest.FetchTest : NHibernate.ADOException : could not execute query<br />[ SELECT this_."Email Address-ID" as Email1_7_0_, this_."Member_id" as Member2_7_0_, this_."System #" as System3_7_0_, this_."Mail@" as Mail4_7_0_, this_."Include in Mailing" as Include5_7_0_ FROM "dbo"."Email Addresses" this_ WHERE this_."Email Address-ID" = ? ]<br />Positional parameters: 0 aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa<br />[SQL: SELECT this_."Email Address-ID" as Email1_7_0_, this_."Member_id" as Member2_7_0_, this_."System #" as System3_7_0_, this_."Mail@" as Mail4_7_0_, this_."Include in Mailing" as Include5_7_0_ FROM "dbo"."Email Addresses" this_ WHERE this_."Email Address-ID" = ?]<br /> ----> InterSystems.Data.CacheClient.CacheException : Type out of range: System.Guid<br /> at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0tag:blogger.com,1999:blog-7873287608809972274.post-85506316887712917702007-04-28T21:22:00.000+02:002007-05-31T07:16:46.441+02:00GenWise Templates and the Project life-cycleOne of the unique features of the GenWise Template System is the fact that the templates are always alive during your project life-cycle. The Generation process is not a single step (normally an initial step) but it's present during the whole life-cycle.<br /><br />This has major advantages:<br />#1) Template can adapt themselves to new scenarios<br />This is basically achieved by the fact that their input meta-data can change and template will regenerate their code according to the new input.<br />Several templates have "Auto Calculated Template Options", for this cases the advantage is even greater since the templates will also adapt the default values of the Template Options (Questions to the user).<br /><br />#2) Template Option Changes can be easier applied since the Template Options are still available at the end of the project.<br /><br />#3) Same applies to Global Changes, or global extension : like adding Security Template, make project Ajax aware ( Ajax Templates ), or any other extension.<br /><br />#4 ) Template itself (new version) can improve or fix a specific scenario and this change might automatically apply to all template instances in your projects.<br /><br /><br />To make this possible, the IDE needs to keep a Project System. This project system is part of the GenWise Framework which contains ALL your project meta-data.Sebastian Talamonihttp://www.blogger.com/profile/07572995351085791938noreply@blogger.com0