示例#1
0
        protected override Task<Driver> GetDriver(RnetDevice device)
        {
            if (device is RnetController)
                return GetDriver((RnetController)device);

            return Task.FromResult<Driver>(null);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="owner"></param>
        protected LogicalBusObject(RnetDevice owner)
            : base(owner.Bus)
        {
            Contract.Requires<ArgumentNullException>(owner != null);

            this.SetContainerContext(owner, owner);
        }
示例#3
0
 protected override Task<Driver> GetDriver(RnetDevice device)
 {
     if (device is RnetController)
         return Task.FromResult<Driver>(new ControllerDriver((RnetController)device));
     else if (device is RnetLocalDevice)
         return Task.FromResult<Driver>(new LocalDeviceDriver((RnetLocalDevice)device));
     else
         return Task.FromResult<Driver>(null);
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="target"></param>
 protected DeviceBase(RnetDevice target)
     : base(target)
 {
     Contract.Requires<ArgumentNullException>(target != null);
 }
示例#5
0
        async Task<DeviceData> FillDeviceData(IContext context, RnetDevice o, DeviceData d)
        {
            Contract.Requires<ArgumentNullException>(o != null);
            Contract.Requires<ArgumentNullException>(d != null);

            await FillObjectData(context, o, d);
            d.RnetId = o.GetId();
            d.DataUri = o.GetUri(context).UriCombine(Util.DATA_URI_SEGMENT);
            return d;
        }
示例#6
0
        /// <summary>
        /// Transforms the given <see cref="RnetDevice"/> into a <see cref="DeviceData"/> instance.
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public async Task<DeviceData> DeviceToData(IContext context, RnetDevice d)
        {
            Contract.Requires<ArgumentNullException>(d != null);

            if (d is RnetController)
                return await ControllerToData(context, (RnetController)d);
            else
                return await FillDeviceData(context, d, new DeviceData());
        }