Isn't this going to be much easier in .NET 2.0 with the introduction of generics? I know it is currently that way with Java in JDK 5.
Java: List <MyObject> = new ArrayList<MyObject>(); Apparently the C# notation is identical. Brandon On 5/23/05, Chad Humphries <[EMAIL PROTECTED]> wrote: > Resharper can do all this and more! (insert deeply convincing > argument to switch here). It supports the same type of generation > via Live Templates > (http://www.jetbrains.com/resharper/features/liveTemplates.html). > You would need to create a Live Template for your Custom Collection > but the same result is achievable. > > I suppose since everyone else is throwing their custom collection code > in I'll bring mine out. I enjoy the CustomCollectionBase I created. > Implementation is very simple (basically copy/paste). A > CustomCollection that uses it would look something like this: > > using System; > using SuperSecret.Collections.Filters; > using SuperSecret.Domain; > > namespace SuperSecret.Collections > { > [Serializable()] > public class SecretCollection : CustomCollectionBase > { > public SecretCollection():base(typeof(Secret)){} > public void Add(Secret o){InnerList.Add(o);} > public void Remove(Secret o){InnerList.Remove(o);} > public new Secret this[int index] > { > get{return((Secret)List[index]);} > set{List[index] = value;} > } > public new Secret FindOne(PropertyFilter cfSearch) > { > return (Secret)base.FindOne(cfSearch); > } > public new SecretCollection FindMany(PropertyFilter cfSearch) > { > return (SecretCollection)base.FindMany(cfSearch); > } > } > } > > Anyway, you can pretty much accomplish this type of generation via who > knows how many ways so hopefully this thread will give people more > information on the different ways out there. > > -Chad > > On 5/23/05, Ron Grabowski <[EMAIL PROTECTED]> wrote: > > I've seen that. I think my app is faster when you need to generate 20 > > collections at once. Using the VS.Net template method, you need to > > repeat the same step 20 times. Not to mention the time it takes to > > click through all the menus. Even with using keyboard shortcuts its > > still a pain. Their templates just extend CollectionBase. The template > > I'm using includes xml comments along with a bunch of other "stuff". > > Plus some corporate environments have their Windows machines locked > > down and altering Visual Studio is not always an option. > > > > The way I do it now (using QuickCodes) is that I type this on a line: > > > > coll Product > > > > and press Alt-Q and it generates the collection. > > > > Does ReSharper allow you to generate things like that? Everyone keeps > > nagging me to switch over to it :) > > > > --- Gilles Bayon <[EMAIL PROTECTED]> wrote: > > > Even better, > > > http://weblogs.asp.net/egarmon/archive/2003/11/13/37383.aspx > > > Just create a collection from VS.NET <http://VS.NET> as a class. > > > > > > On 5/23/05, Ron Grabowski <[EMAIL PROTECTED]> wrote: > > > > > > > > Others may find this useful... > > > > > > > > Since IBatisNet plays well with strongly typed collections, I wrote > > > a > > > > small tool to help me create strongly typed collections: > > > > > > > > http://www.ronosaurus.com/IBatisNet/collgen/ > > > > > > > > Basically I enter the name of my entity objects in the TextBox (one > > > per > > > > line, as many as I want): > > > > > > > > Product > > > > Category > > > > > > > > and it generates a .zip file on-the-fly containing: > > > > > > > > ProductCollection > > > > CategoryCollection > > > > > > > > The ProductCollection consists of the following items: > > > > > > > > Interface IProductCollection > > > > Interface IProductList > > > > Interface IProductEnumerator > > > > Class ProductCollection > > > > > > > > There is also support for collections being in a different > > > namespace > > > > than the entity objects. > > > > > > > > Here is an example output file: > > > > > > > > > > > > > > > > > http://www.ronosaurus.com/IBatisNet/collgen/StonglyTypedCollections.zip > > > > > > > > Yes, I am aware of Code Smith and QuickCode. In fact the template > > > > collection came from a QuickCode submission. If you need more > > > > functionality than what my single one form app does, by all means > > > use > > > > Code Smith or QuickCode. > > > > > > > > What's nice about generating collections this way is that I can > > > have my > > > > browser open up the generated .zip file after its done downloading > > > then > > > > I simply drag the .cs files into Visual Studio. No need to open > > > another > > > > program, select a template, type things into it, generate the > > > files, > > > > then close out of everything. > > > > > > > > Maybe I'll allow the user to specify what type of collection they > > > want: > > > > > > > > > > > > simple: just extend CollectionBase > > > > advanced: all the bells and whistles (how it is now) > > > > > > > > - Ron > > > > > > > > > >