internal FloatOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?.Name, oa) { textField = null; value = 0.0f; limits = FindLimitAttribute(prop); }
internal FloatOptionsEntry(string title, string tooltip, PropertyInfo prop) : base(prop?.Name, title, tooltip) { LimitAttribute fieldLimits = null; textField = null; value = 0.0f; // Look for limits foreach (var attr in prop.GetCustomAttributes(false)) if ((fieldLimits = GetLimits(attr)) != null) break; limits = fieldLimits; }
/// <summary> /// Searches for LimitAttribute attributes on the property wrapped by an OptionsEntry. /// </summary> /// <param name="prop">The property with annotations.</param> /// <returns>The Limit attribute if present, or null if none is.</returns> protected static LimitAttribute FindLimitAttribute(PropertyInfo prop) { LimitAttribute fieldLimits = null; foreach (var attr in prop.GetCustomAttributes(false)) { if ((fieldLimits = LimitAttribute.CreateFrom(attr)) != null) { break; } } return(fieldLimits); }
public StringOptionsEntry(string field, IOptionSpec spec, LimitAttribute limit = null) : base(field, spec) { // Use the maximum limit value for the max length, if present if (limit != null) { maxLength = Math.Max(2, (int)Math.Round(limit.Maximum)); } else { maxLength = 256; } textField = null; value = ""; }
internal IntOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?.Name, oa) { LimitAttribute fieldLimits = null; textField = null; value = 0; // Look for limits foreach (var attr in prop.GetCustomAttributes(false)) { if ((fieldLimits = GetLimits(attr)) != null) { break; } } limits = fieldLimits; }
internal StringOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?.Name, oa) { var limits = LimitAttribute.FindFrom(prop); // Use the maximum limit value for the max length, if present if (limits != null) { maxLength = Math.Max(2, (int)Math.Round(limits.Maximum)); } else { maxLength = 256; } textField = null; value = ""; }
/// <summary> /// Tries to retrieve the limits for an option. /// </summary> /// <param name="attr">The annotation to check.</param> /// <returns>The LimitAttribute matching that annotation, or null if it is not a LimitAttribute.</returns> internal static LimitAttribute GetLimits(object attr) { if (attr == null) { throw new ArgumentNullException("attr"); } LimitAttribute la = null; if (attr.GetType().Name == typeof(LimitAttribute).Name) { // Has limit type var trAttr = Traverse.Create(attr); double min = trAttr.GetProperty <double>(nameof(LimitAttribute.Minimum)), max = trAttr.GetProperty <double>(nameof(LimitAttribute.Maximum)); if (min != 0.0 || max != 0.0) { la = new LimitAttribute(min, max); } } return(la); }
public NullableFloatOptionsEntry(string field, IOptionSpec spec, LimitAttribute limit = null) : base(field, spec, limit) { textField = null; value = null; }
protected IntOptionsEntry(string title, string tooltip, string category = "", LimitAttribute limits = null) : base(title, tooltip, category, limits) { textField = null; value = 0; }
protected SlidingBaseOptionsEntry(string field, IOptionSpec spec, LimitAttribute limit = null) : base(field, spec) { limits = limit; slider = null; }
protected SlidingBaseOptionsEntry(OptionAttribute oa, PropertyInfo prop) : base(prop?. Name, oa) { limits = LimitAttribute.FindFrom(prop); slider = null; }
protected SlidingBaseOptionsEntry(string title, string tooltip, string category, LimitAttribute limits) : base(title, tooltip, category) { this.limits = limits; slider = null; }