コード例 #1
0
        // Checks to see if an action already exists to modify the same characteristic
        // as the action passed in. If such an action exists, the method tells the
        // existing action to update its target value. Otherwise, the new action is
        // simply added to the action set.
        void AddAction(HMCharacteristicWriteAction action, HMActionSet actionSet, Action <NSError> completion)
        {
            var existingAction = ExistingActionInActionSetMatchingAction(action);

            if (existingAction != null)
            {
                existingAction.UpdateTargetValue(action.TargetValue, completion);
            }
            else
            {
                actionSet.AddAction(action, completion);
            }
        }
コード例 #2
0
        // Checks to see if there is already an HMCharacteristicWriteAction in
        // the action set that matches the provided action.
        HMCharacteristicWriteAction ExistingActionInActionSetMatchingAction(HMCharacteristicWriteAction action)
        {
            var actionSet = ActionSet;

            if (actionSet != null)
            {
                foreach (var existingAction in actionSet.Actions.Cast <HMCharacteristicWriteAction>())
                {
                    if (action.Characteristic == existingAction.Characteristic)
                    {
                        return(existingAction);
                    }
                }
            }
            return(null);
        }
コード例 #3
0
		// Checks to see if there is already an HMCharacteristicWriteAction in
		// the action set that matches the provided action.
		HMCharacteristicWriteAction ExistingActionInActionSetMatchingAction (HMCharacteristicWriteAction action)
		{
			var actionSet = ActionSet;
			if (actionSet != null) {
				foreach (var existingAction in actionSet.Actions.Cast<HMCharacteristicWriteAction>()) {
					if (action.Characteristic == existingAction.Characteristic)
						return existingAction;
				}
			}
			return null;
		}
コード例 #4
0
		// Checks to see if an action already exists to modify the same characteristic
		// as the action passed in. If such an action exists, the method tells the
		// existing action to update its target value. Otherwise, the new action is
		// simply added to the action set.
		void AddAction (HMCharacteristicWriteAction action, HMActionSet actionSet, Action<NSError>completion)
		{
			var existingAction = ExistingActionInActionSetMatchingAction (action);
			if (existingAction != null)
				existingAction.UpdateTargetValue (action.TargetValue, completion);
			else
				actionSet.AddAction (action, completion);
		}