Beispiel #1
0
 public static bool Parse(string attrEx, out Dictionary <string, ItemAttributeElement> attributes)
 {
     string[] array = attrEx.Split(new char[]
     {
         ',',
         '[',
         ']'
     });
     if (array.Length == 0)
     {
         attributes = new Dictionary <string, ItemAttributeElement>();
         return(true);
     }
     attributes = new Dictionary <string, ItemAttributeElement>();
     foreach (string text in array)
     {
         if (!(text == ""))
         {
             ItemAttributeElement itemAttributeElement = ItemClassExBuilder.ParseSingleAttribute(text);
             if (itemAttributeElement != null)
             {
                 try
                 {
                     attributes.Add(itemAttributeElement.AttributeName, itemAttributeElement);
                 }
                 catch (Exception arg)
                 {
                     throw new Exception(string.Format("Item Parse Error [attrEx : {1}] [AttributeName : {2}]- {0}", arg, attrEx, itemAttributeElement.AttributeName));
                 }
             }
         }
     }
     return(true);
 }
Beispiel #2
0
 public static string Build(string itemClass, ICollection <ItemAttributeElement> attributes)
 {
     if (attributes.Count > 0)
     {
         StringBuilder stringBuilder = new StringBuilder(itemClass);
         stringBuilder.Append("[");
         stringBuilder.Append(ItemClassExBuilder.Build(attributes));
         stringBuilder.Append("]");
         return(stringBuilder.ToString());
     }
     return(itemClass);
 }
Beispiel #3
0
 public TransferredItemInfo(long ItemID, string ItemClass, IDictionary <string, ItemAttributeElement> attributes, int ItemCount, int Color1, int Color2, int Color3, int ReducedDurability, int MaxDurabilityBonus, bool IsCharacterBinded, DateTime?expireDateTime)
 {
     this.ItemID             = ItemID;
     this.ItemClassEx        = ItemClassExBuilder.Build(ItemClass, attributes);
     this.ItemCount          = ItemCount;
     this.Color1             = Color1;
     this.Color2             = Color2;
     this.Color3             = Color3;
     this.ReducedDurability  = ReducedDurability;
     this.MaxDurabilityBonus = MaxDurabilityBonus;
     this.IsCharacterBinded  = IsCharacterBinded;
     this.ExpireDateTime     = expireDateTime;
 }
Beispiel #4
0
        public static bool Parse(string itemClassEx, out string itemClass, out Dictionary <string, ItemAttributeElement> attributes)
        {
            string[] array = itemClassEx.Split(new char[]
            {
                ',',
                '[',
                ']'
            });
            if (array.Length == 0)
            {
                Log <ItemClassExBuilder> .Logger.WarnFormat("No Data [{0}]", itemClassEx);

                itemClass  = null;
                attributes = null;
                return(false);
            }
            itemClass  = array[0];
            attributes = new Dictionary <string, ItemAttributeElement>();
            foreach (string text in array.Skip(1))
            {
                if (!(text == ""))
                {
                    ItemAttributeElement itemAttributeElement = ItemClassExBuilder.ParseSingleAttribute(text);
                    if (itemAttributeElement != null)
                    {
                        try
                        {
                            attributes.Add(itemAttributeElement.AttributeName, itemAttributeElement);
                        }
                        catch (Exception arg)
                        {
                            throw new Exception(string.Format("Item Parse Error [ItemClass : {1}] [AttributeName : {2}]- {0}", arg, itemClassEx, itemAttributeElement.AttributeName));
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #5
0
 public static string Build(IDictionary <string, ItemAttributeElement> attributes)
 {
     return(ItemClassExBuilder.Build(attributes.Values));
 }
Beispiel #6
0
        public static ItemAttributeElement ParseSingleAttribute(string attrStr)
        {
            string text  = null;
            string text2 = null;
            int    arg   = 0;
            int    arg2  = 0;
            int    i     = 0;
            int    num   = 0;
            int    num2  = 0;

            while (i < attrStr.Length)
            {
                char c  = attrStr[i];
                char c2 = c;
                switch (c2)
                {
                case '(':
                    if (num2 == 1)
                    {
                        text2 = attrStr.Substring(num, i - num).Trim();
                    }
                    num2 = 2;
                    num  = i + 1;
                    break;

                case ')':
                    if (num2 == 2)
                    {
                        arg = ItemClassExBuilder.ToArgInt(attrStr.Substring(num, i - num));
                    }
                    num2 = -1;
                    break;

                default:
                    switch (c2)
                    {
                    case ':':
                        if (num2 != 0)
                        {
                            Log <ItemClassExBuilder> .Logger.WarnFormat("parse Error [{0}, {1}]", attrStr, i);

                            return(null);
                        }
                        text = attrStr.Substring(num, i - num).Trim();
                        num2 = 1;
                        num  = i + 1;
                        break;

                    case '<':
                        if (num2 == 1)
                        {
                            text2 = attrStr.Substring(num, i - num).Trim();
                        }
                        num2 = 3;
                        num  = i + 1;
                        break;

                    case '>':
                        if (num2 == 3)
                        {
                            arg2 = ItemClassExBuilder.ToArgInt(attrStr.Substring(num, i - num));
                        }
                        num2 = -1;
                        break;
                    }
                    break;
                }
                i++;
            }
            if (num2 == 1)
            {
                text2 = attrStr.Substring(num, i - num).Trim();
            }
            if (text != null && text2 != null)
            {
                return(new ItemAttributeElement(text, text2, arg, arg2));
            }
            return(null);
        }