tag:blogger.com,1999:blog-39131097814912847132023-11-15T18:07:40.395+00:00Code-D-Codea blog about software developmentgeehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-3913109781491284713.post-42056908443900040652013-08-26T20:13:00.001+01:002013-08-26T20:13:27.269+01:00Unity Generic Container Interface Implementation<p>An implementation of the IIoCGenericContainer interface for the Unity container.</p> <div id="codeSnippetWrapper"> <pre id="codeSnippet" class="csharpcode">using System;<br />using System.Collections.Generic;<br />using System.Linq;<br />using System.Text;<br />using Microsoft.Practices.Unity;<br /><br />namespace IoC<br />{<br /> public class UnityGenericContainer : IIoCGenericContainer<br /> {<br /> private IUnityContainer container;<br /><br /> public UnityGenericContainer(IUnityContainer container)<br /> {<br /> this.container = container;<br /> }<br /><br /> #region IGenericContainer Members<br /><br /> public TType Resolve<span class="kwrd"><</span><span class="html">TType</span><span class="kwrd">></span>()<br /> {<br /> return this.container.Resolve<span class="kwrd"><</span><span class="html">TType</span><span class="kwrd">></span>();<br /> }<br /><br /> public TType TryResolve<span class="kwrd"><</span><span class="html">TType</span><span class="kwrd">></span>()<br /> {<br /> TType result;<br /><br /> try<br /> {<br /> result = this.container.Resolve<span class="kwrd"><</span><span class="html">TType</span><span class="kwrd">></span>();<br /> }<br /> catch (Exception)<br /> {<br /> result = default(TType);<br /> }<br /><br /> return result;<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>()<br /> {<br /> this.container.RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>(bool singleton)<br /> {<br /> if (singleton)<br /> {<br /> this.container.RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>(new ContainerControlledLifetimeManager());<br /> }<br /> else<br /> {<br /> this.container.RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /> }<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>(bool singleton) where TTo : TFrom<br /> {<br /> if (singleton)<br /> {<br /> this.container.RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>(new ContainerControlledLifetimeManager());<br /> }<br /> else<br /> {<br /> this.container.RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>();<br /> }<br /> }<br /><br /> public void RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(TInterface instance, bool singleton)<br /> {<br /> if (singleton)<br /> {<br /> this.container.RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(instance, new ContainerControlledLifetimeManager());<br /> }<br /> else<br /> {<br /> this.container.RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(instance);<br /> }<br /> }<br /><br /> public void RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(TInterface instance)<br /> {<br /> this.container.RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(instance);<br /> }<br /><br /><br /> public object Resolve(Type t)<br /> {<br /> return this.container.Resolve(t);<br /> }<br /><br /> public IEnumerable<span class="kwrd"><</span><span class="html">object</span><span class="kwrd">></span> ResolveAll(Type t)<br /> {<br /> return this.container.ResolveAll(t);<br /> }<br /><br /> public IEnumerable<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span> ResolveAll<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>()<br /> {<br /> return this.container.ResolveAll<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>() where TTo : TFrom<br /> {<br /> this.container.RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>();<br /> }<br /><br /> public void RegisterInstance(object instance)<br /> {<br /> this.container.RegisterInstance(instance);<br /> }<br /><br /> #endregion<br /> }<br />}<br /></pre>
<br /></div> geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-35211016932694375682013-08-25T20:57:00.001+01:002013-08-25T20:57:23.546+01:00Ninject Generic Container Interface Implementation<p>An implementation of the IIoCGenericContainer interface for the Ninject container.</p> <div id="codeSnippetWrapper"> <pre id="codeSnippet" class="csharpcode">using System;<br />using Ninject;<br />using System.Collections.Generic;<br /><br />namespace IoC<br />{<br /> public class NinjectGenericContainer : IIoCGenericContainer<br /> {<br /> IKernel kernel;<br /><br /> public NinjectGenericContainer(IKernel kernel)<br /> {<br /> this.kernel = kernel;<br /> }<br /><br /><br /><br /> public object Resolve(Type t)<br /> {<br /> return this.kernel.Get(t);<br /> }<br /><br /> public T Resolve<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>()<br /> {<br /> return this.kernel.Get<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /> }<br /><br /> public T TryResolve<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>()<br /> {<br /> return this.kernel.TryGet<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /> }<br /><br /> public IEnumerable<span class="kwrd"><</span><span class="html">object</span><span class="kwrd">></span> ResolveAll(Type t)<br /> {<br /> return this.kernel.GetAll(t);<br /> }<br /><br /> public IEnumerable<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span> ResolveAll<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>()<br /> {<br /> return this.kernel.GetAll<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>()<br /> {<br /> this.kernel.Bind<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>().ToSelf();<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>(bool singleton)<br /> {<br /> if (singleton)<br /> {<br /> this.kernel.Bind<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>().ToSelf().InSingletonScope();<br /> }<br /> else<br /> {<br /> this.RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /> }<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>() where TTo : TFrom<br /> {<br /> this.kernel.Bind<span class="kwrd"><</span><span class="html">TFrom</span><span class="kwrd">></span>().To<span class="kwrd"><</span><span class="html">TTo</span><span class="kwrd">></span>();<br /> }<br /><br /> public void RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>(bool singleton) where TTo : TFrom<br /> {<br /> if (singleton)<br /> {<br /> this.kernel.Bind<span class="kwrd"><</span><span class="html">TFrom</span><span class="kwrd">></span>().To<span class="kwrd"><</span><span class="html">TTo</span><span class="kwrd">></span>().InSingletonScope();<br /> }<br /> else<br /> {<br /> RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>();<br /> }<br /> }<br /><br /> public void RegisterInstance(object instance)<br /> {<br /> this.kernel.Inject(instance);<br /> }<br /><br /> public void RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(TInterface instance)<br /> {<br /> this.kernel.Inject(instance);<br /> }<br /><br /> public void RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(TInterface instance, bool singleton)<br /> {<br /> throw new NotImplementedException();<br /> }<br /> }<br />}<br /></pre>
<br /></div> geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-18661133474990321512013-08-25T00:35:00.000+01:002013-08-25T00:35:00.482+01:00IoC Generic Container Interface<p>A generic interface that can be implemented for different IoC containers. By using the interface switching between container implementations would be easy, particularly helpfull when testing the use of a container.</p> <div id="codeSnippetWrapper"> <pre id="codeSnippet" class="csharpcode">using System;<br />using System.Collections.Generic;<br /><br />namespace IoC<br />{<br /> public interface IIoCGenericContainer<br /> {<br /> object Resolve(Type t);<br /><br /> T Resolve<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /><br /> T TryResolve<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /><br /> IEnumerable<span class="kwrd"><</span><span class="html">object</span><span class="kwrd">></span> ResolveAll(Type t);<br /><br /> IEnumerable<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span> ResolveAll<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /><br /> void RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>();<br /><br /> void RegisterType<span class="kwrd"><</span><span class="html">T</span><span class="kwrd">></span>(bool singleton);<br /><br /> void RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>() where TTo : TFrom;<br /><br /> void RegisterType<span class="kwrd"><</span><span class="html">TFrom</span>, <span class="attr">TTo</span><span class="kwrd">></span>(bool singleton) where TTo : TFrom;<br /><br /> void RegisterInstance(object instance);<br /><br /> void RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(TInterface instance);<br /><br /> void RegisterInstance<span class="kwrd"><</span><span class="html">TInterface</span><span class="kwrd">></span>(TInterface instance, bool singleton);<br /> }<br />}</pre>
<br /></div> geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-508885891487293082012-04-30T15:45:00.001+01:002012-07-18T15:38:53.363+01:00Use Windows Phone GPS Emulator with a desktop applicationWindows phone GPS emulator as the name suggests is a GPS emulator desktop application that helps you debug your windows phone 7 gps client application. You can get hold of the <a href="http://create.msdn.com/en-us/education/catalog/article/GPS-Emulator" target="_blank" title="GPS Emulator">GPS Emulator here</a>.<br>
<a href="http://code-d-code.blogspot.com/2012/04/use-windows-phone-gps-emulator-with.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com1tag:blogger.com,1999:blog-3913109781491284713.post-52825907193733455942012-04-20T00:26:00.001+01:002012-04-20T00:28:45.461+01:00Place Google ads inline your blog post using XsltPlugin<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:514f8bdc-1c58-4e9c-ab94-19b3945b55fd:0470e62c-664f-47c1-9c5f-d51404226c29" class="wlWriterEditableSmartContent"><div class="" style="text-align: center "> <script type="text/javascript"><!--
google_ad_client = "ca-pub-4268910085464607";
/* Prog, 234x60, created 1/16/11 */
google_ad_slot = "1220170560";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> </div></div> <p>Create an xml file where you will be keeping the adsense code for your ads. Between the CDATA sections you should put your adsense code for each ad. Give it a name ie. “ads.xml” and save it. It should be similar to this:</p> <a href="http://code-d-code.blogspot.com/2012/04/place-google-ads-inline-your-blog-post.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-76741718060440431022012-02-19T16:57:00.001+00:002012-02-20T00:22:07.840+00:00Insert Rss feed items using the WLW XsltPlugin<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:514f8bdc-1c58-4e9c-ab94-19b3945b55fd:218bb40b-8ef4-4f05-88c5-6f4a25ce9425" class="wlWriterEditableSmartContent"><div class="" style="text-align: center "> <script type="text/javascript"><!--
google_ad_client = "ca-pub-4268910085464607";
/* banner 468x60 */
google_ad_slot = "2835026479";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> </div></div> <p>Choose an rss feed address. For the sake of this example we are choosing the rss feed of <a href="http://feeds.mashable.com/Mashable">Mashable(http://feeds.mashable.com/Mashable)</a>. Now using a text editor copy and paste the following piece of xslt into a file and save it as ie. rsslinks.xslt:</p> <a href="http://code-d-code.blogspot.com/2012/02/insert-rss-feed-items-using-wlw.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-26652901434846449862012-02-15T16:51:00.001+00:002012-04-20T00:29:43.085+01:00Using NuGet with a central repository<p>It may be suited to your development process to use a central repository where all the NuGet packages you use in different projects are kept. That way you don’t have various packages scattered around in your pc or if you archive references you can keep doing so or if you don’t have internet connection you can still use existing packages from the central repository.</p> <a href="http://code-d-code.blogspot.com/2012/02/using-nuget-with-central-repository.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-25460659494564684372012-02-13T01:30:00.001+00:002012-05-04T00:22:48.629+01:00Xslt Plugin for Windows Live Writer<p>A plugin for the Windows LIve Writer blogging software was developed. A simple but yet a very powerful plugin that can make your blog posts more pretty and customised to your liking. The Xslt plugin can transform your content data. The plugin offers the benefit of preparing an xslt template that can be reused, can have css formatting and can be applied to the matched xml content data. </p> <a href="http://code-d-code.blogspot.com/2012/02/xslt-plugin-for-windows-live-writer.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-9531345765743660452011-01-04T17:17:00.000+00:002011-01-04T20:44:22.255+00:00Search trip from IDisposable to RDL<p>I opened the codeproject’s newsletter I am subscribed and picked a few articles. I picked those that were relevant to the things I am interested more, I have worked in the past or relate to an idea that I am working on it. At first I read this article about <a title="about IDisposable" href="http://blogs.msdn.com/b/nicgrave/archive/2010/12/28/using-idisposable-objects.aspx" target="_blank">IDisposable</a> because an article about IDisposable is always interesting. It presents the right way to use this interface or at least it attempts to. </p> <a href="http://code-d-code.blogspot.com/2011/01/search-trip-from-idisposable-to-rdl.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-13601871394702706382010-12-25T23:16:00.001+00:002010-12-26T04:46:24.557+00:00How to use CLR in the MSSQL server<p>To use the CLR in MSSQL Server you need to enable CLR Integration first. It can be enabled in the sql server surface area configuration.</p> <a href="http://code-d-code.blogspot.com/2010/12/how-to-use-clr-in-mssql-server.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-50871603905110167552010-05-20T17:00:00.001+01:002010-12-26T04:42:11.755+00:00A T4 Generator Tool for VS Express<div style="padding-bottom: 4px; margin: 0px; padding-left: 8px; padding-right: 0px; float: right; padding-top: 0px"></div> <p>T4 stands for Text Templating Transformation Toolkit which is a transformation engine built into all VS studio editions. In a few words, you can write a text template file which consists of plain text and source code wrapped around the T4 language notation. The T4 notation is similar to the ASP.NET design page source code. You indicate directives by using <#@ tags, statements with <# tags, and expressions with <#= tags. Below is a simple T4 template.</p> <pre class="csharpcode"><#@ template debug=<span class="str">"true"</span> language=<span class="str">"C#v3.5"</span>#>
<#@ Import Namespace=<span class="str">"System.Linq"</span> #>
<#@ Assembly Name=<span class="str">"System.Core,Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"</span> #>
<#@ output extension=<span class="str">".cs"</span> #>
<# WriteLine(<span class="str">@"Hello World"</span>);#></pre>
<a href="http://code-d-code.blogspot.com/2010/05/t4-generator-tool-for-vs-express.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-14135637178322660942010-04-18T19:28:00.000+01:002010-12-26T04:55:41.496+00:00Reverse Engineer a Web Service from the existing WSDL<p>Sometimes you need to create the web service methods and you only have the web service description file(wsdl) as a staring point. You can utilise the wsdl.exe tool to generate the web service's server stub methods. This file exists in Program Files\Microsoft SDKs\Windows\v6.0A\bin\ if you have the VS express edition installed or somewhere in the VS installation folders if you have other editions. Just by running : </p> <a href="http://code-d-code.blogspot.com/2010/04/reverse-engineer-web-service-from.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0tag:blogger.com,1999:blog-3913109781491284713.post-49948360102914374492010-03-30T17:56:00.000+01:002010-12-26T05:06:20.635+00:00How to use Subsonic 3 T4 templates in VS Express<p>Subsonic is an ORM tool that works up your database access and can speed your development cycle. It can be downloaded from <a title="Subsonic" href="http://subsonicproject.com/" rel="tag" target="_blank">Subsonic</a>. To use subsonic in your visual studio express project you can follow the steps below:</p> <a href="http://code-d-code.blogspot.com/2010/03/how-to-use-subsonic-3-t4-templates-in.html#more">Read more »</a>geehttp://www.blogger.com/profile/07498990196349740374noreply@blogger.com0