public string SetLocalState(Type enumType, string newState) { // set local state var actionVerb = SinricActionAttribute.GetActionVerb(enumType); BasicState[actionVerb] = newState; return(newState); }
public string GetLocalState <T>() { // try to look up the type in the state dictionary and resolve to a "state" string value var actionVerb = SinricActionAttribute.GetActionVerb(typeof(T)); BasicState.TryGetValue(actionVerb, out var stateString); // if state was not previously set, will return null return(stateString); }
public string SetLocalState <T>(T stateEnumValue) where T : Enum { // newState will be the description of the enum value, ie. open or closed var actionVerb = SinricActionAttribute.GetActionVerb(typeof(T)); var newState = SinricMessageAttribute.Get(stateEnumValue).SendValue; // set local state BasicState[actionVerb] = newState; return(newState); }
static SinricDeviceBase() { // initialize Actions -> Enums dictionary var enums = typeof(StateEnums).GetNestedTypes().Where(t => t.IsEnum).ToList(); foreach (var member in enums) { // verb describing what the enum is for ie. setLockState, setContactState var actionVerb = SinricActionAttribute.GetActionVerb(member); // add an entry for the corresponding enum type ActionStateEnums[actionVerb] = member.UnderlyingSystemType; } }
public void SendNewState <T>(T stateEnumValue) where T : Enum { // actionVerb will be the description of the enum, ie. setContactState var actionVerb = SinricActionAttribute.GetActionVerb(stateEnumValue.GetType()); var newState = SetLocalState(stateEnumValue); // send a message to the server indicating new state var message = NewMessage(SinricPayload.MessageType.Event); message.Payload.SetCause(SinricCause.CauseType, SinricCause.PhysicalInteraction); message.Payload.SetValue(SinricValue.State, newState); message.Payload.Action = actionVerb; // queue for sending OutgoingMessages.Enqueue(message); }
public void SetHandler <T>(T conditionState, Action <BasicStateChangeInfo <T> > actionDelegate) { var actionVerb = SinricActionAttribute.GetActionVerb(typeof(T)); Handlers[actionVerb + ":" + SinricMessageAttribute.Get(conditionState).ReceiveValue] = actionDelegate; }
public void SetHandler <T>(Action <BasicStateChangeInfo <T> > actionDelegate) { var actionVerb = SinricActionAttribute.GetActionVerb(typeof(T)); Handlers[actionVerb] = actionDelegate; }