未验证 提交 02f7370b 编写于 作者: L lindexi 提交者: GitHub

Replace String.CompareOrdinal to string.Equals Final Part (#8042)

* Replace String.CompareOrdinal to string.Equals Final Part

* Fix User.cs use ToUpperInvariant to compare OrdinalIgnoreCase string

* Fix missing code
上级 2bfa149e
...@@ -189,7 +189,7 @@ public CultureInfo GetEquivalentCulture() ...@@ -189,7 +189,7 @@ public CultureInfo GetEquivalentCulture()
// see http://www.w3.org/International/questions/qa-no-language // see http://www.w3.org/International/questions/qa-no-language
// //
// Just treat it the same as xml:lang="" // Just treat it the same as xml:lang=""
if(String.CompareOrdinal(lowerCaseTag, "und") == 0) if(string.Equals(lowerCaseTag, "und", StringComparison.Ordinal))
{ {
lowerCaseTag = String.Empty; lowerCaseTag = String.Empty;
} }
...@@ -229,7 +229,7 @@ public CultureInfo GetSpecificCulture() ...@@ -229,7 +229,7 @@ public CultureInfo GetSpecificCulture()
{ {
if (_specificCulture == null) if (_specificCulture == null)
{ {
if (_lowerCaseTag.Length == 0 || String.CompareOrdinal(_lowerCaseTag, "und") == 0) if (_lowerCaseTag.Length == 0 || string.Equals(_lowerCaseTag, "und", StringComparison.Ordinal))
{ {
_specificCulture = GetEquivalentCulture(); _specificCulture = GetEquivalentCulture();
} }
......
...@@ -694,7 +694,7 @@ private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName ...@@ -694,7 +694,7 @@ private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName
return null; return null;
} }
if (String.CompareOrdinal(elementFullName.BaseName, _glyphRunName) == 0) if (string.Equals(elementFullName.BaseName, _glyphRunName, StringComparison.Ordinal))
{ {
// Ignore glyph runs during flow pass over a FixedPage. // Ignore glyph runs during flow pass over a FixedPage.
if (_filterState == FilterState.FindNextFlowUnit) if (_filterState == FilterState.FindNextFlowUnit)
...@@ -708,7 +708,7 @@ private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName ...@@ -708,7 +708,7 @@ private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName
} }
} }
if (String.CompareOrdinal(elementFullName.BaseName, _fixedPageName) == 0) if (string.Equals(elementFullName.BaseName, _fixedPageName, StringComparison.Ordinal))
{ {
// Ignore FixedPage element (i.e. root element) during flow pass over a fixed page. // Ignore FixedPage element (i.e. root element) during flow pass over a fixed page.
if (_filterState == FilterState.FindNextFlowUnit) if (_filterState == FilterState.FindNextFlowUnit)
...@@ -723,7 +723,7 @@ private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName ...@@ -723,7 +723,7 @@ private IndexingContentUnit HandleFixedFormatTag(ElementTableKey elementFullName
} }
} }
if (String.CompareOrdinal(elementFullName.BaseName, _pageContentName) == 0) if (string.Equals(elementFullName.BaseName, _pageContentName, StringComparison.Ordinal))
{ {
// If the element has a Source attribute, any inlined content should be ignored. // If the element has a Source attribute, any inlined content should be ignored.
string sourceUri = _xamlReader.GetAttribute(_pageContentSourceAttribute); string sourceUri = _xamlReader.GetAttribute(_pageContentSourceAttribute);
...@@ -777,7 +777,7 @@ private IndexingContentUnit ProcessGlyphRun() ...@@ -777,7 +777,7 @@ private IndexingContentUnit ProcessGlyphRun()
private IndexingContentUnit ProcessFixedPage() private IndexingContentUnit ProcessFixedPage()
{ {
// Reader is positioned on the start-tag for a FixedPage element. // Reader is positioned on the start-tag for a FixedPage element.
Debug.Assert(String.CompareOrdinal(_xamlReader.LocalName, _fixedPageName) == 0); Debug.Assert(string.Equals(_xamlReader.LocalName, _fixedPageName, StringComparison.Ordinal));
// A FixedPage nested in a FixedPage is invalid. // A FixedPage nested in a FixedPage is invalid.
// XmlException gets handled inside this class (see GetChunk). // XmlException gets handled inside this class (see GetChunk).
......
...@@ -39,8 +39,8 @@ internal XmlGlyphRunInfo(XmlNode glyphsNode) ...@@ -39,8 +39,8 @@ internal XmlGlyphRunInfo(XmlNode glyphsNode)
// Assert that XmlFixedPageInfo (only caller) has correctly identified glyph runs // Assert that XmlFixedPageInfo (only caller) has correctly identified glyph runs
// prior to invoking this constructor. // prior to invoking this constructor.
Debug.Assert(_glyphsNode != null Debug.Assert(_glyphsNode != null
&& String.CompareOrdinal(_glyphsNode.LocalName, _glyphRunName) == 0 && string.Equals(_glyphsNode.LocalName, _glyphRunName, StringComparison.Ordinal)
&& String.CompareOrdinal(_glyphsNode.NamespaceURI, ElementTableKey.FixedMarkupNamespace) == 0); && string.Equals(_glyphsNode.NamespaceURI, ElementTableKey.FixedMarkupNamespace, StringComparison.Ordinal));
} }
#endregion Constructors #endregion Constructors
...@@ -176,7 +176,7 @@ internal override uint LanguageID ...@@ -176,7 +176,7 @@ internal override uint LanguageID
// That's what the Indexing Search team told us to do. // That's what the Indexing Search team told us to do.
// There's no CultureInfo for "und". // There's no CultureInfo for "und".
// CultureInfo("und") will cause an error. // CultureInfo("und") will cause an error.
if (string.CompareOrdinal(languageString.ToUpperInvariant(), _undeterminedLanguageStringUpper) == 0) if (string.Equals(languageString.ToUpperInvariant(), _undeterminedLanguageStringUpper, StringComparison.Ordinal))
{ {
_languageID = 0; _languageID = 0;
} }
......
...@@ -496,12 +496,7 @@ private static void UpdateBaseUri(DependencyObject d, ImageSource source) ...@@ -496,12 +496,7 @@ private static void UpdateBaseUri(DependencyObject d, ImageSource source)
/// </summary> /// </summary>
bool IProvidePropertyFallback.CanProvidePropertyFallback(string property) bool IProvidePropertyFallback.CanProvidePropertyFallback(string property)
{ {
if (String.CompareOrdinal(property, "Source") == 0) return string.Equals(property, "Source", StringComparison.Ordinal);
{
return true;
}
return false;
} }
/// <summary> /// <summary>
...@@ -509,7 +504,7 @@ bool IProvidePropertyFallback.CanProvidePropertyFallback(string property) ...@@ -509,7 +504,7 @@ bool IProvidePropertyFallback.CanProvidePropertyFallback(string property)
/// </summary> /// </summary>
object IProvidePropertyFallback.ProvidePropertyFallback(string property, Exception cause) object IProvidePropertyFallback.ProvidePropertyFallback(string property, Exception cause)
{ {
if (String.CompareOrdinal(property, "Source") == 0) if (string.Equals(property, "Source", StringComparison.Ordinal))
{ {
RaiseEvent(new ExceptionRoutedEventArgs(ImageFailedEvent, this, cause)); RaiseEvent(new ExceptionRoutedEventArgs(ImageFailedEvent, this, cause));
} }
......
...@@ -1375,7 +1375,7 @@ public void OnUpdateComposition(UnsafeNativeMethods.ITfCompositionView view, Uns ...@@ -1375,7 +1375,7 @@ public void OnUpdateComposition(UnsafeNativeMethods.ITfCompositionView view, Uns
CompositionEventRecord previousRecord = (this.CompositionEventList.Count == 0) ? null : this.CompositionEventList[this.CompositionEventList.Count - 1]; CompositionEventRecord previousRecord = (this.CompositionEventList.Count == 0) ? null : this.CompositionEventList[this.CompositionEventList.Count - 1];
if (_lastCompositionText == null || if (_lastCompositionText == null ||
String.CompareOrdinal(compositionText, _lastCompositionText) != 0) !string.Equals(compositionText, _lastCompositionText, StringComparison.Ordinal))
{ {
// Add the new update event. // Add the new update event.
this.CompositionEventList.Add(record); this.CompositionEventList.Add(record);
......
...@@ -700,12 +700,12 @@ internal bool DoesAttributeMatch(short id, short ownerTypeId, string name) ...@@ -700,12 +700,12 @@ internal bool DoesAttributeMatch(short id, short ownerTypeId, string name)
KnownProperties knownId = (KnownProperties)(-id); KnownProperties knownId = (KnownProperties)(-id);
string propertyName = GetAttributeNameFromKnownId(knownId); string propertyName = GetAttributeNameFromKnownId(knownId);
KnownElements knownElement = KnownTypes.GetKnownElementFromKnownCommonProperty(knownId); KnownElements knownElement = KnownTypes.GetKnownElementFromKnownCommonProperty(knownId);
return (ownerTypeId == -(short)knownElement && (String.CompareOrdinal(propertyName, name) == 0)); return (ownerTypeId == -(short)knownElement && (string.Equals(propertyName, name, StringComparison.Ordinal)));
} }
else else
{ {
BamlAttributeInfoRecord record = (BamlAttributeInfoRecord)AttributeIdMap[id]; BamlAttributeInfoRecord record = (BamlAttributeInfoRecord)AttributeIdMap[id];
return (record.OwnerTypeId == ownerTypeId) && (String.CompareOrdinal(record.Name, name) == 0); return (record.OwnerTypeId == ownerTypeId) && (string.Equals(record.Name, name, StringComparison.Ordinal));
} }
} }
...@@ -714,7 +714,7 @@ internal bool DoesAttributeMatch(short id, string name) ...@@ -714,7 +714,7 @@ internal bool DoesAttributeMatch(short id, string name)
string propertyName = GetAttributeNameFromId(id); string propertyName = GetAttributeNameFromId(id);
if (null == propertyName) if (null == propertyName)
return false; return false;
return (String.CompareOrdinal(propertyName, name) == 0); return (string.Equals(propertyName, name, StringComparison.Ordinal));
} }
internal bool DoesAttributeMatch(short id, BamlAttributeUsage attributeUsage) internal bool DoesAttributeMatch(short id, BamlAttributeUsage attributeUsage)
......
...@@ -6874,7 +6874,7 @@ public XamlPropertyFullName(Type ownerType, string name) ...@@ -6874,7 +6874,7 @@ public XamlPropertyFullName(Type ownerType, string name)
public override bool Equals(object o) public override bool Equals(object o)
{ {
XamlPropertyFullName other = (XamlPropertyFullName)o; XamlPropertyFullName other = (XamlPropertyFullName)o;
return (_ownerType == other.OwnerType && (0==string.CompareOrdinal(_name, other.Name))); return (_ownerType == other.OwnerType && (string.Equals(_name, other.Name, StringComparison.Ordinal)));
} }
public override int GetHashCode() public override int GetHashCode()
......
...@@ -228,7 +228,7 @@ private CustomAttributeData[] GetAttributes(Assembly asm, string fullClrName) ...@@ -228,7 +228,7 @@ private CustomAttributeData[] GetAttributes(Assembly asm, string fullClrName)
// get the Constructor info // get the Constructor info
CustomAttributeData data = allAttributes[i]; CustomAttributeData data = allAttributes[i];
ConstructorInfo cinfo = data.Constructor; ConstructorInfo cinfo = data.Constructor;
if(0 == String.CompareOrdinal(cinfo.ReflectedType.FullName, fullClrName)) if(string.Equals(cinfo.ReflectedType.FullName, fullClrName, StringComparison.Ordinal))
{ {
foundAttributes.Add(allAttributes[i]); foundAttributes.Add(allAttributes[i]);
} }
...@@ -362,7 +362,7 @@ private void LoadClrnsToAssemblyNameMappingCache(Assembly[] asmList) ...@@ -362,7 +362,7 @@ private void LoadClrnsToAssemblyNameMappingCache(Assembly[] asmList)
throw new ArgumentException(SR.Format(SR.ParserAttributeArgsLow, "XmlnsDefinitionAttribute")); throw new ArgumentException(SR.Format(SR.ParserAttributeArgsLow, "XmlnsDefinitionAttribute"));
} }
if (0 == String.CompareOrdinal(xmlnsRequested, xmlns)) if (string.Equals(xmlnsRequested, xmlns, StringComparison.Ordinal))
{ {
pairList.Add(new ClrNamespaceAssemblyPair(clrns, assemblyName)); pairList.Add(new ClrNamespaceAssemblyPair(clrns, assemblyName));
} }
......
...@@ -1913,11 +1913,11 @@ Uri fontUri ...@@ -1913,11 +1913,11 @@ Uri fontUri
{ {
//Extract file extension //Extract file extension
String path = fontUri.OriginalString; String path = fontUri.OriginalString;
String extension = Path.GetExtension(path).ToLower(CultureInfo.InvariantCulture); String extension = Path.GetExtension(path);
String fileName = Path.GetFileNameWithoutExtension(path); String fileName = Path.GetFileNameWithoutExtension(path);
ContentType contentType = null; ContentType contentType = null;
if (String.CompareOrdinal(extension, XpsS0Markup.ObfuscatedFontExt.ToLower(CultureInfo.InvariantCulture)) == 0) if (string.Equals(extension, XpsS0Markup.ObfuscatedFontExt, StringComparison.OrdinalIgnoreCase))
{ {
// Verify that the filename is a valid GUID string // Verify that the filename is a valid GUID string
// Until Guid has a TryParse method we will have to depend on an exception being thrown // Until Guid has a TryParse method we will have to depend on an exception being thrown
......
...@@ -1278,8 +1278,7 @@ ContentType contentType ...@@ -1278,8 +1278,7 @@ ContentType contentType
} }
else else
{ {
if (String.CompareOrdinal(contentType.TypeComponent.ToUpper(CultureInfo.InvariantCulture), if (string.Equals(contentType.TypeComponent, "Image", StringComparison.OrdinalIgnoreCase))
"Image".ToUpper(CultureInfo.InvariantCulture))==0)
{ {
key = "Image"; key = "Image";
} }
......
...@@ -29,8 +29,7 @@ internal class CaseInsensitiveOrdinalStringComparer : ...@@ -29,8 +29,7 @@ internal class CaseInsensitiveOrdinalStringComparer :
bool IEqualityComparer.Equals(Object x, Object y) bool IEqualityComparer.Equals(Object x, Object y)
{ {
Invariant.Assert((x is String) && (y is String)); Invariant.Assert((x is String) && (y is String));
return (String.CompareOrdinal(((String) x).ToUpperInvariant(), return string.Equals(((string) x), ((string) y), StringComparison.OrdinalIgnoreCase);
((String) y).ToUpperInvariant()) == 0);
} }
int IComparer.Compare(Object x, Object y) int IComparer.Compare(Object x, Object y)
......
...@@ -76,7 +76,7 @@ public override bool Equals(object o) ...@@ -76,7 +76,7 @@ public override bool Equals(object o)
// Note that because of the GetType() checking above, the casting must be valid. // Note that because of the GetType() checking above, the casting must be valid.
CompoundFileStorageReference r = (CompoundFileStorageReference)o; CompoundFileStorageReference r = (CompoundFileStorageReference)o;
return (String.CompareOrdinal(_fullName.ToUpperInvariant(), r._fullName.ToUpperInvariant()) == 0); return (string.Equals(_fullName, r._fullName, StringComparison.OrdinalIgnoreCase));
} }
/// <summary>Returns an integer suitable for including this object in a hash table</summary> /// <summary>Returns an integer suitable for including this object in a hash table</summary>
......
...@@ -91,7 +91,7 @@ public override bool Equals(object o) ...@@ -91,7 +91,7 @@ public override bool Equals(object o)
return false; return false;
CompoundFileStreamReference r = (CompoundFileStreamReference)o; CompoundFileStreamReference r = (CompoundFileStreamReference)o;
return (String.CompareOrdinal(_fullName.ToUpperInvariant(), r._fullName.ToUpperInvariant()) == 0); return (string.Equals(_fullName, r._fullName, StringComparison.OrdinalIgnoreCase));
} }
/// <summary>Returns an integer suitable for including this object in a hash table</summary> /// <summary>Returns an integer suitable for including this object in a hash table</summary>
......
...@@ -408,9 +408,7 @@ private void EnsureParsed() ...@@ -408,9 +408,7 @@ private void EnsureParsed()
// Ensure that the feature name is as expected. // Ensure that the feature name is as expected.
// //
// NOTE: We preserve case, but do case-insensitive comparison. // NOTE: We preserve case, but do case-insensitive comparison.
if (String.CompareOrdinal( if (!string.Equals(_fileVersion.FeatureIdentifier, _codeVersion.FeatureIdentifier, StringComparison.OrdinalIgnoreCase))
_fileVersion.FeatureIdentifier.ToUpper(CultureInfo.InvariantCulture),
_codeVersion.FeatureIdentifier.ToUpper(CultureInfo.InvariantCulture)) != 0)
{ {
throw new FileFormatException( throw new FileFormatException(
SR.Format( SR.Format(
......
...@@ -80,7 +80,7 @@ private static XmlElement SelectNodeByIdFromObjects(Signature signature, string ...@@ -80,7 +80,7 @@ private static XmlElement SelectNodeByIdFromObjects(Signature signature, string
foreach (DataObject dataObject in signature.ObjectList) foreach (DataObject dataObject in signature.ObjectList)
{ {
// direct reference to Object id - supported for all reference typs // direct reference to Object id - supported for all reference typs
if (String.CompareOrdinal(idValue, dataObject.Id) == 0) if (string.Equals(idValue, dataObject.Id, StringComparison.Ordinal))
{ {
// anticipate duplicate ID's and throw if any found // anticipate duplicate ID's and throw if any found
if (node != null) if (node != null)
...@@ -116,7 +116,7 @@ private static XmlElement SelectSubObjectNodeForXAdES(Signature signature, strin ...@@ -116,7 +116,7 @@ private static XmlElement SelectSubObjectNodeForXAdES(Signature signature, strin
foreach (Reference reference in signature.SignedInfo.References) foreach (Reference reference in signature.SignedInfo.References)
{ {
// if we get a match by Type? // if we get a match by Type?
if (String.CompareOrdinal(reference.Type, _XAdESTargetType) == 0) if (string.Equals(reference.Type, _XAdESTargetType, StringComparison.Ordinal))
{ {
// now try to match by Uri // now try to match by Uri
// strip off any preceding # mark to facilitate matching // strip off any preceding # mark to facilitate matching
...@@ -128,7 +128,7 @@ private static XmlElement SelectSubObjectNodeForXAdES(Signature signature, strin ...@@ -128,7 +128,7 @@ private static XmlElement SelectSubObjectNodeForXAdES(Signature signature, strin
// if we have a XAdES type reference and the ID matches the requested one // if we have a XAdES type reference and the ID matches the requested one
// search all object tags for the XML with this ID // search all object tags for the XML with this ID
if (String.CompareOrdinal(uri, idValue) == 0) if (string.Equals(uri, idValue, StringComparison.Ordinal))
{ {
node = SelectSubObjectNodeForXAdESInDataObjects(signature, idValue); node = SelectSubObjectNodeForXAdESInDataObjects(signature, idValue);
break; break;
...@@ -155,7 +155,7 @@ private static XmlElement SelectSubObjectNodeForXAdESInDataObjects(Signature sig ...@@ -155,7 +155,7 @@ private static XmlElement SelectSubObjectNodeForXAdESInDataObjects(Signature sig
foreach (DataObject dataObject in signature.ObjectList) foreach (DataObject dataObject in signature.ObjectList)
{ {
// skip the package object // skip the package object
if (String.CompareOrdinal(dataObject.Id, XTable.Get(XTable.ID.OpcAttrValue)) != 0) if (!string.Equals(dataObject.Id, XTable.Get(XTable.ID.OpcAttrValue), StringComparison.Ordinal))
{ {
XmlElement element = dataObject.GetXml(); XmlElement element = dataObject.GetXml();
...@@ -184,7 +184,7 @@ private static XmlElement SelectSubObjectNodeForXAdESInDataObjects(Signature sig ...@@ -184,7 +184,7 @@ private static XmlElement SelectSubObjectNodeForXAdESInDataObjects(Signature sig
temp = temp.ParentNode; temp = temp.ParentNode;
// only match if the target is in the XAdES namespace // only match if the target is in the XAdES namespace
if ((temp != null) && (String.CompareOrdinal(temp.NamespaceURI, _XAdESNameSpace) == 0)) if ((temp != null) && (string.Equals(temp.NamespaceURI, _XAdESNameSpace, StringComparison.Ordinal)))
{ {
node = local as XmlElement; node = local as XmlElement;
// continue searching, to find duplicates from different objects // continue searching, to find duplicates from different objects
......
...@@ -195,7 +195,7 @@ private static Exception GetExceptionIfPartUriInvalid(Uri partUri, out string pa ...@@ -195,7 +195,7 @@ private static Exception GetExceptionIfPartUriInvalid(Uri partUri, out string pa
//to verify the uri correctly. //to verify the uri correctly.
//We perform the comparison in a case-insensitive manner, as at this point, //We perform the comparison in a case-insensitive manner, as at this point,
//only escaped hex digits (A-F) might vary in casing. //only escaped hex digits (A-F) might vary in casing.
if (String.CompareOrdinal(partUri.OriginalString.ToUpperInvariant(), wellFormedPartName.ToUpperInvariant()) != 0) if (!string.Equals(partUri.OriginalString, wellFormedPartName, StringComparison.OrdinalIgnoreCase))
return new ArgumentException(SR.InvalidPartUri); return new ArgumentException(SR.InvalidPartUri);
//if we get here, the partUri is valid and so we return null, as there is no exception. //if we get here, the partUri is valid and so we return null, as there is no exception.
...@@ -513,7 +513,7 @@ private bool IsRelationshipUri() ...@@ -513,7 +513,7 @@ private bool IsRelationshipUri()
(segments[segments.Length - 1].Length > _relationshipPartExtensionName.Length)) (segments[segments.Length - 1].Length > _relationshipPartExtensionName.Length))
{ {
// look for "_RELS" segment which must be second last segment // look for "_RELS" segment which must be second last segment
result = (String.CompareOrdinal(segments[segments.Length - 2], _relationshipPartUpperCaseSegmentName) == 0); result = string.Equals(segments[segments.Length - 2], _relationshipPartUpperCaseSegmentName, StringComparison.Ordinal);
} }
// In addition we need to make sure that the relationship is not created by taking another relationship // In addition we need to make sure that the relationship is not created by taking another relationship
......
...@@ -710,7 +710,7 @@ out ps ...@@ -710,7 +710,7 @@ out ps
pszVal = Marshal.StringToCoTaskMemAnsi(inputString); pszVal = Marshal.StringToCoTaskMemAnsi(inputString);
string convertedString = Marshal.PtrToStringAnsi(pszVal); string convertedString = Marshal.PtrToStringAnsi(pszVal);
if (String.CompareOrdinal(inputString, convertedString) != 0) if (!string.Equals(inputString, convertedString, StringComparison.Ordinal))
{ {
// The string is not an ASCII string. Use UTF-8 to encode it! // The string is not an ASCII string. Use UTF-8 to encode it!
byte[] byteArray = UTF8Encoding.UTF8.GetBytes(inputString); byte[] byteArray = UTF8Encoding.UTF8.GetBytes(inputString);
......
...@@ -150,9 +150,7 @@ internal bool Verify(X509Certificate2 signer) ...@@ -150,9 +150,7 @@ internal bool Verify(X509Certificate2 signer)
// Compare ordinal case-sensitive which is more strict than normal ContentType // Compare ordinal case-sensitive which is more strict than normal ContentType
// comparision because this is manadated by the OPC specification. // comparision because this is manadated by the OPC specification.
PackagePart part = _manager.Package.GetPart(partEntry.Uri); PackagePart part = _manager.Package.GetPart(partEntry.Uri);
if (String.CompareOrdinal( if (!string.Equals(partEntry.ContentType.OriginalString, part.ValidatedContentType().OriginalString, StringComparison.Ordinal))
partEntry.ContentType.OriginalString,
part.ValidatedContentType().OriginalString) != 0)
{ {
result = false; // content type mismatch result = false; // content type mismatch
break; break;
...@@ -164,7 +162,7 @@ internal bool Verify(X509Certificate2 signer) ...@@ -164,7 +162,7 @@ internal bool Verify(X509Certificate2 signer)
{ {
// ensure hash algorithm object is available - re-use if possible // ensure hash algorithm object is available - re-use if possible
if (((hashAlgorithm != null) && (!hashAlgorithm.CanReuseTransform)) || if (((hashAlgorithm != null) && (!hashAlgorithm.CanReuseTransform)) ||
String.CompareOrdinal(partEntry.HashAlgorithm, currentHashAlgorithmName) != 0) !string.Equals(partEntry.HashAlgorithm, currentHashAlgorithmName, StringComparison.Ordinal))
{ {
if (hashAlgorithm != null) if (hashAlgorithm != null)
((IDisposable)hashAlgorithm).Dispose(); ((IDisposable)hashAlgorithm).Dispose();
...@@ -185,7 +183,7 @@ internal bool Verify(X509Certificate2 signer) ...@@ -185,7 +183,7 @@ internal bool Verify(X509Certificate2 signer)
String base64EncodedHashValue = GenerateDigestValue(s, partEntry.Transforms, hashAlgorithm); String base64EncodedHashValue = GenerateDigestValue(s, partEntry.Transforms, hashAlgorithm);
// now compare the hash - must be identical // now compare the hash - must be identical
if (String.CompareOrdinal(base64EncodedHashValue, partEntry.HashValue) != 0) if (!string.Equals(base64EncodedHashValue, partEntry.HashValue, StringComparison.Ordinal))
{ {
result = false; // hash mismatch result = false; // hash mismatch
break; break;
...@@ -459,7 +457,7 @@ internal String TimeFormat ...@@ -459,7 +457,7 @@ internal String TimeFormat
{ {
// ignore empty strings at this point (as well as Relationship Transforms) - these are legal // ignore empty strings at this point (as well as Relationship Transforms) - these are legal
if ((transformName.Length == 0) if ((transformName.Length == 0)
|| (String.CompareOrdinal(transformName, XTable.Get(XTable.ID.RelationshipsTransformName)) == 0)) || (string.Equals(transformName, XTable.Get(XTable.ID.RelationshipsTransformName), StringComparison.Ordinal)))
{ {
continue; continue;
} }
...@@ -556,11 +554,11 @@ private static Transform StringToTransform(String transformName) ...@@ -556,11 +554,11 @@ private static Transform StringToTransform(String transformName)
{ {
Invariant.Assert(transformName != null); Invariant.Assert(transformName != null);
if (String.CompareOrdinal(transformName, SignedXml.XmlDsigC14NTransformUrl) == 0) if (string.Equals(transformName, SignedXml.XmlDsigC14NTransformUrl, StringComparison.Ordinal))
{ {
return new XmlDsigC14NTransform(); return new XmlDsigC14NTransform();
} }
else if (String.CompareOrdinal(transformName, SignedXml.XmlDsigC14NWithCommentsTransformUrl) == 0) else if (string.Equals(transformName, SignedXml.XmlDsigC14NWithCommentsTransformUrl, StringComparison.Ordinal))
{ {
return new XmlDsigC14NWithCommentsTransform(); return new XmlDsigC14NWithCommentsTransform();
} }
...@@ -582,8 +580,8 @@ internal static bool IsValidXmlCanonicalizationTransform(String transformName) ...@@ -582,8 +580,8 @@ internal static bool IsValidXmlCanonicalizationTransform(String transformName)
{ {
Invariant.Assert(transformName != null); Invariant.Assert(transformName != null);
if (String.CompareOrdinal(transformName, SignedXml.XmlDsigC14NTransformUrl) == 0 || if (string.Equals(transformName, SignedXml.XmlDsigC14NTransformUrl, StringComparison.Ordinal) ||
String.CompareOrdinal(transformName, SignedXml.XmlDsigC14NWithCommentsTransformUrl) == 0) string.Equals(transformName, SignedXml.XmlDsigC14NWithCommentsTransformUrl, StringComparison.Ordinal))
{ {
return true; return true;
} }
...@@ -650,8 +648,8 @@ private SignedXml EnsureXmlSignatureParsed() ...@@ -650,8 +648,8 @@ private SignedXml EnsureXmlSignatureParsed()
} }
if ((node.NodeType != XmlNodeType.Element) || if ((node.NodeType != XmlNodeType.Element) ||
(String.CompareOrdinal(node.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) != 0) || (!string.Equals(node.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal)) ||
(String.CompareOrdinal(node.LocalName, XTable.Get(XTable.ID.SignatureTagName)) != 0)) (!string.Equals(node.LocalName, XTable.Get(XTable.ID.SignatureTagName), StringComparison.Ordinal)))
{ {
throw new XmlException(SR.PackageSignatureCorruption); throw new XmlException(SR.PackageSignatureCorruption);
} }
...@@ -993,7 +991,7 @@ private void ParsePackageDataObject() ...@@ -993,7 +991,7 @@ private void ParsePackageDataObject()
// parse the <Object> tag - ensure that it is in the correct namespace // parse the <Object> tag - ensure that it is in the correct namespace
reader.Read(); // enter the Object tag reader.Read(); // enter the Object tag
if (String.CompareOrdinal(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) != 0) if (!string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal))
throw new XmlException(SR.XmlSignatureParseError); throw new XmlException(SR.XmlSignatureParseError);
string signaturePropertiesTagName = XTable.Get(XTable.ID.SignaturePropertiesTagName); string signaturePropertiesTagName = XTable.Get(XTable.ID.SignaturePropertiesTagName);
...@@ -1003,10 +1001,10 @@ private void ParsePackageDataObject() ...@@ -1003,10 +1001,10 @@ private void ParsePackageDataObject()
while (reader.Read() && (reader.NodeType == XmlNodeType.Element)) while (reader.Read() && (reader.NodeType == XmlNodeType.Element))
{ {
if (reader.MoveToContent() == XmlNodeType.Element if (reader.MoveToContent() == XmlNodeType.Element
&& (String.CompareOrdinal(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) == 0) && (string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal))
&& reader.Depth == 1) && reader.Depth == 1)
{ {
if (!signaturePropertiesTagFound && String.CompareOrdinal(reader.LocalName, signaturePropertiesTagName) == 0) if (!signaturePropertiesTagFound && string.Equals(reader.LocalName, signaturePropertiesTagName, StringComparison.Ordinal))
{ {
signaturePropertiesTagFound = true; signaturePropertiesTagFound = true;
...@@ -1016,7 +1014,7 @@ private void ParsePackageDataObject() ...@@ -1016,7 +1014,7 @@ private void ParsePackageDataObject()
continue; continue;
} }
else if (!manifestTagFound && String.CompareOrdinal(reader.LocalName, manifestTagName) == 0) else if (!manifestTagFound && string.Equals(reader.LocalName, manifestTagName, StringComparison.Ordinal))
{ {
manifestTagFound = true; manifestTagFound = true;
...@@ -1052,7 +1050,7 @@ private DataObject GetPackageDataObject() ...@@ -1052,7 +1050,7 @@ private DataObject GetPackageDataObject()
DataObject returnValue = null; DataObject returnValue = null;
foreach (DataObject dataObject in _signedXml.Signature.ObjectList) foreach (DataObject dataObject in _signedXml.Signature.ObjectList)
{ {
if (String.CompareOrdinal(dataObject.Id, opcId) == 0) if (string.Equals(dataObject.Id, opcId, StringComparison.Ordinal))
{ {
// duplicates not allowed // duplicates not allowed
if (returnValue != null) if (returnValue != null)
...@@ -1179,7 +1177,7 @@ private void ValidateReferences(IEnumerable references, bool allowPackageSpecifi ...@@ -1179,7 +1177,7 @@ private void ValidateReferences(IEnumerable references, bool allowPackageSpecifi
{ {
//As per the OPC spec, there MUST be exactly one package specific reference to the //As per the OPC spec, there MUST be exactly one package specific reference to the
//package specific <Object> element //package specific <Object> element
if (String.CompareOrdinal(currentReference.Uri, XTable.Get(XTable.ID.OpcLinkAttrValue)) == 0) if (string.Equals(currentReference.Uri, XTable.Get(XTable.ID.OpcLinkAttrValue), StringComparison.Ordinal))
{ {
if (!allowPackageSpecificReferences) if (!allowPackageSpecificReferences)
throw new ArgumentException(SR.PackageSpecificReferenceTagMustBeUnique); throw new ArgumentException(SR.PackageSpecificReferenceTagMustBeUnique);
......
...@@ -131,8 +131,8 @@ internal static class XmlSignatureManifest ...@@ -131,8 +131,8 @@ internal static class XmlSignatureManifest
while (reader.Read() && (reader.MoveToContent() == XmlNodeType.Element)) while (reader.Read() && (reader.MoveToContent() == XmlNodeType.Element))
{ {
// should be on a <Reference> tag // should be on a <Reference> tag
if (String.CompareOrdinal(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) == 0 if (string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal)
&& (String.CompareOrdinal(reader.LocalName, referenceTagName) == 0) && (string.Equals(reader.LocalName, referenceTagName, StringComparison.Ordinal))
&& reader.Depth == 2) && reader.Depth == 2)
{ {
// Parse each reference - distinguish between Relationships and Parts // Parse each reference - distinguish between Relationships and Parts
...@@ -168,7 +168,7 @@ private static string ParseDigestAlgorithmTag(XmlReader reader) ...@@ -168,7 +168,7 @@ private static string ParseDigestAlgorithmTag(XmlReader reader)
{ {
// verify namespace and lack of attributes // verify namespace and lack of attributes
if (PackagingUtilities.GetNonXmlnsAttributeCount(reader) > 1 if (PackagingUtilities.GetNonXmlnsAttributeCount(reader) > 1
|| String.CompareOrdinal(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) != 0 || !string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal)
|| reader.Depth != 3) || reader.Depth != 3)
throw new XmlException(SR.XmlSignatureParseError); throw new XmlException(SR.XmlSignatureParseError);
...@@ -195,7 +195,7 @@ private static string ParseDigestValueTag(XmlReader reader) ...@@ -195,7 +195,7 @@ private static string ParseDigestValueTag(XmlReader reader)
// verify namespace and lack of attributes // verify namespace and lack of attributes
if (PackagingUtilities.GetNonXmlnsAttributeCount(reader) > 0 if (PackagingUtilities.GetNonXmlnsAttributeCount(reader) > 0
|| String.CompareOrdinal(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) != 0 || !string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal)
|| reader.Depth != 3) || reader.Depth != 3)
throw new XmlException(SR.XmlSignatureParseError); throw new XmlException(SR.XmlSignatureParseError);
...@@ -261,7 +261,7 @@ private static PartManifestEntry ParseReference(XmlReader reader) ...@@ -261,7 +261,7 @@ private static PartManifestEntry ParseReference(XmlReader reader)
while (reader.Read() && (reader.MoveToContent() == XmlNodeType.Element)) while (reader.Read() && (reader.MoveToContent() == XmlNodeType.Element))
{ {
// Correct Namespace? // Correct Namespace?
if (String.CompareOrdinal(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) != 0 if (!string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal)
|| reader.Depth != 3) || reader.Depth != 3)
{ {
throw new XmlException(SR.PackageSignatureCorruption); throw new XmlException(SR.PackageSignatureCorruption);
...@@ -269,7 +269,7 @@ private static PartManifestEntry ParseReference(XmlReader reader) ...@@ -269,7 +269,7 @@ private static PartManifestEntry ParseReference(XmlReader reader)
// DigestMethod? // DigestMethod?
if (hashAlgorithm == null && if (hashAlgorithm == null &&
String.CompareOrdinal(reader.LocalName, XTable.Get(XTable.ID.DigestMethodTagName)) == 0) string.Equals(reader.LocalName, XTable.Get(XTable.ID.DigestMethodTagName), StringComparison.Ordinal))
{ {
hashAlgorithm = ParseDigestAlgorithmTag(reader); hashAlgorithm = ParseDigestAlgorithmTag(reader);
continue; continue;
...@@ -277,7 +277,7 @@ private static PartManifestEntry ParseReference(XmlReader reader) ...@@ -277,7 +277,7 @@ private static PartManifestEntry ParseReference(XmlReader reader)
// DigestValue? // DigestValue?
if (hashValue == null && if (hashValue == null &&
String.CompareOrdinal(reader.LocalName, XTable.Get(XTable.ID.DigestValueTagName)) == 0) string.Equals(reader.LocalName, XTable.Get(XTable.ID.DigestValueTagName), StringComparison.Ordinal))
{ {
hashValue = ParseDigestValueTag(reader); hashValue = ParseDigestValueTag(reader);
continue; continue;
...@@ -285,7 +285,7 @@ private static PartManifestEntry ParseReference(XmlReader reader) ...@@ -285,7 +285,7 @@ private static PartManifestEntry ParseReference(XmlReader reader)
// TransformsTag? // TransformsTag?
if (!transformsParsed && if (!transformsParsed &&
String.CompareOrdinal(reader.LocalName, XTable.Get(XTable.ID.TransformsTagName)) == 0) string.Equals(reader.LocalName, XTable.Get(XTable.ID.TransformsTagName), StringComparison.Ordinal))
{ {
transforms = ParseTransformsTag(reader, partUri, ref relationshipSelectors); transforms = ParseTransformsTag(reader, partUri, ref relationshipSelectors);
transformsParsed = true; transformsParsed = true;
...@@ -341,8 +341,8 @@ private static List<String> ParseTransformsTag(XmlReader reader, Uri partUri, re ...@@ -341,8 +341,8 @@ private static List<String> ParseTransformsTag(XmlReader reader, Uri partUri, re
// at this level, all tags must be Transform tags // at this level, all tags must be Transform tags
if (reader.Depth != 4 if (reader.Depth != 4
|| String.CompareOrdinal(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl) != 0 || !string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal)
|| String.CompareOrdinal(reader.LocalName, XTable.Get(XTable.ID.TransformTagName)) != 0) || !string.Equals(reader.LocalName, XTable.Get(XTable.ID.TransformTagName), StringComparison.Ordinal))
{ {
throw new XmlException(SR.XmlSignatureParseError); throw new XmlException(SR.XmlSignatureParseError);
} }
...@@ -357,7 +357,7 @@ private static List<String> ParseTransformsTag(XmlReader reader, Uri partUri, re ...@@ -357,7 +357,7 @@ private static List<String> ParseTransformsTag(XmlReader reader, Uri partUri, re
if ((transformName != null) && (transformName.Length > 0)) if ((transformName != null) && (transformName.Length > 0))
{ {
// what type of transform? // what type of transform?
if (String.CompareOrdinal(transformName, XTable.Get(XTable.ID.RelationshipsTransformName)) == 0) if (string.Equals(transformName, XTable.Get(XTable.ID.RelationshipsTransformName), StringComparison.Ordinal))
{ {
if (!relationshipTransformFound) if (!relationshipTransformFound)
{ {
...@@ -430,10 +430,10 @@ private static void ParseRelationshipsTransform(XmlReader reader, Uri partUri, r ...@@ -430,10 +430,10 @@ private static void ParseRelationshipsTransform(XmlReader reader, Uri partUri, r
// both types have no children, a single required attribute and belong to the OPC namespace // both types have no children, a single required attribute and belong to the OPC namespace
if (reader.IsEmptyElement if (reader.IsEmptyElement
&& PackagingUtilities.GetNonXmlnsAttributeCount(reader) == 1 && PackagingUtilities.GetNonXmlnsAttributeCount(reader) == 1
&& (String.CompareOrdinal(reader.NamespaceURI, XTable.Get(XTable.ID.OpcSignatureNamespace)) == 0)) && (string.Equals(reader.NamespaceURI, XTable.Get(XTable.ID.OpcSignatureNamespace), StringComparison.Ordinal)))
{ {
// <RelationshipReference>? // <RelationshipReference>?
if (String.CompareOrdinal(reader.LocalName, XTable.Get(XTable.ID.RelationshipReferenceTagName)) == 0) if (string.Equals(reader.LocalName, XTable.Get(XTable.ID.RelationshipReferenceTagName), StringComparison.Ordinal))
{ {
// RelationshipReference tags are legal and these must be empty with a single SourceId attribute // RelationshipReference tags are legal and these must be empty with a single SourceId attribute
// get the SourceId attribute // get the SourceId attribute
...@@ -448,7 +448,7 @@ private static void ParseRelationshipsTransform(XmlReader reader, Uri partUri, r ...@@ -448,7 +448,7 @@ private static void ParseRelationshipsTransform(XmlReader reader, Uri partUri, r
continue; continue;
} }
} // <RelationshipsGroupReference>? } // <RelationshipsGroupReference>?
else if ((String.CompareOrdinal(reader.LocalName, XTable.Get(XTable.ID.RelationshipsGroupReferenceTagName)) == 0)) else if ((string.Equals(reader.LocalName, XTable.Get(XTable.ID.RelationshipsGroupReferenceTagName), StringComparison.Ordinal)))
{ {
// RelationshipsGroupReference tags must be empty with a single SourceType attribute // RelationshipsGroupReference tags must be empty with a single SourceType attribute
string type = reader.GetAttribute(XTable.Get(XTable.ID.SourceTypeAttrName)); string type = reader.GetAttribute(XTable.Get(XTable.ID.SourceTypeAttrName));
......
...@@ -172,8 +172,8 @@ internal static DateTime ParseSigningTime(XmlReader reader, string signatureId, ...@@ -172,8 +172,8 @@ internal static DateTime ParseSigningTime(XmlReader reader, string signatureId,
{ {
//Looking for <SignatureProperty> tag //Looking for <SignatureProperty> tag
if (reader.MoveToContent() == XmlNodeType.Element if (reader.MoveToContent() == XmlNodeType.Element
&& (String.CompareOrdinal(reader.NamespaceURI, w3cSignatureNameSpace) == 0) && (string.Equals(reader.NamespaceURI, w3cSignatureNameSpace, StringComparison.Ordinal))
&& (String.CompareOrdinal(reader.LocalName, signaturePropertyTag) == 0) && (string.Equals(reader.LocalName, signaturePropertyTag, StringComparison.Ordinal))
&& reader.Depth == 2) && reader.Depth == 2)
{ {
//Verify Attributes //Verify Attributes
...@@ -201,13 +201,13 @@ internal static DateTime ParseSigningTime(XmlReader reader, string signatureId, ...@@ -201,13 +201,13 @@ internal static DateTime ParseSigningTime(XmlReader reader, string signatureId,
//Look for end tag corresponding to </SignatureProperty> or //Look for end tag corresponding to </SignatureProperty> or
//if these are other custom defined properties, then anything with //if these are other custom defined properties, then anything with
//depth greater than 2 should be ignored as these can be nested elements. //depth greater than 2 should be ignored as these can be nested elements.
if (((String.CompareOrdinal(signaturePropertyTag, reader.LocalName) == 0 if (((string.Equals(signaturePropertyTag, reader.LocalName, StringComparison.Ordinal)
&& (reader.NodeType == XmlNodeType.EndElement))) && (reader.NodeType == XmlNodeType.EndElement)))
|| reader.Depth > 2) || reader.Depth > 2)
continue; continue;
else else
//If we find the end tag for </SignatureProperties> then we can stop parsing //If we find the end tag for </SignatureProperties> then we can stop parsing
if ((String.CompareOrdinal(signaturePropertiesTag, reader.LocalName) == 0 if ((string.Equals(signaturePropertiesTag, reader.LocalName, StringComparison.Ordinal)
&& (reader.NodeType == XmlNodeType.EndElement))) && (reader.NodeType == XmlNodeType.EndElement)))
break; break;
else else
...@@ -255,19 +255,19 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF ...@@ -255,19 +255,19 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF
//Look for <SignatureTime> Tag //Look for <SignatureTime> Tag
if (reader.Read() if (reader.Read()
&& reader.MoveToContent() == XmlNodeType.Element && reader.MoveToContent() == XmlNodeType.Element
&& (String.CompareOrdinal(reader.NamespaceURI, opcSignatureNameSpace) == 0) && (string.Equals(reader.NamespaceURI, opcSignatureNameSpace, StringComparison.Ordinal))
&& (String.CompareOrdinal(reader.LocalName, signatureTimeTag) == 0) && (string.Equals(reader.LocalName, signatureTimeTag, StringComparison.Ordinal))
&& reader.Depth == 3 && reader.Depth == 3
&& PackagingUtilities.GetNonXmlnsAttributeCount(reader) == expectedAttributeCount) && PackagingUtilities.GetNonXmlnsAttributeCount(reader) == expectedAttributeCount)
{ {
while (reader.Read()) while (reader.Read())
{ {
if (String.CompareOrdinal(reader.NamespaceURI, opcSignatureNameSpace) == 0 if (string.Equals(reader.NamespaceURI, opcSignatureNameSpace, StringComparison.Ordinal)
&& reader.MoveToContent() == XmlNodeType.Element && reader.MoveToContent() == XmlNodeType.Element
&& reader.Depth == 4) && reader.Depth == 4)
{ {
// which tag do we have? // which tag do we have?
if ((String.CompareOrdinal(reader.LocalName, timeValueTagName) == 0) if ((string.Equals(reader.LocalName, timeValueTagName, StringComparison.Ordinal))
&& PackagingUtilities.GetNonXmlnsAttributeCount(reader) == expectedAttributeCount) && PackagingUtilities.GetNonXmlnsAttributeCount(reader) == expectedAttributeCount)
{ {
if (timeValue == null if (timeValue == null
...@@ -287,7 +287,7 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF ...@@ -287,7 +287,7 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF
//are other nested elements of if they are of a different XmlNodeType type //are other nested elements of if they are of a different XmlNodeType type
throw new XmlException(SR.PackageSignatureCorruption); throw new XmlException(SR.PackageSignatureCorruption);
} }
else if ((String.CompareOrdinal(reader.LocalName, timeFormatTagName) == 0) else if ((string.Equals(reader.LocalName, timeFormatTagName, StringComparison.Ordinal))
&& PackagingUtilities.GetNonXmlnsAttributeCount(reader) == expectedAttributeCount) && PackagingUtilities.GetNonXmlnsAttributeCount(reader) == expectedAttributeCount)
{ {
if (timeFormat == null if (timeFormat == null
...@@ -314,7 +314,7 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF ...@@ -314,7 +314,7 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF
else else
//If we have encountered the end tag for the <SignatureTime> tag //If we have encountered the end tag for the <SignatureTime> tag
//then we are done parsing the tag, and we can stop the parsing. //then we are done parsing the tag, and we can stop the parsing.
if (String.CompareOrdinal(signatureTimeTag, reader.LocalName) == 0 if (string.Equals(signatureTimeTag, reader.LocalName, StringComparison.Ordinal)
&& (reader.NodeType == XmlNodeType.EndElement)) && (reader.NodeType == XmlNodeType.EndElement))
{ {
//We must find a </SignatureProperty> tag at this point, //We must find a </SignatureProperty> tag at this point,
...@@ -322,7 +322,7 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF ...@@ -322,7 +322,7 @@ private static DateTime ParseSignatureTimeTag(XmlReader reader, out String timeF
//other tags nested here and that is an error. //other tags nested here and that is an error.
if (reader.Read() if (reader.Read()
&& reader.MoveToContent() == XmlNodeType.EndElement && reader.MoveToContent() == XmlNodeType.EndElement
&& String.CompareOrdinal(signaturePropertyTag, reader.LocalName) == 0) && string.Equals(signaturePropertyTag, reader.LocalName, StringComparison.Ordinal))
break; break;
else else
throw new XmlException(SR.PackageSignatureCorruption); throw new XmlException(SR.PackageSignatureCorruption);
...@@ -386,7 +386,7 @@ private static int GetIndex(String format) ...@@ -386,7 +386,7 @@ private static int GetIndex(String format)
{ {
for (int i = 0; i < _dateTimePatternMap.GetLength(0); i++) for (int i = 0; i < _dateTimePatternMap.GetLength(0); i++)
{ {
if (String.CompareOrdinal(_dateTimePatternMap[i].Format, format) == 0) if (string.Equals(_dateTimePatternMap[i].Format, format, StringComparison.Ordinal))
{ {
return i; return i;
} }
...@@ -414,7 +414,7 @@ private static bool VerifyIdAttribute(XmlReader reader) ...@@ -414,7 +414,7 @@ private static bool VerifyIdAttribute(XmlReader reader)
string idAttrValue = reader.GetAttribute(XTable.Get(XTable.ID.SignaturePropertyIdAttrName)); string idAttrValue = reader.GetAttribute(XTable.Get(XTable.ID.SignaturePropertyIdAttrName));
if(idAttrValue!=null if(idAttrValue!=null
&& (String.CompareOrdinal(idAttrValue,XTable.Get(XTable.ID.SignaturePropertyIdAttrValue)) == 0)) && (string.Equals(idAttrValue, XTable.Get(XTable.ID.SignaturePropertyIdAttrValue), StringComparison.Ordinal)))
return true; return true;
else else
return false; return false;
...@@ -435,13 +435,13 @@ private static bool VerifyTargetAttribute(XmlReader reader, string signatureId) ...@@ -435,13 +435,13 @@ private static bool VerifyTargetAttribute(XmlReader reader, string signatureId)
//whether there is an Id attribute on the <Signature> tag or no, //whether there is an Id attribute on the <Signature> tag or no,
//an empty Target attribute on <SignatureProperty> tag, is allowed. //an empty Target attribute on <SignatureProperty> tag, is allowed.
//Empty string means current document //Empty string means current document
if (String.CompareOrdinal(idTargetValue, String.Empty) == 0) if (string.Equals(idTargetValue, String.Empty, StringComparison.Ordinal))
return true; return true;
else else
{ {
//If the Target attribute has a non-empty string then //If the Target attribute has a non-empty string then
//it must match the <Signature> tag Id attribute value //it must match the <Signature> tag Id attribute value
if (signatureId != null && String.CompareOrdinal(idTargetValue, "#" + signatureId) == 0) if (signatureId != null && string.Equals(idTargetValue, "#" + signatureId, StringComparison.Ordinal))
return true; return true;
else else
return false; return false;
......
...@@ -663,7 +663,7 @@ private static int FindNewEntryIndex(ArrayList oldList, ArrayList newList) ...@@ -663,7 +663,7 @@ private static int FindNewEntryIndex(ArrayList oldList, ArrayList newList)
foreach (string oldElement in oldList) foreach (string oldElement in oldList)
{ {
if (String.CompareOrdinal(newElement, oldElement) == 0) if (string.Equals(newElement, oldElement, StringComparison.Ordinal))
{ {
matchFound = true; matchFound = true;
break; break;
...@@ -1331,9 +1331,7 @@ internal static ContentUser ...@@ -1331,9 +1331,7 @@ internal static ContentUser
0); 0);
// We recognise authentication type Windows everything else is assumed to be Passport // We recognise authentication type Windows everything else is assumed to be Passport
if (String.CompareOrdinal( if (string.Equals(AuthenticationType.Windows.ToString(), authenticationType, StringComparison.OrdinalIgnoreCase))
AuthenticationType.Windows.ToString().ToUpper(CultureInfo.InvariantCulture),
authenticationType.ToUpper(CultureInfo.InvariantCulture)) == 0)
{ {
return new ContentUser(name, AuthenticationType.Windows); return new ContentUser(name, AuthenticationType.Windows);
} }
...@@ -1853,7 +1851,7 @@ internal static Uri GetUseLicenseAcquisitionUriFromPublishLicense(string publish ...@@ -1853,7 +1851,7 @@ internal static Uri GetUseLicenseAcquisitionUriFromPublishLicense(string publish
distributionPointQueryHandle, distributionPointQueryHandle,
NativeConstants.QUERY_OBJECTTYPE, NativeConstants.QUERY_OBJECTTYPE,
0); 0);
if (String.CompareOrdinal(addressType, distributionPointType) == 0) if (string.Equals(addressType, distributionPointType, StringComparison.Ordinal))
{ {
nameAttributeValue = GetUnboundLicenseStringAttribute( nameAttributeValue = GetUnboundLicenseStringAttribute(
distributionPointQueryHandle, distributionPointQueryHandle,
...@@ -1936,7 +1934,7 @@ internal static Nullable<ContentRight> GetRightFromString(string rightName) ...@@ -1936,7 +1934,7 @@ internal static Nullable<ContentRight> GetRightFromString(string rightName)
for (int i = 0; i < _rightEnums.Length; i++) for (int i = 0; i < _rightEnums.Length; i++)
{ {
if (String.CompareOrdinal(_rightNames[i], rightName) == 0) if (string.Equals(_rightNames[i], rightName, StringComparison.Ordinal))
{ {
return _rightEnums[i]; return _rightEnums[i];
} }
......
...@@ -594,7 +594,7 @@ static private ContentUser GetUserFromHandle(SafeRightsManagementPubHandle userH ...@@ -594,7 +594,7 @@ static private ContentUser GetUserFromHandle(SafeRightsManagementPubHandle userH
string userIdTypeStr = null; string userIdTypeStr = null;
if (userIdType != null) if (userIdType != null)
{ {
userIdTypeStr = userIdType.ToString().ToUpperInvariant(); userIdTypeStr = userIdType.ToString();
} }
string userIdStr = null; string userIdStr = null;
...@@ -604,15 +604,15 @@ static private ContentUser GetUserFromHandle(SafeRightsManagementPubHandle userH ...@@ -604,15 +604,15 @@ static private ContentUser GetUserFromHandle(SafeRightsManagementPubHandle userH
} }
// based on the UserTypeId build appropriate instance of User class // based on the UserTypeId build appropriate instance of User class
if (String.CompareOrdinal(userIdTypeStr, AuthenticationType.Windows.ToString().ToUpperInvariant()) == 0) if (string.Equals(userIdTypeStr, AuthenticationType.Windows.ToString(), StringComparison.OrdinalIgnoreCase))
{ {
return new ContentUser(userNameStr, AuthenticationType.Windows); return new ContentUser(userNameStr, AuthenticationType.Windows);
} }
else if (String.CompareOrdinal(userIdTypeStr, AuthenticationType.Passport.ToString().ToUpperInvariant()) == 0) else if (string.Equals(userIdTypeStr, AuthenticationType.Passport.ToString(), StringComparison.OrdinalIgnoreCase))
{ {
return new ContentUser(userNameStr, AuthenticationType.Passport); return new ContentUser(userNameStr, AuthenticationType.Passport);
} }
else if (String.CompareOrdinal(userIdTypeStr, AuthenticationType.Internal.ToString().ToUpperInvariant()) == 0) else if (string.Equals(userIdTypeStr, AuthenticationType.Internal.ToString(), StringComparison.OrdinalIgnoreCase))
{ {
// internal anyone user // internal anyone user
if (ContentUser.CompareToAnyone(userIdStr)) if (ContentUser.CompareToAnyone(userIdStr))
...@@ -624,7 +624,7 @@ static private ContentUser GetUserFromHandle(SafeRightsManagementPubHandle userH ...@@ -624,7 +624,7 @@ static private ContentUser GetUserFromHandle(SafeRightsManagementPubHandle userH
return ContentUser.OwnerUser; return ContentUser.OwnerUser;
} }
} }
else if (String.CompareOrdinal(userIdTypeStr, UnspecifiedAuthenticationType.ToUpperInvariant()) == 0) else if (string.Equals(userIdTypeStr, UnspecifiedAuthenticationType, StringComparison.OrdinalIgnoreCase))
{ {
return new ContentUser(userNameStr, AuthenticationType.WindowsPassport); return new ContentUser(userNameStr, AuthenticationType.WindowsPassport);
} }
......
...@@ -231,7 +231,7 @@ public override bool Equals(Object obj) ...@@ -231,7 +231,7 @@ public override bool Equals(Object obj)
// Parameter 'v' to this public method must be validated: A null-dereference can occur here. // Parameter 'v' to this public method must be validated: A null-dereference can occur here.
//This is a false positive as the checks above can gurantee no null dereference will occur //This is a false positive as the checks above can gurantee no null dereference will occur
#pragma warning disable 6506 #pragma warning disable 6506
if (String.CompareOrdinal(_featureIdentifier.ToUpperInvariant(), v.FeatureIdentifier.ToUpperInvariant()) != 0 if (!string.Equals(_featureIdentifier, v.FeatureIdentifier, StringComparison.OrdinalIgnoreCase)
|| _reader != v.ReaderVersion || _reader != v.ReaderVersion
|| _writer != v.WriterVersion || _writer != v.WriterVersion
|| _updater != v.UpdaterVersion) || _updater != v.UpdaterVersion)
......
...@@ -831,19 +831,15 @@ private void EnsureTransformInformation() ...@@ -831,19 +831,15 @@ private void EnsureTransformInformation()
string id = dataTransform.TransformIdentifier as string; string id = dataTransform.TransformIdentifier as string;
if (id != null) if (id != null)
{ {
id = id.ToUpperInvariant(); if (string.Equals(id, RightsManagementEncryptionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase)
if (String.CompareOrdinal(id,
RightsManagementEncryptionTransform.ClassTransformIdentifier.ToUpperInvariant()) == 0
&& &&
(dataTransform as RightsManagementEncryptionTransform) != null) (dataTransform as RightsManagementEncryptionTransform) != null)
{ {
_encryptionOption = EncryptionOption.RightsManagement; _encryptionOption = EncryptionOption.RightsManagement;
} }
else if (String.CompareOrdinal(id, else if (string.Equals(id, CompressionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase)
CompressionTransform.ClassTransformIdentifier.ToUpperInvariant()) == 0 &&
&& (dataTransform as CompressionTransform) != null)
(dataTransform as CompressionTransform) != null)
{ {
// We don't persist the compression level used during compression process // We don't persist the compression level used during compression process
// When we access the stream, all we can determine is whether it is compressed or not // When we access the stream, all we can determine is whether it is compressed or not
......
...@@ -937,8 +937,7 @@ private void ...@@ -937,8 +937,7 @@ private void
{ {
string id = dataTransform.TransformIdentifier as string; string id = dataTransform.TransformIdentifier as string;
if (id != null && if (id != null &&
String.CompareOrdinal(id.ToUpperInvariant(), string.Equals(id, RightsManagementEncryptionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase))
RightsManagementEncryptionTransform.ClassTransformIdentifier.ToUpperInvariant()) == 0)
{ {
// Do not allow more than one RM Transform // Do not allow more than one RM Transform
if (rmet != null) if (rmet != null)
......
...@@ -931,7 +931,7 @@ public StringMatchPredicate(String id) ...@@ -931,7 +931,7 @@ public StringMatchPredicate(String id)
public bool Match(String id) public bool Match(String id)
{ {
return (String.CompareOrdinal(_id, id) == 0); return (string.Equals(_id, id, StringComparison.Ordinal));
} }
private string _id; private string _id;
...@@ -993,7 +993,7 @@ private void VerifyPartsExist(IEnumerable<Uri> parts) ...@@ -993,7 +993,7 @@ private void VerifyPartsExist(IEnumerable<Uri> parts)
foreach (DataObject obj in signatureObjects) foreach (DataObject obj in signatureObjects)
{ {
// ensure they don't duplicate the reserved one // ensure they don't duplicate the reserved one
if (String.CompareOrdinal(obj.Id, XTable.Get(XTable.ID.OpcAttrValue)) == 0) if (string.Equals(obj.Id, XTable.Get(XTable.ID.OpcAttrValue), StringComparison.Ordinal))
throw new ArgumentException(SR.SignaturePackageObjectTagMustBeUnique, "signatureObjects"); throw new ArgumentException(SR.SignaturePackageObjectTagMustBeUnique, "signatureObjects");
// check for duplicates // check for duplicates
......
...@@ -94,9 +94,9 @@ public override bool Equals(object obj) ...@@ -94,9 +94,9 @@ public override bool Equals(object obj)
//PRESHARP:Parameter to this public method must be validated: A null-dereference can occur here. //PRESHARP:Parameter to this public method must be validated: A null-dereference can occur here.
//This is a false positive as the checks above can gurantee no null dereference will occur //This is a false positive as the checks above can gurantee no null dereference will occur
#pragma warning disable 6506 #pragma warning disable 6506
return (String.CompareOrdinal(localizedNameDescr.Name, Name) == 0) return (string.Equals(localizedNameDescr.Name, Name, StringComparison.Ordinal))
&& &&
(String.CompareOrdinal(localizedNameDescr.Description, Description) == 0); (string.Equals(localizedNameDescr.Description, Description, StringComparison.Ordinal));
#pragma warning restore 6506 #pragma warning restore 6506
} }
......
...@@ -158,7 +158,7 @@ public override bool Equals(object x) ...@@ -158,7 +158,7 @@ public override bool Equals(object x)
// Note that because of the GetType() checking above, the casting must be valid. // Note that because of the GetType() checking above, the casting must be valid.
UseLicense obj = (UseLicense)x; UseLicense obj = (UseLicense)x;
return (String.CompareOrdinal(_serializedUseLicense, obj._serializedUseLicense) == 0); return (string.Equals(_serializedUseLicense, obj._serializedUseLicense, StringComparison.Ordinal));
} }
/// <summary> /// <summary>
......
...@@ -135,7 +135,7 @@ public override bool Equals(object obj) ...@@ -135,7 +135,7 @@ public override bool Equals(object obj)
ContentUser userObj = (ContentUser)obj; ContentUser userObj = (ContentUser)obj;
return (String.CompareOrdinal(_name.ToUpperInvariant(), userObj._name.ToUpperInvariant()) == 0) return (string.Equals(_name, userObj._name, StringComparison.OrdinalIgnoreCase))
&& &&
_authenticationType.Equals(userObj._authenticationType); _authenticationType.Equals(userObj._authenticationType);
} }
...@@ -228,7 +228,7 @@ internal bool GenericEquals(ContentUser userObj) ...@@ -228,7 +228,7 @@ internal bool GenericEquals(ContentUser userObj)
} }
else else
{ {
return (String.CompareOrdinal(_name.ToUpperInvariant(), userObj._name.ToUpperInvariant()) == 0) return (string.Equals(_name, userObj._name, StringComparison.OrdinalIgnoreCase))
&& &&
_authenticationType.Equals(userObj._authenticationType); _authenticationType.Equals(userObj._authenticationType);
} }
...@@ -263,12 +263,12 @@ int IEqualityComparer<ContentUser>.GetHashCode(ContentUser user) ...@@ -263,12 +263,12 @@ int IEqualityComparer<ContentUser>.GetHashCode(ContentUser user)
internal static bool CompareToAnyone(string name) internal static bool CompareToAnyone(string name)
{ {
return (0 == String.CompareOrdinal(AnyoneUserName.ToUpperInvariant(), name.ToUpperInvariant())); return string.Equals(AnyoneUserName, name, StringComparison.OrdinalIgnoreCase);
} }
internal static bool CompareToOwner(string name) internal static bool CompareToOwner(string name)
{ {
return (0 == String.CompareOrdinal(OwnerUserName.ToUpperInvariant(), name.ToUpperInvariant())); return string.Equals(OwnerUserName, name, StringComparison.OrdinalIgnoreCase);
} }
private const string WindowsAuthProvider = "WindowsAuthProvider"; private const string WindowsAuthProvider = "WindowsAuthProvider";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册