예제 #1
0
파일: Action.cs 프로젝트: 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));
        }
예제 #2
0
파일: ActionParam.cs 프로젝트: VsPun/DPP
        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);
        }