Browse Source

Adhere to mono coding guidelines.

rjvdboon 11 years ago
parent
commit
d90ab2a697

+ 49 - 36
mcs/class/System.IdentityModel/System.IdentityModel.Tokens/BootstrapContext.cs

@@ -27,80 +27,93 @@
 //
 #if NET_4_5
 using System;
+using System.IO;
 using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
 
-namespace System.IdentityModel.Tokens
-{
+namespace System.IdentityModel.Tokens {
 	[Serializable]
-	public class BootstrapContext : ISerializable
-	{
+	public class BootstrapContext : ISerializable {
 		/// <summary>Gets the string that was used to initialize the context.</summary>
 		public string Token { get; private set; }
 		/// <summary>Gets the array that was used to initialize the context.</summary>
-		public byte[] TokenBytes { get; private set; }
+		public byte [] TokenBytes { get; private set; }
 		/// <summary>Gets the security token that was used to initialize the context.</summary>
 		public SecurityToken SecurityToken { get; private set; }
 		/// <summary>Gets the token handler that was used to initialize the context.</summary>
 		public SecurityTokenHandler SecurityTokenHandler { get; private set; }
 
 		/// <summary>Initializes a new instance of the <see cref="BootstrapContext"/> class by using the specified string.</summary>
-		public BootstrapContext (string token) {
-			if (token == null) throw new ArgumentNullException("token");
+		public BootstrapContext (string token)
+		{
+			if (token == null)
+				throw new ArgumentNullException ("token");
 			Token = token;
 		}
 
 		/// <summary>Initializes a new instance of the <see cref="BootstrapContext"/> class by using the specified array.</summary>
-		public BootstrapContext (byte[] token) {
-			if (token == null) throw new ArgumentNullException("token");
+		public BootstrapContext (byte [] token)
+		{
+			if (token == null)
+				throw new ArgumentNullException ("token");
 			TokenBytes = token;
 		}
 
 		/// <summary>Initializes a new instance of the <see cref="BootstrapContext"/> class by using the specified security token and token handler.</summary>
-		public BootstrapContext (SecurityToken token, SecurityTokenHandler handler) {
-			if (token == null) throw new ArgumentNullException("token");
-			if (handler == null) throw new ArgumentNullException("handler");
+		public BootstrapContext (SecurityToken token, SecurityTokenHandler handler)
+		{
+			if (token == null)
+				throw new ArgumentNullException ("token");
+			if (handler == null)
+				throw new ArgumentNullException ("handler");
 			SecurityToken = token;
 			SecurityTokenHandler = handler;
 		}
-		
+
 		/// <summary>Initializes a new instance of the <see cref="BootstrapContext"/> class from a stream.</summary>
-		protected BootstrapContext(SerializationInfo info, StreamingContext context) {
-			if (info == null) throw new ArgumentNullException("info");
-			char type = info.GetChar("K");
+		protected BootstrapContext (SerializationInfo info, StreamingContext context)
+		{
+			if (info == null)
+				throw new ArgumentNullException ("info");
+			char type = info.GetChar ("K");
 			switch (type) {
 			case 'S':
-				Token = info.GetString("T");
+				Token = info.GetString ("T");
 				break;
 			case 'B':
-				TokenBytes = (byte[])info.GetValue("T", typeof(byte[]));
+				TokenBytes = (byte [])info.GetValue ("T", typeof (byte []));
 				break;
 			case 'T':
-				Token = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(info.GetString("T")));
+				Token = Encoding.UTF8.GetString (Convert.FromBase64String (info.GetString ("T")));
 				break;
 			}
 		}
-		
+
 		/// <summary>Populates the <see cref="SerializationInfo"/> with data needed to serialize the current <see cref="BootstrapContext"/> object.</summary>
-		public void GetObjectData(SerializationInfo info, StreamingContext context) {
-			if (info == null) throw new ArgumentNullException("info");
+		public void GetObjectData (SerializationInfo info, StreamingContext context)
+		{
+			if (info == null)
+				throw new ArgumentNullException ("info");
 			if (Token != null) {
-				info.AddValue("K", 'S');
-				info.AddValue("T", Token);
-			} else if (TokenBytes != null) {
-				info.AddValue("K", 'B');
-				info.AddValue("T", TokenBytes);
-			} else if (SecurityToken != null && SecurityTokenHandler != null) {
-				info.AddValue("K", 'T');
-				using(var ms = new System.IO.MemoryStream())
-				using(var streamWriter = new System.IO.StreamWriter(ms, new System.Text.UTF8Encoding(false)))
-				using(var writer = System.Xml.XmlWriter.Create(streamWriter, new System.Xml.XmlWriterSettings { OmitXmlDeclaration = true })) {
-					SecurityTokenHandler.WriteToken(writer, SecurityToken);
-					writer.Flush();
-					info.AddValue("T", Convert.ToBase64String(ms.ToArray()));
+				info.AddValue ("K", 'S');
+				info.AddValue ("T", Token);
+			}
+			else if (TokenBytes != null) {
+				info.AddValue ("K", 'B');
+				info.AddValue ("T", TokenBytes);
+			}
+			else if (SecurityToken != null && SecurityTokenHandler != null) {
+				info.AddValue ("K", 'T');
+				using (var ms = new MemoryStream ())
+				using (var streamWriter = new StreamWriter (ms, new UTF8Encoding (false)))
+				using (var writer = XmlWriter.Create (streamWriter, new XmlWriterSettings { OmitXmlDeclaration = true })) {
+					SecurityTokenHandler.WriteToken (writer, SecurityToken);
+					writer.Flush ();
+					info.AddValue ("T", Convert.ToBase64String (ms.ToArray ()));
 				}
 			}
 		}
-
 	}
 }
 #endif

File diff suppressed because it is too large
+ 5 - 8
mcs/class/System.IdentityModel/Test/System.IdentityModel.Tokens/BootstrapContextTest.cs


Some files were not shown because too many files changed in this diff