protected override void ExecuteCmdlet() { switch (ParameterSetName) { case ParameterSet_LIST: var list = List.GetList(CurrentWeb); if (list == null) { throw new PSArgumentException("The provided List could not be found", nameof(List)); } WriteObject(list.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); break; case ParameterSet_SCOPE: switch (Scope) { case Enums.EventReceiverScope.Site: WriteObject(ClientContext.Site.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); break; case Enums.EventReceiverScope.Web: WriteObject(CurrentWeb.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); break; default: throw new PSArgumentException($"An event receiver cannot be addedd to the scope {Scope}", nameof(Scope)); } break; } }
protected override void ExecuteCmdlet() { if (ParameterSpecified(nameof(List))) { var list = List.GetList(CurrentWeb); WriteObject(list.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); } else { WriteObject(CurrentWeb.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); } }