public static ServiceConfigurator <T> WhenSessionChanged <T>(this ServiceConfigurator <T> configurator,
                                                                     Action <T, SessionChangedArguments> callback)
            where T : class
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            configurator.WhenSessionChanged((service, control, arguments) =>
            {
                callback(service, arguments);
            });

            return(configurator);
        }
Exemple #2
0
        public static ServiceConfigurator <T> ConstructUsingStructureMap <T>(this ServiceConfigurator <T> configurator) where T : class
        {
            var hasInterfaces = typeof(T).GetInterfaces()?.Length > 0;

            if (hasInterfaces && IsAssignable <ServiceControl, T>())
            {
                configurator.WhenStarted((service, control) => ((ServiceControl)service).Start(control));
                configurator.WhenStopped((service, control) => ((ServiceControl)service).Stop(control));
            }

            if (hasInterfaces && IsAssignable <ServiceSessionChange, T>())
            {
                configurator.WhenSessionChanged((service, control, args) => ((ServiceSessionChange)service).SessionChange(control, args));
            }

            configurator.ConstructUsing(GetFactory <T>());
            return(configurator);
        }