コード例 #1
0
        public static APIEndPointIOWarning Convert(Endpoint sourceEndPoint, Thing sourceThing, List <Location> affectedLocations, List <LocationView> affectedViews)
        {
            APIEndPointIOWarning result = new APIEndPointIOWarning();

            result.SourceEndPoint = APIEndPointAdapter.fromEndpoint(sourceEndPoint, false, false);
            result.SourceThing    = APIThingAdapter.fromThing(sourceThing, false, false);

            List <APILocation> apiLocations = new List <APILocation>();

            foreach (Location l in affectedLocations)
            {
                apiLocations.Add(APILocationAdapter.fromLocation(l, false, false));
            }
            result.AffectedLocations = apiLocations;

            List <APILocationView> apiLocationViews = new List <APILocationView>();

            foreach (LocationView v in affectedViews)
            {
                apiLocationViews.Add(APILocationViewAdapter.fromLocationView(v, false));
            }
            result.AffectedLocationViews = apiLocationViews;


            return(result);
        }
コード例 #2
0
        public static APIDevice fromDevice(Device sourceDevice, bool loadEndPoints, bool loadDeviceCommands)
        {
            APIDevice result = new APIDevice();

            result.ID                      = sourceDevice.ID;
            result.Guid                    = System.Guid.Parse(sourceDevice.GUID.ToString());
            result.KeyPass                 = System.Guid.Parse(sourceDevice.KeyPass.ToString());
            result.Title                   = sourceDevice.Title;
            result.IsConnected             = sourceDevice.IsConnected0;
            result.IsConnectedDelay        = sourceDevice.IsConnectedDelay;
            result.LastConnectionTimeStamp = sourceDevice.LastConnectionTimeStamp;
            result.UTC_Diff                = sourceDevice.UTC_Diff;

            #region Load Master Types
            result.DeviceStatus = TypesMapper.APIDeviceStatusAdapter.fromDeviceStatus(sourceDevice.DeviceStatu);
            #endregion

            #region Load Parents

            #endregion

            #region Load Childs
            #region Load Endpoints
            if (loadEndPoints)
            {
                #region EndPoints
                List <APIEndPoint> ens = new List <APIEndPoint>();
                foreach (Endpoint end in sourceDevice.Endpoints)
                {
                    APIEndPoint apiEnd = APIEndPointAdapter.fromEndpoint(end, false, false);
                    ens.Add(apiEnd);
                }
                result.EndPoints = ens;
                #endregion
            }
            #endregion

            #region Load DeviceCommands
            if (loadDeviceCommands)
            {
                #region Device Commands
                List <APIDeviceCommand> cmds = new List <APIDeviceCommand>();
                foreach (DeviceCommand cmd in sourceDevice.DeviceCommands)
                {
                    APIDeviceCommand apiCmd = APIDeviceCommandAdapter.fromDeviceCommand(cmd, false);
                    cmds.Add(apiCmd);
                }
                result.DeviceCommands = cmds;
                #endregion
            }
            #endregion
            #endregion


            return(result);
        }