private static ControlCollection InterceptCollection(Control owner, ControlCollection originalCollection) { CreateControlCollectionDelegate factoryMethod = GetInterceptedCollectionFactory(owner.GetType(), originalCollection.GetType()); ControlCollection interceptedCollection = factoryMethod(owner); ReflectionUtils.MemberwiseCopy(originalCollection, interceptedCollection); return interceptedCollection; }
/// <summary> /// Creates a new Accessor for a given <see cref="ControlCollection"/>. /// </summary> /// <param name="controls">The <see cref="ControlCollection"/> to be accessed</param> public ControlCollectionAccessor(ControlCollection controls) { _controls = controls; _controlsType = controls.GetType(); }