public void ToString(StringBuilder builder) { builder.Append(StringTokens.TagOpen); builder.Append(Tag); builder.Append(StringTokens.ArgumentsOpen); Condition.ToString(builder); builder.Append(StringTokens.ArgumentsClose); builder.Append(StringTokens.TagClose); if (TrueValue != null) { TrueValue.ToString(builder); } if (FalseValue != null) { builder.Append(StringTokens.ElseTag); FalseValue.ToString(builder); } builder.Append(StringTokens.TagOpen); builder.Append(StringTokens.ElementClose); builder.Append(Tag); builder.Append(StringTokens.TagClose); }
/// <inheritdoc/> public override object DeserializeObject(Type type, object encoded) { if (encoded == null) { return(null); } if (encoded is string) { var s = encoded.ToString(); if (s.IsIEqualTo(TrueValue.ToString())) { return(true); } if (s.IsIEqualTo(FalseValue.ToString())) { return(false); } } else { var value = Convert.ChangeType(encoded, type, CultureInfo.InvariantCulture); if (value == TrueValue) { return(true); } else if (value == FalseValue) { return(false); } } throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Value {0} could not be converted to bool.", encoded)); }
public override void ToString(NodeStringBuilder strBuilder) { Condition.ToString(strBuilder); strBuilder.Append(" ? "); TrueValue.ToString(strBuilder); strBuilder.Append(" : "); FalseValue.ToString(strBuilder); }
/// <summary>Initializes a new item.</summary> /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param> /// <param name="defaultValue">The starting value of the item</param> /// <remarks><see cref="RawValue"/> initializes to <b>false</b>.<br/> /// For <see cref="DefaultValue"/> to be set to <b>true</b>, <i>defaultValue</i> must match <see cref="TrueValue"/> or "<b>true</b>" (case-insensitive). All other inputs will be read as <b>false</b>.</remarks> public BoolVar(VarCollection parent, string defaultValue) { _parent = parent; _type = VarType.Bool; bool loading = _parent.isLoading; _parent.isLoading = true; RawValue = false; DefaultValue = (defaultValue != null && (defaultValue == TrueValue.ToString() || defaultValue.ToString().ToLower() == "true")); _parent.isLoading = loading; }
public override string GetDescriptionString() { string adjustedStr; if (valueIsPercentage) { adjustedStr = (TrueValue * 100).ToString() + "%"; } else { adjustedStr = TrueValue.ToString(); } return("+" + adjustedStr + " " + StatsList.StatsEnumToString(StatEnum) + "\n"); }
private bool ResolveEnum() { if (!isEnumResolved) { if (EnumType != null) { if (Enum.TryParse(EnumType, TrueValue.ToString(), out object trueEnum) && Enum.TryParse(EnumType, FalseValue.ToString(), out object falseEnum)) { _trueEnum = trueEnum; _falseEnum = falseEnum; isEnumResolved = true; } } } return(isEnumResolved); }
internal void ToSettings(string indexName, Dictionary <string, string> settings, bool isSubField) { var category = "Index-" + indexName.ToLower() + "-Fields-" + this.Name.ToLower(); Lib.AddSettingAsNeeded(settings, category, "IsSubField", isSubField.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "Name", this.Name, true); Lib.AddSettingAsNeeded(settings, category, "Ordinal", Ordinal.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "Value", ("" + Value).ToString(), true); Lib.AddSettingAsNeeded(settings, category, "IsPrimaryKey", IsPrimaryKey.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "StoredInIndex", StoredInIndex.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "Searchable", Searchable.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "Format", Format.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "Type", DataType.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "IsBoolean", IsBoolean.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "TrueValue", TrueValue.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "IsCreatedDate", IsCreatedDate.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "IsModifiedDate", IsModifiedDate.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "ForeignKeyTable", ForeignKeyTable.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "ForeignKeyField", ForeignKeyField.ToString(), true); Lib.AddSettingAsNeeded(settings, category, "Calculation", Calculation.ToString(), true); foreach (Field sf in this.SubFields) { sf.ToSettings(indexName, settings, true); } }
/// <summary>Initializes a new item.</summary> /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param> /// <param name="trueValue">The raw byte value stored in the file for <b>true</b>. Accepted values are <b>-1</b> to <b>255</b>. Default is <b>1</b>.</param> /// <param name="falseValue">The raw byte value stored in the file for <b>false</b>. Accepted values are <b>-1</b> to <b>255</b>. Default is <b>0</b>.</param> /// <param name="defaultValue">The starting value of the item</param> /// <exception cref="OverflowException"><i>trueValue</i> or <i>falseValue</i> is less than <b>-1</b> or greater than <b>255</b>.</exception> /// <remarks><see cref="RawValue"/> initializes to <b>false</b>.<br/> /// If <i>trueValue</i> or <i>falseValue</i> are <b>null</b> or cannot parsed, default values are used.<br/> /// Values of <b>-1</b> are converted to <b>255</b>.<br/> /// For <see cref="DefaultValue"/> to be set to <b>true</b>, <i>defaultValue</i> must match <see cref="TrueValue"/> or "<b>true</b>" (case-insensitive). All other inputs will be read as <b>false</b>.</remarks> public BoolVar(VarCollection parent, string trueValue, string falseValue, string defaultValue) { _parent = parent; _type = VarType.Bool; bool loading = _parent.isLoading; _parent.isLoading = true; try { TrueValue = byte.Parse(trueValue); } catch (FormatException) { /* do nothing */ } catch (ArgumentNullException) { /* do nothing */ } catch (OverflowException x) { if (trueValue == "-1") { TrueValue = 255; } else { throw x; } } try { FalseValue = byte.Parse(falseValue); } catch (FormatException) { /* do nothing */ } catch (ArgumentNullException) { /* do nothing */ } catch (OverflowException x) { if (falseValue == "-1") { FalseValue = 255; } else { throw x; } } RawValue = false; DefaultValue = (defaultValue != null && (defaultValue == TrueValue.ToString() || defaultValue.ToString().ToLower() == "true")); _parent.isLoading = loading; }
internal void FillDataSet(DataSet ds, string indexName, bool isSubField) { var dtField = ds.Tables["index_field"]; var drFields = dtField.Select("index_name = '" + indexName + "' and field_name = '" + Name + "'"); var drField = dtField.NewRow(); if (drFields.Length == 0) { dtField.Rows.Add(drField); } else { drField = drFields[0]; } drField["index_name"] = indexName; drField["field_name"] = Name.ToString(); drField["ordinal"] = Ordinal.ToString(); //drField["value"] = ("" + Value).ToString(); drField["is_primary_key"] = IsPrimaryKey.ToString(); drField["is_stored_in_index"] = StoredInIndex.ToString(); drField["is_searchable"] = Searchable.ToString(); drField["format"] = Format.ToString(); drField["type"] = DataType.ToString(); drField["is_boolean"] = IsBoolean.ToString(); drField["true_value"] = TrueValue.ToString(); drField["foreign_key_table"] = ForeignKeyTable.ToString(); drField["foreign_key_field"] = ForeignKeyField.ToString(); drField["calculation"] = Calculation.ToString(); foreach (Field sf in this.SubFields) { sf.FillDataSet(ds, indexName, true); } }
public override string ToString(Formatting formatting) { return(String.Format("(({0}) ? ({1}) : ({2}))", Condition.ToString(formatting), TrueValue.ToString(formatting), FalseValue.ToString(formatting))); }