Exemple #1
0
        /// <inheritdoc />
        public CompetitiveMap Convert(CompetitiveMapDTO value, object state)
        {
            var entity = new UnknownCompetitiveMap();

            this.Merge(entity, value, state);
            return(entity);
        }
Exemple #2
0
        /// <summary>Converts the given object of type <see cref="CompetitiveMapDataContract"/> to an object of type <see cref="CompetitiveMap"/>.</summary>
        /// <param name="value">The value to convert.</param>
        /// <param name="state"></param>
        /// <returns>The converted value.</returns>
        public CompetitiveMap Convert(CompetitiveMapDataContract value, object state)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value", "Precondition: value != null");
            }

            // Create a new map object
            CompetitiveMap competitiveMap;
            IConverter <CompetitiveMapDataContract, CompetitiveMap> converter;

            if (this.typeConverters.TryGetValue(value.Type, out converter))
            {
                competitiveMap = converter.Convert(value, state);
            }
            else
            {
                competitiveMap = new UnknownCompetitiveMap();
            }

            // Set the scoreboard
            var scores = value.Scores;

            if (scores != null && scores.Length == 3)
            {
                competitiveMap.Scores = this.converterForScoreboard.Convert(scores, state);
            }

            // Set the status of each objective
            var objectiveDataContracts = value.Objectives;

            if (objectiveDataContracts != null)
            {
                var objectives = new List <Objective>(objectiveDataContracts.Count);
                objectives.AddRange(objectiveDataContracts.Select(value1 => this.converterForObjective.Convert(value1, state)));
                competitiveMap.Objectives = objectives;
            }

            // Set the status of each map bonus
            var bonusDataContracts = value.Bonuses;

            if (bonusDataContracts != null)
            {
                var bonuses = new List <MapBonus>(bonusDataContracts.Count);
                bonuses.AddRange(bonusDataContracts.Select(value1 => this.converterForMapBonus.Convert(value1, state)).Where(mapBonus => mapBonus != null));
                competitiveMap.Bonuses = bonuses;
            }

            // Return the map object
            return(competitiveMap);
        }
Exemple #3
0
 // Implement this method in a buddy class to set properties that are specific to 'UnknownCompetitiveMap' (if any)
 partial void Merge(UnknownCompetitiveMap entity, CompetitiveMapDTO dto, object state);