/// <summary> /// Returns the set of event codes that are not in the current set. /// </summary> /// <returns></returns> public SwitchEventCodeSet Not() { var result = new SwitchEventCodeSet(); for (int i = 0; i < this.eventSet.Length; i++) { result.eventSet[i] = !this.eventSet[i]; } return(result); }
/// <summary> /// Returns a new set that includes the event codes that are in /// both the current set but not in the set passed. /// </summary> /// <param name="set">The event set to be combined.</param> public SwitchEventCodeSet Difference(SwitchEventCodeSet set) { var result = new SwitchEventCodeSet(); for (int i = 0; i < this.eventSet.Length; i++) { result.eventSet[i] = this.eventSet[i] && !set.eventSet[i]; } return(result); }
/// <summary> /// Returns a new set that includes the event codes that are in /// both the current set and the set passed. /// </summary> /// <param name="set">The event set to be combined.</param> public SwitchEventCodeSet Intersect(SwitchEventCodeSet set) { var result = new SwitchEventCodeSet(); for (int i = 0; i < this.eventSet.Length; i++) { result.eventSet[i] = this.eventSet[i] && set.eventSet[i]; } return(result); }
/// <summary> /// Returns a deep clone of the instance. /// </summary> /// <returns>The cloned instance.</returns> /// <remarks> /// <note> /// The clone of a read-only set is <b>not read-only</b>. /// </note> /// </remarks> public SwitchEventCodeSet Clone() { var clone = new SwitchEventCodeSet(); clone.isReadOnly = false; for (int i = 0; i < this.eventSet.Length; i++) { clone.eventSet[i] = this.eventSet[i]; } return(clone); }
/// <summary> /// Static constructor. /// </summary> static SwitchEventCodeSet() { // Compute the maximum possible event code. int maxCode = 0; foreach (var code in Enum.GetValues(typeof(SwitchEventCode))) { if ((int)code > maxCode) { maxCode = (int)code; } } MaxSwitchEventCode = (SwitchEventCode)maxCode; //--------------------------------------------- // Construct Empty Empty = new SwitchEventCodeSet() { IsReadOnly = true }; //--------------------------------------------- // Construct AllEvents AllEvents = new SwitchEventCodeSet(); foreach (SwitchEventCode code in Enum.GetValues(typeof(SwitchEventCode))) { if (code != SwitchEventCode.AllEvents) { AllEvents.Add(code); } } AllEvents.IsReadOnly = true; //--------------------------------------------- // Construct ChannelEvents ChannelEvents = new SwitchEventCodeSet( SwitchEventCode.ChannelCreate, SwitchEventCode.ChannelDestroy, SwitchEventCode.ChannelState, SwitchEventCode.ChannelCallState, SwitchEventCode.ChannelAnswer, SwitchEventCode.ChannelHangup, SwitchEventCode.ChannelHangupComplete, SwitchEventCode.ChannelExecute, SwitchEventCode.ChannelExecuteComplete, SwitchEventCode.ChannelHold, SwitchEventCode.ChannelUnhold, SwitchEventCode.ChannelBridge, SwitchEventCode.ChannelUnbridge, SwitchEventCode.ChannelProgress, SwitchEventCode.ChannelProgressMedia, SwitchEventCode.ChannelOutgoing, SwitchEventCode.ChannelPark, SwitchEventCode.ChannelUnpark, SwitchEventCode.ChannelAction, SwitchEventCode.ChannelOriginate, SwitchEventCode.ChannelUUID) { IsReadOnly = true }; //----------------------------------------------------------------- // Construct ImplicitEvents ImplicitEvents = new SwitchEventCodeSet( SwitchEventCode.Custom, SwitchEventCode.InboundChannel, SwitchEventCode.OutboundChannel, SwitchEventCode.SessionCrash, SwitchEventCode.ModuleLoad, SwitchEventCode.ModuleUnload, SwitchEventCode.PresenceIn, SwitchEventCode.PresenceNotifyIn, SwitchEventCode.PresenceOut, SwitchEventCode.PresenceProbe, SwitchEventCode.MessageWaiting, SwitchEventCode.MessageWaitingQuery, SwitchEventCode.Roster, SwitchEventCode.Codec, SwitchEventCode.DetectedSpeech, SwitchEventCode.DetectedTone, SwitchEventCode.PrivateCommand, SwitchEventCode.CriticalError, SwitchEventCode.AddSchedule, SwitchEventCode.RemoveSchedule, SwitchEventCode.ExecuteSchedule, SwitchEventCode.Reschedule, SwitchEventCode.SendMessage, SwitchEventCode.RequestParams, SwitchEventCode.ChannelData, SwitchEventCode.SessionHeartbeat, SwitchEventCode.ClientDisconnected, SwitchEventCode.ServerDisconnected, SwitchEventCode.SendInfo, SwitchEventCode.ReceiveInfo, SwitchEventCode.ReceiveRTCPMessage, SwitchEventCode.CallSecure, SwitchEventCode.RecordStart, SwitchEventCode.RecordStop, SwitchEventCode.PlaybackStart, SwitchEventCode.PlaybackStop, SwitchEventCode.CallUpdate, SwitchEventCode.SocketData, SwitchEventCode.MediaBugStart, SwitchEventCode.MediaBugStop) { IsReadOnly = true }; }