コード例 #1
0
        private readonly IDataService _service; //  Data service for accessing DataTypes

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Ctor: Accepts injected dataservice
        /// </summary>
        /// <param name="dataService">The DataService instance being injected</param>
        /// <param name="dataTypeMapper">The mapper instance</param>
        public DatatypeController(IDataService dataService, IDataTypeMapper dataTypeMapper, IDataTypeLinkGenerator generator)
        {
            if (dataService == null)
                throw new ArgumentNullException("dataService", "No valid dataservice supplied to the controller.");
            if (dataTypeMapper == null)
                throw new ArgumentNullException("dataTypeMapper", "No valid mapper class supplied to the controller.");
            if (generator == null)
                throw new ArgumentNullException("generator", "No valid link generator supplied to the controller.");

            _service = dataService;
            _mapper = dataTypeMapper;
            _generator = generator;
        }
コード例 #2
0
 /// <summary>
 /// Responsibile for mapping a collection of Windfarm Data types
 /// to the set of links to be returned by the web service
 /// </summary>
 /// <param name="dataTypes">Collection of Windfarm DataTypes</param>
 /// <returns>Collection of available aggregate data types, including links</returns>
 public IEnumerable<DataType> MapTypesToLinks(IEnumerable<string> dataTypes, IDataTypeLinkGenerator generator)
 {
     var types = new List<DataType>();
     foreach (var type in dataTypes)
     {
         var uiType = new DataType()
         {
             Type = type,
             Links = generator.GenerateCollectionLinks(type)
         };
         types.Add(uiType);
     }
     return types;
 }