<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-8691068330397730091.post1710514592183372660..comments</id><updated>2010-02-23T21:14:49.092-05:00</updated><category term='C#'/><category term='NHibernate'/><category term='Repository'/><category term='Visual Studio'/><category term='Unit of Work'/><category term='Insanity'/><category term='WCF'/><category term='IIS'/><category term='ASP.NET'/><category term='.NET'/><category term='Windows 7'/><category term='Pattern'/><title type='text'>Comments on blog.jamesjones.name: Generic Enum "Composed Of" Test</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.jamesjones.name/feeds/1710514592183372660/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default'/><link rel='alternate' type='text/html' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html'/><author><name>James</name><uri>http://www.blogger.com/profile/07743081202945582329</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8691068330397730091.post-3329782189398738239</id><published>2010-02-23T21:14:49.092-05:00</published><updated>2010-02-23T21:14:49.092-05:00</updated><title type='text'>I agree with you on is that the application of thi...</title><content type='html'>I agree with you on is that the application of this function is narrow. It&amp;#39;s one of the first blog posts I&amp;#39;ve ever made so I cherry-picked a topic with a narrow scope thinking that people wouldn&amp;#39;t criticize the usefulness of something that they don&amp;#39;t plan on using or don&amp;#39;t care about. But I digress...&lt;br /&gt;&lt;br /&gt;When I say &amp;quot;strongly typed enum&amp;quot;, I&amp;#39;m describing the difference between dealing directly with the enum in question verses the enum cast to the Enum class. The keyword &amp;quot;enum&amp;quot; vs. the class &amp;quot;Enum&amp;quot;. You can see from the screen shot I posted that Anon&amp;#39;s method doesn&amp;#39;t compile when using Enum (the class).&lt;br /&gt;&lt;br /&gt;Good observation that Microsoft will be offering a replacement to this function in .NET 4. I&amp;#39;ll put a note at the top of my post to observe that this code snippet is obsolete. Thanks!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/3329782189398738239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/3329782189398738239'/><link rel='alternate' type='text/html' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html?showComment=1266977689092#c3329782189398738239' title=''/><author><name>James</name><uri>http://www.blogger.com/profile/07743081202945582329</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Xy29Qj1Kzis/SqvNcn_yjlI/AAAAAAAAAAM/W3EzrXtMOEA/S220/me.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html' ref='tag:blogger.com,1999:blog-8691068330397730091.post-1710514592183372660' source='http://www.blogger.com/feeds/8691068330397730091/posts/default/1710514592183372660' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-425983316'/></entry><entry><id>tag:blogger.com,1999:blog-8691068330397730091.post-9154843683002183303</id><published>2010-02-23T17:49:00.438-05:00</published><updated>2010-02-23T17:49:00.438-05:00</updated><title type='text'>This application seems so narrow, I don&amp;#39;t see ...</title><content type='html'>This application seems so narrow, I don&amp;#39;t see why you&amp;#39;d need a 30-line generic implementation to address the issue. I don&amp;#39;t understand why you couldn&amp;#39;t use the other commenter&amp;#39;s simpler solution. Do you honestly have multiple enumerations whose values are used as bit flags, and whose underlying value types you don&amp;#39;t know? Speaking of which, ideally you should be using the [Flags] attribute, which should also help simplify this.&lt;br /&gt;&lt;br /&gt;Luckily, in .NET 4 you can use the Enum.HasFlag method and avoid jumping through even the hoop of the simple bitwise AND.&lt;br /&gt;&lt;br /&gt;Also, what do you mean by &amp;quot;strongly typed enum&amp;quot;? C# enums are naturally strongly typed.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/9154843683002183303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/9154843683002183303'/><link rel='alternate' type='text/html' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html?showComment=1266965340438#c9154843683002183303' title=''/><author><name>throwawayjj</name><uri>http://throwawayjj.livejournal.com/</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html' ref='tag:blogger.com,1999:blog-8691068330397730091.post-1710514592183372660' source='http://www.blogger.com/feeds/8691068330397730091/posts/default/1710514592183372660' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1341742565'/></entry><entry><id>tag:blogger.com,1999:blog-8691068330397730091.post-2785778055680961099</id><published>2010-02-21T13:18:40.563-05:00</published><updated>2010-02-21T13:18:40.563-05:00</updated><title type='text'>Mr. Anonymous,

You are absolutely correct. I tota...</title><content type='html'>Mr. Anonymous,&lt;br /&gt;&lt;br /&gt;You are absolutely correct. I totally misrepresented the context that I was working in, where this function would be handy. That context was that I didn&amp;#39;t have a strongly typed enum to work with. What I WAS working with was the &amp;quot;Enum&amp;quot; class, which you cannot perform bitwise operations on.&lt;br /&gt;&lt;br /&gt;Thank you for pointing out my oversight. I&amp;#39;ll update my post accordingly.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/2785778055680961099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/2785778055680961099'/><link rel='alternate' type='text/html' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html?showComment=1266776320563#c2785778055680961099' title=''/><author><name>James</name><uri>http://www.blogger.com/profile/07743081202945582329</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_Xy29Qj1Kzis/SqvNcn_yjlI/AAAAAAAAAAM/W3EzrXtMOEA/S220/me.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html' ref='tag:blogger.com,1999:blog-8691068330397730091.post-1710514592183372660' source='http://www.blogger.com/feeds/8691068330397730091/posts/default/1710514592183372660' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-425983316'/></entry><entry><id>tag:blogger.com,1999:blog-8691068330397730091.post-660317506913397395</id><published>2010-02-19T15:21:23.027-05:00</published><updated>2010-02-19T15:21:23.027-05:00</updated><title type='text'>While this may work, there is a far more elegant s...</title><content type='html'>While this may work, there is a far more elegant solution: just use bitwise operations. To test if Modify contains Read in the example above, you just need to write one line:&lt;br /&gt;&lt;br /&gt;  (FilePermission.Modify &amp;amp; FilePermission.Read) == FilePermission.Read&lt;br /&gt;&lt;br /&gt;That line returns true since the logical AND operation between 0001 (Read) and 0011 (Modify) returns 0001 (Read).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/660317506913397395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8691068330397730091/1710514592183372660/comments/default/660317506913397395'/><link rel='alternate' type='text/html' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html?showComment=1266610883027#c660317506913397395' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.jamesjones.name/2009/09/generic-enum-composed-of-test.html' ref='tag:blogger.com,1999:blog-8691068330397730091.post-1710514592183372660' source='http://www.blogger.com/feeds/8691068330397730091/posts/default/1710514592183372660' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-380991028'/></entry></feed>
