Ejemplo n.º 1
0
        /// <summary>
        /// Reads the JSON representation of the ranges.
        /// </summary>
        /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="existingValue">The existing value of object being read.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <returns>The object value.</returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var ranges = new ListOfInt();

            switch (reader.TokenType)
            {
            case JsonToken.StartArray:
                while (reader.Read() && reader.TokenType != JsonToken.EndArray)
                {
                    if (reader.TokenType == JsonToken.Integer)
                    {
                        ranges.Add((int)(long)reader.Value);
                    }
                    else if (reader.TokenType == JsonToken.Float)
                    {
                        ranges.Add((int)Math.Round((double)reader.Value));
                    }
                    else
                    {
                        throw new JsonException("Unexcpected token type when reading range value: " + reader.TokenType + ". Expected Integer. Path: " + reader.Path);
                    }
                }
                break;

            case JsonToken.String:
                ranges.Add(0);
                break;

            default:
                throw new JsonException("Can only deseialize 'range' from an array of integers, or the string 'self'. Path: " + reader.Path);
            }
            return(ranges);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new <see cref="StaticSpell"/> instance.
 /// </summary>
 public StaticSpell()
 {
     Cooldown = new ListOfDouble();
     Cost = new ListOfInt();
     Effect = new ListOfListOfDouble();
     EffectBurn = new ListOfString();
     Image = new Image();
     LevelTip = new LevelTip();
     Range = new ListOfInt();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new <see cref="StaticItem"/> instance.
 /// </summary>
 public StaticItem()
 {
     // Note: default values are defined in the "basic" property of an ItemList or RuneList.
     Depth = 1;
     Effect = new DictionaryOfString();
     From = new ListOfInt();
     Gold = new Gold();
     InStore = true;
     Into = new ListOfInt();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Reads the JSON representation of the ranges.
 /// </summary>
 /// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
 /// <param name="objectType">Type of the object.</param>
 /// <param name="existingValue">The existing value of object being read.</param>
 /// <param name="serializer">The calling serializer.</param>
 /// <returns>The object value.</returns>
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     var ranges = new ListOfInt();
     switch (reader.TokenType)
     {
         case JsonToken.StartArray:
             while (reader.Read() && reader.TokenType != JsonToken.EndArray)
             {
                 if (reader.TokenType == JsonToken.Integer)
                     ranges.Add((int)(long)reader.Value);
                 else if (reader.TokenType == JsonToken.Float)
                     ranges.Add((int)Math.Round((double)reader.Value));
                 else
                     throw new JsonException("Unexcpected token type when reading range value: " + reader.TokenType + ". Expected Integer. Path: " + reader.Path);
             }
             break;
         case JsonToken.String:
             ranges.Add(0);
             break;
         default:
             throw new JsonException("Can only deseialize 'range' from an array of integers, or the string 'self'. Path: " + reader.Path);
     }
     return ranges;
 }
Ejemplo n.º 5
0
        private static bool AreTypesIncompatible(ValidationHelper helper, ArticleService articleSerivce, int marketingProductTypeId, ListOfInt productIds, string productTypeName)
        {
            bool typesIncompatible = false;

            int productContentId = helper.GetSettingValue(SettingsTitles.PRODUCTS_CONTENT_ID);

            var productTypeIds = articleSerivce.GetFieldValues(productIds.ToArray(), productContentId, productTypeName).Distinct().ToArray();

            if (productTypeIds.Length == 1)
            {
                string productTypeId = productTypeIds[0];

                int productTypesContentId = helper.GetSettingValue(SettingsTitles.PRODUCT_TYPES_CONTENT_ID);

                var allTypesCompatibility = articleSerivce.List(productTypesContentId, null, true);

                typesIncompatible = !allTypesCompatibility.Any(x =>
                                                               x.FieldValues.FirstOrDefault(a => a.Field.Name == Constants.FieldProductContent)?.Value == productTypeId
                                                               &&
                                                               x.FieldValues.FirstOrDefault(a => a.Field.Name == Constants.FieldMarkProductContent)?.Value ==
                                                               marketingProductTypeId.ToString());
            }
            else if (productTypeIds.Length > 1)
            {
                typesIncompatible = true
                ;
            }
            return(typesIncompatible);
        }