summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOAuth.Test/MessageSerializerTest.cs15
-rw-r--r--src/DotNetOAuth.Test/Mocks/TestMessage.cs28
-rw-r--r--src/DotNetOAuth.Test/ServiceProviderTest.cs13
-rw-r--r--src/DotNetOAuth.Test/Settings.StyleCop25
-rw-r--r--src/DotNetOAuth/Consumer.cs8
-rw-r--r--src/DotNetOAuth/DictionaryXmlReader.cs220
-rw-r--r--src/DotNetOAuth/DictionaryXmlWriter.cs173
-rw-r--r--src/DotNetOAuth/DirectMessageChannel.cs18
-rw-r--r--src/DotNetOAuth/DotNetOAuth.csproj2
-rw-r--r--src/DotNetOAuth/IProtocolMessage.cs16
-rw-r--r--src/DotNetOAuth/IProtocolMessageRequest.cs12
-rw-r--r--src/DotNetOAuth/IndirectMessage.cs41
-rw-r--r--src/DotNetOAuth/IndirectMessageEncoder.cs18
-rw-r--r--src/DotNetOAuth/Logger.cs2
-rw-r--r--src/DotNetOAuth/MessageScheme.cs11
-rw-r--r--src/DotNetOAuth/MessageTransport.cs10
-rw-r--r--src/DotNetOAuth/Protocol.cs66
-rw-r--r--src/DotNetOAuth/ProtocolException.cs38
-rw-r--r--src/DotNetOAuth/ProtocolMessageSerializer.cs83
-rw-r--r--src/DotNetOAuth/ServiceProvider.cs35
-rw-r--r--src/DotNetOAuth/UriUtil.cs29
-rw-r--r--src/Settings.StyleCop20
22 files changed, 583 insertions, 300 deletions
diff --git a/src/DotNetOAuth.Test/MessageSerializerTest.cs b/src/DotNetOAuth.Test/MessageSerializerTest.cs
index 9faebfe..24b7c9c 100644
--- a/src/DotNetOAuth.Test/MessageSerializerTest.cs
+++ b/src/DotNetOAuth.Test/MessageSerializerTest.cs
@@ -1,8 +1,17 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+//-----------------------------------------------------------------------
+// <copyright file="MessageSerializerTest.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth.Test {
+ using System;
+ using System.Collections.Generic;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ /// <summary>
+ /// Tests for the <see cref="MessageSerializer"/> class.
+ /// </summary>
[TestClass()]
public class MessageSerializerTest : TestBase {
[TestMethod, ExpectedException(typeof(ArgumentNullException))]
diff --git a/src/DotNetOAuth.Test/Mocks/TestMessage.cs b/src/DotNetOAuth.Test/Mocks/TestMessage.cs
index 6fbac65..1fb58ad 100644
--- a/src/DotNetOAuth.Test/Mocks/TestMessage.cs
+++ b/src/DotNetOAuth.Test/Mocks/TestMessage.cs
@@ -1,9 +1,15 @@
-using System.Runtime.Serialization;
-using System;
+//-----------------------------------------------------------------------
+// <copyright file="TestMessage.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth.Test.Mocks {
- [DataContract(Namespace = Protocol.DataContractNamespace)]
- class TestMessage : IProtocolMessage {
+ using System;
+ using System.Runtime.Serialization;
+
+ [DataContract(Namespace = Protocol.DataContractNamespaceV10)]
+ internal class TestMessage : IProtocolMessage {
[DataMember(Name = "age", IsRequired = true)]
public int Age { get; set; }
[DataMember]
@@ -15,14 +21,18 @@ namespace DotNetOAuth.Test.Mocks {
#region IProtocolMessage Members
- void IProtocolMessage.EnsureValidMessage() {
- if (EmptyMember != null || Age < 0) {
- throw new ProtocolException();
- }
+ Protocol IProtocolMessage.Protocol {
+ get { return Protocol.V10; }
}
MessageTransport IProtocolMessage.Transport {
- get { return MessageTransport.Direct; }
+ get { return MessageTransport.Direct; }
+ }
+
+ void IProtocolMessage.EnsureValidMessage() {
+ if (this.EmptyMember != null || this.Age < 0) {
+ throw new ProtocolException();
+ }
}
#endregion
diff --git a/src/DotNetOAuth.Test/ServiceProviderTest.cs b/src/DotNetOAuth.Test/ServiceProviderTest.cs
index 38836f4..d4bced7 100644
--- a/src/DotNetOAuth.Test/ServiceProviderTest.cs
+++ b/src/DotNetOAuth.Test/ServiceProviderTest.cs
@@ -1,7 +1,16 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+//-----------------------------------------------------------------------
+// <copyright file="ServiceProviderTest.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth.Test {
+ using System;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ /// <summary>
+ /// Tests for the <see cref="ServiceProvider"/> class.
+ /// </summary>
[TestClass]
public class ServiceProviderTest : TestBase {
/// <summary>
diff --git a/src/DotNetOAuth.Test/Settings.StyleCop b/src/DotNetOAuth.Test/Settings.StyleCop
index 7f55ce6..100fae5 100644
--- a/src/DotNetOAuth.Test/Settings.StyleCop
+++ b/src/DotNetOAuth.Test/Settings.StyleCop
@@ -1 +1,24 @@
-<StyleCopSettings Version="4.3" /> \ No newline at end of file
+<StyleCopSettings Version="4.3">
+ <Analyzers>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
+ <Rules>
+ <Rule Name="ElementsMustBeDocumented">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.LayoutRules">
+ <Rules>
+ <Rule Name="SingleLineCommentMustBePrecededByBlankLine">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ </Analyzers>
+</StyleCopSettings> \ No newline at end of file
diff --git a/src/DotNetOAuth/Consumer.cs b/src/DotNetOAuth/Consumer.cs
index 7082727..1a73d5f 100644
--- a/src/DotNetOAuth/Consumer.cs
+++ b/src/DotNetOAuth/Consumer.cs
@@ -1,4 +1,10 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="Consumer.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
/// <summary>
/// A website or application that uses OAuth to access the Service Provider on behalf of the User.
/// </summary>
diff --git a/src/DotNetOAuth/DictionaryXmlReader.cs b/src/DotNetOAuth/DictionaryXmlReader.cs
index ff6ef51..6650d88 100644
--- a/src/DotNetOAuth/DictionaryXmlReader.cs
+++ b/src/DotNetOAuth/DictionaryXmlReader.cs
@@ -1,4 +1,10 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="DictionaryXmlReader.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -10,7 +16,7 @@
/// <summary>
/// An XmlReader-looking object that actually reads from a dictionary.
/// </summary>
- class DictionaryXmlReader {
+ internal class DictionaryXmlReader {
/// <summary>
/// Creates an XmlReader that reads data out of a dictionary instead of XML.
/// </summary>
@@ -23,10 +29,14 @@
}
return CreateRoundtripReader(rootElement, fields);
- // The pseudo reader MAY be more efficient, but it's buggy.
- //return CreatePseudoReader(rootElement, fields);
}
+ /// <summary>
+ /// Creates an <see cref="XmlReader"/> that will read values out of a dictionary.
+ /// </summary>
+ /// <param name="rootElement">The surrounding root XML element to generate.</param>
+ /// <param name="fields">The dictionary to list values from.</param>
+ /// <returns>The generated <see cref="XmlReader"/>.</returns>
private static XmlReader CreateRoundtripReader(XName rootElement, IDictionary<string, string> fields) {
MemoryStream stream = new MemoryStream();
XmlWriter writer = XmlWriter.Create(stream);
@@ -42,11 +52,13 @@
return XmlReader.Create(stream);
}
- static XmlReader CreatePseudoReader(XName rootElement, IDictionary<string, string> fields) {
- return new PseudoXmlReader(fields);
- }
-
- static void SerializeDictionaryToXml(XmlWriter writer, XName rootElement, IDictionary<string, string> fields) {
+ /// <summary>
+ /// Writes out the values in a dictionary as XML.
+ /// </summary>
+ /// <param name="writer">The <see cref="XmlWriter"/> to write out the XML to.</param>
+ /// <param name="rootElement">The name of the root element to use to surround the dictionary values.</param>
+ /// <param name="fields">The dictionary with values to serialize.</param>
+ private static void SerializeDictionaryToXml(XmlWriter writer, XName rootElement, IDictionary<string, string> fields) {
if (writer == null) {
throw new ArgumentNullException("writer");
}
@@ -55,201 +67,15 @@
}
writer.WriteStartElement(rootElement.LocalName, rootElement.NamespaceName);
+
// The elements must be serialized in alphabetical order so the DataContractSerializer will see them.
foreach (var pair in fields.OrderBy(pair => pair.Key, StringComparer.Ordinal)) {
writer.WriteStartElement(pair.Key, rootElement.NamespaceName);
writer.WriteValue(pair.Value);
writer.WriteEndElement();
}
- writer.WriteEndElement();
- }
-
- /// <summary>
- /// Reads in a dictionary as if it were XML.
- /// </summary>
- class PseudoXmlReader : XmlReader {
- IDictionary<string, string> dictionary;
- IEnumerator<string> keyEnumerator;
- bool isFinished;
- int depth;
- XmlNodeType currentNode = XmlNodeType.None;
-
- internal PseudoXmlReader(IDictionary<string, string> dictionary) {
- this.dictionary = dictionary;
- keyEnumerator = dictionary.Keys.OrderBy(key => key, StringComparer.Ordinal).GetEnumerator();
- }
-
- public override int AttributeCount {
- get { return 0; }
- }
- public override bool IsEmptyElement {
- get {
- if (keyEnumerator.Current == null) {
- return isFinished;
- }
- string value;
- bool result = !dictionary.TryGetValue(keyEnumerator.Current, out value) || String.IsNullOrEmpty(value);
- return result;
- }
- }
-
- public override string LocalName {
- get { return keyEnumerator.Current; }
- }
-
- public override bool MoveToElement() {
- Trace.WriteLine("MoveToElement()");
- bool result = currentNode != XmlNodeType.Element && depth > 0;
- currentNode = depth > 0 ? XmlNodeType.Element : XmlNodeType.None;
- return result;
- }
-
- public override bool MoveToNextAttribute() {
- Trace.WriteLine("MoveToNextAttribute()");
- if (depth == 1 && currentNode != XmlNodeType.Attribute) {
- currentNode = XmlNodeType.Attribute;
- return true;
- } else {
- return false;
- }
- }
-
- public override string NamespaceURI {
- get {
- string result = depth == 1 && currentNode == XmlNodeType.Attribute ?
- "http://www.w3.org/2000/xmlns/" : Protocol.DataContractNamespace;
- return result;
- }
- }
-
- public override XmlNodeType NodeType {
- get { return currentNode; }
- }
-
- public override bool Read() {
- Trace.WriteLine("Read()");
- if (isFinished) {
- if (depth > 0) {
- depth--;
- }
- return depth > 0;
- }
- switch (depth) {
- case 0: // moving to root node
- depth++; // -> 1
- currentNode = XmlNodeType.Element;
- return true;
- case 1: // moving to first content node
- depth++; // -> 2
- isFinished = !keyEnumerator.MoveNext();
- currentNode = isFinished ? XmlNodeType.EndElement : XmlNodeType.Element;
- return true;
- case 2: // content node
- switch (currentNode) {
- case XmlNodeType.Element:
- currentNode = XmlNodeType.Text;
- return true;
- case XmlNodeType.Text:
- currentNode = XmlNodeType.EndElement;
- return true;
- case XmlNodeType.EndElement:
- bool result = keyEnumerator.MoveNext();
- if (!result) {
- isFinished = true;
- depth--;
- currentNode = XmlNodeType.EndElement;
- } else {
- currentNode = XmlNodeType.Element;
- }
- return true;
- }
- break;
- }
- throw new InvalidOperationException();
- }
-
- public override string Value {
- get { return dictionary[keyEnumerator.Current]; }
- }
-
- #region Unimplemented methods
-
- public override string BaseURI {
- get { throw new NotImplementedException(); }
- }
-
- public override void Close() {
- throw new NotImplementedException();
- }
-
- public override int Depth {
- get {
- Trace.WriteLine("Depth: " + (depth - 1));
- return depth - 1;
- }
- }
-
- public override bool EOF {
- get { throw new NotImplementedException(); }
- }
-
- public override string GetAttribute(int i) {
- throw new NotImplementedException();
- }
-
- public override string GetAttribute(string name, string namespaceURI) {
- throw new NotImplementedException();
- }
-
- public override string GetAttribute(string name) {
- throw new NotImplementedException();
- }
-
- public override bool HasValue {
- get { throw new NotImplementedException(); }
- }
-
- public override string LookupNamespace(string prefix) {
- throw new NotImplementedException();
- }
-
- public override bool MoveToAttribute(string name, string ns) {
- throw new NotImplementedException();
- }
-
- public override bool MoveToAttribute(string name) {
- throw new NotImplementedException();
- }
-
- public override bool MoveToFirstAttribute() {
- throw new NotImplementedException();
- }
-
- public override XmlNameTable NameTable {
- get { throw new NotImplementedException(); }
- }
-
- public override string Prefix {
- get { throw new NotImplementedException(); }
- }
-
- public override ReadState ReadState {
- get {
- Trace.WriteLine("ReadState");
- return ReadState.Interactive;
- }
- }
-
- public override bool ReadAttributeValue() {
- throw new NotImplementedException();
- }
-
- public override void ResolveEntity() {
- throw new NotImplementedException();
- }
-
- #endregion
+ writer.WriteEndElement();
}
}
}
diff --git a/src/DotNetOAuth/DictionaryXmlWriter.cs b/src/DotNetOAuth/DictionaryXmlWriter.cs
index 0068f21..6d166fd 100644
--- a/src/DotNetOAuth/DictionaryXmlWriter.cs
+++ b/src/DotNetOAuth/DictionaryXmlWriter.cs
@@ -1,4 +1,10 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="DictionaryXmlWriter.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
using System;
using System.Collections.Generic;
using System.Text;
@@ -7,9 +13,9 @@
/// <summary>
/// An XmlWriter-looking object that actually saves data to a dictionary.
/// </summary>
- class DictionaryXmlWriter {
+ internal class DictionaryXmlWriter {
/// <summary>
- /// Creates an <see cref="XmlWriter"/> that actually writes to an <see cref="IDictionary<string, string>"/> instance.
+ /// Creates an <see cref="XmlWriter"/> that actually writes to an IDictionary&lt;string, string&gt; instance.
/// </summary>
/// <param name="dictionary">The dictionary to save the written XML to.</param>
/// <returns>The XmlWriter that will save data to the given dictionary.</returns>
@@ -20,116 +26,243 @@
/// <summary>
/// Writes out a dictionary as if it were XML.
/// </summary>
- class PseudoXmlWriter : XmlWriter {
- IDictionary<string, string> dictionary;
- string key;
- StringBuilder value = new StringBuilder();
+ private class PseudoXmlWriter : XmlWriter {
+ /// <summary>
+ /// The dictionary to write values to.
+ /// </summary>
+ private IDictionary<string, string> dictionary;
+
+ /// <summary>
+ /// The key being written at the moment.
+ /// </summary>
+ private string key;
+ /// <summary>
+ /// The value being written out at the moment.
+ /// </summary>
+ private StringBuilder value = new StringBuilder();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PseudoXmlWriter"/> class.
+ /// </summary>
+ /// <param name="dictionary">The dictionary that will be written to.</param>
internal PseudoXmlWriter(IDictionary<string, string> dictionary) {
+ if (dictionary == null) {
+ throw new ArgumentNullException("dictionary");
+ }
+
this.dictionary = dictionary;
}
+ /// <summary>
+ /// Gets the spoofed state of the <see cref="XmlWriter"/>.
+ /// </summary>
+ public override WriteState WriteState {
+ get { return WriteState.Element; }
+ }
+
+ /// <summary>
+ /// Prepares to write out a new key/value pair with the given key name to the dictionary.
+ /// </summary>
+ /// <param name="prefix">This parameter is ignored.</param>
+ /// <param name="localName">The key to store in the dictionary.</param>
+ /// <param name="ns">This parameter is ignored.</param>
public override void WriteStartElement(string prefix, string localName, string ns) {
- key = localName;
- value.Length = 0;
+ this.key = localName;
+ this.value.Length = 0;
}
+ /// <summary>
+ /// Appends some text to the value that is to be stored in the dictionary.
+ /// </summary>
+ /// <param name="text">The text to append to the value.</param>
public override void WriteString(string text) {
- if (!string.IsNullOrEmpty(key)) {
- value.Append(text);
+ if (!string.IsNullOrEmpty(this.key)) {
+ this.value.Append(text);
}
}
+ /// <summary>
+ /// Writes out a completed key/value to the dictionary.
+ /// </summary>
public override void WriteEndElement() {
- if (key != null) {
- dictionary[key] = value.ToString();
- key = null;
- value.Length = 0;
+ if (this.key != null) {
+ this.dictionary[this.key] = this.value.ToString();
+ this.key = null;
+ this.value.Length = 0;
}
}
- public override WriteState WriteState {
- get { return WriteState.Element; }
- }
-
+ /// <summary>
+ /// Clears the internal key/value building state.
+ /// </summary>
+ /// <param name="prefix">This parameter is ignored.</param>
+ /// <param name="localName">This parameter is ignored.</param>
+ /// <param name="ns">This parameter is ignored.</param>
public override void WriteStartAttribute(string prefix, string localName, string ns) {
- key = null;
+ this.key = null;
}
+ /// <summary>
+ /// This method does not do anything.
+ /// </summary>
public override void WriteEndAttribute() { }
+ /// <summary>
+ /// This method does not do anything.
+ /// </summary>
public override void Close() { }
#region Unimplemented methods
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
public override void Flush() {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="ns">This parameter is ignored.</param>
+ /// <returns>None, since an exception is always thrown.</returns>
public override string LookupPrefix(string ns) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="buffer">This parameter is ignored.</param>
+ /// <param name="index">This parameter is ignored.</param>
+ /// <param name="count">This parameter is ignored.</param>
public override void WriteBase64(byte[] buffer, int index, int count) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="text">This parameter is ignored.</param>
public override void WriteCData(string text) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="ch">This parameter is ignored.</param>
public override void WriteCharEntity(char ch) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="buffer">This parameter is ignored.</param>
+ /// <param name="index">This parameter is ignored.</param>
+ /// <param name="count">This parameter is ignored.</param>
public override void WriteChars(char[] buffer, int index, int count) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="text">This parameter is ignored.</param>
public override void WriteComment(string text) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="name">This parameter is ignored.</param>
+ /// <param name="pubid">This parameter is ignored.</param>
+ /// <param name="sysid">This parameter is ignored.</param>
+ /// <param name="subset">This parameter is ignored.</param>
public override void WriteDocType(string name, string pubid, string sysid, string subset) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
public override void WriteEndDocument() {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="name">This parameter is ignored.</param>
public override void WriteEntityRef(string name) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
public override void WriteFullEndElement() {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="name">This parameter is ignored.</param>
+ /// <param name="text">This parameter is ignored.</param>
public override void WriteProcessingInstruction(string name, string text) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="data">This parameter is ignored.</param>
public override void WriteRaw(string data) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="buffer">This parameter is ignored.</param>
+ /// <param name="index">This parameter is ignored.</param>
+ /// <param name="count">This parameter is ignored.</param>
public override void WriteRaw(char[] buffer, int index, int count) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="standalone">This parameter is ignored.</param>
public override void WriteStartDocument(bool standalone) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
public override void WriteStartDocument() {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="lowChar">This parameter is ignored.</param>
+ /// <param name="highChar">This parameter is ignored.</param>
public override void WriteSurrogateCharEntity(char lowChar, char highChar) {
throw new NotImplementedException();
}
+ /// <summary>
+ /// Throws <see cref="NotImplementedException"/>.
+ /// </summary>
+ /// <param name="ws">This parameter is ignored.</param>
public override void WriteWhitespace(string ws) {
throw new NotImplementedException();
}
diff --git a/src/DotNetOAuth/DirectMessageChannel.cs b/src/DotNetOAuth/DirectMessageChannel.cs
index 2ece51d..147b7d5 100644
--- a/src/DotNetOAuth/DirectMessageChannel.cs
+++ b/src/DotNetOAuth/DirectMessageChannel.cs
@@ -1,6 +1,20 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="DirectMessageChannel.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
+ /// <summary>
+ /// Manages sending direct messages to a remote party and receiving responses.
+ /// </summary>
internal class DirectMessageChannel {
- public void Send(IProtocolMessage message) {
+ /// <summary>
+ /// Sends a direct message and returns the response.
+ /// </summary>
+ /// <param name="message">The message to send.</param>
+ /// <returns>The message response.</returns>
+ public IProtocolMessage Send(IProtocolMessage message) {
throw new System.NotImplementedException();
}
}
diff --git a/src/DotNetOAuth/DotNetOAuth.csproj b/src/DotNetOAuth/DotNetOAuth.csproj
index d8de8ba..b510238 100644
--- a/src/DotNetOAuth/DotNetOAuth.csproj
+++ b/src/DotNetOAuth/DotNetOAuth.csproj
@@ -106,4 +106,4 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\tools\DotNetOAuth.Versioning.targets" />
-</Project>
+</Project> \ No newline at end of file
diff --git a/src/DotNetOAuth/IProtocolMessage.cs b/src/DotNetOAuth/IProtocolMessage.cs
index a1ba259..76512a4 100644
--- a/src/DotNetOAuth/IProtocolMessage.cs
+++ b/src/DotNetOAuth/IProtocolMessage.cs
@@ -1,4 +1,10 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="IProtocolMessage.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
using System;
using System.Collections.Generic;
using System.Text;
@@ -7,11 +13,17 @@
/// The interface that classes must implement to be serialized/deserialized
/// as OAuth messages.
/// </summary>
- interface IProtocolMessage {
+ internal interface IProtocolMessage {
+ /// <summary>
+ /// Gets the version of the protocol this message is prepared to implement.
+ /// </summary>
+ Protocol Protocol { get; }
+
/// <summary>
/// Gets whether this is a direct or indirect message.
/// </summary>
MessageTransport Transport { get; }
+
/// <summary>
/// Checks the message state for conformity to the protocol specification
/// and throws an exception if the message is invalid.
diff --git a/src/DotNetOAuth/IProtocolMessageRequest.cs b/src/DotNetOAuth/IProtocolMessageRequest.cs
index 5d38b41..61dfddc 100644
--- a/src/DotNetOAuth/IProtocolMessageRequest.cs
+++ b/src/DotNetOAuth/IProtocolMessageRequest.cs
@@ -1,12 +1,18 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="IProtocolMessageRequest.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
using System;
/// <summary>
/// Implemented by messages that are sent as requests.
/// </summary>
- interface IProtocolMessageRequest : IProtocolMessage {
+ internal interface IProtocolMessageRequest : IProtocolMessage {
/// <summary>
- /// The URL of the intended receiver of this message.
+ /// Gets or sets the URL of the intended receiver of this message.
/// </summary>
Uri Recipient {
get;
diff --git a/src/DotNetOAuth/IndirectMessage.cs b/src/DotNetOAuth/IndirectMessage.cs
index 98295bf..638b4fd 100644
--- a/src/DotNetOAuth/IndirectMessage.cs
+++ b/src/DotNetOAuth/IndirectMessage.cs
@@ -1,16 +1,49 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="IndirectMessage.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
using System.Net;
+ /// <summary>
+ /// A protocol message that passes between Consumer and Service Provider
+ /// via the user agent using a redirect or form POST submission.
+ /// </summary>
+ /// <remarks>
+ /// An <see cref="IndirectMessage"/> instance describes the HTTP response that must
+ /// be sent to the user agent to initiate the message transfer.
+ /// </remarks>
public class IndirectMessage {
- public WebHeaderCollection Headers { get; set; }
+ /// <summary>
+ /// Gets the headers that must be included in the response to the user agent.
+ /// </summary>
+ /// <remarks>
+ /// The headers in this collection are not meant to be a comprehensive list
+ /// of exactly what should be sent, but are meant to augment whatever headers
+ /// are generally included in a typical response.
+ /// </remarks>
+ public WebHeaderCollection Headers { get; internal set; }
- public byte[] Body { get; set; }
+ /// <summary>
+ /// Gets the body of the HTTP response.
+ /// </summary>
+ public byte[] Body { get; internal set; }
- public HttpStatusCode Status { get; set; }
+ /// <summary>
+ /// Gets the HTTP status code to use in the HTTP response.
+ /// </summary>
+ public HttpStatusCode Status { get; internal set; }
+ /// <summary>
+ /// Gets or sets a reference to the actual protocol message that
+ /// is being sent via the user agent.
+ /// </summary>
internal IProtocolMessage OriginalMessage { get; set; }
/// <summary>
+ /// Automatically sends the appropriate response to the user agent.
/// Requires a current HttpContext.
/// </summary>
public void Send() {
diff --git a/src/DotNetOAuth/IndirectMessageEncoder.cs b/src/DotNetOAuth/IndirectMessageEncoder.cs
index 3f55b71..fd9495e 100644
--- a/src/DotNetOAuth/IndirectMessageEncoder.cs
+++ b/src/DotNetOAuth/IndirectMessageEncoder.cs
@@ -1,6 +1,20 @@
-namespace DotNetOAuth {
+//-----------------------------------------------------------------------
+// <copyright file="IndirectMessageEncoder.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
+ /// <summary>
+ /// A message encoder that prepares messages for transmittal.
+ /// </summary>
internal class IndirectMessageEncoder {
- public IndirectMessage Encode(IProtocolMessage message) {
+ /// <summary>
+ /// Prepares a protocol message for sending
+ /// </summary>
+ /// <param name="message">The indirect message to send.</param>
+ /// <returns>The encoded message to send to the user agent.</returns>
+ internal IndirectMessage Encode(IProtocolMessage message) {
throw new System.NotImplementedException();
}
}
diff --git a/src/DotNetOAuth/Logger.cs b/src/DotNetOAuth/Logger.cs
index 8e7e2cb..844dcc6 100644
--- a/src/DotNetOAuth/Logger.cs
+++ b/src/DotNetOAuth/Logger.cs
@@ -7,8 +7,8 @@
namespace DotNetOAuth {
using System;
using System.Globalization;
- using log4net.Core;
using DotNetOAuth.Loggers;
+ using log4net.Core;
/// <summary>
/// A general logger for the entire YOURLIBNAME library.
diff --git a/src/DotNetOAuth/MessageScheme.cs b/src/DotNetOAuth/MessageScheme.cs
index 282194f..9336159 100644
--- a/src/DotNetOAuth/MessageScheme.cs
+++ b/src/DotNetOAuth/MessageScheme.cs
@@ -1,6 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+//-----------------------------------------------------------------------
+// <copyright file="MessageScheme.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth {
/// <summary>
@@ -14,14 +16,17 @@ namespace DotNetOAuth {
/// In the HTTP Authorization header as defined in OAuth HTTP Authorization Scheme (OAuth HTTP Authorization Scheme).
/// </summary>
AuthorizationHeaderRequest,
+
/// <summary>
/// As the HTTP POST request body with a content-type of application/x-www-form-urlencoded.
/// </summary>
PostRequest,
+
/// <summary>
/// Added to the URLs in the query part (as defined by [RFC3986] (Berners-Lee, T., “Uniform Resource Identifiers (URI): Generic Syntax,” .) section 3).
/// </summary>
GetRequest,
+
/// <summary>
/// Response parameters are sent by the Service Provider to return Tokens and other information to the Consumer in the HTTP response body. The parameter names and values are first encoded as per Parameter Encoding (Parameter Encoding), and concatenated with the ‘&amp;’ character (ASCII code 38) as defined in [RFC3986] (Berners-Lee, T., “Uniform Resource Identifiers (URI): Generic Syntax,” .) Section 2.1.
/// </summary>
diff --git a/src/DotNetOAuth/MessageTransport.cs b/src/DotNetOAuth/MessageTransport.cs
index 4097cba..5e08197 100644
--- a/src/DotNetOAuth/MessageTransport.cs
+++ b/src/DotNetOAuth/MessageTransport.cs
@@ -1,7 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+//-----------------------------------------------------------------------
+// <copyright file="MessageTransport.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth {
/// <summary>
@@ -12,6 +13,7 @@ namespace DotNetOAuth {
/// A message that is sent directly from the Consumer to the Service Provider, or vice versa.
/// </summary>
Direct,
+
/// <summary>
/// A message that is sent from one party to another via a redirect in the user agent.
/// </summary>
diff --git a/src/DotNetOAuth/Protocol.cs b/src/DotNetOAuth/Protocol.cs
index 0969a26..e96b4d2 100644
--- a/src/DotNetOAuth/Protocol.cs
+++ b/src/DotNetOAuth/Protocol.cs
@@ -1,9 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+//-----------------------------------------------------------------------
+// <copyright file="Protocol.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
/// <summary>
/// Constants used in the OAuth protocol.
/// </summary>
@@ -11,13 +17,33 @@ namespace DotNetOAuth {
/// OAuth Protocol Parameter names and values are case sensitive. Each OAuth Protocol Parameters MUST NOT appear more than once per request, and are REQUIRED unless otherwise noted,
/// per OAuth 1.0 section 5.
/// </remarks>
- class Protocol {
+ internal class Protocol {
+ /// <summary>
+ /// Gets the default <see cref="Protocol"/> instance.
+ /// </summary>
internal static readonly Protocol Default = V10;
+
+ /// <summary>
+ /// The namespace to use for V1.0 of the protocol.
+ /// </summary>
+ internal const string DataContractNamespaceV10 = "http://oauth.net/core/1.0/";
+
+ /// <summary>
+ /// Gets the <see cref="Protocol"/> instance with values initialized for V1.0 of the protocol.
+ /// </summary>
internal static readonly Protocol V10 = new Protocol {
+ dataContractNamespace = DataContractNamespaceV10,
};
- internal const string DataContractNamespace = "http://oauth.net/core/1.0/";
- internal string ParameterPrefix = "oauth_";
+ /// <summary>
+ /// The namespace to use for this version of the protocol.
+ /// </summary>
+ private string dataContractNamespace;
+
+ /// <summary>
+ /// The prefix used for all key names in the protocol.
+ /// </summary>
+ private string parameterPrefix = "oauth_";
/// <summary>
/// Strings that identify the various message schemes.
@@ -25,8 +51,32 @@ namespace DotNetOAuth {
/// <remarks>
/// These strings should be checked with case INsensitivity.
/// </remarks>
- internal Dictionary<MessageScheme, string> MessageSchemes = new Dictionary<MessageScheme,string> {
+ private Dictionary<MessageScheme, string> messageSchemes = new Dictionary<MessageScheme, string> {
{ MessageScheme.AuthorizationHeaderRequest, "OAuth" },
};
+
+ /// <summary>
+ /// Gets the namespace to use for this version of the protocol.
+ /// </summary>
+ internal string DataContractNamespace {
+ get { return this.dataContractNamespace; }
+ }
+
+ /// <summary>
+ /// Gets the prefix used for all key names in the protocol.
+ /// </summary>
+ internal string ParameterPrefix {
+ get { return this.parameterPrefix; }
+ }
+
+ /// <summary>
+ /// Gets the strings that identify the various message schemes.
+ /// </summary>
+ /// <remarks>
+ /// These strings should be checked with case INsensitivity.
+ /// </remarks>
+ internal IDictionary<MessageScheme, string> MessageSchemes {
+ get { return this.messageSchemes; }
+ }
}
}
diff --git a/src/DotNetOAuth/ProtocolException.cs b/src/DotNetOAuth/ProtocolException.cs
index b2bd93f..4505c59 100644
--- a/src/DotNetOAuth/ProtocolException.cs
+++ b/src/DotNetOAuth/ProtocolException.cs
@@ -1,14 +1,42 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+//-----------------------------------------------------------------------
+// <copyright file="ProtocolException.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth {
- [global::System.Serializable]
+ using System;
+
+ /// <summary>
+ /// An exception to represent errors in the local or remote implementation of the protocol.
+ /// </summary>
+ [Serializable]
public class ProtocolException : Exception {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ProtocolException"/> class.
+ /// </summary>
public ProtocolException() { }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ProtocolException"/> class.
+ /// </summary>
+ /// <param name="message">A message describing the specific error the occurred or was detected.</param>
public ProtocolException(string message) : base(message) { }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ProtocolException"/> class.
+ /// </summary>
+ /// <param name="message">A message describing the specific error the occurred or was detected.</param>
+ /// <param name="inner">The inner exception to include.</param>
public ProtocolException(string message, Exception inner) : base(message, inner) { }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ProtocolException"/> class.
+ /// </summary>
+ /// <param name="info">The <see cref="System.Runtime.Serialization.SerializationInfo"/>
+ /// that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The System.Runtime.Serialization.StreamingContext
+ /// that contains contextual information about the source or destination.</param>
protected ProtocolException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
diff --git a/src/DotNetOAuth/ProtocolMessageSerializer.cs b/src/DotNetOAuth/ProtocolMessageSerializer.cs
index b44aec6..153bd95 100644
--- a/src/DotNetOAuth/ProtocolMessageSerializer.cs
+++ b/src/DotNetOAuth/ProtocolMessageSerializer.cs
@@ -1,40 +1,88 @@
-using System;
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-using System.Xml;
-using System.Xml.Linq;
+//-----------------------------------------------------------------------
+// <copyright file="ProtocolMessageSerializer.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Runtime.Serialization;
+ using System.Xml;
+ using System.Xml.Linq;
+
/// <summary>
/// Serializes/deserializes OAuth messages for/from transit.
/// </summary>
+ /// <typeparam name="T">The specific <see cref="IProtocolMessage"/>-derived type
+ /// that will be serialized and deserialized using this class.</typeparam>
internal class ProtocolMessageSerializer<T> where T : IProtocolMessage {
- DataContractSerializer serializer;
- readonly XName rootElement = XName.Get("root", Protocol.DataContractNamespace);
+ /// <summary>
+ /// Backing field for the <see cref="RootElement"/> property
+ /// </summary>
+ private XName rootElement;
+
+ /// <summary>
+ /// The serializer that will be used as a reflection engine to extract
+ /// the OAuth message properties out of their containing <see cref="IProtocolMessage"/>
+ /// objects.
+ /// </summary>
+ private DataContractSerializer serializer;
+ /// <summary>
+ /// Initializes a new instance of the ProtocolMessageSerializer class.
+ /// </summary>
internal ProtocolMessageSerializer() {
- serializer = new DataContractSerializer(typeof(T), rootElement.LocalName, rootElement.NamespaceName);
+ this.serializer = new DataContractSerializer(
+ typeof(T), this.RootElement.LocalName, this.RootElement.NamespaceName);
+ }
+
+ /// <summary>
+ /// Gets the XML element that is used to surround all the XML values from the dictionary.
+ /// </summary>
+ private XName RootElement {
+ get {
+ if (this.rootElement == null) {
+ DataContractAttribute attribute = typeof(T).GetCustomAttributes(typeof(DataContractAttribute), false).OfType<DataContractAttribute>().Single();
+ this.rootElement = XName.Get("root", attribute.Namespace);
+ }
+
+ return this.rootElement;
+ }
}
/// <summary>
/// Reads the data from a message instance and returns a series of name=value pairs for the fields that must be included in the message.
/// </summary>
/// <param name="message">The message to be serialized.</param>
+ /// <returns>The dictionary of values to send for the message.</returns>
internal IDictionary<string, string> Serialize(T message) {
- if (message == null) throw new ArgumentNullException("message");
+ if (message == null) {
+ throw new ArgumentNullException("message");
+ }
var fields = new Dictionary<string, string>(StringComparer.Ordinal);
- Serialize(fields, message);
+ this.Serialize(fields, message);
return fields;
}
+ /// <summary>
+ /// Saves the [DataMember] properties of a message to an existing dictionary.
+ /// </summary>
+ /// <param name="fields">The dictionary to save values to.</param>
+ /// <param name="message">The message to pull values from.</param>
internal void Serialize(IDictionary<string, string> fields, T message) {
- if (fields == null) throw new ArgumentNullException("fields");
- if (message == null) throw new ArgumentNullException("message");
+ if (fields == null) {
+ throw new ArgumentNullException("fields");
+ }
+ if (message == null) {
+ throw new ArgumentNullException("message");
+ }
message.EnsureValidMessage();
using (XmlWriter writer = DictionaryXmlWriter.Create(fields)) {
- serializer.WriteObjectContent(writer, message);
+ this.serializer.WriteObjectContent(writer, message);
}
}
@@ -42,13 +90,16 @@ namespace DotNetOAuth {
/// Reads name=value pairs into an OAuth message.
/// </summary>
/// <param name="fields">The name=value pairs that were read in from the transport.</param>
+ /// <returns>The instantiated and initialized <see cref="IProtocolMessage"/> instance.</returns>
internal T Deserialize(IDictionary<string, string> fields) {
- if (fields == null) throw new ArgumentNullException("fields");
+ if (fields == null) {
+ throw new ArgumentNullException("fields");
+ }
- var reader = DictionaryXmlReader.Create(rootElement, fields);
+ var reader = DictionaryXmlReader.Create(this.RootElement, fields);
T result;
try {
- result = (T)serializer.ReadObject(reader, false);
+ result = (T)this.serializer.ReadObject(reader, false);
} catch (SerializationException ex) {
// Missing required fields is one cause of this exception.
throw new ProtocolException(Strings.InvalidIncomingMessage, ex);
diff --git a/src/DotNetOAuth/ServiceProvider.cs b/src/DotNetOAuth/ServiceProvider.cs
index 345c5cb..49bfb9f 100644
--- a/src/DotNetOAuth/ServiceProvider.cs
+++ b/src/DotNetOAuth/ServiceProvider.cs
@@ -1,9 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Web;
+//-----------------------------------------------------------------------
+// <copyright file="ServiceProvider.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth {
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+ using System.Web;
+
/// <summary>
/// A web application that allows access via OAuth.
/// </summary>
@@ -16,32 +22,41 @@ namespace DotNetOAuth {
/// </list>
/// </remarks>
internal class ServiceProvider {
+ /// <summary>
+ /// The field used to store the value of the <see cref="RequestTokenUri"/> property.
+ /// </summary>
private Uri requestTokenUri;
/// <summary>
- /// The URL used to obtain an unauthorized Request Token, described in Section 6.1 (Obtaining an Unauthorized Request Token).
+ /// Gets or sets the URL used to obtain an unauthorized Request Token,
+ /// described in Section 6.1 (Obtaining an Unauthorized Request Token).
/// </summary>
/// <remarks>
/// The request URL query MUST NOT contain any OAuth Protocol Parameters.
/// </remarks>
/// <exception cref="ArgumentException">Thrown if this property is set to a URI with OAuth protocol parameters.</exception>
public Uri RequestTokenUri {
- get { return requestTokenUri; }
+ get {
+ return this.requestTokenUri;
+ }
+
set {
if (UriUtil.QueryStringContainsOAuthParameters(value)) {
throw new ArgumentException(Strings.RequestUrlMustNotHaveOAuthParameters);
}
- requestTokenUri = value;
+ this.requestTokenUri = value;
}
}
/// <summary>
- /// The URL used to obtain User authorization for Consumer access, described in Section 6.2 (Obtaining User Authorization).
+ /// Gets or sets the URL used to obtain User authorization for Consumer access,
+ /// described in Section 6.2 (Obtaining User Authorization).
/// </summary>
- public Uri UserAuthorizationUri { get; set; }
+ public Uri UserAuthorizationUri { get; set; }
/// <summary>
- /// The URL used to exchange the User-authorized Request Token for an Access Token, described in Section 6.3 (Obtaining an Access Token).
+ /// Gets or sets the URL used to exchange the User-authorized Request Token
+ /// for an Access Token, described in Section 6.3 (Obtaining an Access Token).
/// </summary>
public Uri AccessTokenUri { get; set; }
}
diff --git a/src/DotNetOAuth/UriUtil.cs b/src/DotNetOAuth/UriUtil.cs
index 9ce913d..74f9e3e 100644
--- a/src/DotNetOAuth/UriUtil.cs
+++ b/src/DotNetOAuth/UriUtil.cs
@@ -1,12 +1,29 @@
-using System;
-using System.Collections.Specialized;
-using System.Linq;
-using System.Web;
+//-----------------------------------------------------------------------
+// <copyright file="UriUtil.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
namespace DotNetOAuth {
- class UriUtil {
+ using System;
+ using System.Collections.Specialized;
+ using System.Linq;
+ using System.Web;
+
+ /// <summary>
+ /// Utility methods for working with URIs.
+ /// </summary>
+ internal class UriUtil {
+ /// <summary>
+ /// Tests a URI for the presence of an OAuth payload.
+ /// </summary>
+ /// <param name="uri">The URI to test.</param>
+ /// <returns>True if the URI contains an OAuth message.</returns>
internal static bool QueryStringContainsOAuthParameters(Uri uri) {
- if (uri == null) return false;
+ if (uri == null) {
+ return false;
+ }
+
NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query);
return nvc.Keys.OfType<string>().Any(key => key.StartsWith(Protocol.V10.ParameterPrefix, StringComparison.Ordinal));
}
diff --git a/src/Settings.StyleCop b/src/Settings.StyleCop
index 8831d6b..791e073 100644
--- a/src/Settings.StyleCop
+++ b/src/Settings.StyleCop
@@ -17,6 +17,26 @@
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
+ <Rule Name="ElementMustNotBeOnSingleLine">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="ClosingCurlyBracketMustBeFollowedByBlankLine">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
+ <Rules>
+ <Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>