public object ConvertTo(Database.Tuple source, object value) { if (value == null) { return(_default); } if (value is bool) { return((bool)value ? _true : _false); } string val = (string)value; if (val == "true" || val == "yes" || val == "1") { return(_true); } if (val == "false" || val == "no" || val == "0" || val == "") { return(_false); } return(Boolean.Parse((string)value) ? _true : _false); }
public T ConvertFrom <T>(Database.Tuple source, object value) { if (typeof(T) == typeof(int)) { if (value == null) { return((T)(object)-1); } string val2 = (string)value; if (val2 == "") { return((T)(object)-1); } if (val2.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) { return((T)(object)FormatConverters.IntOrHexConverter(val2)); } return((T)(object)Int32.Parse(val2)); } if (value == null) { return((T)(object)""); } string val = (string)value; return((T)(object)val.Replace("0x", "").Replace("0X", "")); }
private bool _isNotNullDifferent(string newValue, DbAttribute attribute, Database.Tuple item) { if (string.IsNullOrEmpty(newValue)) { return(false); } return(newValue != item.GetValue <string>(attribute)); }
private int _getInt(DbAttribute attribute, Database.Tuple tupleSource) { var sValue = tupleSource.GetValue <string>(attribute); int ival; Int32.TryParse(sValue, out ival); return(ival); }
public T ConvertFrom <T>(Database.Tuple source, object value) { if (typeof(T) == typeof(string)) { if (value == null) { return((T)(object)"-1"); } string val = (string)value; if (val == "") { return((T)(object)"-1"); } return((T)(object)val); } if (typeof(T) == typeof(int)) { if (value == null) { return((T)(object)-1); } if (value is string) { string val = (string)value; if (val == "") { return((T)(object)-1); } return((T)(object)Int32.Parse(val)); } if (value is int) { return((T)value); } return((T)(object)Int32.Parse(value.ToString())); } if (value == null) { return((T)(object)-1); } string val2 = (string)value; if (val2 == "") { return((T)(object)-1); } return((T)(object)Int32.Parse(val2)); }
public T ConvertFrom <T>(Database.Tuple source, object value) { try { if (typeof(T) == typeof(string)) { if (value == null) { return((T)(object)"0"); } if (value is string) { string val = (string)value; if (val == "") { return((T)(object)"0"); } return((T)(object)val); } if (value is int) { return((T)(object)((int)value).ToString(CultureInfo.InvariantCulture)); } return((T)value); } if (typeof(T) == typeof(int)) { if (value == null) { return((T)(object)0); } if (value is int) { return((T)value); } string val = (string)value; if (val == "") { return((T)(object)0); } return(ParseToInt <T>(val)); } return((T)value); } catch { return(default(T)); } }
public T ConvertFrom <T>(Database.Tuple source, object toReturn) { if (toReturn == null) { return((T)(object)""); } return((T)(object)toReturn.ToString().Trim(new char[] { '\r', '\n' })); }
public T ConvertFrom <T>(Database.Tuple source, object value) { if (value == null) { value = new Evolution(); source.SetRawValue(ServerPetAttributes.Evolution, value); } return((T)value); }
public T ConvertFrom <T>(Database.Tuple source, object value) { if (value == null) { value = new ParameterHolder(source); source.SetRawValue(ClientItemAttributes.Parameters, value); } return((T)value); }
private void _autoField <TKey>( ref Regex regex, Func <bool> cond, Func <string> input, Func <string> output, Database.Tuple item, AbstractDb <TKey> db, TKey newKey, int i, DbAttribute attribute) { if (cond()) { if (regex == null) { regex = new Regex(input(), RegexOptions.RightToLeft); } var attributeValue = item.GetValue <string>(attribute); var newAttributeValue = output(); var newTuple = db.Table.TryGetTuple(newKey); int current = 0; foreach (Match match in regex.Matches(attributeValue)) { foreach (Group group in match.Groups) { if (current == 0) { current++; continue; } int iv; if (Int32.TryParse(group.Value, out iv)) { newAttributeValue = newAttributeValue.Replace("\\" + current + "++", (iv + i).ToString(CultureInfo.InvariantCulture)); newAttributeValue = newAttributeValue.Replace("\\" + current + "=i", i.ToString(CultureInfo.InvariantCulture)); } if (group.Value == "") { continue; } newAttributeValue = newAttributeValue.Replace("\\" + current, group.Value); current++; } break; } for (int j = 0; j <= 9; j++) { newAttributeValue = newAttributeValue.Replace("\\" + j + "++", ""); newAttributeValue = newAttributeValue.Replace("\\" + j + "=i", ""); newAttributeValue = newAttributeValue.Replace("\\" + j, ""); } db.Table.Commands.Set(newKey, newTuple, attribute, newAttributeValue); } }
public object ConvertTo(Database.Tuple source, object value) { if (value == null) { return(""); } string val = (string)value; return("\"" + val.Trim(new char[] { '\t', ' ' }) + "\""); }
private bool _emptyFill(DbAttribute attribute, Database.Tuple item) { string value = item.GetValue <string>(attribute); if (ProjectConfiguration.AutocompleteFillOnlyEmptyFields) { return(String.IsNullOrEmpty(value)); } return(true); }
public object ConvertTo(Database.Tuple source, object value) { if (value == null) { if (AllowSetEmpty) { return(DefaultString); } return(_values[0]); } if (value is bool) { return((bool)value ? _values[1] : _values[0]); } if (value is string) { int ival; if (Int32.TryParse((string)value, out ival)) { if (ival < 0) { return(""); } return(_values[ival]); } bool bval; if (Boolean.TryParse((string)value, out bval)) { return(_values[bval ? 1 : 0]); } if ((string)value == "") { return(DefaultString); } return(value); } if (value is int) { return(_values[(int)value]); } return(value); }
public object ConvertTo(Database.Tuple source, object value) { if (value == null) { return("0"); } if (value is string && (string)value == "") { return("0"); } return(value); }
public object Get(Database.Tuple source, object value) { if (value == null || (value is string && (string)value == "")) { var mobDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs); var mobTuple = mobDb.TryGetTuple(source.GetKey <int>()); if (mobTuple != null) { value = mobTuple.GetStringValue(ServerMobAttributes.IRoName.Index); source.SetRawValue(ServerPetAttributes.JName, value); } } return(value); }
public object ConvertTo(Database.Tuple source, object value) { if (source == null) { return(value); } string returnedValue; if (value == null) { returnedValue = ""; } else { if (value is bool) { returnedValue = (bool)value ? "1" : "0"; } else { string val = (string)value; if (val == "true" || val == "1") { returnedValue = "1"; } else if (val == "false" || val == "0" || val == "") { returnedValue = "0"; } else { returnedValue = Boolean.Parse((string)value) ? "1" : "0"; } } } int itemType = source.GetValue <int>(ServerItemAttributes.Type); if (_isNull(itemType, returnedValue)) { return(""); } return(returnedValue); }
public T ConvertFrom <T>(Database.Tuple source, object value) { if (value == null) { return((T)(object)""); } string val = (string)value; val = val.Trim(' '); if (val.StartsWith(_left)) { val = val.Substring(1, val.Length - 2); } return((T)(object)val.Trim(' ')); }
public ParameterHolder(Database.Tuple item) { string description = item.GetValue <string>(ClientItemAttributes.IdentifiedDescription); foreach (string parameter in SearchKnownItemParameters) { int index; if ((index = _indexOf(parameter, description, 0)) > -1) { try { string value; int toRemove = _readNextElement(parameter, description, index, out value); description = description.Remove(index, toRemove); _values[parameter] = value; } catch { } if (ParameterHolderKeys.Redirections[parameter] != null) { _values[ParameterHolderKeys.Redirections[parameter]] = _values[parameter]; } } } // Removes any other parameter foreach (Match match in _parameter.Matches(description).Cast <Match>().OrderByDescending(p => p.Index)) { description = description.Remove(match.Index, match.Length); } description = description.Trim('\r', '\n', '\t', ' '); //while (description.EndsWith("\r\n")) { // description = description.Remove(description.Length - 2, 2); //} //while (description.EndsWith("\n")) { // description = description.Remove(description.Length - 1, 1); //} _values[ParameterHolderKeys.Description] = description; }
public override string ToString() { if (AttachedAttribute.AttachedObject == null) { return("NULL BINDING"); } Table <int, ReadableTuple <int> > btable = ((BaseDb)AttachedAttribute.AttachedObject).GetMeta <int>(ServerDbs.Items); string value = Tuple.GetValue <string>(0); List <string> values = value.Split(':').ToList(); List <string> output = new List <string>(); for (int i = 0; i < values.Count; i++) { int val; Int32.TryParse(values[i], out val); if (val == 0) { output.Add(""); } else { Database.Tuple tuple = btable.TryGetTuple(val); if (tuple == null) { output.Add("Unknown"); } else { output.Add(tuple.GetValue <string>(ServerItemAttributes.Name)); } } } return(string.Join(Environment.NewLine, output.ToArray())); }
public object ConvertTo(Database.Tuple source, object value) { if (value == null) { return("0xFFFFFFFF"); } string val = (string)value; if (val.StartsWith("0x") || val.StartsWith("0X")) { val = val.Substring(2); } if (val.Length == 0) { return(""); } return("0x" + val.ToUpper()); }
public object ConvertTo(Database.Tuple source, object value) { if (value == null) { return("0"); } if (value is int) { return(value.ToString()); } string val = (string)value; if (val == "") { return("0"); } return(value); }
public object ConvertTo(Database.Tuple source, object value) { string newObject = value.ToString(); if (!newObject.StartsWith("\r\n")) { newObject = newObject.Insert(0, "\r\n"); } if (!newObject.EndsWith("\r\n")) { newObject += "\r\n"; } if (source != null) { source.SetRawValue(ClientItemAttributes.Parameters, null); } return(newObject); }
public object ConvertTo(Database.Tuple source, object value) { if (source == null) { return(value); } if (value == null) { return("0"); } if (value is string && (string)value == "") { return("0"); } int ival; if (Int32.TryParse(value.ToString(), out ival)) { bool refineable = source.GetValue <bool>(ServerItemAttributes.Refineable); if (!refineable) { if (ival == 4 || ival == 5) { source.SetRawValue(ServerItemAttributes.Refineable, "0"); } else { source.SetRawValue(ServerItemAttributes.Refineable, ""); } } //if (AllLoaders.GetServerType() == ServerType.RAthena) { //} } return(value); }
public object ConvertTo(Database.Tuple source, object value) { string newPath = (value ?? "").ToString(); // Convert the string back to the display encoding var intern = newPath.ToDisplayEncoding(false); var display = intern.ToEncoding(SdeAppConfiguration.EncodingResDisplay); var display2 = intern.ToEncoding(EncodingService.Korean); // Must be compatible with both the display encoding and Korean var ansiDisplay = display.ToEncoding(EncodingService.Ansi); var ansiDisplay2 = display2.ToEncoding(EncodingService.Ansi); var ansiPath = newPath.ToEncoding(EncodingService.Ansi); if (ansiDisplay != ansiPath || ansiDisplay2 != ansiPath) { // The encoding has been confused, output the result as raw \### ascii characters newPath = newPath.ToEncoding(EncodingService.Ansi).Escape(EscapeMode.RawAscii); } return(newPath.ToDisplayEncoding(false)); }
public object ConvertTo(Database.Tuple source, object value) { if (value == null) { return("0"); } string val = value.ToString(); if ((val.StartsWith("0x") || val.StartsWith("0X"))) { if (val.Length > 2) { int ival = Convert.ToInt32(val, 16); return(ival.ToString(CultureInfo.InvariantCulture)); } return("0"); } return(val); }
public T ConvertFrom <T>(Database.Tuple source, object value) { if (typeof(T) == typeof(string)) { if (value == null) { return((T)(object)""); } string val = (string)value; if (val == "") { return((T)(object)""); } return((T)(object)val.Trim(new char[] { '\t', ' ' }).Trim('\"')); } if (typeof(T) == typeof(int)) { if (value == null) { return((T)(object)0); } string val = (string)value; if (val == "") { return((T)(object)0); } return((T)(object)Int32.Parse(val)); } return((T)value); }
public T ConvertFrom <T>(Database.Tuple source, object value) { if (value == null) { return((T)(object)""); } string val = (string)value; if (val.StartsWith("0x") || val.StartsWith("0X")) { int ival = val.Length > 2 ? Convert.ToInt32(val, 16) : 0; if (typeof(T) == typeof(int)) { return((T)(object)ival); } if (typeof(T) == typeof(string)) { return((T)(object)ival.ToString(CultureInfo.InvariantCulture)); } } if (typeof(T) == typeof(int)) { return((T)(object)FormatConverters.IntOrHexConverter(val)); } if (typeof(T) == typeof(string)) { return((T)(object)val); } throw new InvalidCastException("Couldn't convert '" + value + "' to type of " + typeof(T) + "."); }
private void _tupleUpdate(bool bypass = false) { try { if ((_tab.DbComponent.DbSource & ServerDbs.ServerItems) != 0) { var tuple = _tab._listView.SelectedItem as ReadableTuple <int>; ViewIdPreviewDialog.LatestTupe = tuple; if (tuple == null) { return; } if (!bypass) { if (tuple == _lastTuple) { return; } if (_lastTuple != null) { _lastTuple.TupleModified -= _tupleUpdate; } _lastTuple = tuple; _lastTuple.TupleModified += _tupleUpdate; } _helper.Read(tuple, _tab); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public object ConvertTo(Database.Tuple source, object value) { if (value == null) { return(_compose); } string val = (string)value; if (val == "" || val == _compose) { return(_compose); } // Why is this here? The elements in the tuple MUST have the brackets... val = val.Trim(' '); if (val.StartsWith(_left)) { val = val.Substring(1, val.Length - 2).Trim(' '); } return(_leftSpace + val + _rightSpace); }
private bool _overridableString(Database.Tuple tupleSource, DbAttribute attribute, params string[] strings) { string value = tupleSource.GetValue <string>(attribute); return(strings.Any(s => value.IndexOf(s, StringComparison.OrdinalIgnoreCase) > -1)); }