diff options
author | Sebastien Pouliot <sebastien@ximian.com> | 2008-08-07 06:05:52 +0400 |
---|---|---|
committer | Sebastien Pouliot <sebastien@ximian.com> | 2008-08-07 06:05:52 +0400 |
commit | 3f7129f550570b0a56a3f26d7ef54aeb29e83b99 (patch) | |
tree | af081b04e452dcf26fea2a27eb1d74ed69fb2565 /mcs/class/System.Security/System.Security.Cryptography.Xml | |
parent | a5794760dbfa60a0c5c27013765aef9dfebba2fb (diff) |
2008-08-06 Sebastien Pouliot <sebastien@ximian.com>
* XmlDsigC14NTransform.cs,
* XmlDsigExcC14NTransform.cs
* XmlDsigXsltTransform.cs: Don't use is + as.
[Found using Gendarme AvoidRepetitiveCastsRule]
svn path=/trunk/mcs/; revision=109819
Diffstat (limited to 'mcs/class/System.Security/System.Security.Cryptography.Xml')
4 files changed, 53 insertions, 23 deletions
diff --git a/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog b/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog index bb0f7a62eb8..13ac2e14beb 100644 --- a/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog +++ b/mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog @@ -1,3 +1,10 @@ +2008-08-06 Sebastien Pouliot <sebastien@ximian.com> + + * XmlDsigC14NTransform.cs, + * XmlDsigExcC14NTransform.cs + * XmlDsigXsltTransform.cs: Don't use is + as. + [Found using Gendarme AvoidRepetitiveCastsRule] + 2008-06-28 Sebastien Pouliot <sebastien@ximian.com> * XmlDecryptionTransform.cs, diff --git a/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigC14NTransform.cs b/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigC14NTransform.cs index b08f8c662ec..90b15cdb9ac 100644 --- a/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigC14NTransform.cs +++ b/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigC14NTransform.cs @@ -113,21 +113,30 @@ namespace System.Security.Cryptography.Xml { public override void LoadInput (object obj) { - if (obj is Stream) { - s = (obj as Stream); + // possible input: Stream, XmlDocument, and XmlNodeList + Stream stream = (obj as Stream); + if (stream != null) { XmlDocument doc = new XmlDocument (); doc.PreserveWhitespace = true; // REALLY IMPORTANT #if NET_1_1 doc.XmlResolver = GetResolver (); #endif - doc.Load (new XmlSignatureStreamReader ( - new StreamReader ((Stream) obj))); + doc.Load (new XmlSignatureStreamReader (new StreamReader (stream))); // doc.Load ((Stream) obj); s = canonicalizer.Canonicalize (doc); - } else if (obj is XmlDocument) - s = canonicalizer.Canonicalize ((obj as XmlDocument)); - else if (obj is XmlNodeList) - s = canonicalizer.Canonicalize ((obj as XmlNodeList)); + return; + } + + XmlDocument xd = (obj as XmlDocument); + if (xd != null) { + s = canonicalizer.Canonicalize (xd); + return; + } + + XmlNodeList nl = (obj as XmlNodeList); + if (nl != null) { + s = canonicalizer.Canonicalize (nl); + } #if NET_2_0 else throw new ArgumentException ("obj"); diff --git a/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.cs b/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.cs index 83f2bb8ecb9..81541a7a8ae 100644 --- a/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.cs +++ b/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.cs @@ -130,21 +130,30 @@ namespace System.Security.Cryptography.Xml { public override void LoadInput (object obj) { canonicalizer.InclusiveNamespacesPrefixList = InclusiveNamespacesPrefixList; - if (obj is Stream) { - s = (obj as Stream); + // possible input: Stream, XmlDocument, and XmlNodeList + Stream stream = (obj as Stream); + if (stream != null) { XmlDocument doc = new XmlDocument (); doc.PreserveWhitespace = true; // REALLY IMPORTANT #if NET_1_1 doc.XmlResolver = GetResolver (); #endif - doc.Load (new XmlSignatureStreamReader ( - new StreamReader ((Stream) obj))); + doc.Load (new XmlSignatureStreamReader (new StreamReader (stream))); // doc.Load ((Stream) obj); s = canonicalizer.Canonicalize (doc); - } else if (obj is XmlDocument) - s = canonicalizer.Canonicalize ((obj as XmlDocument)); - else if (obj is XmlNodeList) - s = canonicalizer.Canonicalize ((obj as XmlNodeList)); + return; + } + + XmlDocument xd = (obj as XmlDocument); + if (xd != null) { + s = canonicalizer.Canonicalize (xd); + return; + } + + XmlNodeList nl = (obj as XmlNodeList); + if (nl != null) { + s = canonicalizer.Canonicalize (nl); + } #if NET_2_0 else throw new ArgumentException ("obj"); diff --git a/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigXsltTransform.cs b/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigXsltTransform.cs index 2e3911a5713..6ac486d5494 100644 --- a/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigXsltTransform.cs +++ b/mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDsigXsltTransform.cs @@ -141,24 +141,29 @@ namespace System.Security.Cryptography.Xml public override void LoadInput (object obj) { // possible input: Stream, XmlDocument, and XmlNodeList - if (obj is Stream) { + Stream s = (obj as Stream); + if (s != null) { inputDoc = new XmlDocument (); #if NET_1_1 inputDoc.XmlResolver = GetResolver (); #endif // inputDoc.Load (obj as Stream); - inputDoc.Load (new XmlSignatureStreamReader ( - new StreamReader (obj as Stream))); + inputDoc.Load (new XmlSignatureStreamReader (new StreamReader (s))); + return; } - else if (obj is XmlDocument) { - inputDoc= obj as XmlDocument; + + XmlDocument xd = (obj as XmlDocument); + if (xd != null) { + inputDoc = xd; + return; } - else if (obj is XmlNodeList) { + + XmlNodeList nl = (obj as XmlNodeList); + if (nl != null) { inputDoc = new XmlDocument (); #if NET_1_1 inputDoc.XmlResolver = GetResolver (); #endif - XmlNodeList nl = (XmlNodeList) obj; for (int i = 0; i < nl.Count; i++) inputDoc.AppendChild (inputDoc.ImportNode (nl [i], true)); } |