Showing posts with label runtimes. Show all posts
Showing posts with label runtimes. Show all posts

Friday, March 6, 2015

Having fun with C# dynamic and reflection: create a class that let us to avoid access modifier

Yeah, the title says it all.

Have you ever get tired of manually call reflection methods to get a value of an hidden field? Yes I do!

In my spare time I found a funny solution to work around this problem.
I found a dummy way to avoid access modifier without losing 'deafult' syntax: thanks to c# dynamic object!
public class MyClass
{
    private int value = 1 ; 
}
private static void Main(string[] args)
{
    MyClass myInstance = new MyClass();

    //cannot access private field 'value' here
    //myInstance.value = 2;

    dynamic myInstance2 = myInstance.Expose();

    //can do it!
    myInstance2.value = 2;
}

Monday, July 1, 2013

Convert from jar to dll

Nowadays, development is very eased from community.
We can easily re-use our code between different platforms in so many ways, gaining time, money and above all... today have multiple skills is not so as useful as before.

By the way, I recently had necessity to bring some java code to .NET runtimes.
No difficulties with IKVM.NET !

If you follow these steps you can convert from JAR to DLL or even from Runnable JAR to EXE!