Is there any. I just ran the new perf analysis tool of vs2010 and as it turns out this func consumes most of the cpu resources.
Is there something else i can use?
Basically i've got a web service that i'm trying to put some kind of usage logging in.
To do this i've created a class with a logging method.
I instatiate the class on the service and then call the logging method in each of the web methods.
I'm trying to find a way of getting the name of the method that has called the loggong method
Public sub…
printThisMethodSig: aSomething
stack := thisContext stackOfSize: 2.
Transcript show: (stack at: 2); cr.
stack at: 2 returns the method context of the current method. It is possible to retrieve the compiled method of the current method using method message. I want to be able to print the whole signature of the method, for example: from:to:.
I…
Hi All,
Im trying to write an extension method that I can use to copy values from one object property to another object of a different type, as long as the property names and types match exactly.
This is what I have:
public static T CopyFrom<T>(this T toObject, object fromObject)
{
var fromObjectType =…
Hi Guys
I have a block of code that serializes a type into a Html tag.
Type t = typeof(T); // I pass <T> in as a paramter, where myObj is of type T
tagBuilder.Attributes.Add("class", t.Name);
foreach (PropertyInfo prop in t.GetProperties())
{
object propValue = prop.GetValue(myObj, null);
string stringValue…
Given the following case:
<?php
class ParentClass {
public $attrA;
public $attrB;
public $attrC;
public function methodA() {}
public function methodB() {}
public function methodC() {}
}
class ChildClass {
public $attrB;
public function methodA() {}
}
How can I get a list of…
Is there any way to change the name of a dynamic assembly after it has been created? I'm using a framework that uses dynamic methods, and it is creating a dynamic assembly with the same name as my main assembly (which causes problems with WPF when it tries to load resources). So I need to find a workaround, and I…
I've been searching for this for quite a while with no luck so far. Is there an equivalent to Java's ClassFileTransformer in .NET? Basically, I want to create a class CustomClassFileTransformer (which in Java would implement the interface ClassFileTransformer) that gets called whenever a class is loaded, and is…
So I've come around since I asked how to limit setAccessible to only “legitimate” uses and have come to embrace its power for fun. Enabled by its power, of course, is string mutation.
import java.lang.reflect.Field;
public class Mutator {
static void mutate(Object obj, String field, Object newValue) {
…
Is it possible to get the class type from inside the static initialization block?
This is a simplified version of what I currently have::
class Person extends SuperClass {
String firstName;
static{
// This function is on the "SuperClass":
// I'd for this function to be able to get…
Hello,
I wrote the question as a comment in the code, I think its easier to understand this way.
public class Xpto{
protected AbstractClass x;
public void foo(){
// AbstractClass y = new ????? Car or Person ?????
/* here I need a new object of this.x's type (which could be Car…
I have an issue with a Windows Service which throws a NullReference exception whenever I try to use
var myType = Activator.CreateInstance(typeof(MyType))
There is no problem whenever I run the exact same code in a console window - and after debugging the obvious "which user is running this code" I…
Let me explain. I have a List into which I am adding various ASP.NET controls.
I then wish to loop through the list and set a CssClass, however not every Control supports the property CssClass.
What I would like to do is test if the underlying instance type supports the CssClass property and set it,…
we have been trying to benchmark our application performance in multiple way for sometime now.
I always believed that object creation in java using Class.newInstance() was not slow (at least after 1.4 version of java). But we anyways did a test to use newInstance method vs mainitain an object pool…
So I'm playing with geotools and I thought I'd proxy one of their data-access classes and trace how it was being used in their code.
I coded up a dynamic proxy and wrapped a FeatureSource (interface) in it and off it went happily. Then I wanted to look at some of the transitive objects returned by…
I am trying to write some code that will allow me to dynamically load DLLs into my application, depending on an application setting. The idea is that the database to be accessed is set in the application settings and then this loads the appropriate DLL and assigns it to an instance of an interface…
I am trying to find all of the types in the Models namespace within an ASP.NET MVC assembly from within a testing assembly. I was trying to use LINQ to find the relevant set for me but it is returning an empty set on me. I am sure it is some simple mistake, I am still relatively new to LINQ…
I have two attributes - MigrationAttribute and TestDataMigrationAttribute : MigrationAttribute. How can I assert that a class has applied TestDataMigrationAttribute but not MigrationAttribute (which is the parent attribute class)?
Suppose you have a generic interface and an implementation:
public interface MyInterface<T> {
void foo(T param);
}
public class MyImplementation<T> implements MyInterface<T> {
void foo(T param) {
}
}
These two types are frework types. In the next step I want…
Ok, im still a bit new to using nullable types.
I'm writing a reflecting object walker for a project of mine, im getting to the point where im setting the value of a reflected property with the value i've retrieved from a reflected property.
The value i've retrieved is still in object…
Given the following code:
var n1 = new AssemblyName ("TestDll, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
var n2 = new AssemblyName ("TestDll, Version=2.0.0.2001, Culture=en-US, PublicKeyToken=ab7a5c561934e089");
Console.WriteLine…
Let us say we have a method which accepts two arguments o1 and o2 of type Object and returns a boolean value. I want this method to return true only when the arguments are instances of the same class, e.g.:
foo(new Integer(4),new Integer(5));
Should return…
So I have something like the following in Java:
private List<SomeType>variable;
// ....variable is instantiated as so ...
variable = new ArrayList<SomeType>();
// there's also a getter
public List<SomeType> getVariable() { /* code */ }
…