Easy reflection in .NET
C#
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Phantom.Tests
Phantom
.gitignore
Phantom.sln
Readme.html
Readme.textile

Readme.textile

Phantom: Easy reflection in .NET

Phantom is a helper for use relfection in Microsoft.NET.

Phantom Download

Source Code

How to use it?

For begin to use Phantom just put this in your class:

using Phantom;

Simple! This causes appear some extension methods in all objects.

Ok, but what can I do?

Get and set properties, invoke methods, get all properties values and more in objects that you don’t know the Type. Yes, this is cool!

Getting a property value

object person = new Person { Name = "Arthur", Age = 4 };

person.Get("Name");

>> Arthur

Setting a property value

person.Set("Name", "Francine");

Getting all properties values

var properties = person.Values();

foreach(var property in properties)
{
    Console.WriteLine(property.Key + " = " + property.Value);
}

>> Name = Arthur
>> Age = 4

Good to use with Anonymous Objects

public void PrintName(object target)
{
    Console.WriteLine(target.Get("Name"));
}

PrintName(new { Name = "Wagner" });

>> Wagner

Importing values of another object

object animal = new Animal { Age = 20 };

person.Import(animal);

person.Get("Name");
person.Get("Age");

>> Arthur
>> 20

Invoke a method

object name = "Francine";
name.Invoke("ToUpper");

>> FRANCINE

There are other utilities.
That’s All Folks… for now!