public T Save() { try { if (proxy == null) { Confirm.Assertion(register.Keys.Count > 0, "Proxy definition must specify what members have to be intercepted. Specify one or more members utilizing Intercept*() methods."); Confirm.Assertion(register.All(vp => vp.Value.Count > 0), "One or more intercepted members do not specify how to handle interception. Specify interception behavior utilizing On*() methods."); states = new InterceptorStateCollection(); foreach (var key in register.Keys) { states.Add(new InterceptorState(key, register[key])); } context = new InterceptorContext(states); proxy = (target == null) ? CilBuilder.Create <T>(context, implementedTypes.ToArray()) : CilBuilder.Create <T>(target, context, implementedTypes.ToArray()); } } catch (Exception ex) { throw new ProxyInitializationException("Unable to create proxy: " + ex.Message, ex); } return(proxy); }
public InterceptorContext(IList<InterceptorState> collection) { InterceptorStateCollection = new InterceptorStateCollection(collection); }