I have this function:
/**
* Helper function that adds the values of b to the elements of a, treating
* all keys that exist in b but not in a, as existent in a with value 0. NB:
* It operates IN PLACE.
* @param a The {@link java.util.Map} which will hold the result
* @param b The {@link java.util.Map} which will be added to a
*/...
ok this is the thing I have right now which is working quite well except its a bit slow:
Public Function GetList() As List(Of SalesOrder)
Try
Dim list As New List(Of SalesOrder)
Dim ds As DataSet
ds = cls.GetSalesOrderList 'CLS is the data access class
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim row As Data...
I have an existing class for serializing and deserializing objects to/from XML. It's a generic class with a single type parameter T whose only constraint is where T : IXmlSerializable. However, I want to still be able to use this class on classes that do not implement IXmlSerializable but have the [Serializable] attribute. How could I...
Is there a way to do something like this in c#? Consider the following example and assume that Child1, Child2, Child3 are all children of Parent -
class Class1
{
SomeObject< Parent > mSomeObject;
Class1()
{
if (condition1)
mSomeObject = new SomeObject<Child1>();
else if (condition2)
mSomeObje...
I'm trying to create a simple Clamp (so that I can bound the values of anything comparable ... mostly for number types such as int, double, etc.)
The problem is if I do the following I get an error, but according to MSDN IComparable's CompareTo is supposed to be able to handle null values.
Quote: "By definition, any object compares grea...
Example, I have the following interface and classes:
public interface IRole {
DateTime Since {get;}
DateTime Until {get;}
}
public class Manager : IRole {
public DateTime Since {get; private set;}
public DateTime Until {get; private set;}
}
public class Employee : IRole {
public DateTime Since {get; private set;}
...
How to convert List<int> to List<long> in C#?
...
please note that I am trying to use NotifyCollectionChangedAction.Add action instead of .Reset. the latter does work, but it is not very efficient with large collections.
so i subclassed ObservableCollection:
public class SuspendableObservableCollection<T> : ObservableCollection<T>
for some reason, this code:
private List<T> _cache...
I am getting this error with the following code:
The method getItemProperty(capture#2-of ? extends GenericTest.Item) in the type GenericTest.BaseContainer<capture#2-of ? extends GenericTest.Item> is not applicable for the arguments (GenericTest.Item)
import org.junit.Test;
public class GenericTest {
public class Item {
priva...
I have a class Slide, of which I want to place several instances in the clipboard. It works perfectly fine for a single instance.
But when I try to, for example, put a List<Slide> in the clipboard, the SetDataObject call will silently fail.
Internally, a COMException will be thrown and is swallowed. This is because List does not impleme...
I did the following:
container.Register(Component.For<Dictionary<string, string>>()
.Instance(ServiceDictionaryInstance)
.Named("serviceDictionary"));
The class consumes the component is:
public class BusinessService : IDecisionFilter
{
private readonly Dictionary<str...
Hi,
I have following list of users. StudentBean and ProfessorBean are the subtypes of UsersBean.
List<? extends UsersBean> users = this.getUsers(locationId);
for(UsersBean vo :users) { System.out.println("Name : "); }
Here i want to print professorbean's info OR StudentBeans's info. Is there any way to get professor or student bean me...
Hi!
I have confusing situation.
Base Generic Type and successor
public abstract class BaseType<TEntity> : where TEntity : BaseType<TEntity>
public class AnyType : BaseType<AnyType>
It looks like a generic loop)))
I need Method like
public void Method<T>(T data)
{
if(typeof(T).IsSubclassOf(BaseType<????>))
convert data to BaseType<...
EDIT: Rewrote the question. Added bounty as its important for me. The final hint with which i can get findByAttributes to work (without reimplementing it in subclasses) will get my points.
In my app i'm doing typesafe database queries with the new JPA2 Criteria Query. Therefore I have a trait DAO which should be (re)usable for ALL entit...
I have a class called Order which has properties as OrderId,OrderDate,Quantity,Total.
I have a List of this "Order" class.
List<Order> objListOrder=new List<Order> ();
objListOrder=GetOrderList(); // method to fill list of orders
Now i want to sort the list based on one property of the Order object(Ex :i need to sort by the order dat...
Hi
Attempting to generics-ify some legacy code, I'm stuck. I have a ParentObject which wraps a ChildObject to provide group-type operations on the ChildObject. Most usefully, it allows iteration over the collection of child objects.
When I try to add some generics to the mix, I can't work out how to make it play friendly with the itera...
Hello,
I'm trying to convert a generic value into an array of generic values so that I can comma delimit them. However, I can't convert from my generic type into an array of generic types. hopefully some code will help make things clearer...
public T Item
{
get { return item; }
set { item = value; }
}
...
I have four different Business objects and each calls its corresponding FillBusinessObject method to fill all the individual object properties one by one. Now I wish to create a common method which should be able to fill each type of business object. I've created a base class from which all business objects inherit but I am not able to f...
I am getting ready to create a generic EventArgs class for event args that carry a single argument:
public class EventArg<T> : EventArgs
{
// Property variable
private readonly T p_EventData;
// Constructor
public EventArg(T data)
{
p_EventData = data;
}
// Property for EventArgs argument
public...
I am aware of formatted DataContract names, as described here: http://msdn.microsoft.com/en-us/library/ms731045.aspx (Customizing Data Contract Names for Generic Types near the bottom).
Example:
[DataContract( Name = "SearchCriteriaFor{0}", Namespace = "http://schema.mycompany.com/MyProject/" )]
public class SearchCriteria<T> { ...
...