Skip to content

Instantly share code, notes, and snippets.

@lazarmarkov
Created July 6, 2012 08:15
Show Gist options
  • Save lazarmarkov/3058884 to your computer and use it in GitHub Desktop.
Save lazarmarkov/3058884 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using Gardio.GateKeeper.Attributes;
namespace Gardio.GateKeeper.DTO {
[ArmCommandMapping]
public class ArmCommandDTO : CommandDTO {
public String Login { get; set; }
public String Pincode { get; set; }
public ArmCommandDTO() {
}
public ArmCommandDTO(CustomUUID commandId, CustomUUID alarmUnitId, String login, String pincode)
: base(commandId, alarmUnitId) {
Login = login;
Pincode = pincode;
}
public override void Deserialize(Dictionary<String, String> form) {
base.Deserialize(form);
Login = form[Field.AuthLogin];
Pincode = form[Field.AuthPincode];
}
}
}
namespace Gardio.GateKeeper.Attributes {
class MappingAttribute : Attribute{
}
class CommandMappingAttribute : MappingAttribute{
public String CommandId { get { return "command.id"; } }
public String AlarmUnitId { get { return "unit.id"; } }
}
class ArmCommandMappingAttribute : CommandMappingAttribute{
public String AuthLogin { get { return "auth.login"; } }
public String AuthPincode { get { return "auth.pincode"; } }
}
}
using System;
using System.Collections.Generic;
using Gardio.GateKeeper.Attributes;
namespace Gardio.GateKeeper.DTO{
[CommandMapping]
public abstract class CommandDTO{
public CustomUUID CommandId { get; set; }
public CustomUUID AlarmUnitId { get; set; }
protected CommandDTO(){
}
protected CommandDTO(CustomUUID commandId, CustomUUID alarmUnitId) {
AlarmUnitId = alarmUnitId;
CommandId = commandId;
}
public virtual void Deserialize(Dictionary<String, String> form) {
CommandId = new CustomUUID(form[Field.CommandId]);
AlarmUnitId = new CustomUUID(form[Field.AlarmUnitId]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment