Exemplo n.º 1
0
        /// <param name="requestingType">Type of the class for which to create the field</param>
        /// <param name="fieldType">FieldType of the field to construct</param>
        /// <param name="scope">FieldType of the field to construct</param>
        /// <returns>a new Field of the given fieldType, with the scope of it's value being restricted to the Type scope</returns>
        public Field CreateField(Type requestingType, FieldType fieldType, object preferredDefaultValue)
        {
            string requestingTypeName = requestingType.Name;
            string requestedField = requestingTypeName + "." + fieldType.Name;
            object fieldValue = preferredDefaultValue;

            // Check if the configuration exists
            if (LastUsedFieldValues == null)
            {
                LastUsedFieldValues = new Dictionary<string, object>();
            }

            // Check if settings for the requesting type exist, if not create!
            if (LastUsedFieldValues.ContainsKey(requestedField))
            {
                // Check if a value is set (not null)!
                if (LastUsedFieldValues[requestedField] != null)
                {
                    fieldValue = LastUsedFieldValues[requestedField];
                }
                else
                {
                    // Overwrite null value
                    LastUsedFieldValues[requestedField] = fieldValue;
                }
            }
            else
            {
                LastUsedFieldValues.Add(requestedField, fieldValue);
            }
            Field returnField = new Field(fieldType, requestingType);
            returnField.Value = fieldValue;
            return returnField;
        }
		public new Field GetField(FieldType fieldType) {
			Field ret = null;
			if(base.HasField(fieldType)) {
				ret = base.GetField(fieldType);
			} else {
				foreach(IFieldHolder fh in Children) {
					if(fh.HasField(fieldType)) {
						ret = fh.GetField(fieldType);
						break;
					}
				}
			}
			if(ret == null) {
				throw new ArgumentException("Field '"+fieldType+"' does not exist in " + GetType());
			}
			return ret;
		}
 public decimal GetFieldValueAsDecimal(FieldType fieldType)
 {
     return Convert.ToDecimal(GetFieldValue(fieldType));
 }
Exemplo n.º 4
0
 public bool GetFieldValueAsBool(FieldType fieldType)
 {
     return (bool)GetFieldValue(fieldType);
 }
 public new bool HasFieldValue(FieldType fieldType)
 {
     Field f = GetField(fieldType);
     return f != null && f.HasValue;
 }
 public void SetFieldValue(FieldType fieldType, object value)
 {
     try
     {
         fieldsByType[fieldType].Value = value;
     }
     catch (KeyNotFoundException e)
     {
         throw new ArgumentException("Field '" + fieldType + "' does not exist in " + GetType(), e);
     }
 }
 public bool HasField(FieldType fieldType)
 {
     return fieldsByType.ContainsKey(fieldType);
 }
 public bool GetFieldValueAsBool(FieldType fieldType)
 {
     return Convert.ToBoolean(GetFieldValue(fieldType));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Constructs a new Field instance, usually you should be using FieldFactory
 /// to create Fields.
 /// </summary>
 /// <param name="fieldType">FieldType of the Field to be created</param>
 /// <param name="scope">The scope to which the value of this Field is relevant.
 /// Depending on the scope the Field's value may be shared for other elements
 /// containing the same FieldType for defaulting to the last used value.
 /// When scope is set to a Type (e.g. typeof(RectangleContainer)), its value
 /// should not be reused for FieldHolders of another Type (e.g. typeof(EllipseContainer))
 /// </param>
 public Field(FieldType fieldType, Type scope)
 {
     FieldType = fieldType;
     Scope = scope.Name;
 }
Exemplo n.º 10
0
 public string GetFieldValueAsString(FieldType fieldType)
 {
     return (string)GetFieldValue(fieldType);
 }
Exemplo n.º 11
0
 public int GetFieldValueAsInt(FieldType fieldType)
 {
     return (int)GetFieldValue(fieldType);
 }
Exemplo n.º 12
0
 public float GetFieldValueAsFloat(FieldType fieldType)
 {
     return (float)GetFieldValue(fieldType);
 }
Exemplo n.º 13
0
 public double GetFieldValueAsDouble(FieldType fieldType)
 {
     return (double)GetFieldValue(fieldType);
 }
Exemplo n.º 14
0
 public decimal GetFieldValueAsDecimal(FieldType fieldType)
 {
     return (decimal)GetFieldValue(fieldType);
 }
 public double GetFieldValueAsDouble(FieldType fieldType)
 {
     return Convert.ToDouble(GetFieldValue(fieldType));
 }
 public float GetFieldValueAsFloat(FieldType fieldType)
 {
     return Convert.ToSingle(GetFieldValue(fieldType));
 }
Exemplo n.º 17
0
 public Field(FieldType fieldType, string scope)
 {
     FieldType = fieldType;
     Scope = scope;
 }
 public Color GetFieldValueAsColor(FieldType fieldType)
 {
     return (Color)GetFieldValue(fieldType);
 }
Exemplo n.º 19
0
 public Field(FieldType fieldType)
 {
     FieldType = fieldType;
 }
 public bool HasFieldValue(FieldType fieldType)
 {
     return HasField(fieldType) && fieldsByType[fieldType].HasValue;
 }
 public Field GetField(FieldType fieldType)
 {
     try
     {
         return fieldsByType[fieldType];
     }
     catch (KeyNotFoundException e)
     {
         throw new ArgumentException("Field '" + fieldType + "' does not exist in " + GetType(), e);
     }
 }
 public void AddField(Type requestingType, FieldType fieldType, object fieldValue)
 {
     AddField(editorConfiguration.CreateField(requestingType, fieldType, fieldValue));
 }
 public object GetFieldValue(FieldType fieldType)
 {
     return GetField(fieldType).Value;
 }
 public new bool HasField(FieldType fieldType)
 {
     bool ret = base.HasField(fieldType);
     if (!ret)
     {
         foreach (IFieldHolder fh in Children)
         {
             if (fh.HasField(fieldType))
             {
                 ret = true;
                 break;
             }
         }
     }
     return ret;
 }
 public string GetFieldValueAsString(FieldType fieldType)
 {
     return Convert.ToString(GetFieldValue(fieldType));
 }
 public new void SetFieldValue(FieldType fieldType, object value)
 {
     Field f = GetField(fieldType);
     if (f != null) f.Value = value;
 }
 public int GetFieldValueAsInt(FieldType fieldType)
 {
     return Convert.ToInt32(GetFieldValue(fieldType));
 }