Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <copyright file="Peer.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Security;
using System.Runtime.CompilerServices;
// These types exist in System.Net.dll in Silverlight but in System.dll in the Framework.
// Forward them so people can build portable libraries without changing assembly references.
[assembly: TypeForwardedToAttribute(typeof(System.Net.Cookie))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.CookieCollection))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.CookieContainer))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.CookieException))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.DownloadProgressChangedEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.DownloadProgressChangedEventHandler))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.DownloadStringCompletedEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.DownloadStringCompletedEventHandler))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.HttpRequestHeader))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.HttpStatusCode))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.HttpWebRequest))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.HttpWebResponse))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.ICredentials))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.IWebRequestCreate))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.NetworkCredential))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.OpenReadCompletedEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.OpenReadCompletedEventHandler))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.OpenWriteCompletedEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.OpenWriteCompletedEventHandler))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.ProtocolViolationException))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.UploadProgressChangedEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.UploadProgressChangedEventHandler))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.UploadStringCompletedEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.UploadStringCompletedEventHandler))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WebClient))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WebException))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WebExceptionStatus))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WebHeaderCollection))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WebRequest))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WebResponse))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.NetworkInformation.NetworkAddressChangedEventHandler))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.NetworkInformation.NetworkChange))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.NetworkInformation.NetworkInterface))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.DnsEndPoint))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.EndPoint))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.IPAddress))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.IPEndPoint))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.SocketAddress))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.AddressFamily))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.ProtocolType))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.Socket))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketAsyncEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketAsyncOperation))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketError))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketException))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketShutdown))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.Sockets.SocketType))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WriteStreamClosedEventArgs))]
[assembly: TypeForwardedToAttribute(typeof(System.Net.WriteStreamClosedEventHandler))]
[assembly: SecurityCritical]
#pragma warning disable 618
[assembly:SecurityPermission(SecurityAction.RequestMinimum, Execution = true)]
#pragma warning restore 618
namespace System.Net.PeerToPeer
{
}

View File

@@ -0,0 +1,4 @@
using System.Diagnostics.CodeAnalysis;
[module: SuppressMessage("Microsoft.Performance","CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.SR.#GetString(System.String,System.Boolean&)", Justification="baselining v4 auto generated string resources code")]

View File

@@ -0,0 +1,143 @@
;==++==
;
; Copyright (c) Microsoft Corporation. All rights reserved.
;
;==--==
; NOTE: do not use \", use ' instead
; NOTE: Use # or ; for comments
#=------------------------------------------------------------------=
# File system.net.txt
#=------------------------------------------------------------------=
#=------------------------------------------------------------------=
# Common strings
#=------------------------------------------------------------------=
NullUserToken=Parameter userToken cannot be null.
DuplicateUserToken=The userToken must be unique. A duplicate userToken already exists for this operation.
InvalidSecurityElem=Invalid security element.
InvalidSecurityElemNoClass=Invalid security element - no class name.
InvalidSecurityElemNoType=Invalid security element - no type name.
SynchronizingObject=The object used to marshal the event handler calls issued by stand alone events.
MemoryAllocFailed=Memory allocation failed.
#=------------------------------------------------------------------=
# PNRP Permission
#=------------------------------------------------------------------=
PnrpPermission_CantUnionWithNonPnrpPermission=Union not valid with a non PnrpPermission object.
PnrpPermission_CantIntersectWithNonPnrpPermission=Intersection not valid with a non PnrpPermission object.
PnrpPermission_TargetNotAPnrpPermission=Target is not a PnrpPermission object.
#=------------------------------------------------------------------=
# PNRP String
#=------------------------------------------------------------------=
Pnrp_StartupFailed=Pnrp could not be started.
Pnrp_CommentMaxLengthExceeded=Comment length can't be greater than {0} characters.
Pnrp_CommentCantBeNull=Comment can't be null or empty.
Pnrp_CloudNameCantBeNull=Cloud name can't be null or empty.
Pnrp_PeerNameCantBeNull=Peer Name can't be null or empty.
Pnrp_InvalidPeerName=Invalid peer name.
Pnrp_InvalidClassifier=Invalid classifier.
Pnrp_InvalidPeerHostName=Invalid peer host name.
Pnrp_MaxRecordsParameterMustBeGreaterThanZero=Max Records must be greater than 0.
Pnrp_DataCantBeNull=Data can't be null or 0 bytes.
Pnrp_DataLengthExceeded=Data length can't be greater than {0} bytes.
Pnrp_PortOutOfRange=Port must be between IPEndPoint.MinPort and IPEndPoint.MaxPort.
Pnrp_UseUpdateInsteadOfRegister=A previous registration is active. Use the Update method to update the registration.
Pnrp_BlobOrEndpointListNeeded=When auto endpoint selection is disabled, you must specify either a data blob or specify explicit list of endpoints to register.
Pnrp_CallRegisterBeforeUpdate=No registration found. Please use Register method before calling the Update method.
Pnrp_CantChangePeerNameAfterRegistration=Peer Name can't be changed after registration.
Pnrp_NoRegistrationFound=No current registration found.
Pnrp_PeerNameCantBeResolved=Peer Name can't be resolved. No endpoints found.
Pnrp_CouldNotEnumerateClouds=Could not enumerate clouds.
Pnrp_CouldNotCreateUnsecuredPeerName=Could not create unsecured peer name.
Pnrp_CouldNotCreateSecuredPeerName=Could not create secured peer name.
Pnrp_CouldNotGetDefaultIdentity=Could not get the default identity.
Pnrp_CouldNotGetPeerNameFromPeerHostName=Could not get peer name from peer host name.
Pnrp_CouldNotCreateRelativePeerName=Could not create relative peer name.
Pnrp_CouldNotGetPeerHostNameFromPeerName=Could not get peer host name from peer name.
Pnrp_CouldNotRegisterPeerName=Could not register peer name.
Pnrp_CouldNotResolvePeerName=Could not resolve peer name.
Pnrp_CouldNotStartNameResolution=Could not start name resolution.
Pnrp_ExceptionWhileResolvingAPeerName=Exception occurred while resolving a PeerName.
Pnrp_AtleastOneEvenHandlerNeeded=No event handlers added for ResolveAsync. Please add a handler for ResolveCompleted before calling ResolveAsync.
#=------------------------------------------------------------------=
# P2P strings
#=------------------------------------------------------------------=
P2P_NotAvailable=P2P is not available.
P2P_empty_osinstalltype=The Registry value '{0}' was either empty or not a string type.
P2P_cant_determine_osinstalltype=Can't determine OS installation type: Can't read key '{0}'. Exception message: {1}
#=------------------------------------------------------------------=
# Collaboration strings
#=------------------------------------------------------------------=
Collab_StartupFailed=Peer collaboration startup failed.
Collab_CredentialsError=Credentials Error. Cannot open certificate store from credentials.
Collab_PresenceChangedRegFailed=Peer collaboration presence change event register failed.
Collab_GetPresenceChangedDataFailed=Peer collaboration get presence changed event data failed.
Collab_PeerNearMeChangedRegFailed=Peer collaboration peer near me change event register failed.
Collab_GetPeerNearMeChangedDataFailed=Peer collaboration get peer near me changed event data failed.
Collab_ApplicationChangedRegFailed=Peer collaboration application change event register failed.
Collab_GetApplicationChangedDataFailed=Peer collaboration get application event data failed.
Collab_ObjectChangedRegFailed=Peer collaboration object change event register failed.
Collab_GetObjectChangedDataFailed=Peer collaboration get object changed event data failed.
Collab_ReqStatusChangedRegFailed=Peer collaboration request status change event register failed.
Collab_SubListChangedRegFailed=Peer collaboration subscription list change event register failed.
Collab_GetSubListChangedDataFailed=Peer collaboration get subscription list changed event data failed.
Collab_NameChangedRegFailed=Peer collaboration name change event register failed.
Collab_GetNameChangedDataFailed=Peer collaboration get name changed event data failed.
Collab_GetContactsFailed=Peer collaboration get contacts failed.
Collab_ContactNotFound=Contact not found in contact manager.
Collab_ContactExists=Contact already exists in contact manager.
Collab_GetContactFailed=Peer collaboration get contact failed.
Collab_NoEndpointFound=Could not find a PeerEndPoint or Endpoint to use for operation.
Collab_NoEndPointInPeerEndPoint=No EndPoint specified in PeerEndPoint.
Collab_CreateContactFailed=Peer collaboration create contact failed.
Collab_AddContactFailed=Peer collaboration add contact failed.
Collab_AddContactFailedNoXml=Add contact failed. No XML data present. Create this contact again and retry.
Collab_DeleteContactFailed=Peer collaboration delete contact failed.
Collab_NoPeerNameInContact=No PeerName found in PeerContact.
Collab_UpdateContactFailed=Peer collaboration update contact failed.
Collab_SubscribeLocalContactFailed=Cannot set subscribe on local contact. Value is always Allowed.
Collab_DuplicateSubscribeAsync=Another SubscribeAsync operation already in progress.
Collab_DuplicateRefreshAsync=Another RefreshDataAsync operation already in progress.
Collab_UnsubscribeLocalContactFail=Cannot unsubscribe from local contact. It is always subscribed.
Collab_GetPresenceFailed=Peer collaboration get presence information failed.
Collab_GetObjectsFailed=Peer collaboration get objects failed.
Collab_GetAppsFailed=Peer collaboration get application failed.
Collab_InviteFailed=Peer collaboration send invite failed.
Collab_AsyncInviteFailed=Peer collaboration async invite failed.
Collab_AsyncInviteException=Exception occurred while async inviting an endpoint.
Collab_SetLocalPresenceFailed=Peer collaboration LocalPresenceInfo set failed.
Collab_SetLocalEndPointNameFailed=Peer collaboration LocalEndPointName change failed.
Collab_SignInWithNone=Cannot SignIn with None scope.
Collab_SignInFailed=Peer collaboration SignIn failed.
Collab_SignOutFailed=Peer collaboration SignOut failed.
Collab_GetPeersNearMeFailed=Peer collaboration get peers near me failed.
Collab_AppRegNoPathError=Path in PeerApplication is required for registration.
Collab_AppRegFailed=Peer collaboration register application failed.
Collab_AppExists=Application already registered.
Collab_EmptyGuidError=Cannot specify empty Guid.
Collab_AppUnregFailed=Peer collaboration unregister application failed.
Collab_GetLocalAppsFailed=Peer collaboration get local registered applications failed.
Collab_ObjectSetFailed=Peer collaboration set object failed.
Collab_ObjectExists=Object already exists.
Collab_ObjectDeleteFailed=Peer collaboration delete object failed.
Collab_GetLocalObjectsFailed=Peer collaboration get local objects failed.
Collab_PermissionUnionError=Cannot union with non peer collaboration permission objects.
Collab_PermissionIntersectError=Cannot intersect with non peer collaboration permission objects.
Collab_BadPermissionTarget=Target is not a peer collaboration permission.
Collab_ContactToXmlFailed=Peer collaboration contact to xml failed.
Collab_ContactFromXmlFailed=Peer collaboration contact from xml failed.
Collab_NoGuidForCurrApp=No Guid found to send invite for. Current application may not be registered in Collaboration.
Collab_EndPointNotIPv6Error=Peer Collaboration endpoints have to be IPv6.
Collab_AddToContactMgrFailed=Add to Contact Manager failed.
Collab_AddToContactMgrFailedUpdate=Base contact from peer added but display name, nick name and email address not updated.
Collab_EndPointNotAPeerNearMe=Given Endpoint is not an endpoint of any PeerNearMe.
Collab_RefreshDataFailed=Peer collaboration refresh data failed.
Collab_SubscribeFailed=Peer collaboration subscribe failed.
Collab_UnsubscribeFailed=Peer collaboration unsubscribe failed.
Collab_SetPresenceOffline=Local presence cannot be set to Offline.
Collab_ApplicationDataSizeFailed=Peer Application data size cannot exceed 16 kilobytes.
Collab_ObjectDataSizeFailed=Peer Object data size cannot exceed 16 kilobytes.

View File

@@ -0,0 +1,64 @@
using System;
using System.ComponentModel;
namespace System.Net.Sockets
{
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public class HttpPolicyDownloaderProtocol
{
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public HttpPolicyDownloaderProtocol(Uri appUri, IPAddress address) { }
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public void Abort() { }
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public void BeginDownload(SecurityCriticalAction callback) { }
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public void DownloadCallback(IAsyncResult ar) { }
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public void ReadCallback(IAsyncResult ar) { }
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public static void RegisterUnsafeWebRequestCreator(IUnsafeWebRequestCreate creator) { }
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public SocketPolicy Result { get { throw new PlatformNotSupportedException(); } }
}
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public delegate void SecurityCriticalAction();
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public class SocketPolicy
{
}
}

View File

@@ -0,0 +1,49 @@
using System;
using System.ComponentModel;
namespace System.Net
{
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public interface INetworkProgress
{
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
event EventHandler<NetworkProgressChangedEventArgs> ProgressChanged;
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
event EventHandler<NetworkProgressChangedEventArgs> ProgressCompleted;
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
event EventHandler<NetworkProgressChangedEventArgs> ProgressFailed;
}
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public class NetworkProgressChangedEventArgs : ProgressChangedEventArgs
{
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public NetworkProgressChangedEventArgs(int percentage, int processedBytes, int totalBytes, object userState) : base(default(int), null) { }
// Properties
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public int ProcessedBytes { get { throw new PlatformNotSupportedException(); } }
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public int TotalBytes { get { throw new PlatformNotSupportedException(); } }
}
}

View File

@@ -0,0 +1,34 @@
//------------------------------------------------------------------------------
// <copyright file="IPEndPointCollection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
[Serializable]
public class IPEndPointCollection : Collection<IPEndPoint>
{
public IPEndPointCollection() { }
protected override void SetItem(int index, IPEndPoint item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
base.SetItem(index, item);
}
protected override void InsertItem(int index, IPEndPoint item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
base.InsertItem(index, item);
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.ComponentModel;
namespace System.Net
{
//introduced for supporting design-time loading of System.Windows.dll
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public interface IUnsafeWebRequestCreate
{
[Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
[EditorBrowsable(EditorBrowsableState.Never)]
WebRequest Create(Uri uri);
}
}

View File

@@ -0,0 +1,187 @@
//------------------------------------------------------------------------------
// <copyright file="Logging.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net
{
using System.Collections;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Globalization;
using Microsoft.Win32;
using System.Text;
internal static class Logging
{
private static P2PTraceSource s_P2PTraceSource;
// <SecurityKernel Critical="True" Ring="0">
// <SatisfiesLinkDemand Name="AppDomain.add_ProcessExit(System.EventHandler):System.Void" />
// <SatisfiesLinkDemand Name="AppDomain.add_DomainUnload(System.EventHandler):System.Void" />
// <ReferencesCritical Name="Method: ProcessExitEventHandler(Object, EventArgs):Void" Ring="2" />
// <ReferencesCritical Name="Method: DomainUnloadEventHandler(Object, EventArgs):Void" Ring="2" />
// </SecurityKernel>
[System.Security.SecurityCritical]
static Logging()
{
s_P2PTraceSource = new P2PTraceSource();
if (s_P2PTraceSource.Switch.ShouldTrace(TraceEventType.Critical))
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.ProcessExit += new EventHandler(ProcessExitEventHandler);
//currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);
currentDomain.DomainUnload += new EventHandler(DomainUnloadEventHandler);
}
}
// <SecurityKernel Critical="True" Ring="1">
// <ReferencesCritical Name="Method: Close():Void" Ring="1" />
// </SecurityKernel>
[System.Security.SecurityCritical]
private static void DomainUnloadEventHandler(object sender, EventArgs e)
{
Close();
}
/*
private static void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs e)
{
s_P2PTraceSource.TraceEvent(TraceEventType.Critical, UNHANDLED_EXCEPTION_EVENT_ID, "Unhandled Exception {0}", e.ExceptionObject);
}
*/
// <SecurityKernel Critical="True" Ring="1">
// <ReferencesCritical Name="Method: Close():Void" Ring="1" />
// </SecurityKernel>
[System.Security.SecurityCritical]
private static void ProcessExitEventHandler(object sender, EventArgs e)
{
Close();
}
// <SecurityKernel Critical="True" Ring="0">
// <SatisfiesLinkDemand Name="TraceSource.Close():System.Void" />
// </SecurityKernel>
[System.Security.SecurityCritical]
private static void Close()
{
s_P2PTraceSource.Close();
}
//private Logging() {}
internal static P2PTraceSource P2PTraceSource
{
get
{
return s_P2PTraceSource;
}
}
internal static void Enter(TraceSource source, string method)
{
if(source.Switch.ShouldTrace(TraceEventType.Verbose))
{
source.TraceEvent(TraceEventType.Verbose, 0, "Entering --> " + method);
}
}
internal static void Leave(TraceSource source, string message)
{
if (source.Switch.ShouldTrace(TraceEventType.Verbose))
{
source.TraceEvent(TraceEventType.Verbose, 0, "Leaving <-- " + message);
}
}
/*
internal static void Enter(TraceSource source, string type, object obj, string method)
{
}
internal static void Enter(TraceSource source, string type, object obj, string method, params object[] args)
{
}
* */
internal static void DumpData(TraceSource source, TraceEventType eventType, int maxDataSize, byte[] buffer, int offset, int length)
{
if (buffer == null ||
buffer.Length == 0 ||
offset > buffer.Length)
{
return;
}
if (length > maxDataSize)
{
source.TraceEvent(eventType, 0, "dumping {0} of {1} bytes", maxDataSize, length);
length = maxDataSize;
}
if ((length < 0) || (length > buffer.Length - offset))
{
length = buffer.Length - offset;
}
do
{
int n = Math.Min(length, 16);
StringBuilder sb = new StringBuilder();
sb.Append(String.Format(CultureInfo.CurrentCulture, "{0:X8} : ", offset));
for (int i = 0; i < n; ++i)
{
sb.Append(String.Format(CultureInfo.CurrentCulture, "{0:X2}", buffer[offset + i]) + ((i == 7) ? '-' : ' '));
}
for (int i = n; i < 16; ++i)
{
sb.Append(" ");
}
sb.Append(": ");
for (int i = 0; i < n; ++i)
{
sb.Append(((buffer[offset + i] < 0x20) || (buffer[offset + i] > 0x7e))
? '.'
: (char)(buffer[offset + i]));
}
source.TraceEvent(eventType, 0, sb.ToString());
offset += n;
length -= n;
} while (length > 0);
}
}
internal class P2PTraceSource : TraceSource
{
private const string P2PTraceSourceName = "System.Net.PeerToPeer";
private const int DefaultMaxDataSize = 1024;
private const string AttributeNameMaxDataSize = "maxdatasize";
private static readonly string[] P2PTraceSourceSupportedAttributes = new string[] { AttributeNameMaxDataSize };
private readonly int m_maxDataSize = DefaultMaxDataSize;
internal P2PTraceSource() :base(P2PTraceSourceName)
{
if (Attributes.ContainsKey(AttributeNameMaxDataSize))
{
try{
m_maxDataSize = Int32.Parse(Attributes[AttributeNameMaxDataSize], NumberFormatInfo.InvariantInfo);
}
catch (Exception exception) {
if (exception is ThreadAbortException || exception is StackOverflowException || exception is OutOfMemoryException) {
throw;
}
}
}
}
protected override string[] GetSupportedAttributes()
{
return P2PTraceSourceSupportedAttributes;
}
internal int MaxDataSize
{
get
{
return m_maxDataSize;
}
}
}
}

View File

@@ -0,0 +1,362 @@
//------------------------------------------------------------------------------
// <copyright file="Cloud.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net.PeerToPeer
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
/// <remarks>
/// The Cloud class directly represents the native cloud concept in the P2P APIs
/// There are two special static readonly members we support
/// Cloud.All and Cloud.AllLinkLocal
/// Cloud.All is really a notational convinience of null in the native world
/// Cloud.AllLinkLocal is equivalent to PEER_PNRP_ALL_LINK_CLOUDS const in the header file (declared in p2p.h)
///
/// This class is serializable.
/// This class is not sealed because there is no reason for it to be sealed.
/// </remarks>
/// <
[Serializable]
public class Cloud : ISerializable, IEquatable<Cloud>
{
private const string PEER_PNRP_ALL_LINK_CLOUDS = "PEER_PNRP_ALL_LINKS";
private string m_CloudName; //name of the cloud
private PnrpScope m_PnrpScope; //scope of the cloud
private int m_ScopeId; //scope Id of the scope
/// <summary>
/// Cloud.AllAvailable is a notational convinience. The native side uses a null for cloud parameter
/// to indicate all clouds.
/// </summary>
public static readonly Cloud Available = new Cloud("AllAvailable", PnrpScope.All, -1);
/// <summary>
/// AllLinkLocal is a managed abstraction of the native const PEER_PNRP_ALL_LINK_CLOUDS
/// </summary>
public static readonly Cloud AllLinkLocal = new Cloud("AllLinkLocal", PnrpScope.LinkLocal, -1);
/// <summary>
/// The static constructor serves the purpose of checking the
/// availability of the P2P apis on this platform
/// </summary>
static Cloud()
{
//-------------------------------------------------
//Check for the availability of the simpler PNRP APIs
//-------------------------------------------------
if (!PeerToPeerOSHelper.SupportsP2P)
{
throw new PlatformNotSupportedException(SR.GetString(SR.P2P_NotAvailable));
}
}
/// <summary>
/// Constructs an instance of a Cloud.
/// This is not public and accessible for internal members only
/// </summary>
/// <param name="name">Name of the cloud</param>
/// <param name="pnrpScope">scope</param>
/// <param name="scopeId">id ofthe scope</param>
internal Cloud(string name, PnrpScope pnrpScope, int scopeId) {
Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Creating cloud with Name: {0}, PnrpScope: {1}, ScopeID: {2}", name, pnrpScope, scopeId);
m_CloudName = name;
m_PnrpScope = pnrpScope;
m_ScopeId = scopeId;
}
/// <summary>
/// Name
/// </summary>
public string Name {
get {
if (this == Cloud.AllLinkLocal || this == Cloud.Available)
return null;
return m_CloudName;
}
}
internal string InternalName
{
get
{
if (this == Cloud.AllLinkLocal)
return PEER_PNRP_ALL_LINK_CLOUDS;
else if (this == Cloud.Available)
return null;
return m_CloudName;
}
}
/// <summary>
/// Scope
/// </summary>
public PnrpScope Scope {
get {
return m_PnrpScope;
}
}
/// <summary>
/// ScopeId
/// </summary>
public int ScopeId {
get {
return m_ScopeId;
}
}
public static Cloud Global
{
// <SecurityKernel Critical="True" Ring="1">
// <ReferencesCritical Name="Method: GetCloudOrClouds(String, Boolean, CloudCollection&, Cloud&):Void" Ring="1" />
// </SecurityKernel>
//[System.Security.SecurityCritical]
get
{
//throw new PeerToPeerException(SR.GetString(SR.Collab_SubscribeLocalContactFailed));
CloudCollection dummy = null;
Cloud cloud = null;
GetCloudOrClouds(null, true, out dummy, out cloud);
return cloud;
}
}
// <SecurityKernel Critical="True" Ring="1">
// <ReferencesCritical Name="Method: GetCloudOrClouds(String, Boolean, CloudCollection&, Cloud&):Void" Ring="1" />
// </SecurityKernel>
//[System.Security.SecurityCritical]
public static Cloud GetCloudByName(string cloudName)
{
if (cloudName == null || cloudName.Length == 0)
{
throw new ArgumentException(SR.GetString(SR.Pnrp_CloudNameCantBeNull), "cloudName");
}
CloudCollection dummy = null;
Cloud cloud = null;
GetCloudOrClouds(cloudName, false, out dummy, out cloud);
return cloud;
}
/// <summary>
/// The static member returns the list of clouds
/// </summary>
/// <returns></returns>
// <SecurityKernel Critical="True" Ring="1">
// <ReferencesCritical Name="Method: GetCloudOrClouds(String, Boolean, CloudCollection&, Cloud&):Void" Ring="1" />
// </SecurityKernel>
//[System.Security.SecurityCritical]
public static CloudCollection GetAvailableClouds()
{
CloudCollection clouds = null;
Cloud dummy = null;
GetCloudOrClouds(null, false, out clouds, out dummy);
return clouds;
}
// <SecurityKernel Critical="True" Ring="0">
// <CallsSuppressUnmanagedCode Name="UnsafeP2PNativeMethods.PeerPnrpGetCloudInfo(System.UInt32&,System.Net.PeerToPeer.SafePeerData&):System.Int32" />
// <SatisfiesLinkDemand Name="SafeHandle.DangerousGetHandle():System.IntPtr" />
// <SatisfiesLinkDemand Name="Marshal.PtrToStructure(System.IntPtr,System.Type):System.Object" />
// <SatisfiesLinkDemand Name="Marshal.PtrToStringUni(System.IntPtr):System.String" />
// <SatisfiesLinkDemand Name="Marshal.SizeOf(System.Type):System.Int32" />
// <SatisfiesLinkDemand Name="SafeHandle.Dispose():System.Void" />
// <ReferencesCritical Name="Local ArrayOfCloudInfoStructures of type: SafePeerData" Ring="1" />
// <ReferencesCritical Name="Method: UnsafeP2PNativeMethods.PnrpStartup():System.Void" Ring="1" />
// <ReferencesCritical Name="Method: PeerToPeerException.CreateFromHr(System.String,System.Int32):System.Net.PeerToPeer.PeerToPeerException" Ring="1" />
// </SecurityKernel>
[SuppressMessage("Microsoft.Security","CA2129:SecurityTransparentCodeShouldNotReferenceNonpublicSecurityCriticalCode", Justification="System.Net.dll is still using pre-v4 security model and needs this demand")]
[System.Security.SecuritySafeCritical]
private static void GetCloudOrClouds(string cloudName, bool bGlobalCloudOnly, out CloudCollection clouds, out Cloud cloud)
{
cloud = null;
clouds = null;
Logging.Enter(Logging.P2PTraceSource, "Cloud::GetCloudOrClouds()");
//-------------------------------------------------
//Demand for the Unrestricted Pnrp Permission
//-------------------------------------------------
PnrpPermission.UnrestrictedPnrpPermission.Demand();
Int32 result = 0;
UInt32 numClouds = 0;
SafePeerData ArrayOfCloudInfoStructures = null;
if (cloudName == null)
{
//-----------------------------------------
//We need the collection only when we are not
//getting a specific cloud
//-----------------------------------------
clouds = new CloudCollection();
}
try
{
//---------------------------------------------------------------
//No perf hit here, real native call happens only one time if it
//did not already happen
//---------------------------------------------------------------
UnsafeP2PNativeMethods.PnrpStartup();
result = UnsafeP2PNativeMethods.PeerPnrpGetCloudInfo(out numClouds, out ArrayOfCloudInfoStructures);
if (result != 0)
{
throw PeerToPeerException.CreateFromHr(SR.GetString(SR.Pnrp_CouldNotEnumerateClouds), result);
}
if (numClouds != 0)
{
Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Number of clouds returned {0}", numClouds);
IntPtr pPEER_PNRP_CLOUD_INFO = ArrayOfCloudInfoStructures.DangerousGetHandle();
for (ulong i = 0; i < numClouds; i++)
{
PEER_PNRP_CLOUD_INFO cloudinfo = (PEER_PNRP_CLOUD_INFO)Marshal.PtrToStructure(pPEER_PNRP_CLOUD_INFO, typeof(PEER_PNRP_CLOUD_INFO));
string nativeCloudName = Marshal.PtrToStringUni(cloudinfo.pwzCloudName);
pPEER_PNRP_CLOUD_INFO = (IntPtr)((long)pPEER_PNRP_CLOUD_INFO + Marshal.SizeOf(typeof(PEER_PNRP_CLOUD_INFO)));
Cloud c = new Cloud(nativeCloudName, (PnrpScope)((int)cloudinfo.dwScope), (int)cloudinfo.dwScopeId);
if (cloudName == null && !bGlobalCloudOnly)
{
clouds.Add(c);
continue;
}
//If a specific cloud by name is required, then test for name
//note that scope is PnrpScope.All but we don't test that now
if (cloudName != null && cloudName == nativeCloudName)
{
cloud = c;
break;
}
if (bGlobalCloudOnly && c.Scope == PnrpScope.Global)
{
cloud = c;
break;
}
}
}
else
{
Logging.P2PTraceSource.TraceEvent(TraceEventType.Warning, 0, "No Clouds returned from the native call");
}
}
finally
{
if (ArrayOfCloudInfoStructures != null)
{
ArrayOfCloudInfoStructures.Dispose();
}
}
if (cloudName != null && cloud == null)
{
Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "The specific cloud name {0} asked for is not found", cloudName);
}
Logging.Leave(Logging.P2PTraceSource, "Cloud::GetCloudOrClouds()");
}
/// <summary>
/// Two Clouds are equal only when all of the information matches
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public bool Equals(Cloud other)
{
if (other == null) return false;
return other.Name == Name && other.Scope == Scope && other.ScopeId == ScopeId;
}
public override bool Equals(object obj)
{
if (obj == null) return false;
Cloud other = obj as Cloud;
if (other == null)
return false;
return Equals(other);
}
/// <summary>
/// The hash code comes from just the cloud name - for no partular reason.
/// This implementation seems sufficient - since the cloud names or typically
/// unique
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return m_CloudName.GetHashCode();
}
/// <summary>
/// A friendly string for the Cloud object
/// </summary>
/// <returns></returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("Cloud Name:");
sb.Append(Name);
sb.Append(" Scope:");
sb.Append(Scope);
sb.Append(" ScopeId:");
sb.Append(ScopeId);
return sb.ToString();
}
/// <summary>
/// Constructor to enable serialization
/// </summary>
/// <param name="serializationInfo"></param>
/// <param name="streamingContext"></param>
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
protected Cloud(SerializationInfo info, StreamingContext context)
{
m_CloudName = info.GetString("_CloudName");
m_PnrpScope = (PnrpScope)info.GetValue("_CloudScope", typeof(PnrpScope));
m_ScopeId = info.GetInt32("_CloudScopeId");
}
// <SecurityKernel Critical="True" Ring="0">
// <SatisfiesLinkDemand Name="GetObjectData(SerializationInfo, StreamingContext):Void" />
// </SecurityKernel>
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.Net.dll is still using pre-v4 security model and needs this demand")]
[System.Security.SecurityCritical]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter, SerializationFormatter = true)]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
GetObjectData(info, context);
}
/// <summary>
/// This is made virtual so that derived types can be implemented correctly
/// </summary>
/// <param name="serializationInfo"></param>
/// <param name="streamingContext"></param>
[SecurityPermission(SecurityAction.LinkDemand, SerializationFormatter = true)]
protected virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
//Name is tricky since it can be null for AllLinkLocal and Available clouds
//but internally we represent them with non null strings
//so we should use the property here
info.AddValue("_CloudName", Name);
info.AddValue("_CloudScope", m_PnrpScope);
info.AddValue("_CloudScopeId", m_ScopeId);
}
}
}

View File

@@ -0,0 +1,34 @@
//------------------------------------------------------------------------------
// <copyright file="CloudCollection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net.PeerToPeer
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
[Serializable]
public class CloudCollection : Collection<Cloud>
{
public CloudCollection() { }
protected override void SetItem(int index, Cloud item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
base.SetItem(index, item);
}
protected override void InsertItem(int index, Cloud item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
base.InsertItem(index, item);
}
}
}

View File

@@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <copyright file="CollabEnumTypes.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net.PeerToPeer.Collaboration
{
//
// Defines all the enums used by peer collaboration
//
public enum PeerPresenceStatus
{
Offline = 0,
OutToLunch,
Away,
BeRightBack,
Idle,
Busy,
OnThePhone,
Online
}
public enum PeerScope
{
None = 0,
NearMe,
Internet,
All = NearMe | Internet
}
public enum PeerApplicationRegistrationType
{
CurrentUser = 0,
AllUsers
}
public enum PeerInvitationResponseType
{
Declined = 0,
Accepted,
Expired
}
public enum PeerChangeType
{
Added = 0,
Deleted,
Updated
}
public enum SubscriptionType
{
Blocked = 0,
Allowed
}
internal enum PeerCollabEventType
{
WatchListChanged = 1,
EndPointChanged = 2,
EndPointPresenceChanged = 3,
EndPointApplicationChanged = 4,
EndPointObjectChanged = 5,
MyEndPointChanged = 6,
MyPresenceChanged = 7,
MyApplicationChanged = 8,
MyObjectChanged = 9,
PeopleNearMeChanged = 10,
RequestStatusChanged = 11
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,76 @@
//------------------------------------------------------------------------------
// <copyright file="PeerApplicationLaunchInfo.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net.PeerToPeer.Collaboration
{
using System;
/// <summary>
/// Represents launch info that collab gives back for the running application.
/// If this application has been started up via collab invitation then it gives
/// back the details of that invitation.
/// </summary>
public class PeerApplicationLaunchInfo
{
private PeerContact m_peerContact;
private PeerEndPoint m_peerEndPoint;
private PeerApplication m_peerApplication;
private byte[] m_inviteData;
private string m_message;
internal PeerApplicationLaunchInfo() { }
public PeerContact PeerContact
{
get{
return m_peerContact;
}
internal set{
m_peerContact = value;
}
}
public PeerEndPoint PeerEndPoint
{
get{
return m_peerEndPoint;
}
internal set{
m_peerEndPoint = value;
}
}
public PeerApplication PeerApplication
{
get{
return m_peerApplication;
}
internal set{
m_peerApplication = value;
}
}
public byte[] Data
{
get{
return m_inviteData;
}
internal set{
m_inviteData = value;
}
}
public string Message
{
get{
return m_message;
}
internal set{
m_message = value;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,204 @@
//------------------------------------------------------------------------------
// <copyright file="PeerCollaborationPermission.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net.PeerToPeer.Collaboration
{
using System.Security;
using System.Security.Permissions;
using System.Globalization;
/// <remarks>
/// PeerCollaborationPermissionAttribute atrribute
/// </remarks>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor |
AttributeTargets.Class | AttributeTargets.Struct |
AttributeTargets.Assembly,
AllowMultiple = true, Inherited = false)]
[Serializable()]
public sealed class PeerCollaborationPermissionAttribute : CodeAccessSecurityAttribute
{
/// <summary>
/// Just call base constructor
/// </summary>
/// <param name="action"></param>
public PeerCollaborationPermissionAttribute(SecurityAction action) : base(action) { }
/// <summary>
/// As required by the SecurityAttribute class.
/// </summary>
/// <returns></returns>
public override IPermission CreatePermission()
{
if (Unrestricted){
return new PeerCollaborationPermission(PermissionState.Unrestricted);
}
else{
return new PeerCollaborationPermission(PermissionState.None);
}
}
}
/// <remarks>
/// Currently we only support two levels - Unrestrictred or none
/// </remarks>
[Serializable]
public sealed class PeerCollaborationPermission : CodeAccessPermission, IUnrestrictedPermission
{
private bool m_noRestriction;
internal static readonly PeerCollaborationPermission UnrestrictedPeerCollaborationPermission =
new PeerCollaborationPermission(PermissionState.Unrestricted);
/// <summary>
/// <para>
/// Creates a new instance of the <see cref='System.Net.PeerToPeer.Collaboration.PeerCollaborationPermission'/>
/// class that passes all demands or that fails all demands.
/// </para>
/// </summary>
public PeerCollaborationPermission(PermissionState state)
{
m_noRestriction = (state == PermissionState.Unrestricted);
}
internal PeerCollaborationPermission(bool free)
{
m_noRestriction = free;
}
// IUnrestrictedPermission interface methods
/// <summary>
/// <para>
/// Checks the overall permission state of the object.
/// </para>
/// </summary>
public bool IsUnrestricted()
{
return m_noRestriction;
}
// IPermission interface methods
/// <summary>
/// <para>
/// Creates a copy of a <see cref='System.Net.PeerToPeer..Collaboration.PeerCollaborationPermission'/> instance.
/// </para>
/// </summary>
public override IPermission Copy()
{
if (m_noRestriction)
return new PeerCollaborationPermission(true);
else
return new PeerCollaborationPermission(false);
}
/// <summary>
/// <para>Returns the logical union between two <see cref='System.Net.PeerToPeer..Collaboration.PeerCollaborationPermission'/> instances.</para>
/// </summary>
public override IPermission Union(IPermission target)
{
// Pattern suggested by Security engine
if (target == null){
return this.Copy();
}
PeerCollaborationPermission other = target as PeerCollaborationPermission;
if (other == null){
throw new ArgumentException(SR.GetString(SR.Collab_PermissionUnionError), "target");
}
return new PeerCollaborationPermission(m_noRestriction || other.m_noRestriction);
}
/// <summary>
/// <para>Returns the logical intersection between two <see cref='System.Net.PeerToPeer..Collaboration.PeerCollaborationPermission'/> instances.</para>
/// </summary>
public override IPermission Intersect(IPermission target)
{
// Pattern suggested by Security engine
if (target == null){
return null;
}
PeerCollaborationPermission other = target as PeerCollaborationPermission;
if (other == null){
throw new ArgumentException(SR.GetString(SR.Collab_PermissionIntersectError), "target");
}
// return null if resulting permission is restricted and empty
// Hence, the only way for a bool permission will be.
if (this.m_noRestriction && other.m_noRestriction){
return new PeerCollaborationPermission(true);
}
return null;
}
/// <summary>
/// <para>Compares two <see cref='System.Net.PeerToPeer..Collaboration.PeerCollaborationPermission'/> instances.</para>
/// </summary>
public override bool IsSubsetOf(IPermission target)
{
// Pattern suggested by Security engine
if (target == null){
return m_noRestriction == false;
}
PeerCollaborationPermission other = target as PeerCollaborationPermission;
if (other == null){
throw new ArgumentException(SR.GetString(SR.Collab_BadPermissionTarget), "target");
}
//Here is the matrix of result based on m_noRestriction for me and she
// me.noRestriction she.noRestriction me.isSubsetOf(she)
// 0 0 1
// 0 1 1
// 1 0 0
// 1 1 1
return (!m_noRestriction || other.m_noRestriction);
}
/// <summary>
/// Copy from a security element
/// </summary>
/// <param name="securityElement"></param>
public override void FromXml(SecurityElement e)
{
if (e == null){
throw new ArgumentNullException("e");
}
// SecurityElement must be a permission element
if (!e.Tag.Equals("IPermission"))
{
throw new ArgumentException(SR.GetString(SR.InvalidSecurityElem), "e");
}
string className = e.Attribute("class");
// SecurityElement must be a permission element for this type
if (className == null){
throw new ArgumentException(SR.GetString(SR.InvalidSecurityElemNoClass), "e");
}
if (className.IndexOf(this.GetType().FullName, StringComparison.Ordinal) < 0){
throw new ArgumentException(SR.GetString(SR.InvalidSecurityElemNoType), "e");
}
string str = e.Attribute("Unrestricted");
m_noRestriction = (str != null ? (0 == string.Compare(str, "true", StringComparison.OrdinalIgnoreCase)) : false);
}
/// <summary>
/// Copyto a security element
/// </summary>
/// <returns></returns>
public override SecurityElement ToXml()
{
SecurityElement securityElement = new SecurityElement("IPermission");
securityElement.AddAttribute("class", this.GetType().FullName + ", " + this.GetType().Module.Assembly.FullName.Replace('\"', '\''));
securityElement.AddAttribute("version", "1");
if (m_noRestriction){
securityElement.AddAttribute("Unrestricted", "true");
}
return securityElement;
}
}
}

File diff suppressed because it is too large Load Diff

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