I am using an interface called Predicate which is used for sifting through Collections. For example, I can define
public class BlackCatPredicate implements Predicate<Cat> {
public boolean evaluate( Cat c ) {
return c.isBlack();
}
}
and then use some utility findAll( Collection<T> coll, Predicate<T> pred) method to apply th...
Guys,
I'm trying to Databind to my custom dictionary class. In formLoad, I can bind to Car.Desc but I cannot bind to RatesCache.Desc.
They are both public string properties.
What am I missing?
Thanks!
System.ArgumentException was unhandled
Message="Cannot bind to the property or column Desc on the DataSource.\r\nParameter name: ...
I have a List sort question. I am using c# 3.0 and a generic List structure like this:
public class myObject
{
public int ID { get; set; }
public List<mySetting> setting { get; set; }
}
public class mySetting
{
public int ID { get; set; }
public string Name { get; set; }
public string Value { get; set; } // sort o...
Hello,
I have the following simple C# code:
private Stack<Person> m_stack = new Stack<Person>();
public void Add<T>(T obj)
where T : Person
{
m_stack.Push(obj);
}
This will produce the following IL code:
.method public hidebysig instance void
Add<(ConsoleApplication1.Person) T>(!!T obj) cil managed
{
// C...
I'm not exactly sure how to word this but I'll try.
Suppose you have some settings in some piece of your program where your 80% sure you won't ever have to modify again. How do you know where to draw the line on changeable code? You know that taking the settings all the way to a user defined XML file is overkill. However, you also...
Hi,
The setup:
class Item
{
private int _value;
public Item()
{
_value = 0;
}
public int Value { get { return _value; } set { _value = value; } }
}
class ItemCollection : Collection<Item>
{
private string _name;
public ItemCollection()
{
_name = string.Empty;
}
public string ...
Hello ...
I have a Generic class like that :
public class Repository<T> {...}
And I need to instance that with a string ...
Example :
string _sample = "TypeRepository";
var _rep = new Repository<sample>();
How can I do that? Is that even possible?
Thanks!
...
say I have the following declarations:
public enum Complexity { Low = 0, Normal = 1, Medium = 2, High = 3 }
public enum Priority { Normal = 1, Medium = 2, High = 3, Urgent = 4 }
and I want to code it so that I could get the enum value (not the index, like I earlier mentioned):
//should store the value of the Complexity enum member ...
Hi all..
Okay, this is the case:
I got a generic base-class which I need to initialize with some static values. These values have nothing to do with the kind of types my generic baseclass is loaded with.
I want to be able to do something like this:
GenericBaseclass.Initialize(AssociatedObject);
while also having a class doing like ...
In C# one can state that a generic parameter must implement a certain interface like so:
public class Something<T> where T : IComparable
{
...
}
How does one specify this in F#?
...
Hello there
I'm writing a parallel evolutionary algorithm library using C++, MPI and CUDA. I need to extract the raw data from my object oriented design and stick it into a flat array (or std::vector using stl-mpi) for it to be sent across to nodes or the cuda device.
The complete design is quite complex with a lot of inheritance to k...
I've written a small utility function for our base page, it works fine in most cases, but if it's called in the form SetDropDownValue(dropdown, Nothing, True) I have to specify the type T.
Since the compiler only requires a type specified when the type is not used, I'm wondering if there is a better way to write the code.
The method is...
public bool IsList(object value)
{
Type type = value.GetType();
// Check if type is a generic list of any type
}
What's the best way to check if the given object is a list, or can be cast to a list?
...
How i can create a generic datacontext on linq means If database change i don't have to change anything on linq datacontext.
Please specify the code or link
...
Dont know if you allowed to ask this sort of thing here... but as they say easier to ask for forgiveness rather than permission.
I have dipped my toe into "giving back to the community" and would like people's opinion on the project. In short it is a colleciton of generic crud controller and repository classes and interfaces to automat...
I was wandering if there's a way in witch the OS doesn't need to cycle ad infinitum waiting for the input from keyboard (or other input device) and if there are any OS using that. I can't believe that we do need to waste cycling just to wait for input, why can't the input do something once is pressed instead of having the machine to wait...
I am working on this mvc project following Rob Connery's storefront video series and applying the techniques.
On the filtering and extensions methods, i started repeating myself a lot such as:
public static Sponsor WithID(this IQueryable<Sponsor>qry, int ID)
{
return qry.SingleOrDefault(s => s.ID== ID);
}
public static Keyword With...
My code looks as such:
def add_cart(request):
return create_object(request, form_class=CartForm,
post_save_redirect=reverse('test.views.show_cart',
kwargs=dict(object_id='%(key)s')))
Ideally, I would like it to look like so:
def add_cart(request):
newobject = create_object(request, form_clas...
I have an instance that implements IDictionary<T, K>, I don't know T and K at compiletime, and want to get all elements from it. I don't want to use IEnumerable for some reason, which would be the only non-generic interface implemented by IDictionary.
Code I have so far:
// getting types
Type iDictType = instance.GetType().GetInterface...
class Cache
{
int sizeOfCache;//no of RssFeedDocument
private List<RssFeedDocument> listOfRssFeedDocument = null;
}
i want to find a object in this generic list in class based upon RssFeedDocument 's property FeedId.
...