generic

Get nested delegate type ref. from inside a generic class

I tried to retrieve the TYPE for "PreProcess" from DomainDB class using Type.GetType("DomainDBManager.DomainDB`1[System.String]+PreProcess") but this is returning null. Is there anyway to get the Public Field "PreProcess" using Type.GetType? namespace DomainDBManager { public class DomainDB<T> { public Action<string> PrePro...

What is memoization good for and is it really all that helpful?

There are a few automatic memoization libraries available on the internet for various different languages; but without knowing what they are for, where to use them, and how they work, it can be difficult to see their value. What are some convincing arguments for using memoization, and what problem domain does memoization especially shine...

AsyncTask not generic?

Hi When I try to compile to following code, I get two errors: Description Resource Path Location Type Syntax error on token "void", invalid Expression AsyncTask.java /AsyncTask Project/src/org/me/asynctask line 19 Java Problem Description Resource Path Location Type The type AsyncTask is not generic; it cannot be parameterized with arg...

How do I determine if a method is a generic instance of a generic method

Hi all, I have a MethodInfo passed in to a function and I want to do the following MethodInfo containsMethod = typeof(ICollection<>).GetMethod("Contains"); if (methodInfo.Equals(containsMethod) { // do something } But this doesn't work because the methodInfo has a specific generic type. For the example does work if I knew that th...

Generic InternPool<T> in Java?

How would I write a generic InternPool<T> in Java? Does it need a Internable interface? String in Java has interning capabilities; I want to intern classes like BigDecimal and Account. ...

Simple syntax for getting a member of a type in extension method (C#)

I'm trying to write an extension method that will give me the MemberInfo representing a member of a given type, using lambda expressions. Ideally, I'd like to be able to write var info = MyType.GetMember(m => m.MyProperty); or, also acceptable var info = typeof(MyType).GetMember(m => m.MyProperty); or even var info = typeof(MyType...

How do programmers gain experience?

I've been having this on my mind for a while. How do programmers gain their experience? What are the most decisive factors? Is it the books? Or the job? The education? What turned you from the beginning programmer to the knowledgeable one? ...

Telerik MVC: Generic Grid

I am wondering if I could design a generic way to design a Telerik MVC Grid. Example: Model is a List of FieldDescriptor. A FieldDescriptor has a name, a value and a type. Thus I want to show the colums of the Grid according to the data in the model - depending on which fields come and what their type is. But the Telerik MVC Grid onl...

C# templated / generic method at compile time error

I am working in c# with .net 2.0 (i know its old) Here is my setup: struct propertyType { System.type type; } public class DataProperties { private Dictionary<propertyType, object> properties; public void setProperty(propertyType key, object value) { if(value.getType == key.type) //make sur...

asp.net mvc generic controller

I am thinking of implementing a generic Controller in ASP.NET MVC. PlatformObjectController<T> where T is a (generated) platform object. Is this possible? Is there experience / documentation? One related question for example is how the resulting URLs are. ...

C# Xml Serializing List<T> descendant with Xml Attribute

Morning Guys, I have a collection that descends from List and has a public property. The Xml serializer does not pick up my proeprty. The list items serialize fine. I have tried the XmlAttribute attribute to no avail. Do you guys have a solution? public partial class MainWindow : Window { public MainWindow() { Init...

Can a WF4 Generic Activity be Declared in XAML?

I have a Workflow 4 activity that can be run on any number of classes that inherit from my base class. So, the activity is, naturally, generic. Similar to the ForEach or AddToCollection activities, my activity requires a type parameter. My question is: can I create this activity in the designer with XAML? Keep in mind this is a composit...

c++ function template compiles error "‘containerType’ is not a template"

I'm trying to write a function to "stringify" parameters for logging purpose. For example, I'd like to write something like this: vector<string> queries; set<uint_8> filters; LOG(INFO) << stringify<vector, string>(queries); LOG(INFO) << stringify<set, uint_8>(filters); Here is the function template I wrote: template <typename contai...

Java: bounded wildcards or bounded type parameter?

Recently, I read this article: http://download.oracle.com/javase/tutorial/extra/generics/wildcards.html My question is, intead of creating a method like this: public void drawAll(List<? extends Shape> shapes){ for (Shape s: shapes) { s.draw(this); } } I can create a method like this, and it works fine: public <T exte...

Unity 2.0 registering generic types via XML

I am trying to register a generic type in a config file for Unity 2.0 but can't seem to get it right. I have been referring to the MS documentation here : http://msdn.microsoft.com/en-us/library/ff660933%28v=PandP.20%29.aspx#_Generic_Types The code looks like this: public interface IRepository<T> where T : class { ... } public cl...

Is it possible to add two IQueryable's together?

I've been using Union on IQueryable<> (with the same type) to try to get one collection produced from two collections, but it is not working. I believe my understanding is at fault with regards to the IQueryable members. I thought I could use the union method to build (within a foreach) a SQL statement which would execute something like...

using free bound generic type as type parameter

Hi, Do you see a way to specify that my result type have to be MonadType< arg type > within this interface ? interface IMonad<MonadType> // where MonadType : GenricType<> { MonadType<T1> unit<T1>(T1 t) Func<MonadType<T1>, MonadType<T2>> map<T1, T2>(Func<T1, T2> f); } I get as an error : The type parameter 'MonadType' cannot...

Concrete implementation of generic base class and extension method

The end goal for this post is to override the ToString() method of a concrete implementation of a generic base class while still being able to search the implementation using Linq flattening technique. So if you read this and see a better way let me know. I'm using Telerik controls for Silverlight and they won't change their api to allow...

What is exact mean of Generic application in .net?

So many times I found the question, by my team members we have to develop Generic Application either windows or Web. but what is its exact means? Edited:- Also If I want to develop such application then which design pattern will be best approach ? I am sure it should be on situation , but I want to know the scenarios in which we can us...

Binding a Generic List of type struct to a Repeater

Hi All I've had a bit of a problem trying to bind a generic list to a repeater. The type used in the generic list is actually a struct. I've built a basic example below: struct Fruit { public string FruitName; public string Price; // string for simplicity. } protected void Page_Load(object sender, EventArgs e) { List...