private ModelElement ConstructDevice(string persistentID, Dictionary <string, string> rawProperties) { var deviceRecord = new DeviceDataRecord(persistentID); deviceRecord.Properties = rawProperties; var element = ReconstituteDevice(deviceRecord); return(element); }
public bool CanReconstituteThis(DeviceDataRecord raw) { string recordType = raw.GetString(AgentKeys.RecordType); string agent = raw.GetString(AgentKeys.AgentName); bool canHandle = false; if (agent == AgentId && recordType == MODELDEVICE_RECORDTYPE) { canHandle = true; } return(canHandle); }
public ModelDevice ReconstituteDevice(DeviceDataRecord raw) { if (raw == null) { return(null); } if (!CanReconstituteThis(raw)) { return(null); } var device = new ModelDeviceSample(); ExtractCommonDevicePropertiesFromNVPairs(raw, device); device.IPAddress = raw.GetString(Consts.IPADDRESS_KEY); device.DeviceName = raw.GetString(Consts.DEVICENAME_KEY); device.Dirty = false; return(device); }
public DeviceDataRecord CreateDeviceRepresentation(ModelDevice device) { if (device == null) { return(null); } DeviceDataRecord raw = new DeviceDataRecord(device.ParentId); if (device is ModelDevice) { AddCommonDevicePropertiesAsNVPairs(device, raw); raw.AddProperty(AgentKeys.AgentName, AgentId); // mark it as mine var specificDevice = device as ModelDeviceSample; if (specificDevice != null) { AddInfoToDevice(raw, specificDevice); } } return(raw); }
private static void AddInfoToDevice(DeviceDataRecord raw, ModelDeviceSample specificDevice) { raw.AddProperty(Consts.IPADDRESS_KEY, specificDevice.IPAddress); raw.AddProperty(Consts.DEVICENAME_KEY, specificDevice.DeviceName); }
private ModelElement ConstructDevice(string persistentID, Dictionary<string, string> rawProperties) { var deviceRecord = new DeviceDataRecord(persistentID); deviceRecord.Properties = rawProperties; var element = ReconstituteDevice(deviceRecord); return element; }
public ModelDevice ReconstituteDevice(DeviceDataRecord raw) { if (raw == null) return null; if (!CanReconstituteThis(raw)) return null; var device = new ModelDeviceSample(); ExtractCommonDevicePropertiesFromNVPairs(raw, device); device.IPAddress = raw.GetString(Consts.IPADDRESS_KEY); device.DeviceName = raw.GetString(Consts.DEVICENAME_KEY); device.Dirty = false; return device; }
public DeviceDataRecord CreateDeviceRepresentation(ModelDevice device) { if (device == null) return null; DeviceDataRecord raw = new DeviceDataRecord(device.ParentId); if (device is ModelDevice) { AddCommonDevicePropertiesAsNVPairs(device, raw); raw.AddProperty(AgentKeys.AgentName, AgentId); // mark it as mine var specificDevice = device as ModelDeviceSample; if (specificDevice != null) { AddInfoToDevice(raw, specificDevice); } } return raw; }
public bool CanReconstituteThis(DeviceDataRecord raw) { string recordType = raw.GetString(AgentKeys.RecordType); string agent = raw.GetString(AgentKeys.AgentName); bool canHandle = false; if (agent == AgentId && recordType == MODELDEVICE_RECORDTYPE) { canHandle = true; } return canHandle; }