Hi. I'm trying to iterate through all components and for those who implements ISupportsOpen allow to open a project.
The problem is when the anonymous method is called, then the component variable is always the same element (as coming from the outer scope from IEnumerable)
foreach (ISupportsOpen component in something.Site.Container.Com...
I'm using .NET 3.5. I think I know the answer to this, but am looking for confirmation so should be a quick one!
There doesn't appear to be a generic implementation of OrderedDictionary (which is in System.Collections.Specialized namespace). Is there one that I'm missing?
I've found implementations out there to provide the functionali...
Hello guys...
I'm trying to make this code generic:
public final Object unwrap(Class arg0) {
throw new UnsupportedOperationException();
}
It comes from the Wrapper class (java.sql) and looks originally like this:
<T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException;
...
Hello,
In a java serialization problem, I want to save some classes name and I have some problems with generic classes.
For example :
- If I have ArrayList<String> listToDump = new ArrayList<String>();
- If I take the name : listToDump.getName(); or listToDump.getCanonicalName();
- I will have java.util.ArrayList or ArrayList
- And I wan...
I am trying to assign an IronPython instance method to a C# Func<Foo> parameter.
In C# I would have a method like:
public class CSharpClass
{
public void DoSomething(Func<Foo> something)
{
var foo = something()
}
}
And call it from IronPython like this:
class IronPythonClass:
def foobar(self):
return ...
e.g. The code below throws a ClassCastException when the second Object is added to the TreeSet. Couldn't TreeSet have been written so that the type parameter can only be a Comparable type? i.e. TreeSet would not compile because Object is not Comparable. That way generics actually do their job - of being typesafe.
import java.util.TreeSe...
Suppose I want to throw a new exception when invoking a generic method with a type that doesn't have a required attribute. Is there a .NET exception that's appropriate for this situation, or, more likely, one that would be a suitable ancestor for a custom exception?
For example:
public static class ClassA
{
public static T DoSomet...
I'm working with an expression within a moq-ed "Get Service" and ran into a rather annoying issue. In order to get this test to run correctly and the get service to return what it should, there's a translator in between that takes what you've asked for, sends it off and gets what you -really- want. So, thinking this was easy I attempt ...
This confuses me. The following compiles fine under Eclipse.
package com.example.gotchas;
public class GenericHelper1 {
static <T> T fail() throws UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
/**
* just calls fail()
* @return something maybe
*/
public boolean argh() { return fail(); }
p...
This is an extension of this questionand probably might even be a duplicate of some other question(If so, please forgive me). I see from MSDN that generics are usually used with collections
The most common use for generic
classes is with collections like
linked lists, hash tables, stacks,
queues, trees and so on where
operati...
Using the release version of Visual Studio 2010 I think there's a difference in the "Implement Interface" expansion from VS2008
If I speicify an interface and implement it in a class as so:
public interface IRepository<T> where T : IModel
{
T Get<T>(int id);
void Update<T>(T item);
int Add<T>(T item);
}
public class Mo...
Hi
I have a situation which seems a bit different from others I've seen. For clarrification, this isn't the normal question eg; something like IAClass maps to AClass etc - that involves using basically a single concrete classes per interface.
This involves having a single generic class, but I want to be able to load ALL possible usage...
Hi All,
I am trying to to use reflection to achieve the following:
I need a method where i pass in an object and this method will recursively instantiate the object with child objects and set the properties with default values. I need the entire object instantiated going as many levels as needed.
this method needs to be able to handle...
I'm using JSON.simple to generate JSON output from Java. But every time I call jsonobj.put("this", "that"), I see a warning in Eclipse:
Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap should be parameterized
The clean fix would be if JSONObject were genericized, but s...
I have a method for sorting generic lists by the object fields:
public static IQueryable<T> SortTable<T>(IQueryable<T> q, string sortfield, bool ascending)
{
var p = Expression.Parameter(typeof(T), "p");
if (typeof(T).GetProperty(sortfield).PropertyType == typeof(int?))
{
var x = Expression.Lambda<Func<T, int?>>(Exp...
public class MaxHeap<T extends Comparable<T>> implements Heap<T>{
private T[] heap;
private int lastIndex;
public void main(String[] args){
int i;
T[] arr = {1,3,4,5,2}; //ERROR HERE *******
foo
}
public T[] Heapsort(T[]anArray, int n){
// build initial heap
T[]sortedArray = anArray;
for (int i = n-1; i< 0; i--)...
I have a data type that contains a set and a method that expects List<? extends MyClass>. The data type has Set<? extends MyClass>. I need to be able to move the stuff out of the set and into the List. The order it goes into the list doesn't matter, it just needs to start keeping track of it so that it can be reordered when displayed....
I am using the ObservableSortedDictionary from Dr. WPF.
The constructor looks like this:
public ObservableSortedDictionary(IComparer<DictionaryEntry> comparer)
I am really struggling to create an implementation that satisfies the constructor and works.
My current code (that won't compile) is:
public class TimeCreatedComparer<T> : I...
Hello,
I have two classes which both extends Example.
public class ClassA extends Example {
public ClassA() {
super("a", "class");
}
....
}
public class ClassB extends Example {
public ClassB() {
super("b", "class");
}
....
}
public class Example () {
public String get(String x, Strin...
I have a list:
private readonly IList<IList<GameObjectController>> removeTargets;
private readonly IList<IList<GameObjectController>> addTargets;
PickUp inherits from GameObjectController. But when I try this:
public IList<PickUp> Inventory
// ...
gameObjectManager.MoveFromListToWorld(this, user.Model.Inventory);
// ...
// T...