collections

Less defined generics in c#?

Is there a way to use a collection of a generic class, without supplying the underlying type ? Let's explain : Here is what I'd like to have : class TimeSerie<TValue> { enter code here } List<TimeSerie<?>> blah; Here is what I have to do so far : class TimeSerie {} class TypedTimeSerie<TValue> : TimeSerie {} List<TimeSerie> blah; ...

Is there a general concrete implementation of a KeyedCollection?

The System.Collections.ObjectModel.KeyedCollection class is a very useful alternative to System.Collections.Generic.Dictionary, especially when the key data is part of the object being stored or you want to be able to enumerate the items in order. Unfortunately, the class is abstract, and I am unable to find a general concrete implementa...

C++/CLI generics, use T in array<> and other collections

Hi. I'm writing a generics class in C++/CLI (VS2008) to store and manage records of different kinds and I need collections to keep them before flusing them to DB/disk/etc. I was thinking in something like this: ref class Record { // ... }; generic<typename T> where T : Record, gcnew() public ref class Factory { public: // ....f...

Splitting one DB association into several collections in Hibernate.

I am trying to model such situation - there is a cash transfer (I mean a car that carries money), that has required amounts of each currency, and also an actual amount for each currency. And it seems to me pointless to create two separate classes, one for required amount and another for actual amount. So the implementation would look lik...

WPF control design guidance - timeline

I'm working on a control for one of our apps. The control shows the currently focused day as a gird, the X-axis being time of day. The Y axis doesn't have a scale as such, rather it will separate out the items to be displayed. The overall look of the control will be quite similar to a gantt chart, showing the times of day of various t...

.NET: How to efficiently check for uniqueness in a List<string> of 50,000 items?

In some library code, I have a List that can contain 50,000 items or more. Callers of the library can invoke methods that result in strings being added to the list. How do I efficiently check for uniqueness of the strings being added? Currently, just before adding a string, I scan the entire list and compare each string to the to-be...

Silverlight 3 DataGrid Grouping - Detecting Group Header Click or Header Expand/Collapse

I am using a PagedCollectionView in Silverlight 3 to group items in a datagrid. I want to detect when the group headers are clicked but after 6 hours still cannot find any way to do this. (So that when a collapsed header is clicked I can dynamically load the group's content) The datagrid is populated like so: PagedCollectionView coll...

RoR: partials with resources

I have a problem, trying to render partials in ruby on rails with the short notation for resoures. Somehow, RoR displays simply nothing that has to do with the partial, but i get no errors as well. I mean, the resulting HTML looks like the call for the partial simply wouldn't be there. I'm also confused, because i can see in the log, tha...

Using Where With SubSonic Collection

Hi All, I am having problem with collection object. Here is the code CarCollection obj=new CarCollection(); obj.Where("Id","10"); obj.Load(); The problem is the result of the records doubles i.e actually there is only 1 record with the id 10 but it returns 2 same records. Please Help me as i am a newbie. Thanks ...

Collection as Collection of base type c# 2.0

I am aware of http://stackoverflow.com/questions/1174328/passing-a-generic-collection-of-objects-to-a-method-that-requires-a-collection-of How do I do it in .Net 2.0 where I don't have .Cast ??? It has to be reference equality i.e. copies of the list won't do. To re-iterate - I cannot return a new list - it has to be the same list ...

Creating a "true" HashMap implementation with Object Equality in ActionScript 3

I've been spending some of my spare time working a set of collections for ActionScript 3 but I've hit a pretty serious roadblock thanks for the way ActionScript 3 handles equality checks inside Dictionary Objects. When you compare a key in a dictionary, ActionScript uses the === operator to perform the comparison, this has a bit of a na...

ASP.NET MVC: How to maintain TextBox State when your ViewModel is a Collection/List/IEnumerable

I am using ASP.NET MVC 2 Beta. I can create a wizard like workflow using Steven Sanderson's technique (in his book Pro ASP.NET MVC Framework) except using Session instead of hidden form fields to preserve the data across requests. I can go back and forth between pages and maintain the values in a TextBox without any issue when my model i...

If you aren't supposed to return collections to callers, how should you return a collection of data to a caller?

I am writing a method that's intended to return a dictionary filled with configuration keys and values. The method that's building up this dictionary is doing so dynamically, so I need to return this set of keys and values as a collection (probably IDictionary<string, string>). In my various readings (sources escape me at the moment), th...

How can I create a java list using the member variables of an existing list, without using a for loop?

I have a java list List<myclass> myList = myClass.selectFromDB("where clause"); //myClass.selectFromDB returns a list of objects from DB But I want a different list, specifically. List<Integer> goodList = new ArrayList<Integer>(); for(int i = 0;i++; i<= myList.size()) { goodList[i] = myList[i].getGoodInteger(); } Yes, I could...

Java ArrayList not allowing me to add from outside constructor

public class Start { public Register theReg = new Register(); public static Start go = new Start(); public static void main(String[] args) { Register theReg = new Register(); go.regUsers(); if(theReg.logIn("jsmith","password")) { System.out.println("You're logged in as " + ...

Utilities to find Gen1, Gen 2 objects promoted in BizTalk Orchestration?

Hi I am trying to profile a memory guzzling biztalk orchestration. This orchestration is using plenty of maps with a few custom script functoids. I wish to identify the lifetime of the custom objects created by orchestration and how are they promoted in the Garbagage collection. Am not able to use the CLR profiler for the same. Looki...

Preserve multi-column sort in AdvancedDataGrid with dataProvider as GroupingCollection

I have three attributes in my XML object: last name, first name, and age. My sample XML looks like: <dataXML> <info last="Abc" first="Def" age="20"/> <info last="Abc" first="Hij" age="10"/> <info last="Xyz" first="Klm" age="25"/> <info last="Xyz" first="Opq" age="64"/> <info last="Xyz" first="Rst" age="08"/> </dataXML> I am using...

Getting the same element without changing it using Linq

I have a method like this: public List<Fruit> Traverse (IEnumerable<Fruit> collection, Action<Fruit> action) I can do this: Traverse (array, f => f.Text); How can I call the action so I get the same element? Traverse (array, f => f); C# compiler doesn't allow me to do this. EDIT: List<Fruit> result = ... foreach (Fruit fruit i...

How to get the type contained in a collection through reflection

In some part of my code I am passed a collection of objects of type T. I don't know which concrete colletion I will be passed, other than it impements IEnumerable. At run time, I need to find out which type T is (e.g. System.Double, System.String, etc...). Is there any way to find it out? UPDATE: I should maybe clarify a bit more the ...

How can I access my applications images that are in my resources?

I'm going to briefly explain what I want my program to do. I have a lot of Images on my form and I want the image source to change on MouseEnter event. So, if a user moves the mouse over the button, I'd like the button to appear to be glowing. Of course I've made two images for the Image control. One normal, and one glowing. I'm trying...