<Rule Id="CA1721" Action="None" /> <!-- Property names should not match get methods -->
<Rule Id="CA1724" Action="None" /> <!-- Type names should not match namespaces -->
<Rule Id="CA1801" Action="None" /> <!-- Review unused parameters -->
- <Rule Id="CA1802" Action="None" /> <!-- Use literals where appropriate -->
<Rule Id="CA1806" Action="None" /> <!-- Do not ignore method results -->
<Rule Id="CA1810" Action="None" /> <!-- Initialize reference type static fields inline -->
<Rule Id="CA1812" Action="None" /> <!-- Avoid uninstantiated internal classes -->
//-------------------
// Indicator for infinite timeout when starting a timer
- internal static readonly long InfiniteTimeout = 0;
+ internal const long InfiniteTimeout = 0;
// Is this timer in an expired state?
internal bool IsExpired
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Text;
-using System.Net.Mail;
-using System.Globalization;
-using System.Collections.Generic;
using System.Diagnostics;
+using System.Text;
namespace System.Net.Mime
{
// characters allowed inside of comments
internal static readonly bool[] Ctext = CreateCharactersAllowedInComments();
- internal static readonly int Ascii7bitMaxValue = 127;
- internal static readonly char Quote = '\"';
- internal static readonly char Space = ' ';
- internal static readonly char Tab = '\t';
- internal static readonly char CR = '\r';
- internal static readonly char LF = '\n';
- internal static readonly char StartComment = '(';
- internal static readonly char EndComment = ')';
- internal static readonly char Backslash = '\\';
- internal static readonly char At = '@';
- internal static readonly char EndAngleBracket = '>';
- internal static readonly char StartAngleBracket = '<';
- internal static readonly char StartSquareBracket = '[';
- internal static readonly char EndSquareBracket = ']';
- internal static readonly char Comma = ',';
- internal static readonly char Dot = '.';
+ internal const int Ascii7bitMaxValue = 127;
+ internal const char Quote = '\"';
+ internal const char Space = ' ';
+ internal const char Tab = '\t';
+ internal const char CR = '\r';
+ internal const char LF = '\n';
+ internal const char StartComment = '(';
+ internal const char EndComment = ')';
+ internal const char Backslash = '\\';
+ internal const char At = '@';
+ internal const char EndAngleBracket = '>';
+ internal const char StartAngleBracket = '<';
+ internal const char StartSquareBracket = '[';
+ internal const char EndSquareBracket = ']';
+ internal const char Comma = ',';
+ internal const char Dot = '.';
private static readonly char[] s_colonSeparator = new char[] { ':' };
#endif
class SocketAddress
{
+#pragma warning disable CA1802 // these could be const on Windows but need to be static readonly for Unix
internal static readonly int IPv6AddressSize = SocketAddressPal.IPv6AddressSize;
internal static readonly int IPv4AddressSize = SocketAddressPal.IPv4AddressSize;
+#pragma warning restore CA1802
internal int InternalSize;
internal byte[] Buffer;
ConfigurationElement elem = (ConfigurationElement)value;
- if (prop.Name != ConfigurationProperty.s_defaultCollectionPropertyName)
+ if (prop.Name != ConfigurationProperty.DefaultCollectionPropertyName)
{
dataToWrite |= elem.SerializeToXmlElement(writer, prop.Name);
}
{
internal static readonly ConfigurationValidatorBase s_nonEmptyStringValidator = new StringValidator(1);
private static readonly ConfigurationValidatorBase s_defaultValidatorInstance = new DefaultValidator();
- internal static readonly string s_defaultCollectionPropertyName = "";
+ internal const string DefaultCollectionPropertyName = "";
private TypeConverter _converter;
private volatile bool _isConfigurationElementType;
private volatile bool _isTypeInited;
if (((options & ConfigurationPropertyOptions.IsDefaultCollection) != 0) && string.IsNullOrEmpty(name))
{
- name = s_defaultCollectionPropertyName;
+ name = DefaultCollectionPropertyName;
}
else
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class ConfigurationPropertyAttribute : Attribute
{
- // disable csharp compiler warning #0414: field assigned unused value
-#pragma warning disable 0414
- internal static readonly string s_defaultCollectionPropertyName = "";
-#pragma warning restore 0414
+ internal const string DefaultCollectionPropertyName = "";
public ConfigurationPropertyAttribute(string name)
{
}
}
}
-}
\ No newline at end of file
+}
private readonly ArrayList _items = new ArrayList();
internal ConfigurationProperty DefaultCollectionProperty
- => this[ConfigurationProperty.s_defaultCollectionPropertyName];
+ => this[ConfigurationProperty.DefaultCollectionPropertyName];
public ConfigurationProperty this[string name]
{
if (result == null)
{
PropertyInformation defaultColl =
- (PropertyInformation)BaseGet(ConfigurationProperty.s_defaultCollectionPropertyName);
+ (PropertyInformation)BaseGet(ConfigurationProperty.DefaultCollectionPropertyName);
if ((defaultColl != null) && (defaultColl.ProvidedName == propertyName)) result = defaultColl;
}
{
internal sealed class DecimalStorage : DataStorage
{
- private static readonly decimal s_defaultValue = decimal.Zero;
+ private const decimal DefaultValue = decimal.Zero;
private decimal[] _values;
internal DecimalStorage(DataColumn column)
- : base(column, typeof(decimal), s_defaultValue, StorageType.Decimal)
+ : base(column, typeof(decimal), DefaultValue, StorageType.Decimal)
{
}
switch (kind)
{
case AggregateType.Sum:
- decimal sum = s_defaultValue;
+ decimal sum = DefaultValue;
foreach (int record in records)
{
if (HasValue(record))
return _nullValue;
case AggregateType.Mean:
- decimal meanSum = s_defaultValue;
+ decimal meanSum = DefaultValue;
int meanCount = 0;
foreach (int record in records)
{
case AggregateType.Var:
case AggregateType.StDev:
int count = 0;
- double var = (double)s_defaultValue;
- double prec = (double)s_defaultValue;
- double dsum = (double)s_defaultValue;
- double sqrsum = (double)s_defaultValue;
+ double var = (double)DefaultValue;
+ double prec = (double)DefaultValue;
+ double dsum = (double)DefaultValue;
+ double sqrsum = (double)DefaultValue;
foreach (int record in records)
{
decimal valueNo1 = _values[recordNo1];
decimal valueNo2 = _values[recordNo2];
- if (valueNo1 == s_defaultValue || valueNo2 == s_defaultValue)
+ if (valueNo1 == DefaultValue || valueNo2 == DefaultValue)
{
int bitCheck = CompareBits(recordNo1, recordNo2);
if (0 != bitCheck)
}
decimal valueNo1 = _values[recordNo];
- if ((s_defaultValue == valueNo1) && !HasValue(recordNo))
+ if ((DefaultValue == valueNo1) && !HasValue(recordNo))
{
return -1;
}
System.Diagnostics.Debug.Assert(null != value, "null value");
if (_nullValue == value)
{
- _values[record] = s_defaultValue;
+ _values[record] = DefaultValue;
SetNullBit(record, true);
}
else
{
internal sealed class UInt16Storage : DataStorage
{
- private static readonly ushort s_defaultValue = ushort.MinValue;
+ private const ushort DefaultValue = ushort.MinValue;
private ushort[] _values;
public UInt16Storage(DataColumn column)
- : base(column, typeof(ushort), s_defaultValue, StorageType.UInt16)
+ : base(column, typeof(ushort), DefaultValue, StorageType.UInt16)
{
}
switch (kind)
{
case AggregateType.Sum:
- ulong sum = s_defaultValue;
+ ulong sum = DefaultValue;
foreach (int record in records)
{
if (HasValue(record))
return _nullValue;
case AggregateType.Mean:
- long meanSum = s_defaultValue;
+ long meanSum = DefaultValue;
int meanCount = 0;
foreach (int record in records)
{
ushort valueNo1 = _values[recordNo1];
ushort valueNo2 = _values[recordNo2];
- if (valueNo1 == s_defaultValue || valueNo2 == s_defaultValue)
+ if (valueNo1 == DefaultValue || valueNo2 == DefaultValue)
{
int bitCheck = CompareBits(recordNo1, recordNo2);
if (0 != bitCheck)
}
ushort valueNo1 = _values[recordNo];
- if ((s_defaultValue == valueNo1) && !HasValue(recordNo))
+ if ((DefaultValue == valueNo1) && !HasValue(recordNo))
{
return -1;
}
public override object Get(int record)
{
ushort value = _values[record];
- if (!value.Equals(s_defaultValue))
+ if (!value.Equals(DefaultValue))
{
return value;
}
System.Diagnostics.Debug.Assert(null != value, "null value");
if (_nullValue == value)
{
- _values[record] = s_defaultValue;
+ _values[record] = DefaultValue;
SetNullBit(record, true);
}
else
{
internal sealed class UInt32Storage : DataStorage
{
- private static readonly uint s_defaultValue = uint.MinValue;
+ private const uint DefaultValue = uint.MinValue;
private uint[] _values;
public UInt32Storage(DataColumn column)
- : base(column, typeof(uint), s_defaultValue, StorageType.UInt32)
+ : base(column, typeof(uint), DefaultValue, StorageType.UInt32)
{
}
switch (kind)
{
case AggregateType.Sum:
- ulong sum = s_defaultValue;
+ ulong sum = DefaultValue;
foreach (int record in records)
{
if (HasValue(record))
return _nullValue;
case AggregateType.Mean:
- long meanSum = s_defaultValue;
+ long meanSum = DefaultValue;
int meanCount = 0;
foreach (int record in records)
{
uint valueNo1 = _values[recordNo1];
uint valueNo2 = _values[recordNo2];
- if (valueNo1 == s_defaultValue || valueNo2 == s_defaultValue)
+ if (valueNo1 == DefaultValue || valueNo2 == DefaultValue)
{
int bitCheck = CompareBits(recordNo1, recordNo2);
if (0 != bitCheck)
}
uint valueNo1 = _values[recordNo];
- if ((s_defaultValue == valueNo1) && !HasValue(recordNo))
+ if ((DefaultValue == valueNo1) && !HasValue(recordNo))
{
return -1;
}
public override object Get(int record)
{
uint value = _values[record];
- if (!value.Equals(s_defaultValue))
+ if (!value.Equals(DefaultValue))
{
return value;
}
System.Diagnostics.Debug.Assert(null != value, "null value");
if (_nullValue == value)
{
- _values[record] = s_defaultValue;
+ _values[record] = DefaultValue;
SetNullBit(record, true);
}
else
{
internal sealed class UInt64Storage : DataStorage
{
- private static readonly ulong s_defaultValue = ulong.MinValue;
+ private const ulong DefaultValue = ulong.MinValue;
private ulong[] _values;
public UInt64Storage(DataColumn column)
- : base(column, typeof(ulong), s_defaultValue, StorageType.UInt64)
+ : base(column, typeof(ulong), DefaultValue, StorageType.UInt64)
{
}
switch (kind)
{
case AggregateType.Sum:
- ulong sum = s_defaultValue;
+ ulong sum = DefaultValue;
foreach (int record in records)
{
if (HasValue(record))
return _nullValue;
case AggregateType.Mean:
- decimal meanSum = s_defaultValue;
+ decimal meanSum = DefaultValue;
int meanCount = 0;
foreach (int record in records)
{
ulong valueNo1 = _values[recordNo1];
ulong valueNo2 = _values[recordNo2];
- if (valueNo1.Equals(s_defaultValue) || valueNo2.Equals(s_defaultValue))
+ if (valueNo1.Equals(DefaultValue) || valueNo2.Equals(DefaultValue))
{
int bitCheck = CompareBits(recordNo1, recordNo2);
if (0 != bitCheck)
}
ulong valueNo1 = _values[recordNo];
- if ((s_defaultValue == valueNo1) && !HasValue(recordNo))
+ if ((DefaultValue == valueNo1) && !HasValue(recordNo))
{
return -1;
}
public override object Get(int record)
{
ulong value = _values[record];
- if (!value.Equals(s_defaultValue))
+ if (!value.Equals(DefaultValue))
{
return value;
}
System.Diagnostics.Debug.Assert(null != value, "null value");
if (_nullValue == value)
{
- _values[record] = s_defaultValue;
+ _values[record] = DefaultValue;
SetNullBit(record, true);
}
else
private bool m_fNotNull; // false if null. Do not rename (binary serialization)
private byte m_value; // Do not rename (binary serialization)
- private static readonly int s_iBitNotByteMax = ~0xff;
+ private const int s_iBitNotByteMax = ~0xff;
// constructor
// construct a Null
// Constants
// Number of (100ns) ticks per time unit
- private static readonly double s_SQLTicksPerMillisecond = 0.3;
+ private const double s_SQLTicksPerMillisecond = 0.3;
public static readonly int SQLTicksPerSecond = 300;
public static readonly int SQLTicksPerMinute = SQLTicksPerSecond * 60;
public static readonly int SQLTicksPerHour = SQLTicksPerMinute * 60;
private static readonly int s_SQLTicksPerDay = SQLTicksPerHour * 24;
- private static readonly long s_ticksPerSecond = TimeSpan.TicksPerMillisecond * 1000;
+ private const long s_ticksPerSecond = TimeSpan.TicksPerMillisecond * 1000;
private static readonly DateTime s_SQLBaseDate = new DateTime(1900, 1, 1);
private static readonly long s_SQLBaseDateTicks = s_SQLBaseDate.Ticks;
- private static readonly int s_minYear = 1753; // Jan 1 1753
- private static readonly int s_maxYear = 9999; // Dec 31 9999
+ private const int s_minYear = 1753; // Jan 1 1753
+ private const int s_maxYear = 9999; // Dec 31 9999
- private static readonly int s_minDay = -53690; // Jan 1 1753
- private static readonly int s_maxDay = 2958463; // Dec 31 9999 is this many days from Jan 1 1900
- private static readonly int s_minTime = 0; // 00:00:0:000PM
+ private const int s_minDay = -53690; // Jan 1 1753
+ private const int s_maxDay = 2958463; // Dec 31 9999 is this many days from Jan 1 1900
+ private const int s_minTime = 0; // 00:00:0:000PM
private static readonly int s_maxTime = s_SQLTicksPerDay - 1; // = 25919999, 11:59:59:997PM
- private static readonly int s_dayBase = 693595; // Jan 1 1900 is this many days from Jan 1 0001
+ private const int s_dayBase = 693595; // Jan 1 1900 is this many days from Jan 1 0001
private static readonly int[] s_daysToMonth365 = new int[] {
private static readonly DateTime s_maxDateTime = DateTime.MaxValue;
private static readonly TimeSpan s_minTimeSpan = s_minDateTime.Subtract(s_SQLBaseDate);
private static readonly TimeSpan s_maxTimeSpan = s_maxDateTime.Subtract(s_SQLBaseDate);
- private static readonly string s_ISO8601_DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fff";
+ private const string s_ISO8601_DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fff";
// These formats are valid styles in SQL Server (style 9, 12, 13, 14)
// but couldn't be recognized by the default parse. Needs to call
internal uint _data3;
internal uint _data4;
- private static readonly byte s_NUMERIC_MAX_PRECISION = 38; // Maximum precision of numeric
+ private const byte s_NUMERIC_MAX_PRECISION = 38; // Maximum precision of numeric
public static readonly byte MaxPrecision = s_NUMERIC_MAX_PRECISION; // max SS precision
public static readonly byte MaxScale = s_NUMERIC_MAX_PRECISION; // max SS scale
- private static readonly byte s_bNullMask = 1; // bit mask for null bit in m_bStatus
- private static readonly byte s_bIsNull = 0; // is null
- private static readonly byte s_bNotNull = 1; // is not null
- private static readonly byte s_bReverseNullMask = unchecked((byte)~s_bNullMask);
+ private const byte s_bNullMask = 1; // bit mask for null bit in m_bStatus
+ private const byte s_bIsNull = 0; // is null
+ private const byte s_bNotNull = 1; // is not null
+ private const byte s_bReverseNullMask = unchecked((byte)~s_bNullMask);
- private static readonly byte s_bSignMask = 2; // bit mask for sign bit in m_bStatus
- private static readonly byte s_bPositive = 0; // is positive
- private static readonly byte s_bNegative = 2; // is negative
- private static readonly byte s_bReverseSignMask = unchecked((byte)~s_bSignMask);
+ private const byte s_bSignMask = 2; // bit mask for sign bit in m_bStatus
+ private const byte s_bPositive = 0; // is positive
+ private const byte s_bNegative = 2; // is negative
+ private const byte s_bReverseSignMask = unchecked((byte)~s_bSignMask);
- private static readonly uint s_uiZero = 0;
+ private const uint s_uiZero = 0;
- private static readonly int s_cNumeMax = 4;
- private static readonly long s_lInt32Base = ((long)1) << 32; // 2**32
- private static readonly ulong s_ulInt32Base = ((ulong)1) << 32; // 2**32
- private static readonly ulong s_ulInt32BaseForMod = s_ulInt32Base - 1; // 2**32 - 1 (0xFFF...FF)
+ private const int s_cNumeMax = 4;
+ private const long s_lInt32Base = ((long)1) << 32; // 2**32
+ private const ulong s_ulInt32Base = ((ulong)1) << 32; // 2**32
+ private const ulong s_ulInt32BaseForMod = s_ulInt32Base - 1; // 2**32 - 1 (0xFFF...FF)
- internal static readonly ulong s_llMax = long.MaxValue; // Max of Int64
+ internal const ulong s_llMax = long.MaxValue; // Max of Int64
- private static readonly uint s_ulBase10 = 10;
+ private const uint s_ulBase10 = 10;
- private static readonly double s_DUINT_BASE = s_lInt32Base; // 2**32
- private static readonly double s_DUINT_BASE2 = s_DUINT_BASE * s_DUINT_BASE; // 2**64
- private static readonly double s_DUINT_BASE3 = s_DUINT_BASE2 * s_DUINT_BASE; // 2**96
- private static readonly double s_DMAX_NUME = 1.0e+38; // Max value of numeric
- private static readonly uint s_DBL_DIG = 17; // Max decimal digits of double
+ private const double s_DUINT_BASE = s_lInt32Base; // 2**32
+ private const double s_DUINT_BASE2 = s_DUINT_BASE * s_DUINT_BASE; // 2**64
+ private const double s_DUINT_BASE3 = s_DUINT_BASE2 * s_DUINT_BASE; // 2**96
+ private const double s_DMAX_NUME = 1.0e+38; // Max value of numeric
+ private const uint s_DBL_DIG = 17; // Max decimal digits of double
- private static readonly byte s_cNumeDivScaleMin = 6; // Minimum result scale of numeric division
+ private const byte s_cNumeDivScaleMin = 6; // Minimum result scale of numeric division
// Array of multipliers for lAdjust and Ceiling/Floor.
private static readonly uint[] s_rgulShiftBase = new uint[9] {
// Powers of ten (used by BGetPrecI4,BGetPrecI8)
- private static readonly uint s_ulT1 = 10;
- private static readonly uint s_ulT2 = 100;
- private static readonly uint s_ulT3 = 1000;
- private static readonly uint s_ulT4 = 10000;
- private static readonly uint s_ulT5 = 100000;
- private static readonly uint s_ulT6 = 1000000;
- private static readonly uint s_ulT7 = 10000000;
- private static readonly uint s_ulT8 = 100000000;
- private static readonly uint s_ulT9 = 1000000000;
- private static readonly ulong s_dwlT10 = 10000000000;
- private static readonly ulong s_dwlT11 = 100000000000;
- private static readonly ulong s_dwlT12 = 1000000000000;
- private static readonly ulong s_dwlT13 = 10000000000000;
- private static readonly ulong s_dwlT14 = 100000000000000;
- private static readonly ulong s_dwlT15 = 1000000000000000;
- private static readonly ulong s_dwlT16 = 10000000000000000;
- private static readonly ulong s_dwlT17 = 100000000000000000;
- private static readonly ulong s_dwlT18 = 1000000000000000000;
- private static readonly ulong s_dwlT19 = 10000000000000000000;
+ private const uint s_ulT1 = 10;
+ private const uint s_ulT2 = 100;
+ private const uint s_ulT3 = 1000;
+ private const uint s_ulT4 = 10000;
+ private const uint s_ulT5 = 100000;
+ private const uint s_ulT6 = 1000000;
+ private const uint s_ulT7 = 10000000;
+ private const uint s_ulT8 = 100000000;
+ private const uint s_ulT9 = 1000000000;
+ private const ulong s_dwlT10 = 10000000000;
+ private const ulong s_dwlT11 = 100000000000;
+ private const ulong s_dwlT12 = 1000000000000;
+ private const ulong s_dwlT13 = 10000000000000;
+ private const ulong s_dwlT14 = 100000000000000;
+ private const ulong s_dwlT15 = 1000000000000000;
+ private const ulong s_dwlT16 = 10000000000000000;
+ private const ulong s_dwlT17 = 100000000000000000;
+ private const ulong s_dwlT18 = 1000000000000000000;
+ private const ulong s_dwlT19 = 10000000000000000000;
//------------------------------------------------------------------
//BGetPrecI4
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public struct SqlGuid : INullable, IComparable, IXmlSerializable
{
- private static readonly int s_sizeOfGuid = 16;
+ private const int SizeOfGuid = 16;
// Comparison orders.
private static readonly int[] s_rgiGuidOrder = new int[16]
public SqlGuid(byte[] value)
{
- if (value == null || value.Length != s_sizeOfGuid)
+ if (value == null || value.Length != SizeOfGuid)
throw new ArgumentException(SQLResource.InvalidArraySizeMessage);
- m_value = new byte[s_sizeOfGuid];
+ m_value = new byte[SizeOfGuid];
value.CopyTo(m_value, 0);
}
internal SqlGuid(byte[] value, bool ignored)
{
- if (value == null || value.Length != s_sizeOfGuid)
+ if (value == null || value.Length != SizeOfGuid)
throw new ArgumentException(SQLResource.InvalidArraySizeMessage);
m_value = value;
public byte[] ToByteArray()
{
- byte[] ret = new byte[s_sizeOfGuid];
+ byte[] ret = new byte[SizeOfGuid];
m_value.CopyTo(ret, 0);
return ret;
}
private static EComparison Compare(SqlGuid x, SqlGuid y)
{
//Swap to the correct order to be compared
- for (int i = 0; i < s_sizeOfGuid; i++)
+ for (int i = 0; i < SizeOfGuid; i++)
{
byte b1, b2;
private bool m_fNotNull; // false if null. Do not rename (binary serialization)
private short m_value; // Do not rename (binary serialization)
- private static readonly int s_MASKI2 = ~0x00007fff;
+ private const int MaskI2 = ~0x00007fff;
// constructor
// construct a Null
return Null;
int iResult = x.m_value * y.m_value;
- int iTemp = iResult & s_MASKI2;
- if (iTemp != 0 && iTemp != s_MASKI2)
+ int iTemp = iResult & MaskI2;
+ if (iTemp != 0 && iTemp != MaskI2)
throw new OverflowException(SQLResource.ArithOverflowMessage);
else
return new SqlInt16((short)iResult);
private bool m_fNotNull; // false if null, the default ctor (plain 0) will make it Null. Do not rename (binary serialization)
private int m_value; // Do not rename (binary serialization)
- private static readonly long s_iIntMin = int.MinValue; // minimum (signed) int value
- private static readonly long s_lBitNotIntMax = ~int.MaxValue;
+ private const long s_iIntMin = int.MinValue; // minimum (signed) int value
+ private const long s_lBitNotIntMax = ~int.MaxValue;
// constructor
// construct a Null
private bool m_fNotNull; // false if null. Do not rename (binary serialization)
private long m_value; // Do not rename (binary serialization)
- private static readonly long s_lLowIntMask = 0xffffffff;
- private static readonly long s_lHighIntMask = unchecked((long)0xffffffff00000000);
+ private const long s_lLowIntMask = 0xffffffff;
+ private const long s_lHighIntMask = unchecked((long)0xffffffff00000000);
// constructor
// construct a Null
private long _value;
// SQL Server stores money8 as ticks of 1/10000.
- internal static readonly int s_iMoneyScale = 4;
- private static readonly long s_lTickBase = 10000;
- private static readonly double s_dTickBase = s_lTickBase;
+ internal const int s_iMoneyScale = 4;
+ private const long s_lTickBase = 10000;
+ private const double s_dTickBase = s_lTickBase;
- private static readonly long s_minLong = unchecked((long)0x8000000000000000L) / s_lTickBase;
- private static readonly long s_maxLong = 0x7FFFFFFFFFFFFFFFL / s_lTickBase;
+ private const long s_minLong = unchecked((long)0x8000000000000000L) / s_lTickBase;
+ private const long s_maxLong = 0x7FFFFFFFFFFFFFFFL / s_lTickBase;
// constructor
// construct a Null
/// </summary>
public static readonly int BinarySort2 = 0x4000;
- private static readonly SqlCompareOptions s_iDefaultFlag =
+ private const SqlCompareOptions s_iDefaultFlag =
SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType |
SqlCompareOptions.IgnoreWidth;
- private static readonly CompareOptions s_iValidCompareOptionMask =
+ private const CompareOptions s_iValidCompareOptionMask =
CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth |
CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreKanaType;
- internal static readonly SqlCompareOptions s_iValidSqlCompareOptionMask =
+ internal const SqlCompareOptions s_iValidSqlCompareOptionMask =
SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreWidth |
SqlCompareOptions.IgnoreNonSpace | SqlCompareOptions.IgnoreKanaType |
SqlCompareOptions.BinarySort | SqlCompareOptions.BinarySort2;
- internal static readonly int s_lcidUSEnglish = 0x00000409;
- private static readonly int s_lcidBinary = 0x00008200;
+ internal const int s_lcidUSEnglish = 0x00000409;
+ private const int s_lcidBinary = 0x00008200;
// constructor
internal const int DecimalMaxPrecision28 = 28; // there are some cases in Odbc where we need that ...
internal const int DefaultCommandTimeout = 30;
- // security issue, don't rely upon static public readonly values - AS/URT 109635
- internal static readonly string StrEmpty = ""; // String.Empty
-
internal static readonly IntPtr PtrZero = new IntPtr(0); // IntPtr.Zero
internal static readonly int PtrSize = IntPtr.Size;
get
{
string value = _commandText;
- return ((null != value) ? value : ADP.StrEmpty);
+ return ((null != value) ? value : string.Empty);
}
set
{
}
return ProviderInfo.DriverName;
}
- return ADP.StrEmpty;
+ return string.Empty;
}
}
}
else
{
- sqlState = ADP.StrEmpty;
+ sqlState = string.Empty;
}
return retcode;
}
}
else
{
- sqlState = ADP.StrEmpty;
+ sqlState = string.Empty;
}
return retcode;
}
get
{
string parameterName = _parameterName;
- return ((null != parameterName) ? parameterName : ADP.StrEmpty);
+ return ((null != parameterName) ? parameterName : string.Empty);
}
set
{
get
{
string sourceColumn = _sourceColumn;
- return ((null != sourceColumn) ? sourceColumn : ADP.StrEmpty);
+ return ((null != sourceColumn) ? sourceColumn : string.Empty);
}
set
{
internal const int DefaultCommandTimeout = 30;
internal const float FailoverTimeoutStep = 0.08F; // fraction of timeout to use for fast failover connections
- // security issue, don't rely upon public static readonly values
- internal static readonly string StrEmpty = ""; // String.Empty
-
internal const int CharSize = sizeof(char);
internal static Delegate FindBuilder(MulticastDelegate mcd)
get
{
string value = _commandText;
- return ((null != value) ? value : ADP.StrEmpty);
+ return ((null != value) ? value : string.Empty);
}
set
{
{
p.SqlDbType = MetaType.GetSqlDbTypeFromOleDbType((short)r[colNames[(int)ProcParamsColIndex.DataType]],
ADP.IsNull(r[colNames[(int)ProcParamsColIndex.TypeName]]) ?
- ADP.StrEmpty :
+ string.Empty :
(string)r[colNames[(int)ProcParamsColIndex.TypeName]]);
}
// store on TdsEnums instead of SqlDbType because we do not want to expose
// this type to the user.
private static readonly MetaType s_metaSmallVarBinary = new MetaType
- (255, 255, -1, false, false, false, TdsEnums.SQLVARBINARY, TdsEnums.SQLBIGBINARY, ADP.StrEmpty, typeof(byte[]), typeof(SqlBinary), TdsEnums.SmallVarBinary, DbType.Binary, 2);
+ (255, 255, -1, false, false, false, TdsEnums.SQLVARBINARY, TdsEnums.SQLBIGBINARY, string.Empty, typeof(byte[]), typeof(SqlBinary), TdsEnums.SmallVarBinary, DbType.Binary, 2);
internal static readonly MetaType MetaImage = new MetaType
(255, 255, -1, false, true, false, TdsEnums.SQLIMAGE, TdsEnums.SQLIMAGE, MetaTypeName.IMAGE, typeof(byte[]), typeof(SqlBinary), SqlDbType.Image, DbType.Binary, 0);
{
get
{
- return (_xmlSchemaCollection?.Database ?? ADP.StrEmpty);
+ return (_xmlSchemaCollection?.Database ?? string.Empty);
}
set
{
{
get
{
- return (_xmlSchemaCollection?.OwningSchema ?? ADP.StrEmpty);
+ return (_xmlSchemaCollection?.OwningSchema ?? string.Empty);
}
set
{
{
get
{
- return (_xmlSchemaCollection?.Name ?? ADP.StrEmpty);
+ return (_xmlSchemaCollection?.Name ?? string.Empty);
}
set
{
get
{
string parameterName = _parameterName;
- return (parameterName ?? ADP.StrEmpty);
+ return (parameterName ?? string.Empty);
}
set
{
get
{
string typeName = _udtTypeName;
- return (typeName ?? ADP.StrEmpty);
+ return (typeName ?? string.Empty);
}
set
{
public string TypeName
{
- get => (_typeName ?? ADP.StrEmpty);
+ get => (_typeName ?? string.Empty);
set
{
_typeName = value;
public override string SourceColumn
{
- get => (_sourceColumn ?? ADP.StrEmpty);
+ get => (_sourceColumn ?? string.Empty);
set => _sourceColumn = value;
}
namespace System.Data.SqlClient
{
-
internal struct SNIErrorDetails
{
public string errorMessage;
}
else
{
- s = ADP.StrEmpty;
+ s = string.Empty;
}
}
else
internal int GetEncodingCharLength(string value, int numChars, int charOffset, Encoding encoding)
{
- if (value == null || value == ADP.StrEmpty)
+ if (value == null || value == string.Empty)
{
return 0;
}
if (_isYukon && (mt.SqlDbType == SqlDbType.Xml))
{
- if (((param.XmlSchemaCollectionDatabase != null) && (param.XmlSchemaCollectionDatabase != ADP.StrEmpty)) ||
- ((param.XmlSchemaCollectionOwningSchema != null) && (param.XmlSchemaCollectionOwningSchema != ADP.StrEmpty)) ||
- ((param.XmlSchemaCollectionName != null) && (param.XmlSchemaCollectionName != ADP.StrEmpty)))
+ if (((param.XmlSchemaCollectionDatabase != null) && (param.XmlSchemaCollectionDatabase != string.Empty)) ||
+ ((param.XmlSchemaCollectionOwningSchema != null) && (param.XmlSchemaCollectionOwningSchema != string.Empty)) ||
+ ((param.XmlSchemaCollectionName != null) && (param.XmlSchemaCollectionName != string.Empty)))
{
stateObj.WriteByte(1); //Schema present flag
- if ((param.XmlSchemaCollectionDatabase != null) && (param.XmlSchemaCollectionDatabase != ADP.StrEmpty))
+ if ((param.XmlSchemaCollectionDatabase != null) && (param.XmlSchemaCollectionDatabase != string.Empty))
{
tempLen = (param.XmlSchemaCollectionDatabase).Length;
stateObj.WriteByte((byte)(tempLen));
stateObj.WriteByte(0); // No dbname
}
- if ((param.XmlSchemaCollectionOwningSchema != null) && (param.XmlSchemaCollectionOwningSchema != ADP.StrEmpty))
+ if ((param.XmlSchemaCollectionOwningSchema != null) && (param.XmlSchemaCollectionOwningSchema != string.Empty))
{
tempLen = (param.XmlSchemaCollectionOwningSchema).Length;
stateObj.WriteByte((byte)(tempLen));
stateObj.WriteByte(0); // no xml schema name
}
- if ((param.XmlSchemaCollectionName != null) && (param.XmlSchemaCollectionName != ADP.StrEmpty))
+ if ((param.XmlSchemaCollectionName != null) && (param.XmlSchemaCollectionName != string.Empty))
{
tempLen = (param.XmlSchemaCollectionName).Length;
WriteShort((short)(tempLen), stateObj);
// Make sure that the current node read is an Element
if (reader.NodeType == XmlNodeType.Element
&& (reader.Depth == 0)
- && (string.CompareOrdinal(s_relationshipsTagName, reader.LocalName) == 0)
+ && (string.CompareOrdinal(RelationshipsTagName, reader.LocalName) == 0)
&& (string.CompareOrdinal(PackagingUtilities.RelationshipNamespaceUri, reader.NamespaceURI) == 0))
{
ThrowIfXmlBaseAttributeIsPresent(reader);
if (reader.NodeType == XmlNodeType.Element
&& (reader.Depth == 1)
- && (string.CompareOrdinal(s_relationshipTagName, reader.LocalName) == 0)
+ && (string.CompareOrdinal(RelationshipTagName, reader.LocalName) == 0)
&& (string.CompareOrdinal(PackagingUtilities.RelationshipNamespaceUri, reader.NamespaceURI) == 0))
{
ThrowIfXmlBaseAttributeIsPresent(reader);
int expectedAttributesCount = 3;
- string targetModeAttributeValue = reader.GetAttribute(s_targetModeAttributeName);
+ string targetModeAttributeValue = reader.GetAttribute(TargetModeAttributeName);
if (targetModeAttributeValue != null)
expectedAttributesCount++;
}
}
else
- if (!(string.CompareOrdinal(s_relationshipsTagName, reader.LocalName) == 0 && (reader.NodeType == XmlNodeType.EndElement)))
+ if (!(string.CompareOrdinal(RelationshipsTagName, reader.LocalName) == 0 && (reader.NodeType == XmlNodeType.EndElement)))
throw new XmlException(SR.UnknownTagEncountered, null, reader.LineNumber, reader.LinePosition);
}
}
{
// Attribute : TargetMode
- string targetModeAttributeValue = reader.GetAttribute(s_targetModeAttributeName);
+ string targetModeAttributeValue = reader.GetAttribute(TargetModeAttributeName);
//If the TargetMode attribute is missing in the underlying markup then we assume it to be internal
TargetMode relationshipTargetMode = TargetMode.Internal;
}
catch (ArgumentNullException argNullEx)
{
- ThrowForInvalidAttributeValue(reader, s_targetModeAttributeName, argNullEx);
+ ThrowForInvalidAttributeValue(reader, TargetModeAttributeName, argNullEx);
}
catch (ArgumentException argEx)
{
//if the targetModeAttributeValue is not Internal|External then Argument Exception will be thrown.
- ThrowForInvalidAttributeValue(reader, s_targetModeAttributeName, argEx);
+ ThrowForInvalidAttributeValue(reader, TargetModeAttributeName, argEx);
}
}
// Attribute : Target
// create a new PackageRelationship
- string targetAttributeValue = reader.GetAttribute(s_targetAttributeName);
+ string targetAttributeValue = reader.GetAttribute(TargetAttributeName);
if (string.IsNullOrEmpty(targetAttributeValue))
- throw new XmlException(SR.Format(SR.RequiredRelationshipAttributeMissing, s_targetAttributeName), null, reader.LineNumber, reader.LinePosition);
+ throw new XmlException(SR.Format(SR.RequiredRelationshipAttributeMissing, TargetAttributeName), null, reader.LineNumber, reader.LinePosition);
Uri targetUri = new Uri(targetAttributeValue, DotNetRelativeOrAbsolute);
// Attribute : Type
- string typeAttributeValue = reader.GetAttribute(s_typeAttributeName);
+ string typeAttributeValue = reader.GetAttribute(TypeAttributeName);
if (string.IsNullOrEmpty(typeAttributeValue))
- throw new XmlException(SR.Format(SR.RequiredRelationshipAttributeMissing, s_typeAttributeName), null, reader.LineNumber, reader.LinePosition);
+ throw new XmlException(SR.Format(SR.RequiredRelationshipAttributeMissing, TypeAttributeName), null, reader.LineNumber, reader.LinePosition);
// Attribute : Id
// Get the Id attribute (required attribute).
- string idAttributeValue = reader.GetAttribute(s_idAttributeName);
+ string idAttributeValue = reader.GetAttribute(IdAttributeName);
if (string.IsNullOrEmpty(idAttributeValue))
- throw new XmlException(SR.Format(SR.RequiredRelationshipAttributeMissing, s_idAttributeName), null, reader.LineNumber, reader.LinePosition);
+ throw new XmlException(SR.Format(SR.RequiredRelationshipAttributeMissing, IdAttributeName), null, reader.LineNumber, reader.LinePosition);
// Add the relationship to the collection
Add(targetUri, relationshipTargetMode, typeAttributeValue, idAttributeValue, parsing: true);
//Skips over the following - ProcessingInstruction, DocumentType, Comment, Whitespace, or SignificantWhitespace
reader.MoveToContent();
- if (reader.NodeType == XmlNodeType.EndElement && string.CompareOrdinal(s_relationshipTagName, reader.LocalName) == 0)
+ if (reader.NodeType == XmlNodeType.EndElement && string.CompareOrdinal(RelationshipTagName, reader.LocalName) == 0)
return;
else
- throw new XmlException(SR.Format(SR.ElementIsNotEmptyElement, s_relationshipTagName), null, reader.LineNumber, reader.LinePosition);
+ throw new XmlException(SR.Format(SR.ElementIsNotEmptyElement, RelationshipTagName), null, reader.LineNumber, reader.LinePosition);
}
writer.WriteStartDocument();
// start outer Relationships tag
- writer.WriteStartElement(s_relationshipsTagName, PackagingUtilities.RelationshipNamespaceUri);
+ writer.WriteStartElement(RelationshipsTagName, PackagingUtilities.RelationshipNamespaceUri);
// Write Relationship elements.
WriteRelationshipsAsXml(
{
foreach (PackageRelationship relationship in relationships)
{
- writer.WriteStartElement(s_relationshipTagName);
+ writer.WriteStartElement(RelationshipTagName);
// Write RelationshipType attribute.
- writer.WriteAttributeString(s_typeAttributeName, relationship.RelationshipType);
+ writer.WriteAttributeString(TypeAttributeName, relationship.RelationshipType);
// Write Target attribute.
// We would like to persist the uri as passed in by the user and so we use the
// the string can be converted to a valid Uri.
// Also, we are just using it here to persist the information and we are not
// resolving or fetching a resource based on this Uri.
- writer.WriteAttributeString(s_targetAttributeName, relationship.TargetUri.OriginalString);
+ writer.WriteAttributeString(TargetAttributeName, relationship.TargetUri.OriginalString);
// TargetMode is optional attribute in the markup and its default value is TargetMode="Internal"
if (alwaysWriteTargetModeAttribute || relationship.TargetMode == TargetMode.External)
- writer.WriteAttributeString(s_targetModeAttributeName, relationship.TargetMode.ToString());
+ writer.WriteAttributeString(TargetModeAttributeName, relationship.TargetMode.ToString());
// Write Id attribute.
- writer.WriteAttributeString(s_idAttributeName, relationship.Id);
+ writer.WriteAttributeString(IdAttributeName, relationship.Id);
writer.WriteEndElement();
}
//Throws an exception if the xml:base attribute is present in the Relationships XML
private void ThrowIfXmlBaseAttributeIsPresent(XmlCompatibilityReader reader)
{
- string xmlBaseAttributeValue = reader.GetAttribute(s_xmlBaseAttributeName);
+ string xmlBaseAttributeValue = reader.GetAttribute(XmlBaseAttributeName);
if (xmlBaseAttributeValue != null)
- throw new XmlException(SR.Format(SR.InvalidXmlBaseAttributePresent, s_xmlBaseAttributeName), null, reader.LineNumber, reader.LinePosition);
+ throw new XmlException(SR.Format(SR.InvalidXmlBaseAttributePresent, XmlBaseAttributeName), null, reader.LineNumber, reader.LinePosition);
}
//Throws an XML exception if the attribute value is invalid
private string GenerateRelationshipId()
{
// The timestamp consists of the first 8 hex octets of the GUID.
- return string.Concat("R", Guid.NewGuid().ToString("N").Substring(0, s_timestampLength));
+ return string.Concat("R", Guid.NewGuid().ToString("N").Substring(0, TimestampLength));
}
// If 'id' is not of the xsd type ID or is not unique for this collection, throw an exception.
//------------------------------------------------------
// segment that indicates a relationship part
- private static readonly int s_timestampLength = 16;
+ private const int TimestampLength = 16;
- private static readonly string s_relationshipsTagName = "Relationships";
- private static readonly string s_relationshipTagName = "Relationship";
- private static readonly string s_targetAttributeName = "Target";
- private static readonly string s_typeAttributeName = "Type";
- private static readonly string s_idAttributeName = "Id";
- private static readonly string s_xmlBaseAttributeName = "xml:base";
- private static readonly string s_targetModeAttributeName = "TargetMode";
+ private const string RelationshipsTagName = "Relationships";
+ private const string RelationshipTagName = "Relationship";
+ private const string TargetAttributeName = "Target";
+ private const string TypeAttributeName = "Type";
+ private const string IdAttributeName = "Id";
+ private const string XmlBaseAttributeName = "xml:base";
+ private const string TargetModeAttributeName = "TargetMode";
private static readonly string[] s_relationshipKnownNamespaces
= new string[] { PackagingUtilities.RelationshipNamespaceUri };
// Get the partname without the last segment
partName = partName.Substring(0, partName.Length - file.Length);
- partName = Path.Combine(partName, s_relationshipPartSegmentName, file); // Adding the "_rels" segment and the last segment back
+ partName = Path.Combine(partName, RelationshipPartSegmentName, file); // Adding the "_rels" segment and the last segment back
partName = partName.Replace(BackwardSlashChar, ForwardSlashChar);
- partName += s_relationshipPartExtensionName; // Adding the ".rels" extension
+ partName += RelationshipPartExtensionName; // Adding the ".rels" extension
// convert to Uri - We could use PackUriHelper.Create, but since we know that this is a
//valid Part Uri we can just call the Uri constructor.
string partNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
- Debug.Assert((path.Length - partNameWithoutExtension.Length - s_relationshipPartExtensionName.Length - 1) > 0,
+ Debug.Assert((path.Length - partNameWithoutExtension.Length - RelationshipPartExtensionName.Length - 1) > 0,
"The partname may not be well-formed");
//Get the part name without the last segment
- path = path.Substring(0, path.Length - partNameWithoutExtension.Length - s_relationshipPartExtensionName.Length - 1);
+ path = path.Substring(0, path.Length - partNameWithoutExtension.Length - RelationshipPartExtensionName.Length - 1);
- Debug.Assert((path.Length - s_relationshipPartSegmentName.Length) > 0,
+ Debug.Assert((path.Length - RelationshipPartSegmentName.Length) > 0,
"The partname may not be well-formed");
- path = path.Substring(0, path.Length - s_relationshipPartSegmentName.Length); // Removing rels segment
+ path = path.Substring(0, path.Length - RelationshipPartSegmentName.Length); // Removing rels segment
path = Path.Combine(path, partNameWithoutExtension); // Adding the last segment without ".rels" extension
path = path.Replace(BackwardSlashChar, ForwardSlashChar);
private static readonly char[] s_specialCharacterChars = { '%', '@', ',', '?' };
//Rels segment and extension
- private static readonly string s_relationshipPartSegmentName = "_rels";
- private static readonly string s_relationshipPartExtensionName = ".rels";
+ private const string RelationshipPartSegmentName = "_rels";
+ private const string RelationshipPartExtensionName = ".rels";
// Forward Slash
internal const char ForwardSlashChar = '/';
internal static readonly char[] s_forwardSlashCharArray = { ForwardSlashChar };
// Backward Slash
- internal static readonly char BackwardSlashChar = '\\';
+ internal const char BackwardSlashChar = '\\';
/// <summary>
/// pack scheme name
bool result = false;
//exit early if the partUri does not end with the relationship extension
- if (!NormalizedPartUriString.EndsWith(s_relationshipPartUpperCaseExtension, StringComparison.Ordinal))
+ if (!NormalizedPartUriString.EndsWith(RelationshipPartUpperCaseExtension, StringComparison.Ordinal))
return false;
// if uri is /_rels/.rels then we return true
Debug.Assert(segments.Length > 0 && segments[0] == string.Empty);
//If the extension was not equal to .rels, we would have exited early.
- Debug.Assert(string.CompareOrdinal((Path.GetExtension(segments[segments.Length - 1])), s_relationshipPartUpperCaseExtension) == 0);
+ Debug.Assert(string.CompareOrdinal((Path.GetExtension(segments[segments.Length - 1])), RelationshipPartUpperCaseExtension) == 0);
// must be at least two segments and the last one must end with .RELs
// and the length of the segment should be greater than just the extension.
if ((segments.Length >= 3) &&
- (segments[segments.Length - 1].Length > s_relationshipPartExtensionName.Length))
+ (segments[segments.Length - 1].Length > RelationshipPartExtensionName.Length))
{
// look for "_RELS" segment which must be second last segment
- result = (string.CompareOrdinal(segments[segments.Length - 2], s_relationshipPartUpperCaseSegmentName) == 0);
+ result = (string.CompareOrdinal(segments[segments.Length - 2], RelationshipPartUpperCaseSegmentName) == 0);
}
// In addition we need to make sure that the relationship is not created by taking another relationship
// as the source of this uri. So XXX/_rels/_rels/YYY.rels.rels would be invalid.
if (segments.Length > 3 && result == true)
{
- if ((segments[segments.Length - 1]).EndsWith(s_relsrelsUpperCaseExtension, StringComparison.Ordinal))
+ if ((segments[segments.Length - 1]).EndsWith(RelsrelsUpperCaseExtension, StringComparison.Ordinal))
{
// look for "_rels" segment in the third last segment
- if (string.CompareOrdinal(segments[segments.Length - 3], s_relationshipPartUpperCaseSegmentName) == 0)
+ if (string.CompareOrdinal(segments[segments.Length - 3], RelationshipPartUpperCaseSegmentName) == 0)
throw new ArgumentException(SR.NotAValidRelationshipPartUri);
}
}
//String Uppercase variants
- private static readonly string s_relationshipPartUpperCaseExtension = ".RELS";
- private static readonly string s_relationshipPartUpperCaseSegmentName = "_RELS";
- private static readonly string s_relsrelsUpperCaseExtension = string.Concat(s_relationshipPartUpperCaseExtension, s_relationshipPartUpperCaseExtension);
+ private const string RelationshipPartUpperCaseExtension = ".RELS";
+ private const string RelationshipPartUpperCaseSegmentName = "_RELS";
+ private const string RelsrelsUpperCaseExtension = RelationshipPartUpperCaseExtension + RelationshipPartUpperCaseExtension;
//need to use the private constructor to initialize this particular partUri as we need this in the
//IsRelationshipPartUri, that is called from the constructor.
{
internal static class PackagingUtilities
{
- internal static readonly string RelationshipNamespaceUri = "http://schemas.openxmlformats.org/package/2006/relationships";
+ internal const string RelationshipNamespaceUri = "http://schemas.openxmlformats.org/package/2006/relationships";
internal static readonly ContentType RelationshipPartContentType
= new ContentType("application/vnd.openxmlformats-package.relationships+xml");
_zipStreamManager = zipStreamManager; //initialized in the ZipPackage constructor
// The extensions are stored in the default Dictionary in their original form , but they are compared
// in a normalized manner using the ExtensionComparer.
- _defaultDictionary = new Dictionary<string, ContentType>(s_defaultDictionaryInitialSize, s_extensionEqualityComparer);
+ _defaultDictionary = new Dictionary<string, ContentType>(DefaultDictionaryInitialSize, s_extensionEqualityComparer);
// Identify the content type file or files before identifying parts and piece sequences.
// This is necessary because the name of the content type stream is not a part name and
{
get
{
- return s_contentTypesFile;
+ return ContentTypesFile;
}
}
//Lazy init: Initialize when the first part is added.
if (!_contentTypeStreamExists)
{
- _contentTypeZipArchiveEntry = _zipArchive.CreateEntry(s_contentTypesFile, _cachedCompressionLevel);
+ _contentTypeZipArchiveEntry = _zipArchive.CreateEntry(ContentTypesFile, _cachedCompressionLevel);
_contentTypeStreamExists = true;
}
else
writer.WriteStartDocument();
// write root element tag - Types
- writer.WriteStartElement(s_typesTagName, s_typesNamespaceUri);
+ writer.WriteStartElement(TypesTagName, TypesNamespaceUri);
// for each default entry
foreach (string key in _defaultDictionary.Keys)
// The part Uris are stored in the Override Dictionary in their original form , but they are compared
// in a normalized manner using the PartUriComparer
if (_overrideDictionary == null)
- _overrideDictionary = new Dictionary<PackUriHelper.ValidatedPartUri, ContentType>(s_overrideDictionaryInitialSize);
+ _overrideDictionary = new Dictionary<PackUriHelper.ValidatedPartUri, ContentType>(OverrideDictionaryInitialSize);
}
private void ParseContentTypesFile(System.Collections.ObjectModel.ReadOnlyCollection<ZipArchiveEntry> zipFiles)
// Make sure that the current node read is an Element
if ((reader.NodeType == XmlNodeType.Element)
&& (reader.Depth == 0)
- && (string.CompareOrdinal(reader.NamespaceURI, s_typesNamespaceUri) == 0)
- && (string.CompareOrdinal(reader.Name, s_typesTagName) == 0))
+ && (string.CompareOrdinal(reader.NamespaceURI, TypesNamespaceUri) == 0)
+ && (string.CompareOrdinal(reader.Name, TypesTagName) == 0))
{
//There should be a namespace Attribute present at this level.
//Also any other attribute on the <Types> tag is an error including xml: and xsi: attributes
// Currently we expect the Default and Override Tag at Depth 1
if (reader.NodeType == XmlNodeType.Element
&& reader.Depth == 1
- && (string.CompareOrdinal(reader.NamespaceURI, s_typesNamespaceUri) == 0)
- && (string.CompareOrdinal(reader.Name, s_defaultTagName) == 0))
+ && (string.CompareOrdinal(reader.NamespaceURI, TypesNamespaceUri) == 0)
+ && (string.CompareOrdinal(reader.Name, DefaultTagName) == 0))
{
ProcessDefaultTagAttributes(reader);
}
else
if (reader.NodeType == XmlNodeType.Element
&& reader.Depth == 1
- && (string.CompareOrdinal(reader.NamespaceURI, s_typesNamespaceUri) == 0)
- && (string.CompareOrdinal(reader.Name, s_overrideTagName) == 0))
+ && (string.CompareOrdinal(reader.NamespaceURI, TypesNamespaceUri) == 0)
+ && (string.CompareOrdinal(reader.Name, OverrideTagName) == 0))
{
ProcessOverrideTagAttributes(reader);
}
else
- if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 0 && string.CompareOrdinal(reader.Name, s_typesTagName) == 0)
+ if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 0 && string.CompareOrdinal(reader.Name, TypesTagName) == 0)
continue;
else
{
{
foreach (ZipArchiveEntry zipFileInfo in zipFiles)
{
- if (zipFileInfo.Name.ToUpperInvariant().StartsWith(s_contentTypesFileUpperInvariant, StringComparison.Ordinal))
+ if (zipFileInfo.Name.ToUpperInvariant().StartsWith(ContentTypesFileUpperInvariant, StringComparison.Ordinal))
{
// Atomic name.
if (zipFileInfo.Name.Length == ContentTypeFileName.Length)
// get the required Extension and ContentType attributes
- string extensionAttributeValue = reader.GetAttribute(s_extensionAttributeName);
- ValidateXmlAttribute(s_extensionAttributeName, extensionAttributeValue, s_defaultTagName, reader);
+ string extensionAttributeValue = reader.GetAttribute(ExtensionAttributeName);
+ ValidateXmlAttribute(ExtensionAttributeName, extensionAttributeValue, DefaultTagName, reader);
- string contentTypeAttributeValue = reader.GetAttribute(s_contentTypeAttributeName);
- ThrowIfXmlAttributeMissing(s_contentTypeAttributeName, contentTypeAttributeValue, s_defaultTagName, reader);
+ string contentTypeAttributeValue = reader.GetAttribute(ContentTypeAttributeName);
+ ThrowIfXmlAttributeMissing(ContentTypeAttributeName, contentTypeAttributeValue, DefaultTagName, reader);
// The extensions are stored in the Default Dictionary in their original form , but they are compared
// in a normalized manner using the ExtensionComparer.
PackUriHelper.ValidatedPartUri temporaryUri = PackUriHelper.ValidatePartUri(
- new Uri(s_temporaryPartNameWithoutExtension + extensionAttributeValue, UriKind.Relative));
+ new Uri(TemporaryPartNameWithoutExtension + extensionAttributeValue, UriKind.Relative));
_defaultDictionary.Add(temporaryUri.PartUriExtension, new ContentType(contentTypeAttributeValue));
//Skip the EndElement for Default Tag
if (!reader.IsEmptyElement)
- ProcessEndElement(reader, s_defaultTagName);
+ ProcessEndElement(reader, DefaultTagName);
}
// Process the attributes for the Default tag
// get the required Extension and ContentType attributes
- string partNameAttributeValue = reader.GetAttribute(s_partNameAttributeName);
- ValidateXmlAttribute(s_partNameAttributeName, partNameAttributeValue, s_overrideTagName, reader);
+ string partNameAttributeValue = reader.GetAttribute(PartNameAttributeName);
+ ValidateXmlAttribute(PartNameAttributeName, partNameAttributeValue, OverrideTagName, reader);
- string contentTypeAttributeValue = reader.GetAttribute(s_contentTypeAttributeName);
- ThrowIfXmlAttributeMissing(s_contentTypeAttributeName, contentTypeAttributeValue, s_overrideTagName, reader);
+ string contentTypeAttributeValue = reader.GetAttribute(ContentTypeAttributeName);
+ ThrowIfXmlAttributeMissing(ContentTypeAttributeName, contentTypeAttributeValue, OverrideTagName, reader);
PackUriHelper.ValidatedPartUri partUri = PackUriHelper.ValidatePartUri(new Uri(partNameAttributeValue, UriKind.Relative));
//Skip the EndElement for Override Tag
if (!reader.IsEmptyElement)
- ProcessEndElement(reader, s_overrideTagName);
+ ProcessEndElement(reader, OverrideTagName);
}
//If End element is present for Relationship then we process it
private void WriteOverrideElement(XmlWriter xmlWriter, PackUriHelper.ValidatedPartUri partUri, ContentType contentType)
{
- xmlWriter.WriteStartElement(s_overrideTagName);
- xmlWriter.WriteAttributeString(s_partNameAttributeName,
+ xmlWriter.WriteStartElement(OverrideTagName);
+ xmlWriter.WriteAttributeString(PartNameAttributeName,
partUri.PartUriString);
- xmlWriter.WriteAttributeString(s_contentTypeAttributeName, contentType.ToString());
+ xmlWriter.WriteAttributeString(ContentTypeAttributeName, contentType.ToString());
xmlWriter.WriteEndElement();
}
private void WriteDefaultElement(XmlWriter xmlWriter, string extension, ContentType contentType)
{
- xmlWriter.WriteStartElement(s_defaultTagName);
- xmlWriter.WriteAttributeString(s_extensionAttributeName, extension);
- xmlWriter.WriteAttributeString(s_contentTypeAttributeName, contentType.ToString());
+ xmlWriter.WriteStartElement(DefaultTagName);
+ xmlWriter.WriteAttributeString(ExtensionAttributeName, extension);
+ xmlWriter.WriteAttributeString(ContentTypeAttributeName, contentType.ToString());
xmlWriter.WriteEndElement();
}
private bool _contentTypeStreamExists;
private bool _dirty;
private CompressionLevel _cachedCompressionLevel;
- private static readonly string s_contentTypesFile = "[Content_Types].xml";
- private static readonly string s_contentTypesFileUpperInvariant = "[CONTENT_TYPES].XML";
- private static readonly int s_defaultDictionaryInitialSize = 16;
- private static readonly int s_overrideDictionaryInitialSize = 8;
-
+ private const string ContentTypesFile = "[Content_Types].xml";
+ private const string ContentTypesFileUpperInvariant = "[CONTENT_TYPES].XML";
+ private const int DefaultDictionaryInitialSize = 16;
+ private const int OverrideDictionaryInitialSize = 8;
//Xml tag specific strings for the Content Type file
- private static readonly string s_typesNamespaceUri = "http://schemas.openxmlformats.org/package/2006/content-types";
- private static readonly string s_typesTagName = "Types";
- private static readonly string s_defaultTagName = "Default";
- private static readonly string s_extensionAttributeName = "Extension";
- private static readonly string s_contentTypeAttributeName = "ContentType";
- private static readonly string s_overrideTagName = "Override";
- private static readonly string s_partNameAttributeName = "PartName";
- private static readonly string s_temporaryPartNameWithoutExtension = "/tempfiles/sample.";
+ private const string TypesNamespaceUri = "http://schemas.openxmlformats.org/package/2006/content-types";
+ private const string TypesTagName = "Types";
+ private const string DefaultTagName = "Default";
+ private const string ExtensionAttributeName = "Extension";
+ private const string ContentTypeAttributeName = "ContentType";
+ private const string OverrideTagName = "Override";
+ private const string PartNameAttributeName = "PartName";
+ private const string TemporaryPartNameWithoutExtension = "/tempfiles/sample.";
}
}
}
public abstract class ManagementQuery : ICloneable
{
internal const string DEFAULTQUERYLANGUAGE = "WQL";
- internal static readonly string tokenSelect = "select "; // Keep trailing space char.
+ internal const string TokenSelect = "select "; // Keep trailing space char.
//Used when any public property on this object is changed, to signal
//to the containing object that it needs to be refreshed.
{
// Minimally determine if the string is a query or class name.
//
- if (queryOrClassName.TrimStart().StartsWith(tokenSelect, StringComparison.OrdinalIgnoreCase))
+ if (queryOrClassName.TrimStart().StartsWith(TokenSelect, StringComparison.OrdinalIgnoreCase))
{
// Looks to be a query - do further checking.
//
return;
//Select clause
- s = tokenSelect;
+ s = TokenSelect;
//If properties are specified list them
if ((null != selectedProperties) && (0 < selectedProperties.Count))
if (isSchemaQuery == false) //instances query
{
//Find "select" clause and get the property list if exists
- string keyword = tokenSelect;
+ string keyword = TokenSelect;
if ((q.Length >= keyword.Length) && (string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase) == 0)) //select clause found
{
ParseToken (ref q, keyword, ref bFound);
//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC//
public class RelatedObjectQuery : WqlObjectQuery
{
- private static readonly string tokenAssociators = "associators";
- private static readonly string tokenOf = "of";
- private static readonly string tokenWhere = "where";
- private static readonly string tokenResultClass = "resultclass";
- private static readonly string tokenAssocClass = "assocclass";
- private static readonly string tokenResultRole = "resultrole";
- private static readonly string tokenRole = "role";
- private static readonly string tokenRequiredQualifier = "requiredqualifier";
- private static readonly string tokenRequiredAssocQualifier = "requiredassocqualifier";
- private static readonly string tokenClassDefsOnly = "classdefsonly";
- private static readonly string tokenSchemaOnly = "schemaonly";
+ private const string TokenAssociators = "associators";
+ private const string TokenOf = "of";
+ private const string TokenWhere = "where";
+ private const string TokenResultClass = "resultclass";
+ private const string TokenAssocClass = "assocclass";
+ private const string TokenResultRole = "resultrole";
+ private const string TokenRole = "role";
+ private const string TokenRequiredQualifier = "requiredqualifier";
+ private const string TokenRequiredAssocQualifier = "requiredassocqualifier";
+ private const string TokenClassDefsOnly = "classdefsonly";
+ private const string TokenSchemaOnly = "schemaonly";
private bool isSchemaQuery;
private string sourceObject;
{
// Minimally determine if the string is a query or instance name.
//
- if (queryOrSourceObject.TrimStart().StartsWith(tokenAssociators, StringComparison.OrdinalIgnoreCase))
+ if (queryOrSourceObject.TrimStart().StartsWith(TokenAssociators, StringComparison.OrdinalIgnoreCase))
{
// Looks to be a query - do further checking.
//
return;
//"associators" clause
- string s = tokenAssociators + " " + tokenOf + " {" + sourceObject + "}";
+ string s = TokenAssociators + " " + TokenOf + " {" + sourceObject + "}";
//If any of the other parameters are set we need a "where" clause
if (!(RelatedClass.Length==0) ||
classDefinitionsOnly ||
isSchemaQuery)
{
- s = s + " " + tokenWhere;
+ s = s + " " + TokenWhere;
//"ResultClass"
if (!(RelatedClass.Length==0))
- s = s + " " + tokenResultClass + " = " + relatedClass;
+ s = s + " " + TokenResultClass + " = " + relatedClass;
//"AssocClass"
if (!(RelationshipClass.Length==0))
- s = s + " " + tokenAssocClass + " = " + relationshipClass;
+ s = s + " " + TokenAssocClass + " = " + relationshipClass;
//"ResultRole"
if (!(RelatedRole.Length==0))
- s = s + " " + tokenResultRole + " = " + relatedRole;
+ s = s + " " + TokenResultRole + " = " + relatedRole;
//"Role"
if (!(ThisRole.Length==0))
- s = s + " " + tokenRole + " = " + thisRole;
+ s = s + " " + TokenRole + " = " + thisRole;
//"RequiredQualifier"
if (!(RelatedQualifier.Length==0))
- s = s + " " + tokenRequiredQualifier + " = " + relatedQualifier;
+ s = s + " " + TokenRequiredQualifier + " = " + relatedQualifier;
//"RequiredAssocQualifier"
if (!(RelationshipQualifier.Length==0))
- s = s + " " + tokenRequiredAssocQualifier + " = " + relationshipQualifier;
+ s = s + " " + TokenRequiredAssocQualifier + " = " + relationshipQualifier;
//"SchemaOnly" and "ClassDefsOnly"
if (!isSchemaQuery) //this is an instance query - classDefs allowed
{
if (classDefinitionsOnly)
- s = s + " " + tokenClassDefsOnly;
+ s = s + " " + TokenClassDefsOnly;
}
else //this is a schema query, schemaonly required
- s = s + " " + tokenSchemaOnly;
+ s = s + " " + TokenSchemaOnly;
}
//Set the queryString member to the built query (NB: note we set
int i;
//Find "associators" clause
- if (0 != string.Compare(q, 0, tokenAssociators, 0, tokenAssociators.Length, StringComparison.OrdinalIgnoreCase))
+ if (0 != string.Compare(q, 0, TokenAssociators, 0, TokenAssociators.Length, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(SR.InvalidQuery,"associators"); // Invalid query
// Strip off the clause
- q = q.Remove(0, tokenAssociators.Length);
+ q = q.Remove(0, TokenAssociators.Length);
// Must be some white space next
if ((0 == q.Length) || !char.IsWhiteSpace (q[0]))
q = q.TrimStart(null); // Remove the leading whitespace
// Next token should be "of"
- if (0 != string.Compare(q, 0, tokenOf, 0, tokenOf.Length, StringComparison.OrdinalIgnoreCase))
+ if (0 != string.Compare(q, 0, TokenOf, 0, TokenOf.Length, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(SR.InvalidQuery,"of"); // Invalid query
// Strip off the clause and leading WS
- q = q.Remove(0, tokenOf.Length).TrimStart (null);
+ q = q.Remove(0, TokenOf.Length).TrimStart (null);
// Next character should be "{"
if (0 != q.IndexOf('{'))
if (0 < q.Length)
{
// Next should be the "where" clause
- if (0 != string.Compare (q, 0, tokenWhere, 0, tokenWhere.Length, StringComparison.OrdinalIgnoreCase))
+ if (0 != string.Compare (q, 0, TokenWhere, 0, TokenWhere.Length, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(SR.InvalidQuery,"where"); // Invalid query
- q = q.Remove (0, tokenWhere.Length);
+ q = q.Remove (0, TokenWhere.Length);
// Must be some white space next
if ((0 == q.Length) || !char.IsWhiteSpace (q[0]))
// Keep looking for tokens until we are done
while (true)
{
- if ((q.Length >= tokenResultClass.Length) && (0 == string.Compare (q, 0, tokenResultClass, 0, tokenResultClass.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenResultClass, "=", ref bResultClassFound, ref tempRelatedClass);
- else if ((q.Length >= tokenAssocClass.Length) && (0 == string.Compare (q, 0, tokenAssocClass, 0, tokenAssocClass.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenAssocClass, "=", ref bAssocClassFound, ref tempRelationshipClass);
- else if ((q.Length >= tokenResultRole.Length) && (0 == string.Compare (q, 0, tokenResultRole, 0, tokenResultRole.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenResultRole, "=", ref bResultRoleFound, ref tempRelatedRole);
- else if ((q.Length >= tokenRole.Length) && (0 == string.Compare (q, 0, tokenRole, 0, tokenRole.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenRole, "=", ref bRoleFound, ref tempThisRole);
- else if ((q.Length >= tokenRequiredQualifier.Length) && (0 == string.Compare (q, 0, tokenRequiredQualifier, 0, tokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelatedQualifier);
- else if ((q.Length >= tokenRequiredAssocQualifier.Length) && (0 == string.Compare (q, 0, tokenRequiredAssocQualifier, 0, tokenRequiredAssocQualifier.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenRequiredAssocQualifier, "=", ref bRequiredAssocQualifierFound, ref tempRelationshipQualifier);
- else if ((q.Length >= tokenSchemaOnly.Length) && (0 == string.Compare (q, 0, tokenSchemaOnly, 0, tokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase)))
+ if ((q.Length >= TokenResultClass.Length) && (0 == string.Compare (q, 0, TokenResultClass, 0, TokenResultClass.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenResultClass, "=", ref bResultClassFound, ref tempRelatedClass);
+ else if ((q.Length >= TokenAssocClass.Length) && (0 == string.Compare (q, 0, TokenAssocClass, 0, TokenAssocClass.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenAssocClass, "=", ref bAssocClassFound, ref tempRelationshipClass);
+ else if ((q.Length >= TokenResultRole.Length) && (0 == string.Compare (q, 0, TokenResultRole, 0, TokenResultRole.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenResultRole, "=", ref bResultRoleFound, ref tempRelatedRole);
+ else if ((q.Length >= TokenRole.Length) && (0 == string.Compare (q, 0, TokenRole, 0, TokenRole.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenRole, "=", ref bRoleFound, ref tempThisRole);
+ else if ((q.Length >= TokenRequiredQualifier.Length) && (0 == string.Compare (q, 0, TokenRequiredQualifier, 0, TokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelatedQualifier);
+ else if ((q.Length >= TokenRequiredAssocQualifier.Length) && (0 == string.Compare (q, 0, TokenRequiredAssocQualifier, 0, TokenRequiredAssocQualifier.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenRequiredAssocQualifier, "=", ref bRequiredAssocQualifierFound, ref tempRelationshipQualifier);
+ else if ((q.Length >= TokenSchemaOnly.Length) && (0 == string.Compare (q, 0, TokenSchemaOnly, 0, TokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase)))
{
- ParseToken (ref q, tokenSchemaOnly, ref bSchemaOnlyFound);
+ ParseToken (ref q, TokenSchemaOnly, ref bSchemaOnlyFound);
tempIsSchemaQuery = true;
}
- else if ((q.Length >= tokenClassDefsOnly.Length) && (0 == string.Compare (q, 0, tokenClassDefsOnly, 0, tokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase)))
+ else if ((q.Length >= TokenClassDefsOnly.Length) && (0 == string.Compare (q, 0, TokenClassDefsOnly, 0, TokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase)))
{
- ParseToken (ref q, tokenClassDefsOnly, ref bClassDefsOnlyFound);
+ ParseToken (ref q, TokenClassDefsOnly, ref bClassDefsOnlyFound);
tempClassDefsOnly = true;
}
else if (0 == q.Length)
//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC//
public class RelationshipQuery : WqlObjectQuery
{
- private static readonly string tokenReferences = "references";
- private static readonly string tokenOf = "of";
- private static readonly string tokenWhere = "where";
- private static readonly string tokenResultClass = "resultclass";
- private static readonly string tokenRole = "role";
- private static readonly string tokenRequiredQualifier = "requiredqualifier";
- private static readonly string tokenClassDefsOnly = "classdefsonly";
- private static readonly string tokenSchemaOnly = "schemaonly";
+ private const string TokenReferences = "references";
+ private const string TokenOf = "of";
+ private const string TokenWhere = "where";
+ private const string TokenResultClass = "resultclass";
+ private const string TokenRole = "role";
+ private const string TokenRequiredQualifier = "requiredqualifier";
+ private const string TokenClassDefsOnly = "classdefsonly";
+ private const string TokenSchemaOnly = "schemaonly";
private string sourceObject;
private string relationshipClass;
{
// Minimally determine if the string is a query or instance name.
//
- if (queryOrSourceObject.TrimStart().StartsWith(tokenReferences, StringComparison.OrdinalIgnoreCase))
+ if (queryOrSourceObject.TrimStart().StartsWith(TokenReferences, StringComparison.OrdinalIgnoreCase))
{
// Looks to be a query - do further checking.
//
return;
//"references" clause
- string s = tokenReferences + " " + tokenOf + " {" + sourceObject + "}";
+ string s = TokenReferences + " " + TokenOf + " {" + sourceObject + "}";
//If any of the other parameters are set we need a "where" clause
if (!(RelationshipClass.Length==0) ||
classDefinitionsOnly ||
isSchemaQuery)
{
- s = s + " " + tokenWhere;
+ s = s + " " + TokenWhere;
//"ResultClass"
if (!(RelationshipClass.Length==0))
- s = s + " " + tokenResultClass + " = " + relationshipClass;
+ s = s + " " + TokenResultClass + " = " + relationshipClass;
//"Role"
if (!(ThisRole.Length==0))
- s = s + " " + tokenRole + " = " + thisRole;
+ s = s + " " + TokenRole + " = " + thisRole;
//"RequiredQualifier"
if (!(RelationshipQualifier.Length==0))
- s = s + " " + tokenRequiredQualifier + " = " + relationshipQualifier;
+ s = s + " " + TokenRequiredQualifier + " = " + relationshipQualifier;
//"SchemaOnly" and "ClassDefsOnly"
if (!isSchemaQuery) //this is an instance query - classDefs allowed
{
if (classDefinitionsOnly)
- s = s + " " + tokenClassDefsOnly;
+ s = s + " " + TokenClassDefsOnly;
}
else //this is a schema query, schemaonly required
- s = s + " " + tokenSchemaOnly;
+ s = s + " " + TokenSchemaOnly;
}
int i;
//Find "references" clause
- if (0 != string.Compare(q, 0, tokenReferences, 0, tokenReferences.Length, StringComparison.OrdinalIgnoreCase))
+ if (0 != string.Compare(q, 0, TokenReferences, 0, TokenReferences.Length, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(SR.InvalidQuery,"references"); // Invalid query
// Strip off the clause
- q = q.Remove(0, tokenReferences.Length);
+ q = q.Remove(0, TokenReferences.Length);
// Must be some white space next
if ((0 == q.Length) || !char.IsWhiteSpace (q[0]))
q = q.TrimStart(null); // Remove the leading whitespace
// Next token should be "of"
- if (0 != string.Compare(q, 0, tokenOf, 0, tokenOf.Length, StringComparison.OrdinalIgnoreCase))
+ if (0 != string.Compare(q, 0, TokenOf, 0, TokenOf.Length, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(SR.InvalidQuery,"of"); // Invalid query
// Strip off the clause and leading WS
- q = q.Remove(0, tokenOf.Length).TrimStart (null);
+ q = q.Remove(0, TokenOf.Length).TrimStart (null);
// Next character should be "{"
if (0 != q.IndexOf('{'))
if (0 < q.Length)
{
// Next should be the "where" clause
- if (0 != string.Compare (q, 0, tokenWhere, 0, tokenWhere.Length, StringComparison.OrdinalIgnoreCase))
+ if (0 != string.Compare (q, 0, TokenWhere, 0, TokenWhere.Length, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(SR.InvalidQuery,"where"); // Invalid query
- q = q.Remove (0, tokenWhere.Length);
+ q = q.Remove (0, TokenWhere.Length);
// Must be some white space next
if ((0 == q.Length) || !char.IsWhiteSpace (q[0]))
// Keep looking for tokens until we are done
while (true)
{
- if ((q.Length >= tokenResultClass.Length) && (0 == string.Compare (q, 0, tokenResultClass, 0, tokenResultClass.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenResultClass, "=", ref bResultClassFound, ref tempRelationshipClass);
- else if ((q.Length >= tokenRole.Length) && (0 == string.Compare (q, 0, tokenRole, 0, tokenRole.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenRole, "=", ref bRoleFound, ref tempThisRole);
- else if ((q.Length >= tokenRequiredQualifier.Length) && (0 == string.Compare (q, 0, tokenRequiredQualifier, 0, tokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase)))
- ParseToken (ref q, tokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelationshipQualifier);
- else if ((q.Length >= tokenClassDefsOnly.Length) && (0 == string.Compare (q, 0, tokenClassDefsOnly, 0, tokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase)))
+ if ((q.Length >= TokenResultClass.Length) && (0 == string.Compare (q, 0, TokenResultClass, 0, TokenResultClass.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenResultClass, "=", ref bResultClassFound, ref tempRelationshipClass);
+ else if ((q.Length >= TokenRole.Length) && (0 == string.Compare (q, 0, TokenRole, 0, TokenRole.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenRole, "=", ref bRoleFound, ref tempThisRole);
+ else if ((q.Length >= TokenRequiredQualifier.Length) && (0 == string.Compare (q, 0, TokenRequiredQualifier, 0, TokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase)))
+ ParseToken (ref q, TokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelationshipQualifier);
+ else if ((q.Length >= TokenClassDefsOnly.Length) && (0 == string.Compare (q, 0, TokenClassDefsOnly, 0, TokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase)))
{
- ParseToken (ref q, tokenClassDefsOnly, ref bClassDefsOnlyFound);
+ ParseToken (ref q, TokenClassDefsOnly, ref bClassDefsOnlyFound);
tempClassDefsOnly = true;
}
- else if ((q.Length >= tokenSchemaOnly.Length) && (0 == string.Compare (q, 0, tokenSchemaOnly, 0, tokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase)))
+ else if ((q.Length >= TokenSchemaOnly.Length) && (0 == string.Compare (q, 0, TokenSchemaOnly, 0, TokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase)))
{
- ParseToken (ref q, tokenSchemaOnly, ref bSchemaOnlyFound);
+ ParseToken (ref q, TokenSchemaOnly, ref bSchemaOnlyFound);
tempSchemaOnly = true;
}
else if (0 == q.Length)
//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC//
public class WqlEventQuery : EventQuery
{
- private static readonly string tokenSelectAll = "select * ";
+ private const string TokenSelectAll = "select * ";
private string eventClassName;
private TimeSpan withinInterval;
{
// Minimally determine if the string is a query or event class name.
//
- if (queryOrEventClassName.TrimStart().StartsWith(tokenSelectAll, StringComparison.OrdinalIgnoreCase))
+ if (queryOrEventClassName.TrimStart().StartsWith(TokenSelectAll, StringComparison.OrdinalIgnoreCase))
{
QueryString = queryOrEventClassName; // Parse/validate; may throw.
}
}
//Select clause
- string s = tokenSelectAll; //no property list allowed here...
+ string s = TokenSelectAll; //no property list allowed here...
//From clause
s = s + "from " + eventClassName;
bool bFound = false;
//Find "select" clause and make sure it's a select *
- string keyword = tokenSelect;
+ string keyword = TokenSelect;
if ((q.Length < keyword.Length) || (0 != string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase)))
throw new ArgumentException(SR.InvalidQuery);
q = q.Remove(0, keyword.Length).TrimStart(null);
// In debug builds, force there to be 2 engines. In release builds, use half the number of processors when
// there are at least 6. The lower bound is to avoid using multiple engines on systems which aren't servers.
- private static readonly int EngineCount =
+#pragma warning disable CA1802 // const works for debug, but needs to be static readonly for release
+ private static readonly int s_engineCount =
#if DEBUG
2;
#else
Environment.ProcessorCount >= 6 ? Environment.ProcessorCount / 2 : 1;
#endif
+#pragma warning restore CA1802
+
//
// The current engines. We replace an engine when it runs out of "handle" values.
// Must be accessed under s_lock.
//
- private static readonly SocketAsyncEngine[] s_currentEngines = new SocketAsyncEngine[EngineCount];
+ private static readonly SocketAsyncEngine[] s_currentEngines = new SocketAsyncEngine[s_engineCount];
private static int s_allocateFromEngine = 0;
private readonly IntPtr _port;
//
private static readonly IntPtr MaxHandles = IntPtr.Size == 4 ? (IntPtr)int.MaxValue : (IntPtr)long.MaxValue;
#endif
- private static readonly IntPtr MinHandlesForAdditionalEngine = EngineCount == 1 ? MaxHandles : (IntPtr)32;
+ private static readonly IntPtr MinHandlesForAdditionalEngine = s_engineCount == 1 ? MaxHandles : (IntPtr)32;
//
// Sentinel handle value to identify events from the "shutdown pipe," used to signal an event loop to stop
// Round-robin to the next engine once we have sufficient sockets on this one.
if (!engine.HasLowNumberOfSockets)
{
- s_allocateFromEngine = (s_allocateFromEngine + 1) % EngineCount;
+ s_allocateFromEngine = (s_allocateFromEngine + 1) % s_engineCount;
}
}
}
/// <summary>Represents a Unix Domain Socket endpoint as a path.</summary>
public sealed partial class UnixDomainSocketEndPoint : EndPoint
{
+#pragma warning disable CA1802 // on Unix these need to be static readonly rather than const, so we do the same on Windows for consistency
private static readonly int s_nativePathOffset = 2; // sizeof(sun_family)
private static readonly int s_nativePathLength = 108; // sizeof(sun_path)
private static readonly int s_nativeAddressSize = s_nativePathOffset + s_nativePathLength; // sizeof(sockaddr_un)
+#pragma warning restore CA1802
private SocketAddress CreateSocketAddressForSerialize() =>
new SocketAddress(AddressFamily.Unix, s_nativeAddressSize);
Assert.Throws<ArgumentNullException>(() => new UnixDomainSocketEndPoint(null));
Assert.Throws<ArgumentOutOfRangeException>(() => new UnixDomainSocketEndPoint(string.Empty));
- int maxNativeSize = (int)typeof(UnixDomainSocketEndPoint)
- .GetField("s_nativePathLength", BindingFlags.Static | BindingFlags.NonPublic)
- .GetValue(null);
+ FieldInfo fi = typeof(UnixDomainSocketEndPoint).GetField("s_nativePathLength", BindingFlags.Static | BindingFlags.NonPublic);
+ Assert.NotNull(fi);
+ int maxNativeSize = (int)fi.GetValue(null);
string invalidLengthString = new string('a', maxNativeSize + 1);
Assert.Throws<ArgumentOutOfRangeException>(() => new UnixDomainSocketEndPoint(invalidLengthString));
}
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{C427CE0D-0740-41F3-9C3A-552BEA3DDB0D}</ProjectGuid>
<AssemblyName>System.Private.Xml</AssemblyName>
private int _bits;
private int _bitsFilled;
- private static readonly string s_charsBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ private const string CharsBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
private static readonly byte[] s_mapBase64 = ConstructMapBase64();
private const int MaxValidChar = (int)'z';
private const byte Invalid = unchecked((byte)-1);
{
mapBase64[i] = Invalid;
}
- for (int i = 0; i < s_charsBase64.Length; i++)
+ for (int i = 0; i < CharsBase64.Length; i++)
{
- mapBase64[(int)s_charsBase64[i]] = (byte)i;
+ mapBase64[(int)CharsBase64[i]] = (byte)i;
}
return mapBase64;
}
}
}
- private static readonly byte s_NUMERIC_MAX_PRECISION = 38; // Maximum precision of numeric
- private static readonly byte s_maxPrecision = s_NUMERIC_MAX_PRECISION; // max SS precision
+ private const byte s_NUMERIC_MAX_PRECISION = 38; // Maximum precision of numeric
+ private const byte s_maxPrecision = s_NUMERIC_MAX_PRECISION; // max SS precision
- private static readonly int s_cNumeMax = 4;
- private static readonly long s_lInt32Base = ((long)1) << 32; // 2**32
- internal static readonly ulong x_llMax = long.MaxValue; // Max of Int64
- private static readonly double s_DUINT_BASE = (double)s_lInt32Base; // 2**32
+ private const int s_cNumeMax = 4;
+ private const long s_lInt32Base = ((long)1) << 32; // 2**32
+ internal const ulong x_llMax = long.MaxValue; // Max of Int64
+ private const double s_DUINT_BASE = (double)s_lInt32Base; // 2**32
public BinXmlSqlDecimal(byte[] data, int offset, bool trim)
{
}
// Number of (100ns) ticks per time unit
- private static readonly double s_SQLTicksPerMillisecond = 0.3;
- public static readonly int SQLTicksPerSecond = 300;
- public static readonly int SQLTicksPerMinute = SQLTicksPerSecond * 60;
- public static readonly int SQLTicksPerHour = SQLTicksPerMinute * 60;
+ private const double s_SQLTicksPerMillisecond = 0.3;
+ internal const int SQLTicksPerSecond = 300;
+ internal const int SQLTicksPerMinute = SQLTicksPerSecond * 60;
+ internal const int SQLTicksPerHour = SQLTicksPerMinute * 60;
public static string SqlSmallDateTimeToString(short dateticks, ushort timeticks)
/// </summary>
internal static class Bits
{
- private static readonly uint s_MASK_0101010101010101 = 0x55555555;
- private static readonly uint s_MASK_0011001100110011 = 0x33333333;
- private static readonly uint s_MASK_0000111100001111 = 0x0f0f0f0f;
- private static readonly uint s_MASK_0000000011111111 = 0x00ff00ff;
- private static readonly uint s_MASK_1111111111111111 = 0x0000ffff;
+ private const uint MASK_0101010101010101 = 0x55555555;
+ private const uint MASK_0011001100110011 = 0x33333333;
+ private const uint MASK_0000111100001111 = 0x0f0f0f0f;
+ private const uint MASK_0000000011111111 = 0x00ff00ff;
+ private const uint MASK_1111111111111111 = 0x0000ffff;
/// <summary>
/// Returns the number of 1 bits in an unsigned integer. Counts bits by divide-and-conquer method,
/// </summary>
public static int Count(uint num)
{
- num = (num & s_MASK_0101010101010101) + ((num >> 1) & s_MASK_0101010101010101);
- num = (num & s_MASK_0011001100110011) + ((num >> 2) & s_MASK_0011001100110011);
- num = (num & s_MASK_0000111100001111) + ((num >> 4) & s_MASK_0000111100001111);
- num = (num & s_MASK_0000000011111111) + ((num >> 8) & s_MASK_0000000011111111);
- num = (num & s_MASK_1111111111111111) + (num >> 16);
+ num = (num & MASK_0101010101010101) + ((num >> 1) & MASK_0101010101010101);
+ num = (num & MASK_0011001100110011) + ((num >> 2) & MASK_0011001100110011);
+ num = (num & MASK_0000111100001111) + ((num >> 4) & MASK_0000111100001111);
+ num = (num & MASK_0000000011111111) + ((num >> 8) & MASK_0000000011111111);
+ num = (num & MASK_1111111111111111) + (num >> 16);
return (int)num;
}
private static readonly Type s_uriType = typeof(Uri);
private static readonly Type s_timeSpanType = typeof(TimeSpan);
- private static readonly string s_untypedStringTypeName = "xdt:untypedAtomic";
+ private const string UntypedStringTypeName = "xdt:untypedAtomic";
// Static convertor instance
internal static XmlUntypedStringConverter Instance = new XmlUntypedStringConverter(true);
private Exception CreateInvalidClrMappingException(Type sourceType, Type destinationType)
{
- return new InvalidCastException(SR.Format(SR.XmlConvert_TypeListBadMapping2, s_untypedStringTypeName, sourceType.Name, destinationType.Name));
+ return new InvalidCastException(SR.Format(SR.XmlConvert_TypeListBadMapping2, UntypedStringTypeName, sourceType.Name, destinationType.Name));
}
}
}
matchPos = m.Index;
}
- for (int position = 0; position < length - s_encodedCharLength + 1; position++)
+ for (int position = 0; position < length - EncodedCharLength + 1; position++)
{
if (position == matchPos)
{
{
if (u <= 0x0010ffff)
{ //convert to two chars
- copyPosition = position + s_encodedCharLength + 4;
+ copyPosition = position + EncodedCharLength + 4;
char lowChar, highChar;
XmlCharType.SplitSurrogateChar(u, out lowChar, out highChar);
bufBld.Append(highChar);
}
else
{ //convert to single char
- copyPosition = position + s_encodedCharLength + 4;
+ copyPosition = position + EncodedCharLength + 4;
bufBld.Append((char)u);
}
- position += s_encodedCharLength - 1 + 4; //just skip
+ position += EncodedCharLength - 1 + 4; //just skip
}
else
{
- copyPosition = position + s_encodedCharLength;
+ copyPosition = position + EncodedCharLength;
bufBld.Append((char)(
FromHex(name[position + 2]) * 0x1000 +
FromHex(name[position + 3]) * 0x100 +
FromHex(name[position + 4]) * 0x10 +
FromHex(name[position + 5])));
- position += s_encodedCharLength - 1;
+ position += EncodedCharLength - 1;
}
}
}
}
}
- private static readonly int s_encodedCharLength = 7; // ("_xFFFF_".Length);
+ private const int EncodedCharLength = 7; // ("_xFFFF_".Length);
private static volatile Regex s_encodeCharPattern;
private static volatile Regex s_decodeCharPattern;
private static int FromHex(char digit)
// The limit is configurable (see ConfigUtil.cs).
internal sealed partial class PhysicalMemoryMonitor : MemoryMonitor
{
- private const int MIN_TOTAL_MEMORY_TRIM_PERCENT = 10;
- private static readonly long s_TARGET_TOTAL_MEMORY_TRIM_INTERVAL_TICKS = 5 * TimeSpan.TicksPerMinute;
+ private const int MinTotalMemoryTrimPercent = 10;
+ private const long TargetTotalMemoryTrimIntervalTicks = 5 * TimeSpan.TicksPerMinute;
// Returns the percentage of physical machine memory that can be consumed by an
// application before the cache starts forcibly removing items.
long ticksSinceTrim = utcNow.Subtract(lastTrimTime).Ticks;
if (ticksSinceTrim > 0)
{
- percent = Math.Min(50, (int)((lastTrimPercent * s_TARGET_TOTAL_MEMORY_TRIM_INTERVAL_TICKS) / ticksSinceTrim));
- percent = Math.Max(MIN_TOTAL_MEMORY_TRIM_PERCENT, percent);
+ percent = Math.Min(50, (int)((lastTrimPercent * TargetTotalMemoryTrimIntervalTicks) / ticksSinceTrim));
+ percent = Math.Max(MinTotalMemoryTrimPercent, percent);
}
#if PERF
// ADS_RIGHT_DS_WRITE_PROP = 0x20,
// ADS_RIGHT_DS_CONTROL_ACCESS = 0x100
//
- internal static readonly int AccessMaskWithObjectType = 0x1 | 0x2 | 0x8 | 0x10 | 0x20 | 0x100;
+ internal const int AccessMaskWithObjectType = 0x1 | 0x2 | 0x8 | 0x10 | 0x20 | 0x100;
private static AceType TypeFromQualifier(bool isCallback, AceQualifier qualifier)
{
// only these SACL control flags will be automatically carry forward
// when update with new security descriptor.
- private static readonly ControlFlags SACL_CONTROL_FLAGS =
+ private const ControlFlags SACL_CONTROL_FLAGS =
ControlFlags.SystemAclPresent |
ControlFlags.SystemAclAutoInherited |
ControlFlags.SystemAclProtected;
// only these DACL control flags will be automatically carry forward
// when update with new security descriptor
- private static readonly ControlFlags DACL_CONTROL_FLAGS =
+ private const ControlFlags DACL_CONTROL_FLAGS =
ControlFlags.DiscretionaryAclPresent |
ControlFlags.DiscretionaryAclAutoInherited |
ControlFlags.DiscretionaryAclProtected;
// Identifier authority must be at most six bytes long
//
- internal static readonly long MaxIdentifierAuthority = 0xFFFFFFFFFFFF;
+ internal const long MaxIdentifierAuthority = 0xFFFFFFFFFFFF;
//
// Maximum number of subauthorities in a SID
//
- internal static readonly byte MaxSubAuthorities = 15;
+ internal const byte MaxSubAuthorities = 15;
//
// Minimum length of a binary representation of a SID
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
-using System.IO;
-using System.Text;
namespace System.Text.RegularExpressions
{
private const char ZeroWidthJoiner = '\u200D';
private const char ZeroWidthNonJoiner = '\u200C';
- private static readonly string s_internalRegexIgnoreCase = "__InternalRegexIgnoreCase__";
- private static readonly string s_space = "\x64";
- private static readonly string s_notSpace = "\uFF9C";
- private static readonly string s_word = "\u0000\u0002\u0004\u0005\u0003\u0001\u0006\u0009\u0013\u0000";
- private static readonly string s_notWord = "\u0000\uFFFE\uFFFC\uFFFB\uFFFD\uFFFF\uFFFA\uFFF7\uFFED\u0000";
+ private const string InternalRegexIgnoreCase = "__InternalRegexIgnoreCase__";
+ private const string Space = "\x64";
+ private const string NotSpace = "\uFF9C";
+ private const string Word = "\u0000\u0002\u0004\u0005\u0003\u0001\u0006\u0009\u0013\u0000";
+ private const string NotWord = "\u0000\uFFFE\uFFFC\uFFFB\uFFFD\uFFFF\uFFFA\uFFF7\uFFED\u0000";
- public static readonly string SpaceClass = "\u0000\u0000\u0001\u0064";
- public static readonly string NotSpaceClass = "\u0001\u0000\u0001\u0064";
- public static readonly string WordClass = "\u0000\u0000\u000A\u0000\u0002\u0004\u0005\u0003\u0001\u0006\u0009\u0013\u0000";
- public static readonly string NotWordClass = "\u0001\u0000\u000A\u0000\u0002\u0004\u0005\u0003\u0001\u0006\u0009\u0013\u0000";
- public static readonly string DigitClass = "\u0000\u0000\u0001\u0009";
- public static readonly string NotDigitClass = "\u0000\u0000\u0001\uFFF7";
+ internal const string SpaceClass = "\u0000\u0000\u0001\u0064";
+ internal const string NotSpaceClass = "\u0001\u0000\u0001\u0064";
+ internal const string WordClass = "\u0000\u0000\u000A\u0000\u0002\u0004\u0005\u0003\u0001\u0006\u0009\u0013\u0000";
+ internal const string NotWordClass = "\u0001\u0000\u000A\u0000\u0002\u0004\u0005\u0003\u0001\u0006\u0009\u0013\u0000";
+ internal const string DigitClass = "\u0000\u0000\u0001\u0009";
+ internal const string NotDigitClass = "\u0000\u0000\u0001\uFFF7";
private const string ECMASpaceSet = "\u0009\u000E\u0020\u0021";
private const string NotECMASpaceSet = "\0\u0009\u000E\u0020\u0021";
private const string ECMADigitSet = "\u0030\u003A";
private const string NotECMADigitSet = "\0\u0030\u003A";
- public const string ECMASpaceClass = "\x00\x04\x00" + ECMASpaceSet;
- public const string NotECMASpaceClass = "\x01\x04\x00" + ECMASpaceSet;
- public const string ECMAWordClass = "\x00\x0A\x00" + ECMAWordSet;
- public const string NotECMAWordClass = "\x01\x0A\x00" + ECMAWordSet;
- public const string ECMADigitClass = "\x00\x02\x00" + ECMADigitSet;
- public const string NotECMADigitClass = "\x01\x02\x00" + ECMADigitSet;
+ internal const string ECMASpaceClass = "\x00\x04\x00" + ECMASpaceSet;
+ internal const string NotECMASpaceClass = "\x01\x04\x00" + ECMASpaceSet;
+ internal const string ECMAWordClass = "\x00\x0A\x00" + ECMAWordSet;
+ internal const string NotECMAWordClass = "\x01\x0A\x00" + ECMAWordSet;
+ internal const string ECMADigitClass = "\x00\x02\x00" + ECMADigitSet;
+ internal const string NotECMADigitClass = "\x01\x02\x00" + ECMADigitSet;
- public const string AnyClass = "\x00\x01\x00\x00";
- public const string EmptyClass = "\x00\x00\x00";
+ internal const string AnyClass = "\x00\x01\x00\x00";
+ internal const string EmptyClass = "\x00\x00\x00";
// UnicodeCategory is zero based, so we add one to each value and subtract it off later
private const int DefinedCategoriesCapacity = 38;
public void AddCategoryFromName(string categoryName, bool invert, bool caseInsensitive, string pattern, int currentPos)
{
- if (s_definedCategories.TryGetValue(categoryName, out string category) && !categoryName.Equals(s_internalRegexIgnoreCase))
+ if (s_definedCategories.TryGetValue(categoryName, out string category) && !categoryName.Equals(InternalRegexIgnoreCase))
{
if (caseInsensitive)
{
if (categoryName.Equals("Ll") || categoryName.Equals("Lu") || categoryName.Equals("Lt"))
// when RegexOptions.IgnoreCase is specified then {Ll}, {Lu}, and {Lt} cases should all match
- category = s_definedCategories[s_internalRegexIgnoreCase];
+ category = s_definedCategories[InternalRegexIgnoreCase];
}
if (invert)
if (ecma)
AddSet(NotECMAWordSet);
else
- AddCategory(s_notWord);
+ AddCategory(NotWord);
}
else
{
if (ecma)
AddSet(ECMAWordSet);
else
- AddCategory(s_word);
+ AddCategory(Word);
}
}
if (ecma)
AddSet(NotECMASpaceSet);
else
- AddCategory(s_notSpace);
+ AddCategory(NotSpace);
}
else
{
if (ecma)
AddSet(ECMASpaceSet);
else
- AddCategory(s_space);
+ AddCategory(Space);
}
}
#if DEBUG
public static readonly char[] Hex = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- public static readonly string[] Categories = new string[] {"Lu", "Ll", "Lt", "Lm", "Lo", s_internalRegexIgnoreCase,
+ public static readonly string[] Categories = new string[] {"Lu", "Ll", "Lt", "Lm", "Lo", InternalRegexIgnoreCase,
"Mn", "Mc", "Me",
"Nd", "Nl", "No",
"Zs", "Zl", "Zp",
if (!found)
{
- if (group.Equals(s_word))
+ if (group.Equals(Word))
desc.Append("\\w");
- else if (group.Equals(s_notWord))
+ else if (group.Equals(NotWord))
desc.Append("\\W");
else
Debug.Fail("Couldn't find a group to match '" + group + "'");