<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Frans Senden&#039;s Blog</title>
	<atom:link href="http://franssenden.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://franssenden.wordpress.com</link>
	<description>OData &#124; Silverlight &#124; C#</description>
	<lastBuildDate>Tue, 08 Nov 2011 13:09:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='franssenden.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/addc92280c520f1a2688660d96f85fea?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Frans Senden&#039;s Blog</title>
		<link>http://franssenden.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://franssenden.wordpress.com/osd.xml" title="Frans Senden&#039;s Blog" />
	<atom:link rel='hub' href='http://franssenden.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to define an abstract Repository for Entity Framework</title>
		<link>http://franssenden.wordpress.com/2010/07/17/how-to-define-an-abstract-repository-for-entity-framework/</link>
		<comments>http://franssenden.wordpress.com/2010/07/17/how-to-define-an-abstract-repository-for-entity-framework/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 00:42:46 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[OData]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=156</guid>
		<description><![CDATA[During research to useful design-patterns for my Wcf Data Services, I came across the following which I&#8217;d like to share with you. In this case, it&#8217;s not about OData. For this, I&#8217;m still working to build a (rather abstract) Business Layer, first start at the Entity Framework &#8211; level. One of the common methods to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=156&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>During  research to useful design-patterns for my Wcf Data Services, I came across the following which I&#8217;d like to share with you. In this case, it&#8217;s not about OData. For this, I&#8217;m still working to build a (rather abstract) Business Layer, first start at the Entity Framework &#8211; level.</p>
<p>One of the common methods to build a Business Component on top of your (EF) DAL is creating a facade to it using the Repository-Pattern. That is, simply define an interface:</p>
<pre class="brush: csharp;">
public interface IRepository&lt;T&gt;
    {
        T GetById(int id);
        IEnumerable&lt;T&gt; GetAll();
        IQueryable&lt;T&gt; Query(Expression&lt;Func&lt;T, bool&gt;&gt; filter);

    }
</pre>
<p>and then implementing it:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AdventureWorksDAL;
namespace AdventureWorksBC
{

    public class ProductRepos : IRepository&lt;Product&gt;, IDisposable
    {
        private AdventureWorksEntities _context;

        public ProductRepos()
        {
            _context = new AdventureWorksEntities();
            var types = AdventureWorksEntities.GetKnownProxyTypes();
        }

        #region IRepository&lt;Product&gt; Members

        public Product GetById(int id)
        {
            return _context.Product.Where(p =&gt; p.ProductID == id).FirstOrDefault();

        }

        public IEnumerable&lt;Product&gt; GetAll()
        {
            return _context.Product;
        }

        public IQueryable&lt;Product&gt; Query(System.Linq.Expressions.Expression&lt;Func&lt;Product, bool&gt;&gt; filter)
        {

            return _context.Product.Where(filter);
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            if (_context != null)
            {
                _context.Dispose();
            }
            GC.SuppressFinalize(this);
        }
        #endregion
    }
}
</pre>
<p>Ever since I&#8217;m lazy&#8230;. I want to take this to a higher abstract level. With the preceding solution, you always have to implement the Interface for every object in the datacontext. Of course you want to have BusinessComponents where you can leave specific rules, but those GetAll, GetById &#8211; methods are pretty common. Therefore we&#8217;ll have to write a base-class:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;
using System.Data.Metadata.Edm;
using AdventureWorksDAL;
using System.Data.Objects;
using System.Data;
using System.Linq.Expressions;

namespace AdventureWorksBC
{
    public class RepositoryBase&lt;T&gt; : IDisposable where T : EntityObject, new()
    {
        //private IQueryable&lt;T&gt; _entity;

        private AdventureWorksEntities _context;
        private ObjectSet&lt;T&gt; _query;

        public RepositoryBase()
        {
            _context = new AdventureWorksEntities();
            _query = _context.CreateObjectSet&lt;T&gt;();
        }

        public T GetById(int id)
        {

            foreach (T entity in _query)
            {
                if ((int)entity.EntityKey.EntityKeyValues[0].Value == id)
                {
                    return entity;
                }

            }
            return null;
        }

        public IEnumerable&lt;T&gt; GetAll()
        {
            return _query;

        }

        public IQueryable&lt;T&gt; Query(Expression&lt;Func&lt;T, bool&gt;&gt; filter)
        {
            return _query.Where(filter);
        }

        #region IDisposable Members

        public void Dispose()
        {
            if (_context != null)
            {
                _context.Dispose();
            }
            GC.SuppressFinalize(this);
        }
        #endregion
    }
}
</pre>
<p>Well that&#8217;s our baseclass. Let me short explain; </p>
<pre class="brush: csharp;">
public class RepositoryBase&lt;T&gt; : IDisposable where T : EntityObject, new()
</pre>
<p>As you see we&#8217;ve replaced the specific object (like &#8220;Product&#8221; or &#8220;Customer&#8221;) with a generic &#8220;T&#8221;. After this you see the constraint: &#8220;it must be of type EntityObject, and have a parameterless constructor&#8221;.<br />
Then in the constructor we&#8217;re going to initialize our fields_: context and _query. _query now returns an ObjectSet of type T (also it grabs all of those entities from the context).</p>
<p>The methods &#8220;GetAll&#8221; and &#8220;Query&#8221; are somehow self explainable I think, so leave them for now.<br />
What really is kind of tricky is &#8220;GetById(int id). Honestly I have not figured out yet a better way to do this, but the end justifies the means&#8230;</p>
<p>Well now look at a demo app to show what you could do with this base-class:</p>
<p>First define a few childclasses:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AdventureWorksDAL;

namespace AdventureWorksBC
{
    public class ContactRepository : RepositoryBase&lt;Contact&gt;
    {
        public ContactRepository()
        {

        }
    }
    public class ProductRepository : RepositoryBase&lt;Product&gt;
    {
        public ProductRepository()
        {

        }
    }

}
</pre>
<p>Now call our entities through our new BusinessComponent:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using AdventureWorksDAL;
using AdventureWorksBC;
using System.Data.Metadata.Edm;

namespace DemoEFBusinessComponent
{
    class Program
    {
        static void Main(string[] args)
        {

            var productRepos = new ProductRepository();
            Product product = productRepos.GetById(319);
            Console.WriteLine(string.Format(&quot;productId: {0}&quot;,product.ProductID));
            Console.WriteLine(string.Format(&quot;Name: {0}&quot;, product.Name));
            Console.WriteLine(string.Format(&quot;Model: {0}&quot;, product.ProductNumber));
            productRepos.Dispose();
            Console.Read();

            var contactRepos = new ContactRepository();
            var contacts = contactRepos.GetAll();

            foreach (Contact contact in contacts)
            {
                Console.WriteLine(string.Format(&quot;contactId: {0}&quot;, contact.ContactID));
                Console.WriteLine(string.Format(&quot;LastName: {0}&quot;, contact.LastName));
                Console.WriteLine(string.Format(&quot;Email: {0}&quot;, contact.EmailAddress));
                Console.WriteLine(&quot;&quot;);
            }
            contactRepos.Dispose();
            Console.Read();

            var productCategoryRepos = new RepositoryBase&lt;ProductCategory&gt;();
            var specificCategory = productCategoryRepos.Query(pc =&gt; pc.Name.StartsWith(&quot;co&quot;));
            foreach (ProductCategory category in specificCategory)
            {
                Console.WriteLine(&quot;productCategoryId: {0}&quot;, category.ProductCategoryID);
                Console.WriteLine(&quot;productCategoryName: {0}&quot;, category.Name);
            }
            productCategoryRepos.Dispose();
            Console.Read();

        }
    }
}
</pre>
<p>This turns out rather cool, since you don&#8217;t have to define childclasses like &#8220;public class ProductRepository : RepositoryBase&#8221; for instance. Obvious, but let me mention: It&#8217;s really up to business whether you need them. </p>
<p>If you try this at home please forgive me for the endless &#8220;adventureworks&#8221; contacts list!</p>
<p>Thank you:<a href="http://blogs.microsoft.co.il/blogs/gilf/archive/2010/01/20/using-repository-pattern-with-entity-framework.aspx">Gil Fink</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=156&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2010/07/17/how-to-define-an-abstract-repository-for-entity-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding/Creating data to OData/Wcf Data Service batch explained</title>
		<link>http://franssenden.wordpress.com/2010/06/18/addingcreating-data-to-odatawcf-data-service-batch-explained/</link>
		<comments>http://franssenden.wordpress.com/2010/06/18/addingcreating-data-to-odatawcf-data-service-batch-explained/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 00:40:53 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[OData]]></category>
		<category><![CDATA[WCF Data Services]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=135</guid>
		<description><![CDATA[I want to show you how to &#8220;upload&#8221; data to a OData Service, that is make a Http POST from client to your service. For this example I started a new Project by adding an AdventureWorks Entity Model and configuring it to a Wcf Data Service. How to you can read at:msdn (Don&#8217;t worry, this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=135&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I want to show you how to &#8220;upload&#8221; data to a OData Service, that is make a Http POST from client to your service. For this example I started a new Project by adding an AdventureWorks Entity Model and configuring it to a Wcf Data Service. How to you can read at:<a href="http://msdn.microsoft.com/en-us/library/cc838239(v=VS.95).aspx">msdn</a> (Don&#8217;t worry, this is about the Northwind DB, instead choose the AdventureWorks DB, if you not yet downloaded: <a href="http://msftdbprodsamples.codeplex.com/releases/view/45907">check this!</a></p>
<p>Somehow the wcf data service will look like:</p>
<pre class="brush: csharp;">
using System.Collections.Generic;
using System.Data.Services;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using System.Linq.Expressions;
using System.Data.Services.Common;

namespace TestAdventureWorksDataServices
{
    public class AdventureService : DataService&lt;AdventureWorksEntities&gt;
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:
            config.SetEntitySetAccessRule(&quot;*&quot;, EntitySetRights.All);
            // config.SetServiceOperationAccessRule(&quot;MyServiceOperation&quot;, ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            config.UseVerboseErrors = false;
        }

        protected override void HandleException(HandleExceptionArgs args)
        {
            throw new DataServiceException(args.Exception.InnerException.Message, args.Exception);
        }

    }
}
</pre>
<p>Once we&#8217;ve setup our service, it&#8217;s time for a client that makes some calls to it. First add a new project to the solution (ConsoleApplication for now) and make a ServiceReference to the service.<br />
In this example we want to add 3 new products and persist them in the DB producttable. For the last part we don&#8217;t have to worry, since the Entity Framework will handle this all.<br />
Take a look at the client:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Services.Client;

namespace Client
{
    using Client.AdventureWorksServiceReference;

    class Program
    {
        private static AdventureWorksEntities _context = null;

        static void Main(string[] args)
        {
            _context = new AdventureWorksEntities(new Uri(&quot;http://ipv4.fiddler:51824/AdventureService.svc&quot;));

            var product1 = Product.CreateProduct(0, &quot;My Test Product 1&quot;, &quot;1234&quot;, true, true, 1, 1, 100, 200, 3,
                                                DateTime.Now, new Guid(&quot;E29C16AE-908A-4F53-8E19-DC2CFDDF08A0&quot;), DateTime.Now);

            var product2 = Product.CreateProduct(0, &quot;My Test Product 2&quot;, &quot;5678&quot;, true, true, 1, 1, 200, 300, 3,
                                     DateTime.Now, new Guid(&quot;1B9689D6-CCFF-40C3-AA0F-1AC3C5951738&quot;), DateTime.Now);

            var product3 = Product.CreateProduct(0, &quot;My Test Product 3&quot;, &quot;9876&quot;, true, true, 1, 1, 300, 400, 3,
                         DateTime.Now, new Guid(&quot;{0B677FB4-890E-4FAF-AD6A-7477D5703E6E}&quot;), DateTime.Now);

            var collection = new DataServiceCollection&lt;Product&gt;(_context);
            collection.Add(product1);
            collection.Add(product2);
            collection.Add(product3);
            _context.SaveChanges();

            Console.Read();

            //remove products to omit unique constraint next time running this app:
            collection.Remove(product1);
            collection.Remove(product2);
            collection.Remove(product3);
            _context.SaveChanges();

            Console.WriteLine(&quot;Deleted. Sorry, changed my mind!&quot;);
            Console.Read();

        }
    }
}
</pre>
<p>A short walkthrough of what is happening here.<br />
First, take note of instead of setting up the context by calling &#8220;http://localhost:51824/AdventureService.svc&#8221; we include &#8220;http://ipv4.fiddler:51824/AdventureService.svc&#8221;. This is done so that later on we can monitor our calls in <a href="http://www.fiddler2.com/fiddler2/">Fiddler</a>.<br />
When the application fires, a context of our service is setup, which will track all changes. In the end, if we agree with those changes we can call &#8220;context.SaveChanges()&#8221;;<br />
By calling SaveChanges() requests are finally made to store the products. Let&#8217;s take a look in Fiddler:</p>
<p><img src="http://franssenden.files.wordpress.com/2010/06/scrshblogfiddler3requests.png?w=640&#038;h=103" alt="fiddler products add requests" title="fiddler products add requests" width="640" height="103" class="alignleft size-full wp-image-139" /></p>
<p>As you see, there are 3 requests made to the service. Note!: by calling SaveChanges() only once.<br />
Now let&#8217;s do it again, but change some code:<br />
change following line:</p>
<pre class="brush: csharp;">
_context.SaveChanges();
</pre>
<p>into:</p>
<pre class="brush: csharp;">
_context.SaveChanges(SaveChangesOptions.Batch);
</pre>
<p>check this out in fiddler and you&#8217;ll notify the call is only made once:</p>
<p><a href="http://franssenden.wordpress.com/2010/06/18/addingcreating-data-to-odatawcf-data-service-batch-explained/scrshblogfiddler1requests/" rel="attachment wp-att-145"><img src="http://franssenden.files.wordpress.com/2010/06/scrshblogfiddler1requests.png?w=640&#038;h=281" alt=" batch shown in fiddler" title="1 batch request" width="640" height="281" class="alignleft size-full wp-image-145" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=135&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2010/06/18/addingcreating-data-to-odatawcf-data-service-batch-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>

		<media:content url="http://franssenden.files.wordpress.com/2010/06/scrshblogfiddler3requests.png" medium="image">
			<media:title type="html">fiddler products add requests</media:title>
		</media:content>

		<media:content url="http://franssenden.files.wordpress.com/2010/06/scrshblogfiddler1requests.png" medium="image">
			<media:title type="html">1 batch request</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom Security OData Service &#8211; Wcf Data Services</title>
		<link>http://franssenden.wordpress.com/2010/06/14/custom-security-odata-service-wcf-data-services/</link>
		<comments>http://franssenden.wordpress.com/2010/06/14/custom-security-odata-service-wcf-data-services/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 21:51:47 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET security]]></category>
		<category><![CDATA[custom permissions]]></category>
		<category><![CDATA[OData]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[WCF Data Services]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=91</guid>
		<description><![CDATA[I ran into an authentication/authorization make-a-decision-issue, about how to provide custom access to an OData Service. Also, I wanted this to work through &#8220;single&#8221; permissions for each user. What I mean by this is not to give users the final permissions through roles, but more directly, so I could authorize users consuming  the service  in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=91&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I ran into an authentication/authorization make-a-decision-issue, about how to provide custom access to an OData Service. Also, I  wanted this to work through &#8220;single&#8221; permissions for each user. What I mean by this is not to give users the final permissions through roles, but more directly, so I could authorize users consuming  the service  in a more flexible manner.<br />
For the authentication-part: There are many ways to do this.  Please read an interesting article from <a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/06/03/10482.aspx">Mike Taulty</a> on this topic.</p>
<p><strong>Authentication</strong><br />
Fact: You could use asp.net form based authentication, windows authentication etc.. This for me wasn&#8217;t an option, because of the service&#8217;s  &#8220;open&#8221; character. One would bother customers having a complex implementation time; assembling cookies, firing exotic client tools or spent hours on learning the-microsoft-way when they&#8217;re not used to it (which isn&#8217;t a bad thing of course, but let&#8217;s respect our fellow developers <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ) Although, I wanted to leave the MembershipProvider -&#8217;pattern&#8217; in, cause this comes in very handy.</p>
<p>I descided to go for a SSL/Basic Authentication solution, which is absolute secure!! (There are other discussions on this, which I leave out for now). Let&#8217;s talk about Basic Authentication for one minute:</p>
<p>On an Http-Request, Before transmission, the user name is appended with a colon and concatenated with the password. The resulting string is encoded with the Base64 algorithm. For example, given the user name Aladdin and password open sesame, the string Aladdin:open sesame is Base64 encoded, resulting in QWxhZGRpbjpvcGVuIHNlc2FtZQ==. The Base64-encoded string is transmitted and decoded by the receiver, resulting in the colon-separated user name and password string.</p>
<p>First thing we have to do is design some kind of a mechanism to handle requests containing these credentials and authenticate our user through a custom MembershipProvider.<br />
Let&#8217;s start by creating a new class implementing the IHttpModule:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Security.Principal;
using NL.ADA.TNT.CustomService.Modules;
using Ada.Cdf.Logging;

namespace NL.ADA.TNT.CustomService.Modules
{
    public class ODataServiceModule : IHttpModule
    {

        private CustomMembershipProvider membershipProvider;
        private Logger _logger;

        public ODataServiceModule()
        {
            _logger = new Logger();
        }

        #region IHttpModule Members

        public void Dispose()
        {
            _logger.Log(LogEvent.EnterEvent);
            membershipProvider = null;
            _logger.Log(LogEvent.LeaveEvent);
        }

        public void Init(HttpApplication
{
            membershipProvider = (CustomMembershipProvider)Membership.Provider;
            context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
            context.AuthorizeRequest += new EventHandler(context_AuthorizeRequest);
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
                   HttpApplication context = sender as HttpApplication;
            if (context.User == null)
            {
                if (!TryAuthenticate(context))
                {
                    SendAuthHeader(context);
                    return;
                }

            }

        }

        void context_AuthorizeRequest(object sender, EventArgs e)
        {
		//insert custom code
        }

        void context_AuthenticateRequest(object sender, EventArgs e)
        {

            //TODO: rules?
            HttpApplication context = sender as HttpApplication;
            TryAuthenticate(context);

        }

        #endregion

        private void SendAuthHeader(HttpApplication context)
        {
            context.Response.Clear();
            context.Response.StatusCode = 401;
            context.Response.StatusDescription = &quot;Unauthorized&quot;;
            context.Response.AddHeader(&quot;WWW-Authenticate&quot;, &quot;Basic realm=\&quot;Secure Area\&quot;&quot;);
            context.Response.Write(&quot;401 please authenticate&quot;);
            context.Response.End();

        }

        private bool TryAuthenticate(HttpApplication context)
        {

            string authHeader = context.Request.Headers[&quot;Authorization&quot;];

            if (!string.IsNullOrEmpty(authHeader))
            {
                if (authHeader.StartsWith(&quot;basic &quot;, StringComparison.InvariantCultureIgnoreCase))
                {

                    string userNameAndPassword = Encoding.Default.GetString(
                        Convert.FromBase64String(authHeader.Substring(6)));
                    string[] parts = userNameAndPassword.Split(':');

                    if (membershipProvider.ValidateUser(parts[0], parts[1]))
                    {
                        var userIdentity = new GenericIdentity(parts[0].Trim(), &quot;Basic&quot;);
                        context.Context.User = new CustomServicePrincipal(userIdentity);

                        return true;
                    }
               }
            }

            return false;
        }
    }
}
</pre>
<p>As you can see, we create a new Principal in this line:</p>
<p>context.Context.User = new CustomServicePrincipal(userIdentity);</p>
<p>I&#8217;ll come back to this in a minute. First you&#8217;ll have to notice this is a <strong>custom module</strong> that enables you to handle basic-authentication in IIS (7.5).<br />
Next we&#8217;ve to register this as a custom module in IIS&#8230;</p>
<p><a href="http://franssenden.files.wordpress.com/2010/06/scrshblogiismodules.png"><img class="alignleft size-full wp-image-110" title="Add Custom Module In IIS" src="http://franssenden.files.wordpress.com/2010/06/scrshblogiismodules.png?w=640&#038;h=452" alt="Add Custom Module In IIS" width="640" height="452" /></a></p>
<p>&#8230;.and disable all authentication-options, except anonymous:</p>
<p><a href="http://franssenden.files.wordpress.com/2010/06/scrshblogodata.png"><img class="alignleft size-full wp-image-109" title="disable authentication iis" src="http://franssenden.files.wordpress.com/2010/06/scrshblogodata.png?w=600&#038;h=232" alt="disable authentication iis" width="600" height="232" /></a></p>
<p>For now our module is set and intercepts each request doing our custom thing.</p>
<p><strong>Authorization</strong></p>
<p>As I mentioned earlier, for the actual authorization purpose we create a custom principal. that is a new Class that inherits GenericPrincipal. By doing this we&#8217;re able to &#8220;write&#8221; our user to the HttpContext and can call it&#8217;s UserPermissionSet property anytime:</p>
<pre class="brush: csharp;">
   public class CustomServicePrincipal : GenericPrincipal
    {
        private IIdentity _identity;
        private MyEntities _context;

        public CustomServicePrincipal(IIdentity identity)
            : base(identity, new string[] { })
        {

            _context = new MyEntities();
            _identity = identity;
            UserPermissionSet = GetUserPermissionSet();
        }

        public Permission UserPermissionSet { get; set; }
        private Permission GetUserPermissionSet()
        {
            try
            {
                var query = from up in _context.UserPermissions
                            where up.User.UserName == this.Identity.Name
                            select up.Permission;

                Permission flags = 0;
                foreach (var userPermission in query)
                {
                    flags |= (Permission)userPermission.ID;
                }
                return flags;

            }
            catch (Exception ex)
            {

                throw new Exception(string.Format(&quot;could not get permissionset for current user{0}&quot;, this.Identity.Name), ex.InnerException);
            }

        }

     }
</pre>
<p>Please note: the permissionset is received from the database (thru entity-framework 4.0).  If you want to authorize methods, properties and so on, the thing that worked for me is to handle those permissions as bitwise &#8220;flags&#8221; so that later on you can compare very easily throughout all the application. To make this clear, here&#8217;s an example:</p>
<pre class="brush: csharp;">
   [Flags]
    public enum Permission
    {
        userMayReadBedtimeStories = 1,
        userMayReadHorrorStories = 2,
        userMayReadHumoristicStories = 4,
        userMayReadNewsStories = 8,
        userMayReadOtherKindoStories = 16,
        userMayPostStory = 32

    }
</pre>
<p>At the persistance-level I stored these permissions in a &#8220;permission&#8221;-table which relates to table &#8220;User&#8221;. Username and Password are stored here also. Permissions for each user we&#8217;ll get from the &#8220;UserPermission&#8221;-crosstable.</p>
<p>Now we&#8217;re ready to demand some of these permissions on a method:</p>
<pre class="brush: csharp;">
        [ChangeInterceptor(&quot;Stories&quot;)]
        public void OnChangeStory(Story story, UpdateOperations updateOperations)
        {
                      AuthDemand(Permission.userMayPostStory);
//add a story
.
.
.
}
        private void AuthDemand(Permission demandPermissions)
        {
            var userPermissionSet = (HttpContext.Current.User as CustomServicePrincipal).UserPermissionSet;
            if ((userPermissionSet &amp; demandPermissions) != (demandPermissions))
            {
                throw new Exception(&quot;no permission&quot;);//put whatever you want to throw here
            }
        }
</pre>
<p>thank you also:<br />
<a href="http://blog.smithfamily.dk/2008/08/27/ImplementingBasicAuthenticationInASPNET20.aspx">Bjorns Blog</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=91&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2010/06/14/custom-security-odata-service-wcf-data-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>

		<media:content url="http://franssenden.files.wordpress.com/2010/06/scrshblogiismodules.png" medium="image">
			<media:title type="html">Add Custom Module In IIS</media:title>
		</media:content>

		<media:content url="http://franssenden.files.wordpress.com/2010/06/scrshblogodata.png" medium="image">
			<media:title type="html">disable authentication iis</media:title>
		</media:content>
	</item>
		<item>
		<title>Wpf Binding Xml Twitter example</title>
		<link>http://franssenden.wordpress.com/2009/07/18/wpf-binding-xml-twitter-example/</link>
		<comments>http://franssenden.wordpress.com/2009/07/18/wpf-binding-xml-twitter-example/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 23:29:21 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=52</guid>
		<description><![CDATA[Playing with the twitter API these days, of course inspired by Blu, I started a WPF client. For this example let&#8217;s start by showing your friends images thru a ListBox. Wondering how to bind most directly to the twitter API I came accross the following solution; Instead of binding to classes which are generated from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=52&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Playing with the <a href="http://apiwiki.twitter.com">twitter API</a> these days, of course <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  inspired by <a href="http://www.thirteen23.com/experiences/desktop/blu/">Blu</a>, I started a WPF client. For this example let&#8217;s start by showing your friends images thru a ListBox.</p>
<p>Wondering how to bind most directly to the twitter API I came accross the following solution; Instead of binding to classes which are generated from the Xml spit out by the Api, I thought of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.xmldataprovider.aspx">XmlDataProvider</a> is a more proper way of doing&#8230;<br />
First here&#8217;s the xaml:</p>
<pre class="brush: xml;">
&lt;Window x:Class=&quot;WpfTwitter.TwitterView&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        Title=&quot;Twitter View&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt;
    &lt;Window.Resources&gt;
        &lt;XmlDataProvider x:Key=&quot;DataProvider&quot;/&gt;
    &lt;/Window.Resources&gt;
    &lt;Grid&gt;
        &lt;ListBox Width=&quot;300&quot; Height=&quot;500&quot; ItemsSource=&quot;{Binding Source={StaticResource DataProvider}, XPath='users/user'}&quot;&gt;
            &lt;ListBox.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;StackPanel Background=&quot;Aqua&quot;&gt;
                        &lt;Image Source=&quot;{Binding XPath='profile_image_url'}&quot; Width=&quot;50&quot; Height=&quot;50&quot;/&gt;
                    &lt;/StackPanel&gt;
                &lt;/DataTemplate&gt;
            &lt;/ListBox.ItemTemplate&gt;
        &lt;/ListBox&gt;

    &lt;/Grid&gt;
&lt;/Window&gt;
</pre>
<p>For a more loosely coupled design I&#8217;ve chosen the PRISM way: MVP -&gt; model view presenter.:<br />
For this of course you need all 3:<br />
Model: TwitterPresentationModel<br />
View: TwitterView<br />
Presenter: TwitterPresenter</p>
<p>Now the TwitterView implements the ITwitterview, which holds a reference to the model:</p>
<p>    public interface  ITwitterView<br />
    {<br />
        TwitterPresentationModel Model { get; set; }<br />
    }</p>
<p>The model will hold the xmldocument returned from twitter:</p>
<p>namespace WpfTwitter<br />
{<br />
    public class TwitterPresentationModel:XmlDocument<br />
    {<br />
        public TwitterPresentationModel()<br />
        {</p>
<p>        }<br />
    }<br />
}</p>
<p>Notice that it is just inherited from XmlDocument. That will do for now.</p>
<p>Then in the presenter we control both view and model:</p>
<p>    public class TwitterPresenter<br />
    {<br />
        private ITwitterView view;<br />
        private Yedda.Twitter twitter;<br />
        public TwitterPresenter(ITwitterView view)<br />
        {<br />
            twitter = new Yedda.Twitter();<br />
            var twitterPresentationModel = new TwitterPresentationModel();<br />
            twitterPresentationModel.LoadXml(twitter.GetFriends(&#8220;user&#8221;, &#8220;password&#8221;, Yedda.Twitter.OutputFormatType.XML));<br />
            view.Model = twitterPresentationModel;<br />
        }<br />
    }</p>
<p>Here I used the <a href="http://devblog.yedda.com/index.php/twitter-c-library/">Yedda twitter Library</a> Really usefull. All methods from the twitter api are implemented!</p>
<p>In the TwitterView.cs we&#8217;ll start to bind some things:</p>
<p>    public partial class TwitterView : Window, ITwitterView<br />
    {<br />
        public TwitterView()<br />
        {<br />
            InitializeComponent();<br />
            var presenter = new TwitterPresenter(this);<br />
        }</p>
<p>        public TwitterPresentationModel Model<br />
        {<br />
            get<br />
            {<br />
                return (this.Resources["DataProvider"] as XmlDataProvider).Document as TwitterPresentationModel;<br />
            }<br />
            set<br />
            {<br />
                (this.Resources["DataProvider"] as XmlDataProvider).Document = value;<br />
            }<br />
        }<br />
    }</p>
<p>As you can see, we hook the XmlDataProvider to the Model. Thus, Provider becomes Model and Provider becomes Model.<br />
The only thing that&#8217;s left is binding the list to the model. As you can see in the xaml, this is done by binding to the XmlDataProvider and setting the datatemplate-binding to the user node<br />
of the Xml. All can be done with XPath, which a vast bunch o developers still might love:</p>
<pre class="brush: xml;">
        &lt;ListBox Width=&quot;300&quot; Height=&quot;500&quot; ItemsSource=&quot;{Binding Source={StaticResource DataProvider}, XPath='users/user'}&quot;&gt;
            &lt;ListBox.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;StackPanel Background=&quot;Aqua&quot;&gt;
                        &lt;Image Source=&quot;{Binding XPath='profile_image_url'}&quot; Width=&quot;50&quot; Height=&quot;50&quot;/&gt;
                    &lt;/StackPanel&gt;
                &lt;/DataTemplate&gt;
            &lt;/ListBox.ItemTemplate&gt;
        &lt;/ListBox&gt;
</pre>
<p>Great! Try it, use it, love it&#8230; </p>
<p>Frans.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=52&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2009/07/18/wpf-binding-xml-twitter-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>
	</item>
		<item>
		<title>Silverlight Client Access Policy &#8216;solves&#8217; Crossdomain issue</title>
		<link>http://franssenden.wordpress.com/2009/04/08/silverlight-client-access-policy-solves-crossdomain-issue/</link>
		<comments>http://franssenden.wordpress.com/2009/04/08/silverlight-client-access-policy-solves-crossdomain-issue/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 22:36:23 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=35</guid>
		<description><![CDATA[Don&#8217;t feel desperate if you walk into some exception message like this: &#8220;An error occurred while trying to make a request to URI &#8216;http://localhost:1528/MyService.svc&#8217;. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=35&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t feel desperate if you walk into some exception message like this:</p>
<p>&#8220;An error occurred while trying to make a request to URI &#8216;http://localhost:1528/MyService.svc&#8217;. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a &#8230;&#8230;.. etc. etc. etc.&#8221;</p>
<p>Just paste the following into an XML (name it: &#8216;clientaccesspolicy.xml&#8217; ) located in the root of your service application:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;access-policy&gt;
  &lt;cross-domain-access&gt;
&lt;policy&gt;
      &lt;allow-from http-request-headers=&quot;*&quot;&gt;
        &lt;domain uri=&quot;*&quot;/&gt;
      &lt;/allow-from&gt;
      &lt;grant-to&gt;
        &lt;resource path=&quot;/&quot; include-subpaths=&quot;true&quot;/&gt;
      &lt;/grant-to&gt;
    &lt;/policy&gt;
  &lt;/cross-domain-access&gt;
&lt;/access-policy&gt;
</pre>
<p>In fact you can do more with policies on crossdomain-issues. Please read:</pre>
<p><a href="http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx">msdn on this topic</a><br />
<a href="http://www.sajay.com/post/2007/01/05/Thoughts-on-BasicHttpBinding-Security-and-SSL.aspx">Sajai's blog</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=35&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2009/04/08/silverlight-client-access-policy-solves-crossdomain-issue/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>
	</item>
		<item>
		<title>ListBox ItemContainerStyle: Getting rid of that boxed restriction</title>
		<link>http://franssenden.wordpress.com/2009/03/26/listbox-itemcontainerstyle-getting-rid-of-that-boxed-restriction/</link>
		<comments>http://franssenden.wordpress.com/2009/03/26/listbox-itemcontainerstyle-getting-rid-of-that-boxed-restriction/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 11:03:05 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=29</guid>
		<description><![CDATA[When visualizing data using a listbox and &#8216;randomly&#8217; place the ListBoxItems (Please read this article for understanding how to do this), you&#8217;ll notify that there&#8217;s a little friction that makes you consider using an ItemsControl instead: the box that contains your data.   It is default visualized  by a rectangle which contains the ListBoxItem. A simple solution for this is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=29&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When visualizing data using a listbox and &#8216;randomly&#8217; place the ListBoxItems (Please read <a href="http://petermcg.wordpress.com/2009/02/15/customizing-the-silverlight-2-itemscontrol-with-templates/">this article</a> for understanding how to do this), you&#8217;ll notify that there&#8217;s a little friction that makes you consider using an ItemsControl instead: the box that contains your data.   It is default visualized  by a rectangle which contains the ListBoxItem.</p>
<p>A simple solution for this is simply setting the Width and Height property of the ItemContainerStyle:</p>
<p>                &lt;ListBox.ItemContainerStyle&gt;<br />
                    &lt;Style TargetType=&#8221;ListBoxItem&#8221;&gt;<br />
                        &lt;Setter Property=&#8221;Width&#8221; Value=&#8221;0&#8243;/&gt;<br />
                        &lt;Setter Property=&#8221;Height&#8221; Value=&#8221;0&#8243;/&gt;<br />
                    &lt;/Style&gt;<br />
                &lt;/ListBox.ItemContainerStyle&gt;</p>
<p>Although it might be not the most proper solution, it does prevent you from using and customizing the ItemsControl. One of my concerns was to keep all of the selection-functionality from the ListBox Control.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=29&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2009/03/26/listbox-itemcontainerstyle-getting-rid-of-that-boxed-restriction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>
	</item>
		<item>
		<title>Silverlight CAL &amp; Prism</title>
		<link>http://franssenden.wordpress.com/2009/02/12/silverlight-cal-showing-a-window-using-delegatecommand/</link>
		<comments>http://franssenden.wordpress.com/2009/02/12/silverlight-cal-showing-a-window-using-delegatecommand/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 22:18:06 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=21</guid>
		<description><![CDATA[Several weeks now I&#8217;ve been playing with CAL,  that is the &#8216;Composite Application Library&#8217; a robust library from MS Patterns &#38; Practices. I must say I&#8217;m quite impressed by this guidance and in particular the enormous work that must have been done all to the love of  WPF. WPF&#8217;s little sister watched her brother learning to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=21&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Several weeks now I&#8217;ve been playing with CAL,  that is the &#8216;Composite Application Library&#8217; a robust library from MS Patterns &amp; Practices. I must say I&#8217;m quite impressed by this guidance and in particular the enormous work that must have been done all to the love of  WPF. WPF&#8217;s little sister watched her brother learning to dance. Little steps will show us that she might be a better dancer someday.</p>
<p>CAL and Silverlight go together under the name of Prism, which you can find on codeplex.</p>
<p><a href="http://www.codeplex.com/CompositeWPF">http://www.codeplex.com/CompositeWPF</a> </p>
<p>The CAL guidance lets us build a (enterprise-level) client application composed of pieces, that maybe have been designed and developed in different teams. Those pieces will come together and build modules. This module-approach will lead to the composite-application, nicely build up of loosely-coupled parts.</p>
<p>Please read the msdn documentation <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx">here</a></p>
<p>Prism is cooool, because now all those great things we can do in Silverlight too!</p>
<p>Next post I want to share a way to show a usercontrol (by demand) by using  a (Global) Command.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=21&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2009/02/12/silverlight-cal-showing-a-window-using-delegatecommand/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>
	</item>
		<item>
		<title>Sharepoint 2009</title>
		<link>http://franssenden.wordpress.com/2009/02/10/sharepoint-2009/</link>
		<comments>http://franssenden.wordpress.com/2009/02/10/sharepoint-2009/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 20:57:00 +0000</pubDate>
		<dc:creator>franssenden</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Sharepoint]]></category>

		<guid isPermaLink="false">http://franssenden.wordpress.com/?p=3</guid>
		<description><![CDATA[The lady is pregnant, but we&#8217;re just guessing. MS Sharepoint 2009/2010 was promised to be released very shortly from now. Sharepoint14  as  Sharepoint 12 &#8216;s follow up (no comment reveals some features we may now consider obvious: The server software announced as 64 bit only Silverlight Media web parts Backup/Restore/Rollback and Snapshot backups with virtual load [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=3&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The lady is pregnant, but we&#8217;re just guessing. MS Sharepoint 2009/2010 was promised to be released very shortly from now. Sharepoint14  as  Sharepoint 12 &#8216;s follow up (no comment <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  reveals some features we may now consider obvious:</p>
<ul>
<li>The server software announced as 64 bit only</li>
<li>Silverlight Media web parts</li>
<li>Backup/Restore/Rollback and Snapshot backups with virtual load balancing</li>
<li>Claims-based authentication</li>
<li>Possible inclusion of InfoPath style web-based editor &#8211; since Office 14 is allowing for some applications to be web-based with limited functionality.</li>
<li>SQL tables-like behaviour for SharePoint lists    </li>
<li>PowerShell</li>
<li>Master Data Management (MDM)</li>
<li>FAST search (Enterprise Search revamp)</li>
<li>AJAX based interface</li>
<li>.NET 4 based</li>
<li>An STSADM GUI</li>
<li>Groove and SharePoint will now be fully integrated</li>
<li>ODF and PDF support</li>
<li>Content Management Interoperability Services support</li>
<li>SharePoint 2009’s default web interface will be using the Ribbon interface</li>
<li>Super-Lists SQL tables-like behaviour for SharePoint lists</li>
</ul>
<p>Let&#8217;s throw some other speculations &amp; interpretations:</p>
<ol>
<li>CKS (Community Kit 4 SharePoint) will be integrated and more: SharePoint will have some facebook looks</li>
<li>Podcasting Kit for SharePoint</li>
<li>Interactive Media Manager ..?</li>
<li>Full blown Internet, Web 2.0 features.</li>
<li>A More friendly development environment</li>
<li>Workflow. Excessively <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li>Since Groove will be integrated I guess you&#8217;ll have to buy modules for it.</li>
<li>Ghosting/unghosting issues solved.</li>
</ol>
<p>From a developers perspective I think the new WSS will make our job a lot easier. More templates will be available in VS 2010.  Despite of all Blueprints &#8216;Silverlight&#8217; now will be fully integrated. The Geneva platform will definitely make its entrance, although some sources mention it to be planned for an SP. For now the baby has to be born. Follow the star&#8230; </p>
<p>Tx to Jaap Steinvoorte for accurate research!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/franssenden.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/franssenden.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/franssenden.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/franssenden.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/franssenden.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/franssenden.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/franssenden.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/franssenden.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/franssenden.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/franssenden.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/franssenden.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/franssenden.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/franssenden.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/franssenden.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=franssenden.wordpress.com&amp;blog=6245717&amp;post=3&amp;subd=franssenden&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://franssenden.wordpress.com/2009/02/10/sharepoint-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/463160c8ce243f36a34efdea1a6fce87?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">franssenden</media:title>
		</media:content>
	</item>
	</channel>
</rss>
