summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-07-14 01:09:10 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-07-14 01:09:10 -0700
commit025651f81ff3a1eee32f33aa7761f2bcfa7bbc71 (patch)
tree7bf1159c15577b141fdfec062ff0119f28d25da3
parent8e1491aff86b8226ac93e36d9e203159abdc417a (diff)
downloadDotNetOpenAuth-025651f81ff3a1eee32f33aa7761f2bcfa7bbc71.zip
DotNetOpenAuth-025651f81ff3a1eee32f33aa7761f2bcfa7bbc71.tar.gz
DotNetOpenAuth-025651f81ff3a1eee32f33aa7761f2bcfa7bbc71.tar.bz2
Brought in a lot more code and got it to compile on SL3.
-rw-r--r--samples/OpenIdProviderWebForms/Code/CustomStoreDataSet.Designer.cs2
-rw-r--r--samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs2
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuthSL.csproj99
-rw-r--r--src/DotNetOpenAuth/Logger.cs6
-rw-r--r--src/DotNetOpenAuth/Loggers/ILog.cs2
-rw-r--r--src/DotNetOpenAuth/Messaging/CachedDirectWebResponse.cs8
-rw-r--r--src/DotNetOpenAuth/Messaging/ErrorUtilities.cs6
-rw-r--r--src/DotNetOpenAuth/Messaging/HostErrorException.cs4
-rw-r--r--src/DotNetOpenAuth/Messaging/IncomingWebResponse.cs21
-rw-r--r--src/DotNetOpenAuth/Messaging/InternalErrorException.cs4
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagePartAttribute.cs3
-rw-r--r--src/DotNetOpenAuth/Messaging/MessageSerializer.cs2
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingUtilities.cs54
-rw-r--r--src/DotNetOpenAuth/Messaging/ProtocolException.cs6
-rw-r--r--src/DotNetOpenAuth/Messaging/Reflection/MessagePart.cs8
-rw-r--r--src/DotNetOpenAuth/Messaging/Reflection/ProtectionLevel.cs29
-rw-r--r--src/DotNetOpenAuth/OpenId/Identifier.cs2
-rw-r--r--src/DotNetOpenAuth/OpenId/Realm.cs2
18 files changed, 243 insertions, 17 deletions
diff --git a/samples/OpenIdProviderWebForms/Code/CustomStoreDataSet.Designer.cs b/samples/OpenIdProviderWebForms/Code/CustomStoreDataSet.Designer.cs
index d836261..2972f17 100644
--- a/samples/OpenIdProviderWebForms/Code/CustomStoreDataSet.Designer.cs
+++ b/samples/OpenIdProviderWebForms/Code/CustomStoreDataSet.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.3521
+// Runtime Version:2.0.50727.4918
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs
index 580b1fa..913c394 100644
--- a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs
+++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4912
+// Runtime Version:2.0.50727.4918
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
diff --git a/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj b/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj
index 5f9e70b..27e8ed8 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuthSL.csproj
@@ -14,6 +14,26 @@
<SilverlightApplication>false</SilverlightApplication>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>false</ThrowErrorsInValidation>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -37,6 +57,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Microsoft.Contracts, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\..\..\..\Program Files\Microsoft\Contracts\PublicAssemblies\Silverlight2\Microsoft.Contracts.dll</HintPath>
+ </Reference>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
@@ -46,13 +70,82 @@
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Logger.cs" />
+ <Compile Include="Loggers\ILog.cs" />
+ <Compile Include="Loggers\NoOpLogger.cs" />
+ <Compile Include="Messaging\CachedDirectWebResponse.cs" />
+ <Compile Include="Messaging\DirectWebRequestOptions.cs" />
+ <Compile Include="Messaging\ErrorUtilities.cs" />
+ <Compile Include="Messaging\HostErrorException.cs" />
+ <Compile Include="Messaging\HttpDeliveryMethods.cs" />
+ <Compile Include="Messaging\IDirectedProtocolMessage.cs" />
+ <Compile Include="Messaging\IDirectResponseProtocolMessage.cs" />
+ <Compile Include="Messaging\IDirectWebRequestHandler.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Messaging\IExtensionMessage.cs" />
+ <Compile Include="Messaging\IHttpDirectResponse.cs" />
+ <Compile Include="Messaging\IMessage.cs" />
+ <Compile Include="Messaging\IMessageWithEvents.cs" />
+ <Compile Include="Messaging\IncomingWebResponse.cs" />
+ <Compile Include="Messaging\InternalErrorException.cs" />
+ <Compile Include="Messaging\IProtocolMessage.cs" />
+ <Compile Include="Messaging\MessagePartAttribute.cs" />
+ <Compile Include="Messaging\MessageProtections.cs" />
+ <Compile Include="Messaging\MessageSerializer.cs" />
+ <Compile Include="Messaging\MessageTransport.cs" />
+ <Compile Include="Messaging\MessagingStrings.Designer.cs" />
+ <Compile Include="Messaging\MessagingUtilities.cs" />
+ <Compile Include="Messaging\ProtocolException.cs" />
+ <Compile Include="Messaging\Reflection\IMessagePartEncoder.cs" />
+ <Compile Include="Messaging\Reflection\IMessagePartNullEncoder.cs" />
+ <Compile Include="Messaging\Reflection\MessageDescription.cs" />
+ <Compile Include="Messaging\Reflection\MessageDescriptionCollection.cs" />
+ <Compile Include="Messaging\Reflection\MessageDictionary.cs" />
+ <Compile Include="Messaging\Reflection\MessagePart.cs" />
+ <Compile Include="Messaging\Reflection\ProtectionLevel.cs" />
+ <Compile Include="Messaging\Reflection\ValueMapping.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Strings.Designer.cs" />
+ <Compile Include="Util.cs" />
</ItemGroup>
<ItemGroup>
- <Folder Include="Loggers\" />
- <Folder Include="Messaging\" />
+ <EmbeddedResource Include="Messaging\MessagingStrings.resx" />
+ <EmbeddedResource Include="Strings.resx" />
</ItemGroup>
- <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" />
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets" Condition="" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/src/DotNetOpenAuth/Logger.cs b/src/DotNetOpenAuth/Logger.cs
index 6015df5..f3d5b26 100644
--- a/src/DotNetOpenAuth/Logger.cs
+++ b/src/DotNetOpenAuth/Logger.cs
@@ -9,7 +9,9 @@ namespace DotNetOpenAuth {
using System.Globalization;
using DotNetOpenAuth.Loggers;
using DotNetOpenAuth.Messaging;
+#if !SILVERLIGHT
using log4net.Core;
+#endif
/// <summary>
/// A general logger for the entire DotNetOpenAuth library.
@@ -167,7 +169,11 @@ namespace DotNetOpenAuth {
/// <param name="name">The name of the log to initialize.</param>
/// <returns>The <see cref="ILog"/> instance of the logger to use.</returns>
private static ILog InitializeFacade(string name) {
+#if !SILVERLIGHT
ILog result = Log4NetLogger.Initialize(name) ?? TraceLogger.Initialize(name) ?? NoOpLogger.Initialize();
+#else
+ ILog result = NoOpLogger.Initialize();
+#endif
return result;
}
}
diff --git a/src/DotNetOpenAuth/Loggers/ILog.cs b/src/DotNetOpenAuth/Loggers/ILog.cs
index 4ddbd49..817f79f 100644
--- a/src/DotNetOpenAuth/Loggers/ILog.cs
+++ b/src/DotNetOpenAuth/Loggers/ILog.cs
@@ -27,8 +27,10 @@ namespace DotNetOpenAuth.Loggers
{
using System;
using System.Reflection;
+#if !SILVERLIGHT
using log4net;
using log4net.Core;
+#endif
/// <summary>
/// The ILog interface is use by application to log messages into
diff --git a/src/DotNetOpenAuth/Messaging/CachedDirectWebResponse.cs b/src/DotNetOpenAuth/Messaging/CachedDirectWebResponse.cs
index 65cbba1..b256fc9 100644
--- a/src/DotNetOpenAuth/Messaging/CachedDirectWebResponse.cs
+++ b/src/DotNetOpenAuth/Messaging/CachedDirectWebResponse.cs
@@ -86,7 +86,11 @@ namespace DotNetOpenAuth.Messaging {
/// <returns>The text reader, initialized for the proper encoding.</returns>
public override StreamReader GetResponseReader() {
this.ResponseStream.Seek(0, SeekOrigin.Begin);
+#if SILVERLIGHT
+ string contentEncoding = this.Headers["Content-Encoding"];
+#else
string contentEncoding = this.Headers[HttpResponseHeader.ContentEncoding];
+#endif
if (string.IsNullOrEmpty(contentEncoding)) {
return new StreamReader(this.ResponseStream);
} else {
@@ -134,7 +138,11 @@ namespace DotNetOpenAuth.Messaging {
}
Encoding encoding = Encoding.UTF8;
+#if SILVERLIGHT
+ this.Headers["Content-Encoding"] = encoding.WebName;
+#else
this.Headers[HttpResponseHeader.ContentEncoding] = encoding.HeaderName;
+#endif
this.responseStream = new MemoryStream();
StreamWriter writer = new StreamWriter(this.ResponseStream, encoding);
writer.Write(body);
diff --git a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
index 0a60b19..d154933 100644
--- a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
@@ -9,7 +9,9 @@ namespace DotNetOpenAuth.Messaging {
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Globalization;
+#if !SILVERLIGHT
using System.Web;
+#endif
/// <summary>
/// A collection of error checking and reporting methods.
@@ -150,6 +152,7 @@ namespace DotNetOpenAuth.Messaging {
}
}
+#if !SILVERLIGHT
/// <summary>
/// Checks a condition and throws an <see cref="InfoCard.InformationCardException"/>
/// if it evaluates to false.
@@ -169,6 +172,7 @@ namespace DotNetOpenAuth.Messaging {
throw new InfoCard.InformationCardException(errorMessage);
}
}
+#endif
/// <summary>
/// Throws a <see cref="HostErrorException"/> if some <paramref name="condition"/> evaluates to false.
@@ -401,6 +405,7 @@ namespace DotNetOpenAuth.Messaging {
}
}
+#if !SILVERLIGHT
/// <summary>
/// Verifies that <see cref="HttpContext.Current"/> != <c>null</c>.
/// </summary>
@@ -413,5 +418,6 @@ namespace DotNetOpenAuth.Messaging {
ErrorUtilities.VerifyOperation(HttpContext.Current != null, MessagingStrings.HttpContextRequired);
ErrorUtilities.VerifyOperation(HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
}
+#endif
}
}
diff --git a/src/DotNetOpenAuth/Messaging/HostErrorException.cs b/src/DotNetOpenAuth/Messaging/HostErrorException.cs
index 0ab9e51..000f2d4 100644
--- a/src/DotNetOpenAuth/Messaging/HostErrorException.cs
+++ b/src/DotNetOpenAuth/Messaging/HostErrorException.cs
@@ -20,7 +20,9 @@ namespace DotNetOpenAuth.Messaging {
/// or its configuration.</para>
/// <para>It is an internal exception to assist in making it uncatchable.</para>
/// </remarks>
+#if !SILVERLIGHT
[Serializable]
+#endif
internal class HostErrorException : Exception {
/// <summary>
/// Initializes a new instance of the <see cref="HostErrorException"/> class.
@@ -45,6 +47,7 @@ namespace DotNetOpenAuth.Messaging {
: base(message, inner) {
}
+#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the <see cref="HostErrorException"/> class.
/// </summary>
@@ -60,5 +63,6 @@ namespace DotNetOpenAuth.Messaging {
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
+#endif
}
}
diff --git a/src/DotNetOpenAuth/Messaging/IncomingWebResponse.cs b/src/DotNetOpenAuth/Messaging/IncomingWebResponse.cs
index dee81dc..0227ae4 100644
--- a/src/DotNetOpenAuth/Messaging/IncomingWebResponse.cs
+++ b/src/DotNetOpenAuth/Messaging/IncomingWebResponse.cs
@@ -11,7 +11,9 @@ namespace DotNetOpenAuth.Messaging {
using System.Globalization;
using System.IO;
using System.Net;
+#if !SILVERLIGHT
using System.Net.Mime;
+#endif
using System.Text;
/// <summary>
@@ -43,12 +45,21 @@ namespace DotNetOpenAuth.Messaging {
this.RequestUri = requestUri;
if (!string.IsNullOrEmpty(response.ContentType)) {
try {
+#if !SILVERLIGHT
this.ContentType = new ContentType(response.ContentType);
+#else
+ this.ContentType = response.ContentType;
+#endif
} catch (FormatException) {
Logger.Messaging.ErrorFormat("HTTP response to {0} included an invalid Content-Type header value: {1}", response.ResponseUri.AbsoluteUri, response.ContentType);
}
}
+
+#if SILVERLIGHT
+ this.ContentEncoding = string.IsNullOrEmpty(response.Headers["Content-Encoding"]) ? DefaultContentEncoding : response.Headers["Content-Encoding"];
+#else
this.ContentEncoding = string.IsNullOrEmpty(response.ContentEncoding) ? DefaultContentEncoding : response.ContentEncoding;
+#endif
this.FinalUri = response.ResponseUri;
this.Status = response.StatusCode;
this.Headers = response.Headers;
@@ -69,8 +80,12 @@ namespace DotNetOpenAuth.Messaging {
this.Status = statusCode;
if (!string.IsNullOrEmpty(contentType)) {
try {
+#if !SILVERLIGHT
this.ContentType = new ContentType(contentType);
- } catch (FormatException) {
+#else
+ this.ContentType = contentType;
+#endif
+ } catch (FormatException) {
Logger.Messaging.ErrorFormat("HTTP response to {0} included an invalid Content-Type header value: {1}", responseUri.AbsoluteUri, contentType);
}
}
@@ -82,7 +97,11 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// Gets the type of the content.
/// </summary>
+#if !SILVERLIGHT
public ContentType ContentType { get; private set; }
+#else
+ public string ContentType { get; private set; }
+#endif
/// <summary>
/// Gets the content encoding.
diff --git a/src/DotNetOpenAuth/Messaging/InternalErrorException.cs b/src/DotNetOpenAuth/Messaging/InternalErrorException.cs
index 32b44f2..f016822 100644
--- a/src/DotNetOpenAuth/Messaging/InternalErrorException.cs
+++ b/src/DotNetOpenAuth/Messaging/InternalErrorException.cs
@@ -17,7 +17,9 @@ namespace DotNetOpenAuth.Messaging {
/// really an unexpected, potentially unrecoverable exception.
/// </remarks>
[SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic", Justification = "We want this to be internal so clients cannot catch it.")]
+#if !SILVERLIGHT
[Serializable]
+#endif
internal class InternalErrorException : Exception {
/// <summary>
/// Initializes a new instance of the <see cref="InternalErrorException"/> class.
@@ -37,6 +39,7 @@ namespace DotNetOpenAuth.Messaging {
/// <param name="inner">The inner exception.</param>
public InternalErrorException(string message, Exception inner) : base(message, inner) { }
+#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the <see cref="InternalErrorException"/> class.
/// </summary>
@@ -52,5 +55,6 @@ namespace DotNetOpenAuth.Messaging {
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
+#endif
}
}
diff --git a/src/DotNetOpenAuth/Messaging/MessagePartAttribute.cs b/src/DotNetOpenAuth/Messaging/MessagePartAttribute.cs
index 22c660c..57e9b5a 100644
--- a/src/DotNetOpenAuth/Messaging/MessagePartAttribute.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagePartAttribute.cs
@@ -7,8 +7,11 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Diagnostics;
+#if !SILVERLIGHT
using System.Net.Security;
+#endif
using System.Reflection;
+ using DotNetOpenAuth.Messaging.Reflection;
/// <summary>
/// Applied to fields and properties that form a key/value in a protocol message.
diff --git a/src/DotNetOpenAuth/Messaging/MessageSerializer.cs b/src/DotNetOpenAuth/Messaging/MessageSerializer.cs
index 1aafc11..e1df86f 100644
--- a/src/DotNetOpenAuth/Messaging/MessageSerializer.cs
+++ b/src/DotNetOpenAuth/Messaging/MessageSerializer.cs
@@ -13,7 +13,9 @@ namespace DotNetOpenAuth.Messaging {
using System.Globalization;
using System.Reflection;
using DotNetOpenAuth.Messaging.Reflection;
+#if !SILVERLIGHT
using DotNetOpenAuth.OAuth.ChannelElements;
+#endif
/// <summary>
/// Serializes/deserializes OAuth messages for/from transit.
diff --git a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
index b5d535c..43cfbb7 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
@@ -16,9 +16,13 @@ namespace DotNetOpenAuth.Messaging {
using System.Security;
using System.Security.Cryptography;
using System.Text;
+#if !SILVERLIGHT
using System.Web;
using System.Web.Mvc;
+#endif
using DotNetOpenAuth.Messaging.Reflection;
+ using System.Windows.Browser;
+using System.Globalization;
/// <summary>
/// A grab-bag of utility methods useful for the channel stack of the protocol.
@@ -84,6 +88,7 @@ namespace DotNetOpenAuth.Messaging {
{ "=", @"\x3d" },
};
+#if !SILVERLIGHT
/// <summary>
/// Transforms an OutgoingWebResponse to an MVC-friendly ActionResult.
/// </summary>
@@ -139,6 +144,7 @@ namespace DotNetOpenAuth.Messaging {
return uri;
}
}
+#endif
/// <summary>
/// Assembles a message comprised of the message on a given exception and all inner exceptions.
@@ -217,6 +223,7 @@ namespace DotNetOpenAuth.Messaging {
return new string(randomString);
}
+#if !SILVERLIGHT
/// <summary>
/// Adds a set of HTTP headers to an <see cref="HttpResponse"/> instance,
/// taking care to set some headers to the appropriate properties of
@@ -266,6 +273,7 @@ namespace DotNetOpenAuth.Messaging {
}
}
}
+#endif
/// <summary>
/// Copies the contents of one stream to another.
@@ -354,20 +362,26 @@ namespace DotNetOpenAuth.Messaging {
switch (headerName) {
case "Accept": newRequest.Accept = request.Accept; break;
case "Connection": break; // Keep-Alive controls this
- case "Content-Length": newRequest.ContentLength = request.ContentLength; break;
case "Content-Type": newRequest.ContentType = request.ContentType; break;
- case "Expect": newRequest.Expect = request.Expect; break;
case "Host": break; // implicitly copied as part of the RequestUri
+ case "Proxy-Connection": break; // no property equivalent?
+#if !SILVERLIGHT
+ case "Content-Length": newRequest.ContentLength = request.ContentLength; break;
+ case "Expect": newRequest.Expect = request.Expect; break;
case "If-Modified-Since": newRequest.IfModifiedSince = request.IfModifiedSince; break;
case "Keep-Alive": newRequest.KeepAlive = request.KeepAlive; break;
- case "Proxy-Connection": break; // no property equivalent?
case "Referer": newRequest.Referer = request.Referer; break;
case "Transfer-Encoding": newRequest.TransferEncoding = request.TransferEncoding; break;
case "User-Agent": newRequest.UserAgent = request.UserAgent; break;
+#endif
default: newRequest.Headers[headerName] = request.Headers[headerName]; break;
}
}
+ newRequest.CookieContainer = request.CookieContainer;
+ newRequest.Credentials = request.Credentials;
+ newRequest.Method = request.Method;
+#if !SILVERLIGHT
newRequest.AllowAutoRedirect = request.AllowAutoRedirect;
newRequest.AllowWriteStreamBuffering = request.AllowWriteStreamBuffering;
newRequest.AuthenticationLevel = request.AuthenticationLevel;
@@ -376,13 +390,10 @@ namespace DotNetOpenAuth.Messaging {
newRequest.ClientCertificates = request.ClientCertificates;
newRequest.ConnectionGroupName = request.ConnectionGroupName;
newRequest.ContinueDelegate = request.ContinueDelegate;
- newRequest.CookieContainer = request.CookieContainer;
- newRequest.Credentials = request.Credentials;
newRequest.ImpersonationLevel = request.ImpersonationLevel;
newRequest.MaximumAutomaticRedirections = request.MaximumAutomaticRedirections;
newRequest.MaximumResponseHeadersLength = request.MaximumResponseHeadersLength;
newRequest.MediaType = request.MediaType;
- newRequest.Method = request.Method;
newRequest.Pipelined = request.Pipelined;
newRequest.PreAuthenticate = request.PreAuthenticate;
newRequest.ProtocolVersion = request.ProtocolVersion;
@@ -397,6 +408,7 @@ namespace DotNetOpenAuth.Messaging {
} catch (SecurityException) {
Logger.Messaging.Warn("Unable to clone some HttpWebRequest properties due to partial trust.");
}
+#endif
return newRequest;
}
@@ -573,15 +585,24 @@ namespace DotNetOpenAuth.Messaging {
ErrorUtilities.VerifyArgumentNotNull(builder, "builder");
if (args != null && args.Count() > 0) {
- NameValueCollection aggregatedArgs = HttpUtility.ParseQueryString(builder.Query);
+ var aggregatedArgs = ParseQueryString(builder.Query);
foreach (var pair in args) {
aggregatedArgs[pair.Key] = pair.Value;
}
- builder.Query = CreateQueryString(aggregatedArgs.ToDictionary());
+ builder.Query = CreateQueryString(aggregatedArgs);
}
}
+ internal static IDictionary<string, string> ParseQueryString(string query) {
+#if SILVERLIGHT
+ throw new NotImplementedException();
+#else
+ return HttpUtility.ParseQueryString(query).ToDictionary();
+#endif
+ }
+
+#if !SILVERLIGHT
/// <summary>
/// Extracts the recipient from an HttpRequestInfo.
/// </summary>
@@ -590,6 +611,7 @@ namespace DotNetOpenAuth.Messaging {
internal static MessageReceivingEndpoint GetRecipient(this HttpRequestInfo request) {
return new MessageReceivingEndpoint(request.UrlBeforeRewriting, request.HttpMethod == "GET" ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest);
}
+#endif
/// <summary>
/// Copies some extra parameters into a message.
@@ -606,6 +628,7 @@ namespace DotNetOpenAuth.Messaging {
}
}
+#if !SILVERLIGHT
/// <summary>
/// Converts a <see cref="NameValueCollection"/> to an IDictionary&lt;string, string&gt;.
/// </summary>
@@ -619,7 +642,9 @@ namespace DotNetOpenAuth.Messaging {
Contract.Ensures((nvc != null && Contract.Result<Dictionary<string, string>>() != null) || (nvc == null && Contract.Result<Dictionary<string, string>>() == null));
return ToDictionary(nvc, false);
}
+#endif
+ #if !SILVERLIGHT
/// <summary>
/// Converts a <see cref="NameValueCollection"/> to an IDictionary&lt;string, string&gt;.
/// </summary>
@@ -653,6 +678,7 @@ namespace DotNetOpenAuth.Messaging {
return dictionary;
}
+#endif
/// <summary>
/// Sorts the elements of a sequence in ascending order by using a specified comparer.
@@ -743,7 +769,7 @@ namespace DotNetOpenAuth.Messaging {
foreach (var pair in javascriptStaticStringEscaping) {
builder.Replace(pair.Key, pair.Value);
}
- builder.Insert(0, '\'');
+ builder.Insert(0, "\'");
builder.Append('\'');
return builder.ToString();
}
@@ -768,13 +794,21 @@ namespace DotNetOpenAuth.Messaging {
// Upgrade the escaping to RFC 3986, if necessary.
for (int i = 0; i < UriRfc3986CharsToEscape.Length; i++) {
- escaped.Replace(UriRfc3986CharsToEscape[i], Uri.HexEscape(UriRfc3986CharsToEscape[i][0]));
+ escaped.Replace(UriRfc3986CharsToEscape[i], HexEscape(UriRfc3986CharsToEscape[i][0]));
}
// Return the fully-RFC3986-escaped string.
return escaped.ToString();
}
+ private static string HexEscape(char ch) {
+#if SILVERLIGHT
+ return string.Format(CultureInfo.InvariantCulture, "%{0:x2}", (int)ch);
+#else
+ return Uri.HexEscape(ch);
+#endif
+ }
+
/// <summary>
/// A class to convert a <see cref="Comparison&lt;T&gt;"/> into an <see cref="IComparer&lt;T&gt;"/>.
/// </summary>
diff --git a/src/DotNetOpenAuth/Messaging/ProtocolException.cs b/src/DotNetOpenAuth/Messaging/ProtocolException.cs
index daf13d7..c2ffbbf 100644
--- a/src/DotNetOpenAuth/Messaging/ProtocolException.cs
+++ b/src/DotNetOpenAuth/Messaging/ProtocolException.cs
@@ -12,7 +12,9 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// An exception to represent errors in the local or remote implementation of the protocol.
/// </summary>
+#if !SILVERLIGHT
[Serializable]
+#endif
public class ProtocolException : Exception {
/// <summary>
/// Initializes a new instance of the <see cref="ProtocolException"/> class.
@@ -47,6 +49,7 @@ namespace DotNetOpenAuth.Messaging {
this.FaultedMessage = faultedMessage;
}
+#if !SILVERLIGHT
/// <summary>
/// Initializes a new instance of the <see cref="ProtocolException"/> class.
/// </summary>
@@ -60,12 +63,14 @@ namespace DotNetOpenAuth.Messaging {
: base(info, context) {
throw new NotImplementedException();
}
+#endif
/// <summary>
/// Gets the message that caused the exception.
/// </summary>
internal IProtocolMessage FaultedMessage { get; private set; }
+#if !SILVERLIGHT
/// <summary>
/// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with information about the exception.
/// </summary>
@@ -83,5 +88,6 @@ namespace DotNetOpenAuth.Messaging {
base.GetObjectData(info, context);
throw new NotImplementedException();
}
+#endif
}
}
diff --git a/src/DotNetOpenAuth/Messaging/Reflection/MessagePart.cs b/src/DotNetOpenAuth/Messaging/Reflection/MessagePart.cs
index 814c6fc..59ba416 100644
--- a/src/DotNetOpenAuth/Messaging/Reflection/MessagePart.cs
+++ b/src/DotNetOpenAuth/Messaging/Reflection/MessagePart.cs
@@ -10,10 +10,14 @@ namespace DotNetOpenAuth.Messaging.Reflection {
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+#if !SILVERLIGHT
using System.Net.Security;
+#endif
using System.Reflection;
using System.Xml;
+#if !SILVERLIGHT
using DotNetOpenAuth.OpenId;
+#endif
/// <summary>
/// Describes an individual member of a message and assists in its serialization.
@@ -65,9 +69,11 @@ namespace DotNetOpenAuth.Messaging.Reflection {
Map<Uri>(uri => uri.AbsoluteUri, str => new Uri(str));
Map<DateTime>(dt => XmlConvert.ToString(dt, XmlDateTimeSerializationMode.Utc), str => XmlConvert.ToDateTime(str, XmlDateTimeSerializationMode.Utc));
Map<byte[]>(bytes => Convert.ToBase64String(bytes), str => Convert.FromBase64String(str));
+#if !SILVERLIGHT
Map<Realm>(realm => realm.ToString(), str => new Realm(str));
Map<Identifier>(id => id.ToString(), str => Identifier.Parse(str));
- Map<bool>(value => value.ToString().ToLowerInvariant(), str => bool.Parse(str));
+#endif
+ Map<bool>(value => value.ToString().ToLower(CultureInfo.InvariantCulture), str => bool.Parse(str));
Map<CultureInfo>(c => c.Name, str => new CultureInfo(str));
}
diff --git a/src/DotNetOpenAuth/Messaging/Reflection/ProtectionLevel.cs b/src/DotNetOpenAuth/Messaging/Reflection/ProtectionLevel.cs
new file mode 100644
index 0000000..2b5bf74
--- /dev/null
+++ b/src/DotNetOpenAuth/Messaging/Reflection/ProtectionLevel.cs
@@ -0,0 +1,29 @@
+//-----------------------------------------------------------------------
+// <copyright file="ProtectionLevel.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Messaging.Reflection {
+#if SILVERLIGHT // full desktop defines this in the Framework
+ /// <summary>
+ /// Indicates the security services requested for an authenticated stream.
+ /// </summary>
+ public enum ProtectionLevel {
+ /// <summary>
+ /// Authentication only.
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// Sign data to help ensure the integrity of transmitted data.
+ /// </summary>
+ Sign = 1,
+
+ /// <summary>
+ /// Encrypt and sign data to help ensure the confidentiality and integrity of transmitted data.
+ /// </summary>
+ EncryptAndSign = 2,
+ }
+#endif
+}
diff --git a/src/DotNetOpenAuth/OpenId/Identifier.cs b/src/DotNetOpenAuth/OpenId/Identifier.cs
index 1b9570e..ec7cd61 100644
--- a/src/DotNetOpenAuth/OpenId/Identifier.cs
+++ b/src/DotNetOpenAuth/OpenId/Identifier.cs
@@ -16,7 +16,9 @@ namespace DotNetOpenAuth.OpenId {
/// <summary>
/// An Identifier is either a "http" or "https" URI, or an XRI.
/// </summary>
+#if !SILVERLIGHT
[Serializable]
+#endif
[ContractVerification(true)]
[Pure]
[ContractClass(typeof(IdentifierContract))]
diff --git a/src/DotNetOpenAuth/OpenId/Realm.cs b/src/DotNetOpenAuth/OpenId/Realm.cs
index 7f0acdb..968e38b 100644
--- a/src/DotNetOpenAuth/OpenId/Realm.cs
+++ b/src/DotNetOpenAuth/OpenId/Realm.cs
@@ -25,7 +25,9 @@ namespace DotNetOpenAuth.OpenId {
/// This fills the OpenID Authentication 2.0 specification for realms.
/// See http://openid.net/specs/openid-authentication-2_0.html#realms
/// </remarks>
+#if !SILVERLIGHT
[Serializable]
+#endif
[Pure]
public sealed class Realm {
/// <summary>