mirror of https://github.com/dapr/quickstarts.git
				
				
				
			Simplifying SmartDeviceData
This commit is contained in:
		
							parent
							
								
									8db589881f
								
							
						
					
					
						commit
						5cd415dbab
					
				| 
						 | 
				
			
			@ -23,15 +23,10 @@ class Program
 | 
			
		|||
 | 
			
		||||
        // Now you can use the actor interface to call the actor's methods.
 | 
			
		||||
        var data = new SmartDeviceData(){
 | 
			
		||||
            Name = "First Floor",
 | 
			
		||||
            Location = "First Floor",
 | 
			
		||||
            Status = "Ready",
 | 
			
		||||
            Battery = 100.0M,
 | 
			
		||||
            Temperature = 68.0M,
 | 
			
		||||
            Location = "Main Hallway",
 | 
			
		||||
            FirmwareVersion = 1.1M,
 | 
			
		||||
            SerialNo = "ABCDEFG1",
 | 
			
		||||
            MACAddress = "67-54-5D-48-8F-38",
 | 
			
		||||
            LastUpdate = DateTime.Now
 | 
			
		||||
        };
 | 
			
		||||
        Console.WriteLine($"Calling SetDataAsync on {actorType}:{actorId}...");
 | 
			
		||||
        var response = await proxySmartDevice.SetDataAsync(data);
 | 
			
		||||
| 
						 | 
				
			
			@ -45,15 +40,10 @@ class Program
 | 
			
		|||
        // Create a second actor for second device
 | 
			
		||||
        actorId = new ActorId("2");
 | 
			
		||||
        data = new SmartDeviceData(){
 | 
			
		||||
            Name = "Second Floor",
 | 
			
		||||
            Location = "Second Floor",
 | 
			
		||||
            Status = "Ready",
 | 
			
		||||
            Battery = 98.0M,
 | 
			
		||||
            Temperature = 72.0M,
 | 
			
		||||
            Location = "Bedroom",
 | 
			
		||||
            FirmwareVersion = 1.1M,
 | 
			
		||||
            SerialNo = "ABCDEFG2",
 | 
			
		||||
            MACAddress = "50-3A-32-AB-75-DF",
 | 
			
		||||
            LastUpdate = DateTime.Now
 | 
			
		||||
        };
 | 
			
		||||
        Console.WriteLine($"Calling SetDataAsync on {actorType}:{actorId}...");
 | 
			
		||||
        response = await proxySmartDevice.SetDataAsync(data);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,19 +9,13 @@ public interface ISmartDevice : IActor
 | 
			
		|||
 | 
			
		||||
public class SmartDeviceData
 | 
			
		||||
{   
 | 
			
		||||
    public string Name { get; set; } = default!;
 | 
			
		||||
    public string Status { get; set; } = default!;
 | 
			
		||||
    public decimal Battery { get; set; } = default!;
 | 
			
		||||
    public decimal Temperature { get; set; } = default!;
 | 
			
		||||
    public string Location { get; set; } = default!;
 | 
			
		||||
    public decimal FirmwareVersion { get; set; } = default!;
 | 
			
		||||
    public string SerialNo { get; set; } = default!;
 | 
			
		||||
    public string MACAddress { get; set; } = default!;
 | 
			
		||||
    public DateTime LastUpdate { get; set; } = default!;
 | 
			
		||||
 | 
			
		||||
    public override string ToString()
 | 
			
		||||
    {
 | 
			
		||||
        return $"Name: {this.Name}, Status: {this.Status}, Battery: {this.Battery}, Temperature: {this.Temperature}, Location: {this.Location}, " +
 | 
			
		||||
                $"FirmwareVersion: {this.FirmwareVersion}, SerialNo: {this.SerialNo}, MACAddress: {this.MACAddress}, LastUpdate: {this.LastUpdate}";
 | 
			
		||||
        return $"Location: {this.Location}, Status: {this.Status}, Battery: {this.Battery}, Temperature: {this.Temperature}";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue