/// <summary> /// Validates the properties of this object. This method should be called /// after initialization is complete. /// </summary> internal void Validate(this BaseProperty type) { string namePropertyId = GetPropertyId("Name", type); VerifyThrowPropertyNotSetOrEmptyString(type.Name, namePropertyId); string categoryPropertyId = GetPropertyId("Category", type.Name, type); VerifyThrowPropertyEmptyString(typeCategory, categoryPropertyId); // Validate children. if (null != type.DataSource) { type.DataSource.Validate(); } foreach (Argument argument in type.Arguments) { argument.Validate(); } foreach (ValueEditor editor in type.ValueEditors) { editor.Validate(); } // Validate any known derivations. BoolProperty boolProp = type as BoolProperty; if (null != boolProp) { return; } DynamicEnumProperty dynamicEnumProp = type as DynamicEnumProperty; if (dynamicEnumProp != null) { dynamicEnumProp.Validate(); return; } EnumProperty enumProp = type as EnumProperty; if (enumProp != null) { enumProp.Validate(); return; } IntProperty intProp = type as IntProperty; if (intProp != null) { intProp.Validate(); return; } StringListProperty stringListProp = type as StringListProperty; if (stringListProp != null) { return; } StringProperty stringProp = type as StringProperty; if (stringProp != null) { return; } // Unknown derivation, but that's ok. }
/// <summary> /// Validates the properties of this object. This method should be called /// after initialization is complete. /// </summary> internal void Validate(this DynamicEnumProperty type) { (type as BaseProperty).Validate(); ErrorUtilities.VerifyThrowArgumentLength(type.EnumProvider, "EnumProvider"); }
private Property ObtainAttributes(BaseProperty baseProperty, Property parameterGroup) { Property property; if (parameterGroup != null) { property = parameterGroup.Clone(); } else { property = new Property(); } BoolProperty property2 = baseProperty as BoolProperty; DynamicEnumProperty property3 = baseProperty as DynamicEnumProperty; EnumProperty property4 = baseProperty as EnumProperty; IntProperty property5 = baseProperty as IntProperty; StringProperty property6 = baseProperty as StringProperty; StringListProperty property7 = baseProperty as StringListProperty; if (baseProperty.Name != null) { property.Name = baseProperty.Name; } if ((property2 != null) && !string.IsNullOrEmpty(property2.ReverseSwitch)) { property.Reversible = "true"; } if (property2 != null) { property.Type = PropertyType.Boolean; } else if (property4 != null) { property.Type = PropertyType.String; } else if (property3 != null) { property.Type = PropertyType.String; } else if (property5 != null) { property.Type = PropertyType.Integer; } else if (property6 != null) { property.Type = PropertyType.String; } else if (property7 != null) { property.Type = PropertyType.StringArray; } if (((baseProperty.DataSource != null) && !string.IsNullOrEmpty(baseProperty.DataSource.SourceType)) && baseProperty.DataSource.SourceType.Equals("Item", StringComparison.OrdinalIgnoreCase)) { property.Type = PropertyType.ItemArray; } if (property5 != null) { property.Max = property5.MaxValue.HasValue ? property5.MaxValue.ToString() : null; property.Min = property5.MinValue.HasValue ? property5.MinValue.ToString() : null; } if (property2 != null) { property.ReverseSwitchName = property2.ReverseSwitch; } if (baseProperty.Switch != null) { property.SwitchName = baseProperty.Switch; } if (property7 != null) { property.Separator = property7.Separator; } if (baseProperty.Default != null) { property.DefaultValue = baseProperty.Default; } property.Required = baseProperty.IsRequired.ToString().ToLower(CultureInfo.InvariantCulture); if (baseProperty.Category != null) { property.Category = baseProperty.Category; } if (baseProperty.DisplayName != null) { property.DisplayName = baseProperty.DisplayName; } if (baseProperty.Description != null) { property.Description = baseProperty.Description; } if (baseProperty.SwitchPrefix != null) { property.Prefix = baseProperty.SwitchPrefix; } return(property); }