Hello:
I have implemented a Phong Illumination Scheme using a camera that's centered at (0,0,0) and looking directly at the sphere primitive. The following are the relevant contents of the scene file that is used to view the scene using OpenGL as well as to render the scene using my own implementation:
ambient 0 1 0
dir_light 1 1 1 ...
My method looks like:
public string DoObjectProperties<T>(T obj, string text)
{
}
Now from within the method, I need to get the string value of the class name that i pass into the method's 'obj' parameter.
So if I pass in the User object, I need the text 'user'.
To get the properties I am using: typeof(T).GetProperties()
How can I...
I have the following two classes:
public class Address
{
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
}
public class Employee
{
public string FirstName { get; set; }
public ...
I'm contributing to a library called Fasterflect whose purpose is "improving the developer experience of using reflection". As such, it provides an abstraction built on top of classic reflection and would be used in exactly the same scenarios.
The following shows the current syntax for accessing members via an object instance:
obj.SetP...
I want to know if there is a better way (than what I'm currently doing) to obtain and hold a reference to a property in another object using only the object and property string names. Particularly, is there a better way to do this with the new dynamic functionality of .Net 4.0?
Here is what I have right now.
I have a "PropertyReferenc...
Hello all! I'm trying to create an instance of a generic class using a Type object.
Basically, I'll have a collection of objects of varying types at runtime, and since there's no way for sure to know what types they exactly will be, I'm thinking that I'll have to use Reflection.
I was working on something like:
Type elType = Type.Get...
Hi everyone. First of all, sorry if this has been asked before. I've done a pretty comprehensive search and found nothing quite like it, but I may have missed something.
And now to the question: I'm trying to invoke a constructor through reflection, with no luck. Basically, I have an object that I want to clone, so I look up the copy co...
This question is sort of a follow-up to my original question here.
Let's say that I have the following generic class (simplifying! ^_^):
class CasterClass<T> where T : class
{
public CasterClass() { /* none */ }
public T Cast(object obj)
{
return (obj as T);
}
}
Which has the ability to cast an object into a s...
Is there a utility to get a property which isnt prefixed by get from an object using reflection similar to BeanUtils? e.g. if I specify "hashCode" and I want to get the object.hashCode() value.
Thanks.
...
Give a base class Base, I want to write a method Test, like this:
private static bool Test(IEnumerable enumerable)
{
...
}
such that Test returns true if the type of o implements any interface of IEnumerable<X> where X derives from Base, so that if I would do this:
public static IEnumerable<string> Convert(IEnumerable enumerable)
{
...
How can i check whether a package like javax.servlet.* exists or not in my installation of java?
...
Hi all,
I would like to get a list of all the classes belonging to a certain package as well as all of their children. The classes may or may not be already loaded in the JVM.
Walter
...
I have the following classes:
public class MyEventArgs : EventArgs
{
public object State;
public MyEventArgs (object state)
{
this.State = state;
}
}
public class MyClass
{
// ...
public List<string> ErrorMessages
{
get
{
return errorMessages;
}
...
i think this is a simple question but I've searched around and can't seem to find an answer easily.
if you have
var list = List<int>();
... fill list ...
and you want to get the generic type in list, i realise you could just type:
var t = list.FirstOrDefault().GetType();
Is there another way to do this via just the list, rather th...
hi,
i load a class using
Class.forName(klassname,false,loader)
After this i create an instance using
klass.newInstance();
It returns an object type.I want to cast it to specific type(ie.Klassnamw instance).I used normal casting but it gets hung because it is not resolved during runtime.How can i cast it?Hellp
...
Consider that I have to get the overall performance of X. X has Y elements and Y in turn has Z elements which inturn has some N elements. To get the performance of X I do this:
List<double> XQ = new List<double>();
foreach (Elem Y in X.Y){
List<double> YQ = new List<double>();
foreach (Elem Z in Y.Z){
List<double> ZQ = new L...
I need to this at runtime. I checked using Reflector and value types line like Int16, for example, should contain
<Serializable, StructLayout(LayoutKind.Sequential), ComVisible(True)> _
Public Structure Int16
Implements IComparable, IFormattable, IConvertible, IComparable(Of Short), IEquatable(Of Short)
Public Const MaxValue As Sh...
I came to ruby from PHP.
How could i do the next thing in ruby?
$className = 'ArrayObject';
$arrayObject = new $className();
Thank you for any help!
...
How can i create a Action method to use as a argument to the following function?
public void When(Action<T> action)
{
if (internalValue != null)
action(internalValue);
}
I have the MethodInfo on the method, and the parameter type like so:
var methods = value.GetType().GetMethods();
MethodInfo mInfo = methods.First(method...
Hi!
I'm trying to run the Count() function of a Linq statement in an overriden Gridview function. Basically, I want to be able to assign a linq query to a gridview, and on the OnDataBound(e) event in my new extended gridview have it retrieve the count, using the IQueryable.
So, I need to dynamically cast the GridView.DataSource to my L...