Exemplo n.º 1
0
Arquivo: Action.cs Projeto: VsPun/DPP
        public Action(IActionProcessor parameters)
            : this()
        {
            logger = Logger.GetLoggerEx(this.ActionId + BitConverter.ToInt64(parameters.ProcessId.ToByteArray(), 8));

            Logger.Info(string.Format("Action \"{0}\" activating", this.ActionId));

            if (this.usedActionParams == null)
            {
                throw new ArgumentNullException("The list of used action parameters is not defined.");
            }

            this.Parameters = parameters;

            //Create instance of result
            ConstructorInfo ctor = typeof(R).GetConstructors().First(c => c.GetParameters().Count() == 0);

            LoadedActions.ObjectActivator <R> createdActivator = LoadedActions.GetActivator <R>(ctor);
            this.returnResult = createdActivator();

            Logger.Info(string.Format("Action \"{0}\" activated", this.ActionId));
        }
Exemplo n.º 2
0
        public object ToType(Type conversionType, IFormatProvider provider)
        {
            if (conversionType.Equals(this.GetType()))
            {
                return(this);
            }

            //Get property info for Value poperty
            PropertyInfo pi = conversionType.GetProperty(VALUR_PROPERTY_NAME);

            //Create a new ActionParam
            ConstructorInfo ctor = conversionType.GetConstructors().First(c => c.GetParameters().Count() == 0);

            LoadedActions.ObjectActivator <IActionParam> createdActivator = LoadedActions.GetActivator <IActionParam>(ctor);
            IActionParam art = createdActivator();


            //Convert the value into new type of ActionParam
            pi.SetValue(art, Convert.ChangeType(this.Value, pi.PropertyType, System.Globalization.CultureInfo.InvariantCulture), null);

            return(art);
        }