public static ConnectivityMode DetectConnectivityModeForAutoDetect(Uri uri) { if (NetworkDetector.tcpConnectivityStatus == 3 && NetworkDetector.httpConnectivityStatus == 3) { NetworkDetector.Reset(); } Exception[] exceptionArray = new Exception[2]; if (NetworkDetector.IsNetTcpConnectivityAvailable(uri, out exceptionArray[0])) { return(ConnectivityMode.Tcp); } if (!NetworkDetector.IsHttpConnectivityAvailable(uri, out exceptionArray[1])) { Exception[] array = ( from e in (IEnumerable <Exception>)exceptionArray where e != null select e).ToArray <Exception>(); string reach = SRClient.UnableToReach(uri.Host, 9351, 9352); if ((int)array.Length <= 0) { throw Fx.Exception.AsError(new CommunicationException(reach), null); } throw Fx.Exception.AsError(new CommunicationException(reach, new AggregateException(array)), null); } return(ConnectivityMode.Http); }
private void HandleExternalAWACSModeDisconnect(SRSClientSession session, SRClient client) { if (_clients.ContainsKey(client.ClientGuid)) { _clients[client.ClientGuid].Coalition = 0; _clients[client.ClientGuid].Name = ""; _eventAggregator.PublishOnUIThread(new ServerStateMessage(true, new List <SRClient>(_clients.Values))); var message = new NetworkMessage { MsgType = NetworkMessage.MessageType.RADIO_UPDATE, Client = new SRClient { ClientGuid = client.ClientGuid, Coalition = client.Coalition, Name = client.Name, LastUpdate = client.LastUpdate, RadioInfo = new DCSPlayerRadioInfo(), LatLngPosition = client.LatLngPosition, Seat = client.Seat } }; MulticastAllExeceptOne(message.Encode(), session.Id); } }
public override void Validate() { if (string.IsNullOrEmpty(this.SqlExpression)) { throw new FilterException(SRClient.PropertyIsNullOrEmpty("SqlExpression")); } if (this.SqlExpression.Length > 1024) { throw new FilterException(SRClient.SqlFilterStatmentTooLong(this.SqlExpression.Length, 1024)); } Filter filter = this; while (filter.RequiresPreprocessing) { filter = filter.Preprocess(); } try { filter.Validate(); } catch (FilterException filterException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw new FilterException(exception.Message, exception); } throw; } }
private Expression GetExpression(string literal) { Expression expression; try { expression = Expression.Constant(Convert.ChangeType(literal, this.typeCode, NumberFormatInfo.InvariantInfo)); } catch (OverflowException overflowException1) { OverflowException overflowException = overflowException1; throw new OverflowException(SRClient.SQLSyntaxErrorDetailed(this.location.sLin, this.location.sCol, literal, overflowException.Message)); } catch (InvalidCastException invalidCastException1) { InvalidCastException invalidCastException = invalidCastException1; throw new InvalidCastException(SRClient.SQLSyntaxErrorDetailed(this.location.sLin, this.location.sCol, literal, invalidCastException.Message)); } catch (FormatException formatException1) { FormatException formatException = formatException1; throw new FormatException(SRClient.SQLSyntaxErrorDetailed(this.location.sLin, this.location.sCol, literal, formatException.Message)); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; throw new ArgumentException(SRClient.SQLSyntaxErrorDetailed(this.location.sLin, this.location.sCol, literal, argumentException.Message)); } return(expression); }
private void HandleExternalAWACSModeDisconnect(SRSClientSession session, SRClient client) { if (_clients.ContainsKey(client.ClientGuid)) { _clients[client.ClientGuid].Coalition = 0; _clients[client.ClientGuid].Name = ""; _eventAggregator.PublishOnUIThread(new ServerStateMessage(true, new List <SRClient>(_clients.Values))); var message = new NetworkMessage { MsgType = NetworkMessage.MessageType.UPDATE, ServerSettings = _serverSettings.ToDictionary(), Client = new SRClient { ClientGuid = client.ClientGuid, Coalition = client.Coalition, Name = client.Name, LastUpdate = client.LastUpdate, LatLngPosition = client.LatLngPosition } }; Multicast(message.Encode()); } }
private void HandleExternalAWACSModeDisconnect(SRClient client) { if (_clients.ContainsKey(client.ClientGuid)) { _clients[client.ClientGuid].Coalition = 0; _clients[client.ClientGuid].Name = ""; _eventAggregator.PublishOnUIThread(new ServerStateMessage(true, new List <SRClient>(_clients.Values))); var message = new NetworkMessage { MsgType = NetworkMessage.MessageType.UPDATE, ServerSettings = _serverSettings.ToDictionary(), Client = new SRClient { ClientGuid = client.ClientGuid, Coalition = client.Coalition, Name = client.Name, LastUpdate = client.LastUpdate, Position = client.Position } }; foreach (var clientToSent in _clients) { Send(clientToSent.Value.ClientSocket, message); } } }
public IConnection EndConnect(IAsyncResult result) { switch (this.mode) { case InternalConnectivityMode.Tcp: { return(this.TcpConnectionInitiator.EndConnect(result)); } case InternalConnectivityMode.Http: { return(this.HttpConnectionInitiator.EndConnect(result)); } case InternalConnectivityMode.Https: { return(this.HttpsConnectionInitiator.EndConnect(result)); } case InternalConnectivityMode.HttpsWebSocket: { return(this.HttpsConnectionInitiator.EndConnect(result)); } } throw new InvalidOperationException(SRClient.UnsupportedConnectivityMode(this.mode)); }
private static string FormatExceptionMessage(string responseBody, HttpStatusCode code, string reasonPhrase, string trackingId) { var exceptionMessage = string.Empty; using (var stringReader = new StringReader(responseBody)) using (var reader = XmlReader.Create(stringReader)) { try { reader.Read(); reader.ReadStartElement(RootTag); reader.ReadStartElement(HttpStatusCodeTag); reader.ReadString(); reader.ReadEndElement(); reader.ReadStartElement(DetailTag); exceptionMessage = string.Format(CultureInfo.InvariantCulture, "{0} {1}", exceptionMessage, reader.ReadString()); } catch (XmlException) { //Ignore this exception } } if (string.IsNullOrEmpty(exceptionMessage)) { exceptionMessage = SRClient.TrackableHttpExceptionMessageFormat((int)code, code.ToString(), reasonPhrase, CreateClientTrackingExceptionInfo(trackingId)); } return(exceptionMessage); }
public static Exception HandleWebException(WebException webException, int timeoutInMilliseconds, string trackingId) { var webResponse = (HttpWebResponse)webException.Response; var exceptionMessage = webException.Message; if (webResponse == null) { switch (webException.Status) { case WebExceptionStatus.RequestCanceled: case WebExceptionStatus.Timeout: exceptionMessage = SRClient.TrackableExceptionMessageFormat(SRClient.OperationRequestTimedOut(timeoutInMilliseconds), CreateClientTrackingExceptionInfo(trackingId)); return(new TimeoutException(exceptionMessage, webException)); case WebExceptionStatus.ConnectFailure: case WebExceptionStatus.NameResolutionFailure: exceptionMessage = SRClient.TrackableExceptionMessageFormat(exceptionMessage, CreateClientTrackingExceptionInfo(trackingId)); return(new MessagingCommunicationException(exceptionMessage, webException)); } } else { throw webException; } return(new MessagingException(exceptionMessage, webException)); }
private MessagingFactory CreateFactory(IEnumerable <Uri> endpoints, IEnumerable <Uri> stsEndpoints, string operationTimeout, string issuerName, string issuerKey, string sasKeyName, string sasKey, string windowsDomain, string windowsUser, SecureString windowsPassword, string oauthDomain, string oauthUser, SecureString oauthPassword, string transportType) { MessagingFactory messagingFactory; try { MessagingFactorySettings messagingFactorySetting = new MessagingFactorySettings(); if (!string.IsNullOrWhiteSpace(transportType)) { messagingFactorySetting.TransportType = (Microsoft.ServiceBus.Messaging.TransportType)Enum.Parse(typeof(Microsoft.ServiceBus.Messaging.TransportType), transportType); } messagingFactorySetting.TokenProvider = KeyValueConfigurationManager.CreateTokenProvider(stsEndpoints, issuerName, issuerKey, sasKeyName, sasKey, windowsDomain, windowsUser, windowsPassword, oauthDomain, oauthUser, oauthPassword); if (!string.IsNullOrEmpty(operationTimeout)) { messagingFactorySetting.OperationTimeout = TimeSpan.Parse(operationTimeout, CultureInfo.CurrentCulture); } messagingFactory = MessagingFactory.Create(endpoints, messagingFactorySetting); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; throw new ConfigurationErrorsException(SRClient.AppSettingsCreateFactoryWithInvalidConnectionString(argumentException.Message), argumentException); } catch (UriFormatException uriFormatException1) { UriFormatException uriFormatException = uriFormatException1; throw new ConfigurationErrorsException(SRClient.AppSettingsCreateFactoryWithInvalidConnectionString(uriFormatException.Message), uriFormatException); } return(messagingFactory); }
public void Validate() { TimeSpan timeSpan; int num; int num1; if (string.IsNullOrWhiteSpace(this.connectionProperties["Endpoint"])) { throw new ConfigurationErrorsException(SRClient.AppSettingsConfigMissingSetting("Endpoint", "Microsoft.ServiceBus.ConnectionString")); } bool flag = !string.IsNullOrWhiteSpace(this.connectionProperties["SharedSecretIssuer"]); bool flag1 = !string.IsNullOrWhiteSpace(this.connectionProperties["SharedSecretValue"]); if (flag && !flag1) { throw new ConfigurationErrorsException(SRClient.AppSettingsConfigMissingSetting("SharedSecretValue", "Microsoft.ServiceBus.ConnectionString")); } if (!flag && flag1) { throw new ConfigurationErrorsException(SRClient.AppSettingsConfigMissingSetting("SharedSecretIssuer", "Microsoft.ServiceBus.ConnectionString")); } bool flag2 = !string.IsNullOrWhiteSpace(this.connectionProperties["WindowsUsername"]); bool flag3 = !string.IsNullOrWhiteSpace(this.connectionProperties["WindowsPassword"]); if ((!flag2 || !flag3) && (flag2 || flag3)) { CultureInfo currentCulture = CultureInfo.CurrentCulture; object[] objArray = new object[] { "WindowsUsername", "WindowsPassword" }; string str = string.Format(currentCulture, "{0},{1}", objArray); throw new ConfigurationErrorsException(SRClient.AppSettingsConfigIncompleteSettingCombination("Microsoft.ServiceBus.ConnectionString", str)); } bool flag4 = !string.IsNullOrWhiteSpace(this.connectionProperties["OAuthUsername"]); bool flag5 = !string.IsNullOrWhiteSpace(this.connectionProperties["OAuthPassword"]); if ((!flag4 || !flag5) && (flag4 || flag5)) { CultureInfo cultureInfo = CultureInfo.CurrentCulture; object[] objArray1 = new object[] { "OAuthUsername", "OAuthPassword" }; string str1 = string.Format(cultureInfo, "{0},{1}", objArray1); throw new ConfigurationErrorsException(SRClient.AppSettingsConfigIncompleteSettingCombination("Microsoft.ServiceBus.ConnectionString", str1)); } string item = this.connectionProperties["OperationTimeout"]; if (!string.IsNullOrWhiteSpace(item) && !TimeSpan.TryParse(item, CultureInfo.CurrentCulture, out timeSpan)) { throw new ConfigurationErrorsException(SRClient.AppSettingsConfigSettingInvalidValue("OperationTimeout", item)); } string item1 = this.connectionProperties["RuntimePort"]; if (!string.IsNullOrWhiteSpace(item1) && !int.TryParse(item1, out num)) { throw new ConfigurationErrorsException(SRClient.AppSettingsConfigSettingInvalidValue("RuntimePort", item1)); } string item2 = this.connectionProperties["ManagementPort"]; if (!string.IsNullOrWhiteSpace(item2) && !int.TryParse(item2, out num1)) { throw new ConfigurationErrorsException(SRClient.AppSettingsConfigSettingInvalidValue("ManagementPort", item2)); } }
public static IEnumerable <Uri> GetUriList(IEnumerable <string> addresses) { if (addresses == null) { throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.ArgumentNull("addresses"); } List <Uri> uris = new List <Uri>(); foreach (string address in addresses) { Uri uri = null; try { uri = new Uri(address); } catch (UriFormatException uriFormatException) { throw new UriFormatException(SRClient.BadUriFormat(address), uriFormatException); } MessagingUtilities.ThrowIfNullAddressOrPathExists(uri, "uriAddress"); uris.Add(uri); } if (uris.Count == 0) { throw Fx.Exception.Argument("uriAddresses", SRClient.InvalidAddressPath(uris)); } return(uris); }
public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context) where TChannel : class, IChannel { if (context == null) { throw new ArgumentNullException("context"); } if (typeof(TChannel) != typeof(IInputChannel)) { throw new NotImplementedException(SRClient.UnsupportedChannelType(typeof(TChannel))); } NameSettings nameSetting = context.BindingParameters.Find <NameSettings>(); if (nameSetting == null) { nameSetting = new NameSettings(); context.BindingParameters.Add(nameSetting); } if (nameSetting.ServiceSettings.ListenerType == ListenerType.None) { nameSetting.ServiceSettings.ListenerType = (this.ConnectionMode == RelayedOnewayConnectionMode.Unicast ? ListenerType.Unicast : ListenerType.Multicast); nameSetting.ServiceSettings.TransportProtection = (this.transportProtectionEnabled ? RelayTransportProtectionMode.EndToEnd : RelayTransportProtectionMode.None); nameSetting.ServiceSettings.RelayClientAuthenticationType = this.relayClientAuthenticationType; } return((IChannelListener <TChannel>)(new RelayedOnewayChannelListener(context, this))); }
public void ExtractFrameBuffers(ByteBuffer buffer, SerializedWorker <ByteBuffer> bufferHandler) { if (this.currentFrameBuffer != null) { int num = Math.Min(this.currentFrameBuffer.Size, buffer.Length); AmqpBitConverter.WriteBytes(this.currentFrameBuffer, buffer.Buffer, buffer.Offset, num); buffer.Complete(num); if (this.currentFrameBuffer.Size == 0) { ByteBuffer byteBuffer = this.currentFrameBuffer; this.currentFrameBuffer = null; bufferHandler.DoWork(byteBuffer); } } while (buffer.Length >= AmqpCodec.MinimumFrameDecodeSize) { int frameSize = AmqpCodec.GetFrameSize(buffer); if (frameSize < AmqpCodec.MinimumFrameDecodeSize || frameSize > this.maxFrameSize) { throw new AmqpException(AmqpError.FramingError, SRClient.InvalidFrameSize(frameSize, this.maxFrameSize)); } int num1 = Math.Min(frameSize, buffer.Length); this.currentFrameBuffer = new ByteBuffer(frameSize, false); AmqpBitConverter.WriteBytes(this.currentFrameBuffer, buffer.Buffer, buffer.Offset, num1); buffer.Complete(num1); if (frameSize != num1) { break; } ByteBuffer byteBuffer1 = this.currentFrameBuffer; this.currentFrameBuffer = null; bufferHandler.DoWork(byteBuffer1); } }
protected override IEnumerator <IteratorAsyncResult <SharedChannel <TChannel> .CreateChannelAsyncResult> .AsyncStep> GetAsyncSteps() { ServiceBusUriManager serviceBusUriManager = new ServiceBusUriManager(this.sharedChannel.viaAddresses.ToList <Uri>(), false); while (true) { if (serviceBusUriManager.MoveNextUri()) { this.Channel = this.sharedChannel.innerFactory.CreateChannel(new EndpointAddress(serviceBusUriManager.Current, new AddressHeader[0]), serviceBusUriManager.Current); SharedChannel <TChannel> .CreateChannelAsyncResult createChannelAsyncResult = this; IteratorAsyncResult <SharedChannel <TChannel> .CreateChannelAsyncResult> .BeginCall beginCall = (SharedChannel <TChannel> .CreateChannelAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.Channel.BeginOpen(t, c, s); yield return(createChannelAsyncResult.CallAsync(beginCall, (SharedChannel <TChannel> .CreateChannelAsyncResult thisPtr, IAsyncResult r) => thisPtr.Channel.EndOpen(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { break; } this.Channel.Abort(); } else { if (base.LastAsyncStepException == null) { break; } if (!(base.LastAsyncStepException is TimeoutException)) { throw base.LastAsyncStepException; } throw new CommunicationException(SRClient.OpenChannelFailed(base.OriginalTimeout), base.LastAsyncStepException); } } }
public override bool CheckAccess(EndpointIdentity identity, AuthorizationContext authContext) { List <Claim> claims = new List <Claim>(); X509Extension item = null; foreach (ClaimSet claimSet in authContext.ClaimSets) { if (item == null) { X509CertificateClaimSet x509CertificateClaimSet = claimSet as X509CertificateClaimSet; if (x509CertificateClaimSet != null && x509CertificateClaimSet.X509Certificate != null) { item = x509CertificateClaimSet.X509Certificate.Extensions["2.5.29.17"]; } } foreach (Claim claim in claimSet) { if (ClaimTypes.Dns != claim.ClaimType) { continue; } claims.Add(claim); } } if (1 != claims.Count) { throw new InvalidOperationException(SRClient.InvalidDNSClaims(claims.Count)); } if (LenientDnsIdentityVerifier.CheckTopLevelDomainCompatibleness(claims[0].Resource.ToString(), identity.IdentityClaim.Resource.ToString())) { return(true); } return(SecureSocketUtil.CertificateCheckSubjectAlternativeNames(item, identity.IdentityClaim.Resource.ToString())); }
private void Validate() { if (this.Endpoints.Count == 0) { throw Fx.Exception.ArgumentNullOrEmpty("Endpoints"); } bool flag = !string.IsNullOrWhiteSpace(this.SharedSecretIssuerName); bool flag1 = !string.IsNullOrWhiteSpace(this.SharedSecretIssuerSecret); if ((!flag || !flag1) && (flag || flag1)) { throw Fx.Exception.Argument("SharedSecretIssuerName, SharedSecretIssuerSecret", SRClient.ArgumentInvalidCombination("SharedSecretIssuerName, SharedSecretIssuerSecret")); } bool flag2 = !string.IsNullOrWhiteSpace(this.SharedAccessKeyName); bool flag3 = !string.IsNullOrWhiteSpace(this.SharedAccessKey); if ((!flag2 || !flag3) && (flag2 || flag3)) { throw Fx.Exception.Argument("SharedAccessKeyName, SharedAccessSecret", SRClient.ArgumentInvalidCombination("SharedAccessKeyName, SharedAccessSecret")); } bool flag4 = !string.IsNullOrWhiteSpace(this.WindowsCredentialUsername); bool flag5 = (this.WindowsCredentialPassword == null ? false : this.WindowsCredentialPassword.Length > 0); if ((!flag4 || !flag5) && (flag4 || flag5)) { throw Fx.Exception.Argument("WindowsCredentialUsername, WindowsCredentialPassword", SRClient.ArgumentInvalidCombination("WindowsCredentialUsername, WindowsCredentialPassword")); } bool flag6 = !string.IsNullOrWhiteSpace(this.OAuthUsername); bool flag7 = (this.OAuthPassword == null ? false : this.OAuthPassword.Length > 0); if ((!flag6 || !flag7) && (flag6 || flag7)) { throw Fx.Exception.Argument("OAuthUsername, OAuthPassword", SRClient.ArgumentInvalidCombination("OAuthUsername, OAuthPassword")); } }
/// <summary>Validates the APNS credential.</summary> /// <param name="allowLocalMockPns">true to allow local mock PNS; otherwise, false.</param> protected override void OnValidate(bool allowLocalMockPns) { if (this.Properties == null) { throw new InvalidDataContractException(SRClient.ApnsRequiredPropertiesError); } if (string.IsNullOrWhiteSpace(this.Endpoint)) { throw new InvalidDataContractException(SRClient.ApnsEndpointNotSpecified); } if (string.IsNullOrWhiteSpace(this.Token) && string.IsNullOrWhiteSpace(this.ApnsCertificate)) { throw new InvalidDataContractException(SRClient.ApnsPropertiesNotSpecified); } if (!string.IsNullOrWhiteSpace(this.Token) && !string.IsNullOrWhiteSpace(this.ApnsCertificate)) { throw new InvalidDataContractException(SRClient.ApnsProvideOnlyOneCredentialType); } if (!string.IsNullOrWhiteSpace(this.Token) && (string.IsNullOrWhiteSpace(this.KeyId) || string.IsNullOrWhiteSpace(this.AppId) || string.IsNullOrWhiteSpace(this.AppName))) { throw new InvalidDataContractException(SRClient.ApnsTokenPropertiesMissing); } if (!string.IsNullOrWhiteSpace(this.Token)) { return; } try { this.NativeCertificate = this.CertificateKey == null ? new X509Certificate2(Convert.FromBase64String(this.ApnsCertificate)) : new X509Certificate2(Convert.FromBase64String(this.ApnsCertificate), this.CertificateKey); if (!this.NativeCertificate.HasPrivateKey) { throw new InvalidDataContractException(SRClient.ApnsCertificatePrivatekeyMissing); } if (DateTime.UtcNow > this.NativeCertificate.NotAfter) { throw new InvalidDataContractException(SRClient.ApnsCertificateExpired); } if (DateTime.UtcNow < this.NativeCertificate.NotBefore) { throw new InvalidDataContractException(SRClient.ApnsCertificateNotValid); } } catch (CryptographicException ex) { throw new InvalidDataContractException(SRClient.ApnsCertificateNotUsable((object)ex.Message)); } catch (FormatException ex) { throw new InvalidDataContractException(SRClient.ApnsCertificateNotUsable((object)ex.Message)); } }
public IConnection Connect(Uri uri, TimeSpan timeout) { InternalConnectivityMode internalConnectivityMode = this.cache.GetInternalConnectivityMode(uri); switch (internalConnectivityMode) { case InternalConnectivityMode.Tcp: { return(this.TcpConnectionInitiator.Connect(uri, timeout)); } case InternalConnectivityMode.Http: { return(this.HttpConnectionInitiator.Connect(uri, timeout)); } case InternalConnectivityMode.Https: { this.useWebSocket = false; return(this.HttpsConnectionInitiator.Connect(uri, timeout)); } case InternalConnectivityMode.HttpsWebSocket: { this.useWebSocket = true; return(this.HttpsConnectionInitiator.Connect(uri, timeout)); } } throw new InvalidOperationException(SRClient.UnsupportedConnectivityMode(internalConnectivityMode)); }
internal static string ExtractSolutionFromHostname(string hostname) { if (string.IsNullOrEmpty(hostname)) { throw new ArgumentException(SRClient.NullHostname); } string lowerInvariant = hostname.ToLowerInvariant(); string str = RelayEnvironment.RelayHostRootName.ToLowerInvariant(); if (!lowerInvariant.EndsWith(str, StringComparison.Ordinal)) { throw new ArgumentException(SRClient.MismatchServiceBusDomain(lowerInvariant, str)); } string str1 = lowerInvariant.Replace(str, string.Empty); char[] chrArray = new char[] { '.' }; string[] strArrays = str1.Split(chrArray, StringSplitOptions.RemoveEmptyEntries); if ((int)strArrays.Length > 1) { throw new ArgumentException(SRClient.UnsupportedServiceBusDomainPrefix(lowerInvariant, str)); } string empty = string.Empty; if ((int)strArrays.Length == 1) { empty = strArrays[0]; } return(empty); }
public IAsyncResult BeginConnect(Uri uri, TimeSpan timeout, AsyncCallback callback, object state) { this.mode = this.cache.GetInternalConnectivityMode(uri); switch (this.mode) { case InternalConnectivityMode.Tcp: { return(this.TcpConnectionInitiator.BeginConnect(uri, timeout, callback, state)); } case InternalConnectivityMode.Http: { return(this.HttpConnectionInitiator.BeginConnect(uri, timeout, callback, state)); } case InternalConnectivityMode.Https: { this.useWebSocket = false; return(this.HttpsConnectionInitiator.BeginConnect(uri, timeout, callback, state)); } case InternalConnectivityMode.HttpsWebSocket: { this.useWebSocket = true; return(this.HttpsConnectionInitiator.BeginConnect(uri, timeout, callback, state)); } } throw new InvalidOperationException(SRClient.UnsupportedConnectivityMode(this.mode)); }
public void Validate() { if (string.IsNullOrWhiteSpace(this.connectionProperties[EndpointConfigName])) { throw new ConfigurationException(SRClient.AppSettingsConfigMissingSetting(EndpointConfigName, ServiceBusConnectionKeyName)); } }
private OutgoingUDPPackets GenerateOutgoingPacket(UDPVoicePacket udpVoice, PendingPacket pendingPacket, SRClient fromClient) { var outgoingList = new HashSet <IPEndPoint>(); var guid = fromClient.ClientGuid; foreach (var client in _clientsList) { if (!client.Key.Equals(guid)) { var ip = client.Value.VoipPort; if (ip != null) { outgoingList.Add(ip); } } } if (outgoingList.Count > 0) { return(new OutgoingUDPPackets { OutgoingEndPoints = outgoingList.ToList(), ReceivedPacket = pendingPacket.RawBytes }); } else { return(null); } }
internal static void ValidateEventHubPrefetchCount(int value) { if (value < Constants.EventHubMinimumPrefetchCount) { throw FxTrace.Exception.ArgumentOutOfRange("PrefetchCount", value, SRClient.ArgumentOutOfRange(Constants.EventHubMinimumPrefetchCount, 2147483647)); } }
private void ValidateTemplateName() { if (this.TemplateName != null && this.TemplateName.Length > 200) { throw new InvalidDataContractException(SRClient.TemplateNameLengthExceedsLimit(200)); } }
internal static string ParseServiceNamespace(this Uri uri, string expectedHostnameSuffix, bool isReservedSuffixAllowed) { if (uri == null) { throw new ArgumentNullException("uri"); } if (expectedHostnameSuffix == null) { throw new ArgumentNullException("expectedHostnameSuffix"); } string host = uri.Host; string str = null; if (host.EndsWith(expectedHostnameSuffix, StringComparison.OrdinalIgnoreCase)) { str = host.Replace(expectedHostnameSuffix, string.Empty); } if (str == null) { throw new FormatException(SRClient.UnexpedtedURIHostName(uri)); } if (!ServiceBusUriHelper.ServiceBusStringExtension.IsValidServiceNamespace(str, isReservedSuffixAllowed)) { throw new FormatException(SRClient.URIServiceNameSpace(uri)); } return(str); }
private void EnsureCompatibilityLevel() { if (this.CompatibilityLevel != 20) { throw new FilterException(SRClient.NotSupportedCompatibilityLevel(this.CompatibilityLevel)); } }
public void WriteXml(XmlWriter writer) { writer.WriteStartElement("s"); writer.WriteBase64(BitConverter.GetBytes(this.version), 0, 4); writer.WriteBase64(BitConverter.GetBytes(this.GetFieldCount()), 0, 2); byte[] fieldId = new byte[3]; RequestInfo.BinarySerializationItem[] binarySerializationItems = RequestInfo.BinarySerializationItems; for (int i = 0; i < (int)binarySerializationItems.Length; i++) { RequestInfo.BinarySerializationItem binarySerializationItem = binarySerializationItems[i]; if (binarySerializationItem.ShouldSerialize(this)) { fieldId[0] = (byte)binarySerializationItem.FieldId; byte[] extractor = binarySerializationItem.Extractor(this); if ((int)extractor.Length > 65535) { throw Fx.Exception.AsError(new SerializationException(SRClient.ExceededMessagePropertySizeLimit(binarySerializationItem.FieldId.ToString(), 65535)), null); } fieldId[1] = (byte)((int)extractor.Length & 255); fieldId[2] = (byte)(((int)extractor.Length & 65280) >> 8); writer.WriteBase64(fieldId, 0, 3); writer.WriteBase64(extractor, 0, (int)extractor.Length); } } writer.Flush(); writer.WriteEndElement(); }
public uint Add(T value) { for (int i = 0; i < this.fastSegment.Length; ++i) { if (this.fastSegment[i] == null) { this.fastSegment[i] = value; return((uint)i); } } if (this.slowSegment == null) { this.slowSegment = new Dictionary <uint, T>(); } uint handle = (uint)this.fastSegment.Length; while (handle < this.maxHandle && this.slowSegment.ContainsKey(handle)) { ++handle; } if (handle == this.maxHandle) { throw new AmqpException(AmqpError.ResourceLimitExceeded, SRClient.AmqpHandleExceeded(this.maxHandle)); } this.slowSegment.Add(handle, value); return(handle); }
protected override void OnProtocolHeader(ProtocolHeader header) { Utils.Trace(TraceLevel.Frame, "RECV {0}", header); this.TransitState("R:HDR", StateTransition.ReceiveHeader); Exception exception = null; if (this.isInitiator) { if (!this.initialHeader.Equals(header)) { exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } } else { ProtocolHeader supportedHeader = this.amqpSettings.GetSupportedHeader(header); this.SendProtocolHeader(supportedHeader); if (!supportedHeader.Equals(header)) { exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } } if (exception != null) { this.CompleteOpen(false, exception); } }