/// <summary> /// Determine if the given state is opened (online is also opened state) /// </summary> /// <param name="state">the SynchronizationCommunicationState to test</param> /// <returns> /// return true if the given state is in opened or online state /// otherwise false /// </returns> public static bool IsOpened(SynchronizationCommunicationState state) { switch (state) { case SynchronizationCommunicationState.Opened: return(true); case SynchronizationCommunicationState.Online: return(true); default: return(false); } }
/// <summary> /// called when the State changed /// </summary> /// <param name="oldState">The last state prior to the change</param> /// <param name="newState">The new state after the change</param> /// <remarks> /// The developer does not must implement this method , this is only extenstion point /// </remarks> void ISynchronizationBusinessLogic.OnCommunicationStateChanged(SynchronizationCommunicationState oldState, SynchronizationCommunicationState newState) { #if DEBUG LogManager.GetCurrentClassLogger().Debug("OnCommunicationStateChanged {0} -> {1}", oldState, newState); #endif if (SynchronizationCommunicationStateHelper.IsOpened(newState)) { //become opened or online AddOwnDataStateDictionary(); } else if (newState != SynchronizationCommunicationState.Opening) { //become oflline , close , fault etc ClearStateDictionary(); } }
private void InvokeCommunicationStateChanged(object sender, EventArgs e) { try { businessLogic.OnCommunicationStateChanged(oldSynchronizationCommunicationState, State); } catch (Exception exception) { HelperMethods.HandleBusinessLogicException(exception); } oldSynchronizationCommunicationState = State; InvokePropertyChanged("State"); var handler = CommunicationStateChanged; if (handler == null) { return; } handler(sender, e); }