view SSRS/SSRS.Services/Converter.cs @ 113:954f66bb8dbf

Portable library added for DTO
author adminsh@apollo
date Sat, 19 May 2012 16:21:07 +0100
parents b9d5f934cb21
children e51a6af1c98d
line wrap: on
line source

using System.Collections.Generic;
using System.Linq;
using SSRS.Services.DTOs;

namespace SSRS.Services
{
    public class Converter
    {
        public static IList<Parameter> Convert(ReportServiceReference.ItemParameter[] itemParameters)
        {
            if (itemParameters == null) return new List<Parameter>(0);

            var parameters = new List<Parameter>(itemParameters.Length);

            parameters.AddRange(
                itemParameters.Select(
                    parameter => new Parameter()
                    {
                        DefaultValues = parameter.DefaultValues,
                        Name = parameter.Name,
                        Nullable = parameter.Nullable,
                        ParameterType = parameter.ParameterTypeName
                    }));

            return parameters;
        }

        public static ReportExecutionServiceReference.ParameterValue[] Convert(IList<Parameter> parameters)
        {
            if (parameters == null) return new ReportExecutionServiceReference.ParameterValue[0];
            var query = from p in parameters
                        select new ReportExecutionServiceReference.ParameterValue()
                                   {
                                       Name = p.Name, Value = p.Value
                                   };

            return query.ToArray();
        }
    }
}