Beispiel #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="matchDetail"></param>
    /// <returns></returns>
    public static Dictionary <String, Object> RiotImageToDictionary(RiotImage riotImage)
    {
        if (riotImage == null)
        {
            throw new ArgumentException("parameter champion is required.");
        }

        Dictionary <String, Object> propToValueMap = new Dictionary <String, Object>();

        return(propToValueMap);
    }
Beispiel #2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="propToValueMap"></param>
    /// <returns></returns>
    public static RiotImage DictionaryToRiotImage(Dictionary <String, Object> propToValueMap)
    {
        RiotImage riotImage = new RiotImage();

        #region Full Property

        if (propToValueMap.ContainsKey(RiotImage.PropertyNames.Full) && propToValueMap[RiotImage.PropertyNames.Full] is string)
        {
            riotImage.Full = (string)propToValueMap[RiotImage.PropertyNames.Full];
        }

        #endregion

        #region Group Property

        if (propToValueMap.ContainsKey(RiotImage.PropertyNames.Group) && propToValueMap[RiotImage.PropertyNames.Group] is string)
        {
            riotImage.Group = (string)propToValueMap[RiotImage.PropertyNames.Group];
        }

        #endregion

        #region Height Property

        if (propToValueMap.ContainsKey(RiotImage.PropertyNames.Height) && propToValueMap[RiotImage.PropertyNames.Height] is int)
        {
            riotImage.Height = (int)propToValueMap[RiotImage.PropertyNames.Height];
        }

        #endregion

        #region Sprite Property

        if (propToValueMap.ContainsKey(RiotImage.PropertyNames.Sprite) && propToValueMap[RiotImage.PropertyNames.Sprite] is string)
        {
            riotImage.Sprite = (string)propToValueMap[RiotImage.PropertyNames.Sprite];
        }

        #endregion

        #region Width Property

        if (propToValueMap.ContainsKey(RiotImage.PropertyNames.Width) && propToValueMap[RiotImage.PropertyNames.Width] is int)
        {
            riotImage.Width = (int)propToValueMap[RiotImage.PropertyNames.Width];
        }

        #endregion

        #region X Property

        if (propToValueMap.ContainsKey(RiotImage.PropertyNames.X) && propToValueMap[RiotImage.PropertyNames.X] is int)
        {
            riotImage.X = (int)propToValueMap[RiotImage.PropertyNames.X];
        }

        #endregion

        #region Y Property

        if (propToValueMap.ContainsKey(RiotImage.PropertyNames.Y) && propToValueMap[RiotImage.PropertyNames.Y] is int)
        {
            riotImage.Y = (int)propToValueMap[RiotImage.PropertyNames.Y];
        }

        #endregion

        return(riotImage);
    }
Beispiel #3
0
    /// <summary>
    /// Converts a RiotImage into a dictionary
    /// </summary>
    /// <param name="type">Optional - the type of the value parameter</param>
    /// <param name="value">Optional - the instance that is to be converted into a dictionary</param>
    /// <returns>A Dictionary containing the data contained in the value parameter</returns>
    public override Dictionary <String, Object> WriteJson(Type type, Object value)
    {
        RiotImage riotImage = (RiotImage)value;

        return(RiotImageToDictionary(riotImage));
    }
Beispiel #4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="propToValueMap"></param>
    /// <returns></returns>
    public static Champion DictionaryToChampion(Dictionary <String, Object> propToValueMap)
    {
        Champion champion = new Champion();

        #region Allytips Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Allytips) && propToValueMap[Champion.PropertyNames.Allytips] is string[])
        {
            champion.Allytips = (string[])propToValueMap[Champion.PropertyNames.Allytips];
        }

        #endregion

        #region Blurb Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Blurb) && propToValueMap[Champion.PropertyNames.Blurb] is string)
        {
            champion.Blurb = (string)propToValueMap[Champion.PropertyNames.Blurb];
        }

        #endregion

        #region Enemytips Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Enemytips) && propToValueMap[Champion.PropertyNames.Enemytips] is string[])
        {
            champion.Enemytips = (string[])propToValueMap[Champion.PropertyNames.Enemytips];
        }

        #endregion

        #region Id Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Id) && propToValueMap[Champion.PropertyNames.Id] is int)
        {
            champion.Id = (int)propToValueMap[Champion.PropertyNames.Id];
        }

        #endregion

        #region Key Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Key) && propToValueMap[Champion.PropertyNames.Key] is string)
        {
            champion.Key = (string)propToValueMap[Champion.PropertyNames.Key];
        }

        #endregion

        #region Image Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Image) && propToValueMap[Champion.PropertyNames.Image] is Dictionary <String, Object> )
        {
            Dictionary <String, Object> riotImagePropValueMap = (Dictionary <String, Object>)propToValueMap[Champion.PropertyNames.Image];
            RiotImage riotImage = RiotImageConverter.DictionaryToRiotImage(riotImagePropValueMap);

            champion.Image = riotImage;
        }

        #endregion

        #region Info Property

        /*if (propToValueMap.ContainsKey(Champion.PropertyNames.Blurb) && propToValueMap[Champion.PropertyNames.Info] is string)
         * {
         *  champion.Info = (string)propToValueMap[Champion.PropertyNames.Info];
         * }*/

        #endregion

        #region Lore Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Lore) && propToValueMap[Champion.PropertyNames.Lore] is string)
        {
            champion.Lore = (string)propToValueMap[Champion.PropertyNames.Lore];
        }

        #endregion

        #region Name Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Name) && propToValueMap[Champion.PropertyNames.Name] is string)
        {
            champion.Name = (string)propToValueMap[Champion.PropertyNames.Name];
        }

        #endregion

        #region Partype Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Partype) && propToValueMap[Champion.PropertyNames.Partype] is string)
        {
            champion.Partype = (string)propToValueMap[Champion.PropertyNames.Partype];
        }

        #endregion

        #region Passive Property

        /* if (propToValueMap.ContainsKey(Champion.PropertyNames.Passive) && propToValueMap[Champion.PropertyNames.Passive] is string)
         * {
         *  champion.Passive = (string)propToValueMap[Champion.PropertyNames.Passive];
         * }*/

        #endregion

        #region Recommended Property

        /* if (propToValueMap.ContainsKey(Champion.PropertyNames.Recommended) && propToValueMap[Champion.PropertyNames.Recommended] is string)
         * {
         *  champion.Recommended = (string)propToValueMap[Champion.PropertyNames.Recommended];
         * }*/

        #endregion

        #region Skins Property

        /* if (propToValueMap.ContainsKey(Champion.PropertyNames.Skins) && propToValueMap[Champion.PropertyNames.Skins] is string)
         * {
         *  champion.Skins = (string)propToValueMap[Champion.PropertyNames.Skins];
         * }*/

        #endregion

        #region Spells Property

        /* if (propToValueMap.ContainsKey(Champion.PropertyNames.Spells) && propToValueMap[Champion.PropertyNames.Spells] is string)
         * {
         *  champion.Spells = (string)propToValueMap[Champion.PropertyNames.Spells];
         * }*/

        #endregion

        #region Stats Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Stats) && propToValueMap[Champion.PropertyNames.Stats] is Dictionary <string, object> )
        {
            Dictionary <String, Object> championStatsPropValueMap = (Dictionary <String, Object>)propToValueMap[Champion.PropertyNames.Stats];
            ChampionStats championStats = ChampionStatsConverter.DictionaryToChampionStats(championStatsPropValueMap);

            champion.Stats = championStats;
        }

        #endregion

        #region Tags Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Tags) && propToValueMap[Champion.PropertyNames.Tags] is string[])
        {
            champion.Tags = (string[])propToValueMap[Champion.PropertyNames.Tags];
        }

        #endregion

        #region Title Property

        if (propToValueMap.ContainsKey(Champion.PropertyNames.Title) && propToValueMap[Champion.PropertyNames.Title] is string)
        {
            champion.Title = (string)propToValueMap[Champion.PropertyNames.Title];
        }

        #endregion

        return(champion);
    }