Esempio n. 1
0
        protected void BuildParametersFromAttributes()
        {
            this.ParametersByName.Clear();
            Type myChild = this.GetType();

            PropertyInfo[] lookingForIndicatorParameters = myChild.GetProperties();
            foreach (PropertyInfo property in lookingForIndicatorParameters)
            {
                IndicatorParameterAttribute attrFoundUnique = null;
                object[] attributes = property.GetCustomAttributes(typeof(IndicatorParameterAttribute), true);
                foreach (object attrObj in attributes)
                {
                    IndicatorParameterAttribute attr = attrObj as IndicatorParameterAttribute;
                    if (attrFoundUnique != null)
                    {
                        string msg = "ATTRIBUTE_INDICATOR_PARAMETER_SET_MULTIPLE_TIMES_MUST_BE_SINGLE attrFoundUnique[" + attrFoundUnique + "]";
                        Assembler.PopupException(msg);
                    }
                    attrFoundUnique = attr;
                }
                if (attrFoundUnique == null)
                {
                    continue;
                }
                IndicatorParameter param = new IndicatorParameter(attrFoundUnique);

                object valueCurrentCasted = param.ValueCurrent;
                if (property.PropertyType.Name == "Int32")
                {
                    valueCurrentCasted = (int)Math.Round(param.ValueCurrent);
                }
                property.SetValue(this, valueCurrentCasted, null);
                if (this.ParametersByName.ContainsKey(param.Name))
                {
                    string msg = "INDICATOR_PARAMETER_ALREADY_ADDED_MUST_BE_UNIQUE param[" + param + "]";
                    Assembler.PopupException(msg);
                }
                // MOVED_TO_LATER_STAGE
                //string validationError = param.ValidateSelf();
                //if (string.IsNullOrEmpty(validationError) == false) {
                //    string msg = "INDICATOR_SELF_VALIDATION_FAILED [" + validationError + "] for param[" + param + "]";
                //    Assembler.PopupException(msg);
                //}
                this.ParametersByName.Add(param.Name, param);
            }
            // resetting it for fair recalculation to include parameters into this.NameWithParameters; it isn't redundant!
            this.parametersAsStringShort = null;
        }
		//public string ValueString;
		//public BarScaleInterval ValueBarScaleInterval;
		
		public IndicatorParameter(IndicatorParameterAttribute attr) {
			this.Name = attr.Name;
			//if (attr.ValueBarScaleInterval != null) {
			//    this.ValueBarScaleInterval = attr.ValueBarScaleInterval;
			//    return;
			//}
			//if (attr.ValueString != null) {
			//    this.ValueString = attr.ValueString;
			//    return;
			//}
			if (attr.ValueCurrent != null) {
				this.ValueCurrent = attr.ValueCurrent;
				this.ValueMin = attr.ValueMin;
				this.ValueMax = attr.ValueMax;
				this.ValueIncrement = attr.ValueIncrement;
				return;
			}
		}
Esempio n. 3
0
        //public string ValueString;
        //public BarScaleInterval ValueBarScaleInterval;

        public IndicatorParameter(IndicatorParameterAttribute attr)
        {
            this.Name = attr.Name;
            //if (attr.ValueBarScaleInterval != null) {
            //    this.ValueBarScaleInterval = attr.ValueBarScaleInterval;
            //    return;
            //}
            //if (attr.ValueString != null) {
            //    this.ValueString = attr.ValueString;
            //    return;
            //}
            if (attr.ValueCurrent != null)
            {
                this.ValueCurrent   = attr.ValueCurrent;
                this.ValueMin       = attr.ValueMin;
                this.ValueMax       = attr.ValueMax;
                this.ValueIncrement = attr.ValueIncrement;
                return;
            }
        }