protected override void OnValidate()

in src/Microsoft.Azure.NotificationHubs/WnsCredential.cs [125:147]


        protected override void OnValidate(bool allowLocalMockPns)
        {
            if (this.Properties == null || this.Properties.Count > 3)
            {
                throw new InvalidDataContractException(SRClient.PackageSidAndSecretKeyAreRequired);
            }

            if (this.Properties.Count < 2 || string.IsNullOrWhiteSpace(this.PackageSid) ||
                string.IsNullOrWhiteSpace(this.SecretKey))
            {
                throw new InvalidDataContractException(SRClient.PackageSidOrSecretKeyInvalid);
            }

            if (this.Properties.Count == 3 && string.IsNullOrEmpty(this["WindowsLiveEndpoint"]))
            {
                throw new InvalidDataContractException(SRClient.PackageSidAndSecretKeyAreRequired);
            }

            if (!Uri.TryCreate(this.WindowsLiveEndpoint, UriKind.Absolute, out Uri result))
            {
                throw new InvalidDataContractException(SRClient.InvalidWindowsLiveEndpoint);
            }
        }