internal static SqlEnvChange Allocate() { SqlEnvChange retval = null; lock (_items) { while (_count > 0 && retval is null) { int count = _count; // copy the count we think we have int newCount = count - 1; // work out the new value we want // exchange _count for newCount only if _count is the same as our cached copy if (count == Interlocked.CompareExchange(ref _count, newCount, count)) { // count is now the previous value, we're the only thread that has it, so count-1 is safe to access Interlocked.Exchange(ref retval, _items[count - 1]); } else { // otherwise the count wasn't what we expected, spin the while and try again. } } } if (retval is null) { retval = new SqlEnvChange(); } return(retval); }
internal static void Release(SqlEnvChange item, [Runtime.CompilerServices.CallerMemberName] string caller = null) { if (item is null) { Debug.Fail("attenpting to release null packet"); return; } item.Clear(); { #if DEBUG if (_count > 0) { for (int index = 0; index < _count; index += 1) { if (object.ReferenceEquals(item, _items[index])) { Debug.Assert(false, $"releasing an item which already exists in the pool, count={_count}, index={index}, caller={caller}, released at={_stacks[index]}"); } } } #endif int tries = 0; while (!(item is null) && tries < 3 && _count < _capacity) { int count = _count; int newCount = count + 1; if (count == Interlocked.CompareExchange(ref _count, newCount, count)) { _items[count] = item; #if DEBUG _stacks[count] = caller; #endif item = null; } else { tries += 1; } } } }
public void OnEnvChange(SqlEnvChange rec) { switch (rec.type) { case TdsEnums.ENV_DATABASE: // If connection is not open, store the server value as the original. if (!_fConnectionOpen) { _originalDatabase = rec.newValue; } _connectionOptions.InitialCatalog = rec.newValue; break; case TdsEnums.ENV_LANG: // If connection is not open, store the server value as the original. if (!_fConnectionOpen) { _originalLanguage = rec.newValue; } _connectionOptions.CurrentLanguage = rec.newValue; break; case TdsEnums.ENV_PACKETSIZE: _connectionOptions.PacketSize = Int32.Parse(rec.newValue, CultureInfo.InvariantCulture); break; case TdsEnums.ENV_CHARSET: case TdsEnums.ENV_LOCALEID: case TdsEnums.ENV_COMPFLAGS: case TdsEnums.ENV_COLLATION: // only used on parser break; default: Debug.Assert(false, "Missed token in EnvChange!"); break; } }
internal void Clear() { type = 0; oldLength = 0; newLength = 0; length = 0; newValue = null; oldValue = null; if (newBinValue != null) { Array.Clear(newBinValue, 0, newBinValue.Length); if (newBinRented) { ArrayPool <byte> .Shared.Return(newBinValue); } newBinValue = null; } if (oldBinValue != null) { Array.Clear(oldBinValue, 0, oldBinValue.Length); if (oldBinRented) { ArrayPool <byte> .Shared.Return(oldBinValue); } oldBinValue = null; } newBinRented = false; oldBinRented = false; newLongValue = 0; oldLongValue = 0; newCollation = null; oldCollation = null; newRoutingInfo = null; Next = null; }
private bool TryReadTwoStringFields(SqlEnvChange env, TdsParserStateObject stateObj) { // Used by ProcessEnvChangeToken byte newLength, oldLength; string newValue, oldValue; if (!stateObj.TryReadByte(out newLength)) { return false; } if (!stateObj.TryReadString(newLength, out newValue)) { return false; } if (!stateObj.TryReadByte(out oldLength)) { return false; } if (!stateObj.TryReadString(oldLength, out oldValue)) { return false; } env.newLength = newLength; env.newValue = newValue; env.oldLength = oldLength; env.oldValue = oldValue; // env.length includes 1 byte type token env.length = 3 + env.newLength * 2 + env.oldLength * 2; return true; }
private bool TryReadTwoBinaryFields(SqlEnvChange env, TdsParserStateObject stateObj) { // Used by ProcessEnvChangeToken byte byteLength; if (!stateObj.TryReadByte(out byteLength)) { return false; } env.newLength = byteLength; env.newBinValue = new byte[env.newLength]; if (!stateObj.TryReadByteArray(env.newBinValue, 0, env.newLength)) { return false; } if (!stateObj.TryReadByte(out byteLength)) { return false; } env.oldLength = byteLength; env.oldBinValue = new byte[env.oldLength]; if (!stateObj.TryReadByteArray(env.oldBinValue, 0, env.oldLength)) { return false; } // env.length includes 1 byte type token env.length = 3 + env.newLength + env.oldLength; return true; }
private bool TryProcessEnvChange(int tokenLength, TdsParserStateObject stateObj, out SqlEnvChange[] sqlEnvChange) { // There could be multiple environment change messages following this token. byte byteLength; int processedLength = 0; int nvalues = 0; SqlEnvChange[] envarray = new SqlEnvChange[3]; // Why is this hardcoded to 3? sqlEnvChange = null; while (tokenLength > processedLength) { if (nvalues >= envarray.Length) { // This is a rare path. Most of the time we will have 1 or 2 envchange data streams. SqlEnvChange[] newenvarray = new SqlEnvChange[envarray.Length + 3]; for (int ii = 0; ii < envarray.Length; ii++) newenvarray[ii] = envarray[ii]; envarray = newenvarray; } SqlEnvChange env = new SqlEnvChange(); if (!stateObj.TryReadByte(out env.type)) { return false; } envarray[nvalues] = env; nvalues++; switch (env.type) { case TdsEnums.ENV_DATABASE: case TdsEnums.ENV_LANG: if (!TryReadTwoStringFields(env, stateObj)) { return false; } break; case TdsEnums.ENV_CHARSET: // we copied this behavior directly from luxor - see charset envchange // section from sqlctokn.c if (!TryReadTwoStringFields(env, stateObj)) { return false; } if (env.newValue == TdsEnums.DEFAULT_ENGLISH_CODE_PAGE_STRING) { _defaultCodePage = TdsEnums.DEFAULT_ENGLISH_CODE_PAGE_VALUE; _defaultEncoding = System.Text.Encoding.GetEncoding(_defaultCodePage); } else { Debug.Assert(env.newValue.Length > TdsEnums.CHARSET_CODE_PAGE_OFFSET, "TdsParser.ProcessEnvChange(): charset value received with length <=10"); string stringCodePage = env.newValue.Substring(TdsEnums.CHARSET_CODE_PAGE_OFFSET); _defaultCodePage = Int32.Parse(stringCodePage, NumberStyles.Integer, CultureInfo.InvariantCulture); _defaultEncoding = System.Text.Encoding.GetEncoding(_defaultCodePage); } break; case TdsEnums.ENV_PACKETSIZE: // take care of packet size right here Debug.Assert(stateObj._syncOverAsync, "Should not attempt pends in a synchronous call"); if (!TryReadTwoStringFields(env, stateObj)) { // Changing packet size does not support retry, should not pend" throw SQL.SynchronousCallMayNotPend(); } // Only set on physical state object - this should only occur on LoginAck prior // to MARS initialization! Int32 packetSize = Int32.Parse(env.newValue, NumberStyles.Integer, CultureInfo.InvariantCulture); if (_physicalStateObj.SetPacketSize(packetSize)) { // If packet size changed, we need to release our SNIPackets since // those are tied to packet size of connection. _physicalStateObj.ClearAllWritePackets(); // Update SNI ConsumerInfo value to be resulting packet size UInt32 unsignedPacketSize = (UInt32)packetSize; UInt32 result = SNINativeMethodWrapper.SNISetInfo(_physicalStateObj.Handle, SNINativeMethodWrapper.QTypes.SNI_QUERY_CONN_BUFSIZE, ref unsignedPacketSize); Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SNISetInfo"); } break; case TdsEnums.ENV_LOCALEID: if (!TryReadTwoStringFields(env, stateObj)) { return false; } _defaultLCID = Int32.Parse(env.newValue, NumberStyles.Integer, CultureInfo.InvariantCulture); break; case TdsEnums.ENV_COMPFLAGS: if (!TryReadTwoStringFields(env, stateObj)) { return false; } break; case TdsEnums.ENV_COLLATION: Debug.Assert(env.newLength == 5 || env.newLength == 0, "Improper length in new collation!"); if (!stateObj.TryReadByte(out byteLength)) { return false; } env.newLength = byteLength; if (env.newLength == 5) { if (!TryProcessCollation(stateObj, out env.newCollation)) { return false; } // give the parser the new collation values in case parameters don't specify one _defaultCollation = env.newCollation; int newCodePage = GetCodePage(env.newCollation, stateObj); if (newCodePage != _defaultCodePage) { _defaultCodePage = newCodePage; _defaultEncoding = System.Text.Encoding.GetEncoding(_defaultCodePage); } _defaultLCID = env.newCollation.LCID; } if (!stateObj.TryReadByte(out byteLength)) { return false; } env.oldLength = byteLength; Debug.Assert(env.oldLength == 5 || env.oldLength == 0, "Improper length in old collation!"); if (env.oldLength == 5) { if (!TryProcessCollation(stateObj, out env.oldCollation)) { return false; } } env.length = 3 + env.newLength + env.oldLength; break; case TdsEnums.ENV_BEGINTRAN: case TdsEnums.ENV_COMMITTRAN: case TdsEnums.ENV_ROLLBACKTRAN: if (!stateObj.TryReadByte(out byteLength)) { return false; } env.newLength = byteLength; Debug.Assert(env.newLength == 0 || env.newLength == 8, "Improper length for new transaction id!"); if (env.newLength > 0) { if (!stateObj.TryReadInt64(out env.newLongValue)) { return false; } Debug.Assert(env.newLongValue != SqlInternalTransaction.NullTransactionId, "New transaction id is null?"); // the server guarantees that zero is an invalid transaction id. } else { env.newLongValue = SqlInternalTransaction.NullTransactionId; // the server guarantees that zero is an invalid transaction id. } if (!stateObj.TryReadByte(out byteLength)) { return false; } env.oldLength = byteLength; Debug.Assert(env.oldLength == 0 || env.oldLength == 8, "Improper length for old transaction id!"); if (env.oldLength > 0) { if (!stateObj.TryReadInt64(out env.oldLongValue)) { return false; } Debug.Assert(env.oldLongValue != SqlInternalTransaction.NullTransactionId, "Old transaction id is null?"); // the server guarantees that zero is an invalid transaction id. } else { env.oldLongValue = SqlInternalTransaction.NullTransactionId; // the server guarantees that zero is an invalid transaction id. } // env.length includes 1 byte type token env.length = 3 + env.newLength + env.oldLength; break; case TdsEnums.ENV_LOGSHIPNODE: // env.newBinValue is secondary node, env.oldBinValue is witness node // comes before LoginAck so we can't assert this if (!TryReadTwoStringFields(env, stateObj)) { return false; } break; case TdsEnums.ENV_SPRESETCONNECTIONACK: if (!TryReadTwoBinaryFields(env, stateObj)) { return false; } break; case TdsEnums.ENV_USERINSTANCE: if (!TryReadTwoStringFields(env, stateObj)) { return false; } break; case TdsEnums.ENV_ROUTING: ushort newLength; if (!stateObj.TryReadUInt16(out newLength)) { return false; } env.newLength = newLength; byte protocol; if (!stateObj.TryReadByte(out protocol)) { return false; } ushort port; if (!stateObj.TryReadUInt16(out port)) { return false; } UInt16 serverLen; if (!stateObj.TryReadUInt16(out serverLen)) { return false; } string serverName; if (!stateObj.TryReadString(serverLen, out serverName)) { return false; } env.newRoutingInfo = new RoutingInfo(protocol, port, serverName); UInt16 oldLength; if (!stateObj.TryReadUInt16(out oldLength)) { return false; } if (!stateObj.TrySkipBytes(oldLength)) { return false; } env.length = env.newLength + oldLength + 5; // 5=2*sizeof(UInt16)+sizeof(byte) [token+newLength+oldLength] break; // ENVCHANGE tokens not supported by CoreCLR case TdsEnums.ENV_ENLISTDTC: case TdsEnums.ENV_DEFECTDTC: case TdsEnums.ENV_TRANSACTIONENDED: case TdsEnums.ENV_PROMOTETRANSACTION: case TdsEnums.ENV_TRANSACTIONMANAGERADDRESS: throw SQL.UnsupportedFeatureAndToken(_connHandler, ((TdsEnums.EnvChangeType)env.type).ToString()); default: Debug.Assert(false, "Unknown environment change token: " + env.type); break; } processedLength += env.length; } sqlEnvChange = envarray; return true; }
internal void OnEnvChange(SqlEnvChange rec) { Debug.Assert(!IgnoreEnvChange,"This function should not be called if IgnoreEnvChange is set!"); switch (rec.type) { case TdsEnums.ENV_DATABASE: // If connection is not open and recovery is not in progresss, store the server value as the original. if (!_fConnectionOpen && _recoverySessionData == null) { _originalDatabase = rec.newValue; } CurrentDatabase = rec.newValue; break; case TdsEnums.ENV_LANG: // If connection is not open and recovery is not in progresss, store the server value as the original. if (!_fConnectionOpen && _recoverySessionData == null) { _originalLanguage = rec.newValue; } _currentLanguage = rec.newValue; // TODO: finish this. break; case TdsEnums.ENV_PACKETSIZE: _currentPacketSize = Int32.Parse(rec.newValue, CultureInfo.InvariantCulture); break; case TdsEnums.ENV_COLLATION: if (_currentSessionData != null) { _currentSessionData._collation = rec.newCollation; } break; case TdsEnums.ENV_CHARSET: case TdsEnums.ENV_LOCALEID: case TdsEnums.ENV_COMPFLAGS: case TdsEnums.ENV_BEGINTRAN: case TdsEnums.ENV_COMMITTRAN: case TdsEnums.ENV_ROLLBACKTRAN: case TdsEnums.ENV_ENLISTDTC: case TdsEnums.ENV_DEFECTDTC: // only used on parser break; case TdsEnums.ENV_LOGSHIPNODE: if (ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly) { throw SQL.ROR_FailoverNotSupportedServer(this); } _currentFailoverPartner = rec.newValue; break; case TdsEnums.ENV_PROMOTETRANSACTION: PromotedDTCToken = rec.newBinValue; break; case TdsEnums.ENV_TRANSACTIONENDED: break; case TdsEnums.ENV_TRANSACTIONMANAGERADDRESS: // For now we skip these Yukon only env change notifications break; case TdsEnums.ENV_SPRESETCONNECTIONACK: // connection is being reset if (_currentSessionData != null) { _currentSessionData.Reset(); } break; case TdsEnums.ENV_USERINSTANCE: _instanceName = rec.newValue; break; case TdsEnums.ENV_ROUTING: if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlInternalConnectionTds.OnEnvChange> %d#, Received routing info\n", ObjectID); } if (string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || rec.newRoutingInfo.Protocol != 0 || rec.newRoutingInfo.Port == 0) { throw SQL.ROR_InvalidRoutingInfo(this); } _routingInfo = rec.newRoutingInfo; break; default: Debug.Assert(false, "Missed token in EnvChange!"); break; } }
internal void OnEnvChange(SqlEnvChange rec) { Debug.Assert(!IgnoreEnvChange, "This function should not be called if IgnoreEnvChange is set!"); switch (rec.type) { case TdsEnums.ENV_DATABASE: // If connection is not open and recovery is not in progresss, store the server value as the original. if (!_fConnectionOpen && _recoverySessionData == null) { _originalDatabase = rec.newValue; } CurrentDatabase = rec.newValue; break; case TdsEnums.ENV_LANG: // If connection is not open and recovery is not in progresss, store the server value as the original. if (!_fConnectionOpen && _recoverySessionData == null) { _originalLanguage = rec.newValue; } _currentLanguage = rec.newValue; break; case TdsEnums.ENV_PACKETSIZE: _currentPacketSize = Int32.Parse(rec.newValue, CultureInfo.InvariantCulture); break; case TdsEnums.ENV_COLLATION: if (_currentSessionData != null) { _currentSessionData._collation = rec.newCollation; } break; case TdsEnums.ENV_CHARSET: case TdsEnums.ENV_LOCALEID: case TdsEnums.ENV_COMPFLAGS: case TdsEnums.ENV_BEGINTRAN: case TdsEnums.ENV_COMMITTRAN: case TdsEnums.ENV_ROLLBACKTRAN: // only used on parser break; case TdsEnums.ENV_LOGSHIPNODE: if (ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly) { throw SQL.ROR_FailoverNotSupportedServer(this); } _currentFailoverPartner = rec.newValue; break; case TdsEnums.ENV_SPRESETCONNECTIONACK: // connection is being reset if (_currentSessionData != null) { _currentSessionData.Reset(); } break; case TdsEnums.ENV_USERINSTANCE: _instanceName = rec.newValue; break; case TdsEnums.ENV_ROUTING: if (string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || rec.newRoutingInfo.Protocol != 0 || rec.newRoutingInfo.Port == 0) { throw SQL.ROR_InvalidRoutingInfo(this); } _routingInfo = rec.newRoutingInfo; break; // ENVCHANGE tokens not supported by Project K\CoreCLR case TdsEnums.ENV_ENLISTDTC: case TdsEnums.ENV_DEFECTDTC: case TdsEnums.ENV_TRANSACTIONENDED: case TdsEnums.ENV_PROMOTETRANSACTION: case TdsEnums.ENV_TRANSACTIONMANAGERADDRESS: Debug.Assert(false, "Unsupported tokens were passed to OnEnvChange - TdsParser should have failed these"); break; default: Debug.Assert(false, "Missed token in EnvChange!"); break; } }
internal void OnEnvChange(SqlEnvChange rec) { switch (rec.type) { case 1: if (!this._fConnectionOpen) { this._originalDatabase = rec.newValue; } base.CurrentDatabase = rec.newValue; return; case 2: if (!this._fConnectionOpen) { this._originalLanguage = rec.newValue; } this._currentLanguage = rec.newValue; return; case 3: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 14: case 0x10: case 0x11: case 0x12: break; case 4: this._currentPacketSize = int.Parse(rec.newValue, CultureInfo.InvariantCulture); return; case 13: if (base.ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly) { throw SQL.ROR_FailoverNotSupportedServer(); } this._currentFailoverPartner = rec.newValue; return; case 15: base.PromotedDTCToken = rec.newBinValue; return; case 0x13: this._instanceName = rec.newValue; return; case 20: if ((string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || (rec.newRoutingInfo.Protocol != 0)) || (rec.newRoutingInfo.Port == 0)) { throw SQL.ROR_InvalidRoutingInfo(); } this._routingInfo = rec.newRoutingInfo; break; default: return; } }
internal void OnEnvChange(SqlEnvChange rec) { switch (rec.type) { case 1: if (!this._fConnectionOpen) { this._originalDatabase = rec.newValue; } base.CurrentDatabase = rec.newValue; return; case 2: if (!this._fConnectionOpen) { this._originalLanguage = rec.newValue; } this._currentLanguage = rec.newValue; return; case 3: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 14: case 0x10: case 0x11: case 0x12: break; case 4: this._currentPacketSize = int.Parse(rec.newValue, CultureInfo.InvariantCulture); return; case 13: if (base.ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly) { throw SQL.ROR_FailoverNotSupportedServer(); } this._currentFailoverPartner = rec.newValue; return; case 15: base.PromotedDTCToken = rec.newBinValue; return; case 0x13: this._instanceName = rec.newValue; return; case 20: if ((string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || (rec.newRoutingInfo.Protocol != 0)) || (rec.newRoutingInfo.Port == 0)) { throw SQL.ROR_InvalidRoutingInfo(); } this._routingInfo = rec.newRoutingInfo; break; default: return; } }
private void ReadTwoStringFields(SqlEnvChange env, TdsParserStateObject stateObj) { env.newLength = stateObj.ReadByte(); env.newValue = stateObj.ReadString(env.newLength); env.oldLength = stateObj.ReadByte(); env.oldValue = stateObj.ReadString(env.oldLength); env.length = (3 + (env.newLength * 2)) + (env.oldLength * 2); }
private void ReadTwoBinaryFields(SqlEnvChange env, TdsParserStateObject stateObj) { env.newLength = stateObj.ReadByte(); env.newBinValue = new byte[env.newLength]; stateObj.ReadByteArray(env.newBinValue, 0, env.newLength); env.oldLength = stateObj.ReadByte(); env.oldBinValue = new byte[env.oldLength]; stateObj.ReadByteArray(env.oldBinValue, 0, env.oldLength); env.length = (3 + env.newLength) + env.oldLength; }
private SqlEnvChange[] ProcessEnvChange(int tokenLength, TdsParserStateObject stateObj) { int num4 = 0; int index = 0; SqlEnvChange[] changeArray = new SqlEnvChange[3]; while (tokenLength > num4) { int num3; ushort num5; if (index >= changeArray.Length) { SqlEnvChange[] changeArray2 = new SqlEnvChange[changeArray.Length + 3]; for (int i = 0; i < changeArray.Length; i++) { changeArray2[i] = changeArray[i]; } changeArray = changeArray2; } SqlEnvChange env = new SqlEnvChange { type = stateObj.ReadByte() }; changeArray[index] = env; index++; switch (env.type) { case 1: case 2: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 3: this.ReadTwoStringFields(env, stateObj); if (!(env.newValue == "iso_1")) { break; } this._defaultCodePage = 0x4e4; this._defaultEncoding = Encoding.GetEncoding(this._defaultCodePage); goto Label_03E0; case 4: { this.ReadTwoStringFields(env, stateObj); int size = int.Parse(env.newValue, NumberStyles.Integer, CultureInfo.InvariantCulture); if (this._physicalStateObj.SetPacketSize(size)) { this._physicalStateObj._sniPacket.Dispose(); uint qInfo = (uint) size; SNINativeMethodWrapper.SNISetInfo(this._physicalStateObj.Handle, SNINativeMethodWrapper.QTypes.SNI_QUERY_CONN_BUFSIZE, ref qInfo); this._physicalStateObj._sniPacket = new SNIPacket(this._physicalStateObj.Handle); } goto Label_03E0; } case 5: this.ReadTwoStringFields(env, stateObj); this._defaultLCID = int.Parse(env.newValue, NumberStyles.Integer, CultureInfo.InvariantCulture); goto Label_03E0; case 6: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 7: env.newLength = stateObj.ReadByte(); if (env.newLength == 5) { env.newCollation = this.ProcessCollation(stateObj); this._defaultCollation = env.newCollation; int codePage = this.GetCodePage(env.newCollation, stateObj); if (codePage != this._defaultCodePage) { this._defaultCodePage = codePage; this._defaultEncoding = Encoding.GetEncoding(this._defaultCodePage); } this._defaultLCID = env.newCollation.LCID; } env.oldLength = stateObj.ReadByte(); if (env.oldLength == 5) { env.oldCollation = this.ProcessCollation(stateObj); } env.length = (3 + env.newLength) + env.oldLength; goto Label_03E0; case 8: case 9: case 10: case 11: case 12: case 0x11: env.newLength = stateObj.ReadByte(); if (env.newLength <= 0) { goto Label_02B0; } env.newLongValue = stateObj.ReadInt64(); goto Label_02B8; case 13: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 15: env.newLength = stateObj.ReadInt32(); env.newBinValue = new byte[env.newLength]; stateObj.ReadByteArray(env.newBinValue, 0, env.newLength); env.oldLength = stateObj.ReadByte(); env.length = 5 + env.newLength; goto Label_03E0; case 0x10: case 0x12: this.ReadTwoBinaryFields(env, stateObj); goto Label_03E0; case 0x13: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 20: { env.newLength = stateObj.ReadUInt16(); byte protocol = stateObj.ReadByte(); ushort port = stateObj.ReadUInt16(); ushort length = stateObj.ReadUInt16(); string servername = stateObj.ReadString(length); env.newRoutingInfo = new RoutingInfo(protocol, port, servername); num5 = stateObj.ReadUInt16(); num3 = 0; goto Label_03C9; } default: goto Label_03E0; } string s = env.newValue.Substring(2); this._defaultCodePage = int.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture); this._defaultEncoding = Encoding.GetEncoding(this._defaultCodePage); goto Label_03E0; Label_02B0: env.newLongValue = 0L; Label_02B8: env.oldLength = stateObj.ReadByte(); if (env.oldLength > 0) { env.oldLongValue = stateObj.ReadInt64(); } else { env.oldLongValue = 0L; } env.length = (3 + env.newLength) + env.oldLength; goto Label_03E0; Label_03BC: stateObj.ReadByte(); num3++; Label_03C9: if (num3 < num5) { goto Label_03BC; } env.length = (env.newLength + num5) + 5; Label_03E0: num4 += env.length; } return changeArray; }