资 源 简 介
Moved to github: https://github.com/jordao76/nroles
NRoles
NRoles is an experiment with roles in C#. Roles, very similar to traits, are high level constructs that promote better code reuse through easier composition. NRoles is a post-compiler created with Mono.Cecil that transforms an assembly to enable roles and compositions.
Synopsis
Grab the latest NRoles binaries, then reference the NRoles.dll assembly and create some roles and compositions:
```
using NRoles;
namespace Devices {
public class RSwitchable : Role {
private bool on = false;
public void TurnOn() { on = true; }
public void TurnOff() { on = false; }
public bool IsOn { get { return on; } }
public bool IsOff { get { return !on; } }
}
public class RTunable : Role {
public int Channel { get; private set; }
public voi