public static void Dispose(this IWindsorContainer container, object actor, RecordingControlPanel control, RecordDataKeeper dataKeeper)
 {
     container.Release(actor);
     container.Release(dataKeeper);
     container.Release(control);
     container.Dispose();
 }
Пример #2
0
        /// <summary>
        /// Get the interceptor for the instance.
        /// </summary>
        /// <typeparam name="T">Type of service or component (doesn't matter much)</typeparam>
        /// <param name="service"></param>
        /// <param name="recorder"></param>
        /// <param name="control"></param>
        /// <returns>true if the recording interceptor was attached, false otherwise</returns>
        public static bool InterceptorsFor <T>(
            T service,
            out RecordDataKeeper recorder,
            out RecordingControlPanel control)
        {
            var accessor = service as IProxyTargetAccessor;

            if (accessor == null)
            {
                recorder = null;
                control  = null;
                return(false);
            }

            var interceptor = accessor.GetInterceptors().OfType <RecordingInterceptorImpl>().FirstOrDefault();

            if (interceptor == null)
            {
                recorder = null;
                control  = null;
                return(false);
            }

            recorder = interceptor.Recorder;
            control  = interceptor.RecordingControlPanel;
            return(true);
        }
 public RecordingInterceptorImpl(
   RecordDataKeeper recorder,
   RecordingControlPanel recordingControlPanel) {
   if (recorder == null) throw new ArgumentNullException("recorder");
   if (recordingControlPanel == null) throw new ArgumentNullException("recordingControlPanel");
   this.recorder = recorder;
   this.recordingControlPanel = recordingControlPanel;
 }
Пример #4
0
 public RecordingInterceptorImpl(
     RecordDataKeeper recorder,
     RecordingControlPanel recordingControlPanel)
 {
     if (recorder == null)
     {
         throw new ArgumentNullException("recorder");
     }
     if (recordingControlPanel == null)
     {
         throw new ArgumentNullException("recordingControlPanel");
     }
     this.recorder = recorder;
     this.recordingControlPanel = recordingControlPanel;
 }
        public static IWindsorContainer GetTracingContainer <TService, TComponent>(
            Action <SpecWriterFacility> configure,
            out RecordDataKeeper dataKeeper,
            out RecordingControlPanel control,
            out TService actor)
            where TService : class
            where TComponent : TService
        {
            var container = new WindsorContainer();

            container.AddFacility(configure);
            container.Register(Component.For <TService>().ImplementedBy <TComponent>());
            actor = container.Resolve <TService>();
            RecordingInterceptorFinder.InterceptorsFor(actor, out dataKeeper, out control).ShouldBeTrue();
            return(container);
        }