public Inflate ( |
||
source | ||
Результат | bool |
/// <summary> /// Inflate from stream /// </summary> public virtual bool Inflate(Stream source) { // Create options collection Options = new List<TDSSessionStateOption>(); // Current position in the stream InflationSize = 0; // Read the total length uint totalLength = TDSUtilities.ReadUInt(source); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return true; } // Read the length of the string byte byteLength = (byte)source.ReadByte(); // Update offset InflationSize += sizeof(byte); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return true; } // Read the string Database = TDSUtilities.ReadString(source, (ushort)(byteLength * 2)); // Update offset InflationSize += ((uint)byteLength * 2); // one character is 2 bytes long // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return true; } // Read the length of the collation byteLength = (byte)source.ReadByte(); // Update offset InflationSize += sizeof(byte); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return true; } // Check if we have a collation if (byteLength > 0) { // Allocate collation Collation = new byte[5]; // Read collation int readBytes = source.Read(Collation, 0, Collation.Length); // Update offset InflationSize += (uint)readBytes; // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return true; } } // Read the length of the string byteLength = (byte)source.ReadByte(); // Update offset InflationSize += sizeof(byte); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return true; } // Read the string Language = TDSUtilities.ReadString(source, (ushort)(byteLength * 2)); // Update offset InflationSize += ((uint)byteLength * 2); // one character is 2 bytes long // Read while we have data while (totalLength > InflationSize) { // Read a byte that identifies the session state slot byte stateID = (byte)source.ReadByte(); // Update current position InflationSize += sizeof(byte); // Option being inflated TDSSessionStateOption option = null; // Dispatch inflation based on the state switch (stateID) { // UserOptionAll case TDSSessionStateUserOptionsOption.ID: { // Create a new option option = new TDSSessionStateUserOptionsOption(); break; } // DateFirstDateFormat case TDSSessionStateDateFirstDateFormatOption.ID: { // Create a new option option = new TDSSessionStateDateFirstDateFormatOption(); break; } // DbDeadlockPri case TDSSessionStateDeadlockPriorityOption.ID: { // Create a new option option = new TDSSessionStateDeadlockPriorityOption(); break; } // LockTimeout case TDSSessionStateLockTimeoutOption.ID: { // Create a new option option = new TDSSessionStateLockTimeoutOption(); break; } // IsoFips case TDSSessionStateISOFipsOption.ID: { // Create a new option option = new TDSSessionStateISOFipsOption(); break; } // TextSize case TDSSessionStateTextSizeOption.ID: { // Create a new option option = new TDSSessionStateTextSizeOption(); break; } // ContextInfo case TDSSessionStateContextInfoOption.ID: { // Create a new option option = new TDSSessionStateContextInfoOption(); break; } default: { // Create a new option option = new TDSSessionStateGenericOption(stateID); break; } } // Inflate the option option.Inflate(source); // Register option with the collection Options.Add(option); // Update current length with the inflation size of the data InflationSize += option.InflationSize; } // Inflation is complete return true; }
/// <summary> /// Inflate from stream /// </summary> public virtual bool Inflate(Stream source) { // Create options collection Options = new List <TDSSessionStateOption>(); // Current position in the stream InflationSize = 0; // Read the total length uint totalLength = TDSUtilities.ReadUInt(source); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return(true); } // Read the length of the string byte byteLength = (byte)source.ReadByte(); // Update offset InflationSize += sizeof(byte); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return(true); } // Read the string Database = TDSUtilities.ReadString(source, (ushort)(byteLength * 2)); // Update offset InflationSize += ((uint)byteLength * 2); // one character is 2 bytes long // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return(true); } // Read the length of the collation byteLength = (byte)source.ReadByte(); // Update offset InflationSize += sizeof(byte); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return(true); } // Check if we have a collation if (byteLength > 0) { // Allocate collation Collation = new byte[5]; // Read collation int readBytes = source.Read(Collation, 0, Collation.Length); // Update offset InflationSize += (uint)readBytes; // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return(true); } } // Read the length of the string byteLength = (byte)source.ReadByte(); // Update offset InflationSize += sizeof(byte); // Check if we still have space to read if (InflationSize >= totalLength) { // Inflation is complete return(true); } // Read the string Language = TDSUtilities.ReadString(source, (ushort)(byteLength * 2)); // Update offset InflationSize += ((uint)byteLength * 2); // one character is 2 bytes long // Read while we have data while (totalLength > InflationSize) { // Read a byte that identifies the session state slot byte stateID = (byte)source.ReadByte(); // Update current position InflationSize += sizeof(byte); // Option being inflated TDSSessionStateOption option = null; // Dispatch inflation based on the state switch (stateID) { // UserOptionAll case TDSSessionStateUserOptionsOption.ID: { // Create a new option option = new TDSSessionStateUserOptionsOption(); break; } // DateFirstDateFormat case TDSSessionStateDateFirstDateFormatOption.ID: { // Create a new option option = new TDSSessionStateDateFirstDateFormatOption(); break; } // DbDeadlockPri case TDSSessionStateDeadlockPriorityOption.ID: { // Create a new option option = new TDSSessionStateDeadlockPriorityOption(); break; } // LockTimeout case TDSSessionStateLockTimeoutOption.ID: { // Create a new option option = new TDSSessionStateLockTimeoutOption(); break; } // IsoFips case TDSSessionStateISOFipsOption.ID: { // Create a new option option = new TDSSessionStateISOFipsOption(); break; } // TextSize case TDSSessionStateTextSizeOption.ID: { // Create a new option option = new TDSSessionStateTextSizeOption(); break; } // ContextInfo case TDSSessionStateContextInfoOption.ID: { // Create a new option option = new TDSSessionStateContextInfoOption(); break; } default: { // Create a new option option = new TDSSessionStateGenericOption(stateID); break; } } // Inflate the option option.Inflate(source); // Register option with the collection Options.Add(option); // Update current length with the inflation size of the data InflationSize += option.InflationSize; } // Inflation is complete return(true); }
/// <summary> /// Inflate from stream /// </summary> public override bool Inflate(Stream source) { // Create options collection Options = new List<TDSSessionStateOption>(); // We skip feature ID because it was read by construction factory // Read the total length uint totalLength = TDSUtilities.ReadUInt(source); // Current position in the stream uint currentLength = 0; // Read while we have data while (totalLength > currentLength) { // Read a byte that identifies the session state slot byte stateID = (byte)source.ReadByte(); // Update current position currentLength += sizeof(byte); // Option being inflated TDSSessionStateOption option = null; // Dispatch inflation based on the state switch (stateID) { // UserOptionAll case TDSSessionStateUserOptionsOption.ID: { // Create a new option option = new TDSSessionStateUserOptionsOption(); break; } // DateFirstDateFormat case TDSSessionStateDateFirstDateFormatOption.ID: { // Create a new option option = new TDSSessionStateDateFirstDateFormatOption(); break; } // DbDeadlockPri case TDSSessionStateDeadlockPriorityOption.ID: { // Create a new option option = new TDSSessionStateDeadlockPriorityOption(); break; } // LockTimeout case TDSSessionStateLockTimeoutOption.ID: { // Create a new option option = new TDSSessionStateLockTimeoutOption(); break; } // IsoFips case TDSSessionStateISOFipsOption.ID: { // Create a new option option = new TDSSessionStateISOFipsOption(); break; } // TextSize case TDSSessionStateTextSizeOption.ID: { // Create a new option option = new TDSSessionStateTextSizeOption(); break; } // ContextInfo case TDSSessionStateContextInfoOption.ID: { // Create a new option option = new TDSSessionStateContextInfoOption(); break; } default: { // Create a new option option = new TDSSessionStateGenericOption(stateID); break; } } // Inflate the option option.Inflate(source); // Register option with the collection Options.Add(option); // Update current length with the inflation size of the data currentLength += option.InflationSize; } // Inflation is complete return true; }
/// <summary> /// Inflate the token /// </summary> /// <param name="source">Stream to inflate the token from</param> public override bool Inflate(Stream source) { // We skip the token identifier because it is read by token factory // Current inflation offset uint inflationOffset = 0; // Read the length of the token uint tokenLength = TDSUtilities.ReadUInt(source); // NOTE: Length is excluded from the token length // Check if we still have space left to read if (inflationOffset >= tokenLength) { // We read the whole token return(true); } // Read sequence number SequenceNumber = (int)TDSUtilities.ReadUInt(source); // Update inflation offset inflationOffset += sizeof(uint); // Check if we still have space left to read if (inflationOffset >= tokenLength) { // We read the whole token return(true); } // Read status byte status = (byte)source.ReadByte(); // Update inflation offset inflationOffset += sizeof(byte); // Check if we still have space left to read if (inflationOffset >= tokenLength) { // We read the whole token return(true); } // Parse status IsRecoverable = ((status & 0x01) != 0); // Read while we have data while (tokenLength > inflationOffset) { // Read a byte that identifies the session state slot byte stateID = (byte)source.ReadByte(); // Update current position inflationOffset += sizeof(byte); // Option being inflated TDSSessionStateOption option = null; // Dispatch inflation based on the state switch (stateID) { // UserOptionAll case TDSSessionStateUserOptionsOption.ID: { // Create a new option option = new TDSSessionStateUserOptionsOption(); break; } // DateFirstDateFormat case TDSSessionStateDateFirstDateFormatOption.ID: { // Create a new option option = new TDSSessionStateDateFirstDateFormatOption(); break; } // DbDeadlockPri case TDSSessionStateDeadlockPriorityOption.ID: { // Create a new option option = new TDSSessionStateDeadlockPriorityOption(); break; } // LockTimeout case TDSSessionStateLockTimeoutOption.ID: { // Create a new option option = new TDSSessionStateLockTimeoutOption(); break; } // IsoFips case TDSSessionStateISOFipsOption.ID: { // Create a new option option = new TDSSessionStateISOFipsOption(); break; } // TextSize case TDSSessionStateTextSizeOption.ID: { // Create a new option option = new TDSSessionStateTextSizeOption(); break; } // ContextInfo case TDSSessionStateContextInfoOption.ID: { // Create a new option option = new TDSSessionStateContextInfoOption(); break; } default: { // Create a new option option = new TDSSessionStateGenericOption(stateID); break; } } // Inflate the option option.Inflate(source); // Register option with the collection Options.Add(option); // Update current length with the inflation size of the data inflationOffset += option.InflationSize; } return(true); }
/// <summary> /// Inflate the token /// </summary> /// <param name="source">Stream to inflate the token from</param> public override bool Inflate(Stream source) { // We skip the token identifier because it is read by token factory // Current inflation offset uint inflationOffset = 0; // Read the length of the token uint tokenLength = TDSUtilities.ReadUInt(source); // NOTE: Length is excluded from the token length // Check if we still have space left to read if (inflationOffset >= tokenLength) { // We read the whole token return true; } // Read sequence number SequenceNumber = (int)TDSUtilities.ReadUInt(source); // Update inflation offset inflationOffset += sizeof(uint); // Check if we still have space left to read if (inflationOffset >= tokenLength) { // We read the whole token return true; } // Read status byte status = (byte)source.ReadByte(); // Update inflation offset inflationOffset += sizeof(byte); // Check if we still have space left to read if (inflationOffset >= tokenLength) { // We read the whole token return true; } // Parse status IsRecoverable = ((status & 0x01) != 0); // Read while we have data while (tokenLength > inflationOffset) { // Read a byte that identifies the session state slot byte stateID = (byte)source.ReadByte(); // Update current position inflationOffset += sizeof(byte); // Option being inflated TDSSessionStateOption option = null; // Dispatch inflation based on the state switch (stateID) { // UserOptionAll case TDSSessionStateUserOptionsOption.ID: { // Create a new option option = new TDSSessionStateUserOptionsOption(); break; } // DateFirstDateFormat case TDSSessionStateDateFirstDateFormatOption.ID: { // Create a new option option = new TDSSessionStateDateFirstDateFormatOption(); break; } // DbDeadlockPri case TDSSessionStateDeadlockPriorityOption.ID: { // Create a new option option = new TDSSessionStateDeadlockPriorityOption(); break; } // LockTimeout case TDSSessionStateLockTimeoutOption.ID: { // Create a new option option = new TDSSessionStateLockTimeoutOption(); break; } // IsoFips case TDSSessionStateISOFipsOption.ID: { // Create a new option option = new TDSSessionStateISOFipsOption(); break; } // TextSize case TDSSessionStateTextSizeOption.ID: { // Create a new option option = new TDSSessionStateTextSizeOption(); break; } // ContextInfo case TDSSessionStateContextInfoOption.ID: { // Create a new option option = new TDSSessionStateContextInfoOption(); break; } default: { // Create a new option option = new TDSSessionStateGenericOption(stateID); break; } } // Inflate the option option.Inflate(source); // Register option with the collection Options.Add(option); // Update current length with the inflation size of the data inflationOffset += option.InflationSize; } return true; }