Beispiel #1
0
        public void RegisterParameterSeries(MemberInfo member, ParameterSeriesAttribute parameterSeriesAttribute)
        {
            ValidatePropertySetter(member);
            ValidateParameterSeriesMemberType(member);

            const string parameterSeriesRegistrationType = "ParameterSeries";

            RegisterArgumentInstance(
                parameterSeriesRegistrationType,
                TypeHelper.GetMemberType(member).GetElementType(),
                new ParameterSeries
            {
                Name        = parameterSeriesAttribute.Name,
                Description = parameterSeriesAttribute.Description,
                ValueType   = TypeHelper.GetMemberType(member).GetElementType()
            }
                );
        }
        public void SetParameterSeriesValues(MemberInfo member, ParameterSeriesAttribute parameterSeriesAttribute)
        {
            var method     = typeof(CommandArgs).GetMethod("GetParameterSeries");
            var memberType = TypeHelper.GetMemberType(member);
            var generic    = method.MakeGenericMethod(memberType.GetElementType());
            var value      = generic.Invoke(_args, null);

            var itemValues = (IEnumerable)value;
            var length     = itemValues.Cast <object>().Count();

            var array = Array.CreateInstance(memberType.GetElementType(), length);
            var i     = 0;

            foreach (var itemValue in itemValues)
            {
                array.SetValue(itemValue, i++);
            }

            TypeHelper.SetValue(member, _tArgs, array);
        }