Documentation

Operations with single objects

Snapshot

Creates a snapshot of an object with its current property values.

Counter counter = new Counter();
counter.Value++;

// create a snapshot of counter
dynamic snapshot = Dynamics.Snapshot(counter);

// change the counter
counter.Value++;

// snapshot still shows the old value
Console.WriteLine(snapshot.Value);

Operations with multiple objects

Operation Read Write Invoke
Combine First First First
LoadBalance - - Current
Multicast - All All

Combine

Combines multiple objects into a single one.

public class C1
{
	public int A { get; set; }
}
public class C2
{
	public int B { get; set; }
}

dynamic m = Dynamics.Combine(new C1 { A = 1 }, new C2 { B = 2 });
Console.WriteLine(m.A);
Console.WriteLine(m.B);

LoadBalance

Distributes operations across multiple objects of the same kind.

IService s1, s2;

dynamic lb = Dynamics.LoadBalance<IService>(s1, s2);
lb.DoWork(1);
lb.DoWork(2);

Multicast

Handles multiple objects as one, performs every operation on each object.

dynamic allAsOne = Dynamics.Multicast(recipients);
allAsOne.Say("Hello");

Dynamic Collections

DynamicDictionary (in System.Collections.Dynamic)

Provides access to a string-object dictionary directly through member access.

dynamic d = new DynamicDictionary();

// add an element to the dictionary
d.Blue = 0x0000FF;

// access the element from the dictionary
Console.WriteLine(d.Blue);

Last edited Dec 22, 2012 at 9:24 PM by BlueCode, version 4

Comments

No comments yet.