/// <summary> /// Constructs a new instance of the subtype of T generated by /// <see cref="ShieldedType"/>. It implements backing storage /// for all virtual properties (with virtual getters and setters) in one /// Shielded struct container. Base setters will be called before any change, /// and may use the getter to obtain the old value. /// If the class has a virtual method Commute(Action), this will be overriden /// and the override will perform the action as a commute. /// If the class has a protected method OnChanged(string), this will be called /// after every property change, with the property name as argument. /// The subtype is generated once per type, and cached for future calls. /// </summary> public static T NewShielded <T>() where T : class, new() { return((T)_activators.GetOrAdd(ProxyGen.GetFor(typeof(T)), CreateActivator)()); }
/// <summary> /// Returns the proxy subtype for a given type. If arg already is a proxy type, /// then it just returns it directly. The proxy type implements backing storage /// for all virtual properties (with virtual getters and setters) in one /// Shielded struct container. Base setters will be called before any change, /// and may use the getter to obtain the old value. /// If the class has a virtual method Commute(Action), this will be overriden /// and the override will perform the action as a commute. /// If the class has a protected method OnChanged(string), this will be called /// after every property change, with the property name as argument. /// The subtype is generated once per type, and cached for future calls. /// </summary> public static Type ShieldedType(Type t) { return(ProxyGen.GetFor(t)); }