github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

wagnerandrade / Phantom

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Easy reflection in .NET — Read more

  cancel

http://wagnerandrade.com

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Update readme html. 
wagnerandrade (author)
Sat Oct 17 22:29:54 -0700 2009
commit  fea6a0cd7414c5ffd2ee1feb1adacae7a830b098
tree    0b1d6263693c962193c72a0d8a0c6a9a924f11f6
parent  6c73a3f3cdcdd0bc09ec23f3446ffce0cf97f5db
Phantom /
name age
history
message
file .gitignore Loading commit data...
directory Phantom.Tests/
file Phantom.sln
directory Phantom/
file Readme.html
file 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!

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server