.Net Code Monkey RSS 2.0
 Thursday, August 09, 2012
.Net Generics - Wrapper

Have you ever needed a wrapper object that can expose the properties for any object it encompasses?

I frequently do, as when loading a list of entities from the database I often want to send a SearchFilterCriteria object down the call stack for filtering. Nine times out of ten this ends up having the same properties as my Entity. i don't just want to pass an Entity down the call stack and use that as the filter as that feels a bit wrong. What I want is an object that I can wrap around any entity and expose all of the entity properties.

Finally I have found a way to do this and that is with generics. I'd like to share with you what I cam up with. below is the class which will wrap any entity type and expose it as a property.


/// <summary>
 /// Encapsualtes search criteria.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 public class SearchFilterCriteria<T> where T : new()
 {
     private T _internalCriteria = default(T);

     /// <summary>
     /// Gets the criteria.
     /// </summary>
     public T Criteria
     {
         get
         {
             if (this._internalCriteria == null || this._internalCriteria.Equals(default(T)))
             {
                 this._internalCriteria = new T();
             }
             return this._internalCriteria;
         }
     }
 }

And here an example of using the beast for my event object that has many properties but includes Active and Name properties.

public static SearchFilterCriteria<Event> CreateEventSearchFilterCriteria()
{
    SearchFilterCriteria<Event> s = new SearchFilterCriteria<Event>();
    // Set the default values...
    s.Criteria.Active = true;
    s.Criteria.Name = "Easter";
    return s;
}


All of the properties of the Entity are exposed through the Wrapper's Criteria property. If I could just find out how to pass a method parameter as a typeparam I would be really happy. Then I could have a generic factory method that could create a SearchFilterCriteria for any Type, rather than having to have a CreateFooSearchFilterCriteria() and a CreateBarSearchFilterCriteria() method for each type.

Anyway, I hope that may be of some use to you in some future project.

Regards,
Dib
Thursday, August 09, 2012 10:51:32 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.Net | C# | Classes | Genrics | Wrapper
 Tuesday, July 10, 2012

With the impending Metro style applications coming through for the release of Windows 8, I thought all websites I now do must be in the Metro style

Here is a link WeymouthRecovery

Designed to be simple, concise and mobile browser friendly.

Tuesday, July 10, 2012 10:59:27 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Html | JavaScript | Metro | Mobile Phone
 Thursday, February 23, 2012

Corsair Flash Voyager USB Memory Stick - Genuine vs Copy / Fake

I was recently unfortunate enough to purchase some non-genuine Corsair Flash Voyager USB memory sticks of a couple of sellers on ebay. I wasn't aware that i had bought a fake version until one of them failed and became read-only. I was not able to to write files to it all of a sudden and could not format it with any kind of tool either. I contacted the Ram Guy from corsair and asked him what I could do. He asked for the serial numbers and described where I would find them. Unfortunately for me, the stick that  had failed did not have any serial numbers, and the Ram guy advised me I had purchased a fake stick. The seller on eBay who sold me the fake stick that failed did allow me to return the stick and I received a full refund. The second seller did not allow me to return it so I am in the process of reporting him to ebay.

In the mean-time would like to take this opportunity to show the difference between the fake stick I bought off eBay and one I purchased off of amazon, so maybe others do not fall into the trap.

The first two pictures show the packaging that the two sticks came in. The packaging on the left was from the Flash Voyager USB stick purchased Amazon.





The next pictures show the stick it self. The genuine Corsair USB stick is on the left. Notice the led on the fake is missing.






The next two pictures show the corsair Flash voyagers with the caps removed. Notice the shape of the blue pip on the lid. also notice that there is no "CE FC" marks on the fake stick, and the genuine has serial numbers etched onto the metal part of the plug.







A couple of things that you cannot see from the pictures is the rubber used by corsair is much more dense and solid than that of the fake. Also the genuine Corsair Flash Voyager data access time is much quicker than the fake USB stick.

I hope that may help some unsuspecting buyers determine the difference before they click "buy it now" on ebay.

UPDATE:
Since writing this article I have since found this guide on ebay: "How To Spot Fake Corsair Flash Drives : eBay Guides" written by "wakosako". Please read this guide it covers more than I have here.
Thursday, February 23, 2012 6:29:49 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Corsair Flash Voyager
 Saturday, February 18, 2012

Cortext HDTT 5000 Review

I recently purchased a pair of Cortext HDTT 5000 digital music decks off of eBay.I'd like to take this space to review what I know about them so far.

Hardware Build Quality

Over all, the general build quality is good. The units 360mm x 320mm x 110mm, and are similar size to a CDJ1000, I believe. They feel solid and well constructed. The corners are protected with large rubberised mouldings. The platter has solid bearings and feels similar to the CDJ1000. The pitch control is smooth and has no central detent. The buttons all have a very positive action, except believe it or not, The CUE and PLAY buttons! These buttons kind of let the user interaction down a bit. They are probably the most used controls on the deck after the platter and pitch control. Why did they scrimp on this?

Getting Started

You can wire the units up in the same manner as a CDJ with each unit having it's own RCA leads to the mixer and each deck having it's on music source. 1 USB stick each. Or both units can share a USB stick by daisy-chaining. To do this you set up one deck as the master and one as the salve via switches on the back. You then use a USB-A to USB-B lead (not supplied) to connect them. The USB-B goes in the master deck. Do not use cheap leads, as for some reason they (or my one) do not work. You then have to take the slave's RCA leads and take them out of the slave sockets of the master deck. Now both decks can share the same media.

Each deck has five USB-A connectors for media. four in the back and one on top. When daisy chaining I assume the slave can see all five of these. I have only tried with one so far.

Loading Media

Before loading a USB into the unit it is best (time-wise) to download the Cortex PC Database Software and index the tracks via that. It is painfully slow to index on the fly. It also holds up the whole unit, so you would not want your mate popping his new stick in your slot in the middle of a live set!  The Cortex PC DB software allows you to generate the wave forms at the same time. worth doing as again this is slow on the fly.

Turn on the deck and let it prompt you for media. Insert the media and provided you have set up / verified your database via the cortex PC software, you can select to not verify your source and just get on and play some music!


The screen allows shows you the important stuff like track time elapsed or track time remaining. There is also a bar showing how far through the track is.

Issues

I would be concerned using USB media in a live environment where a member of the public could just pull out the stick while you are playing. Especially from the top slot. This would stop all music and probably corrupt the USB stick.


TBC... More to follow as I go along..

The Good

  • Jog Wheel / Platter - solid feel and very easy to line up the beats with.
  • Pitch control ±4%, ±8%, ±16% and ±24%

The Bad

  • Once a memory stick is ejected, the player will not recognise it next time you plug it in without switching the unit off and back on again first.
  • Infrequent blue screen and hang when trying to turn the unit off. Needed power lead pulling out of the back.
  • Blue screen hang on master switch on, if you have already turned slave unit on first.
  • There is no way to see the whole track wave form, unless it is a VERY short track!
  • The Cortex database software crashes often.

The Ugly

  • Removing a USB stick without "Ejecting" it can (and probably will) corrupt the stick beyond recovery! It did for one of mine anyway. £25 down the drain!

TBC... More to follow as I go along..





Links:
Cortex HDTT 5000 product information - http://www.cortex-pro.com/hdtt_5000.php


Saturday, February 18, 2012 5:16:59 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Cortex HDTT 5000
Archive
<May 2013>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Blogroll
 Clemens Vasters
 Harry Pierson
Passion * Technology * Ruthless Competence
 Joshua Flanagan
A .NET Software Developer
 Michael Schwarz's Blog
Developing applications on the Microsoft platform since Windows 3.1!
 Omar Shahine
Yet another Microsoft blogger
 Scot GU
Scott Guthrie lives in Seattle and builds a few products for Microsoft
 Scott Hanselman
Programming Life and the Zen of Computers
 Tom Mertens
Tom's corner
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2013
Duane Wingett
Sign In
Statistics
Total Posts: 43
This Year: 0
This Month: 0
This Week: 0
Comments: 41
Themes
Pick a theme:
All Content © 2013, Duane Wingett
DasBlog theme 'Business' created by Christoph De Baene (delarou)