コード例 #1
0
        private int _getInt(DbAttribute attribute, Database.Tuple tupleSource)
        {
            var sValue = tupleSource.GetValue <string>(attribute);
            int ival;

            Int32.TryParse(sValue, out ival);
            return(ival);
        }
コード例 #2
0
 private bool _isNotNullDifferent(string newValue, DbAttribute attribute, Database.Tuple item)
 {
     if (string.IsNullOrEmpty(newValue))
     {
         return(false);
     }
     return(newValue != item.GetValue <string>(attribute));
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        private bool _emptyFill(DbAttribute attribute, Database.Tuple item)
        {
            string value = item.GetValue <string>(attribute);

            if (ProjectConfiguration.AutocompleteFillOnlyEmptyFields)
            {
                return(String.IsNullOrEmpty(value));
            }

            return(true);
        }
コード例 #5
0
            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);
            }
コード例 #6
0
        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;
        }
コード例 #7
0
        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()));
        }
コード例 #8
0
            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);
            }
コード例 #9
0
        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));
        }
コード例 #10
0
            public T ConvertFrom <T>(Database.Tuple source, object value)
            {
                int itemType = source.GetValue <int>(ServerItemAttributes.Type);

                if (value == null)
                {
                    return((T)(object)false);
                }

                string val = (string)value;

                if (typeof(T) == typeof(bool))
                {
                    if (_isNull(itemType, value))
                    {
                        return((T)(object)false);
                    }
                    if (val == "true" || val == "1")
                    {
                        return((T)(object)true);
                    }
                    if (val == "false" || val == "0" || val == "")
                    {
                        return((T)(object)false);
                    }

                    return((T)(object)(val != ""));
                }

                if (typeof(T) == typeof(string))
                {
                    if (_isNull(itemType, value))
                    {
                        return((T)(object)"");
                    }
                    if (val == "true" || val == "1")
                    {
                        return((T)(object)"true");
                    }
                    if (val == "false" || val == "" || val == "0")
                    {
                        return((T)(object)"false");
                    }

                    return((T)(object)((val != "") ? "true" : "false"));
                }

                if (typeof(T) == typeof(int))
                {
                    if (_isNull(itemType, value))
                    {
                        return((T)(object)0);
                    }
                    if (val == "true" || val == "1")
                    {
                        return((T)(object)1);
                    }
                    if (val == "false" || val == "" || val == "0")
                    {
                        return((T)(object)0);
                    }

                    return((T)(object)(val != ""));
                }

                return((T)value);
            }
コード例 #11
0
        public override int Compare(object x, object y)
        {
            Database.Tuple xT = (Database.Tuple)x;
            Database.Tuple yT = (Database.Tuple)y;

            if (_current != null)
            {
                if (_current.DataType == _intType)
                {
                    int x1;
                    int y1;

                    object xprop = xT.GetRawValue(_attributeSortIndex);

                    if (xprop is int)
                    {
                        x1 = (int)xprop;
                    }
                    //else if (xprop is string)
                    //	x1 = FormatConverters.LongOrHexConverter((string)xprop);
                    else
                    {
                        x1 = _current.DataConverter.ConvertFrom <int>(xT, xprop);
                    }

                    object yprop = yT.GetRawValue(_attributeSortIndex);

                    if (yprop is int)
                    {
                        y1 = (int)yprop;
                    }
                    //else if (xprop is string)
                    //	y1 = FormatConverters.IntOrHexConverter((string)yprop);
                    else
                    {
                        y1 = _current.DataConverter.ConvertFrom <int>(yT, yprop);
                    }

                    return(_direction == ListSortDirection.Ascending ? (x1 - y1) : (y1 - x1));
                }

                if (_current.DataType == _stringType)
                {
                    string x1  = xT.GetValue <string>(_attributeSortIndex);
                    string y1  = yT.GetValue <string>(_attributeSortIndex);
                    var    res = String.Compare(x1, y1, StringComparison.InvariantCultureIgnoreCase);
                    return((_direction == ListSortDirection.Ascending ? 1 : -1) * res);
                }
            }

            object xProp = xT.GetValue(_attributeSortIndex);
            object yProp = yT.GetValue(_attributeSortIndex);

            if (xProp == null || yProp == null)
            {
                return(1);
            }

            if (xProp is string || xProp is int || xProp is bool)
            {
                return((_direction == ListSortDirection.Ascending ? 1 : -1) * Comparer.Default.Compare(xProp, yProp));
            }

            return((_direction == ListSortDirection.Ascending ? 1 : -1) * Comparer.Default.Compare(xProp.ToString(), yProp.ToString()));
        }
コード例 #12
0
ファイル: LuaHelper.cs プロジェクト: userid0/RagnarokSDE
        public static string GetAccAegisNameFromTuple(Database.Tuple tuple)
        {
            string accessoryName = tuple.GetValue <string>(ServerItemAttributes.AegisName.Index);

            return(LatinOnly(accessoryName));
        }