public virtual void GetProperty(string propertyName, out Func <bool> getter, out Action <bool> setter) { getter = null; setter = null; switch (propertyName) { case ("Enabled"): getter = () => this.Enabled; setter = (v) => this.Enabled = v; return; } if (this is IRunnable) { IRunnable runnable = (IRunnable)this; switch (propertyName) { case "InProgress": getter = () => runnable.InProgress; setter = (v) => runnable.InProgress = v; return; case "IsPaused": getter = () => runnable.IsPaused; setter = null; return; } } if (this is IExploding) { IExploding exploding = (IExploding)this; switch (propertyName) { case "IsExploding": getter = () => exploding.IsExploding; setter = (v) => exploding.IsExploding = v; return; } } if (getter == null && setter == null) { throw new InvalidOperationException("Unknown property '" + propertyName + "'"); } }
public static int Damages(this IExploding explosingObject) { return(explosingObject.ExplosionRadius * 100); }