Επεξεργασία

Κοινή χρήση μέσω


CodeConnectAccess(String, Int32) Constructor

Definition

Initializes a new instance of the CodeConnectAccess class.

public:
 CodeConnectAccess(System::String ^ allowScheme, int allowPort);
public CodeConnectAccess (string allowScheme, int allowPort);
new System.Security.Policy.CodeConnectAccess : string * int -> System.Security.Policy.CodeConnectAccess
Public Sub New (allowScheme As String, allowPort As Integer)

Parameters

allowScheme
String

The URI scheme represented by the current instance.

allowPort
Int32

The port represented by the current instance.

Exceptions

allowScheme is null.

-or-

allowScheme is an empty string ("").

-or-

allowScheme contains characters that are not permitted in schemes.

-or-

allowPort is less than 0.

-or-

allowPort is greater than 65,535.

Examples

The following code example demonstrates creating a CodeConnectAccess object that permits downloaded code to connect back to its origin server using the HTTP protocol and the same port it was downloaded on. For an example that demonstrates using CodeConnectAccess objects to create a code group and adding the code group to a policy level, see the CodeConnectAccess class overview.



static CodeConnectAccess^ CreateHttpAndOriginPortAccess()
{
    return gcnew CodeConnectAccess(Uri::UriSchemeHttp, 
        CodeConnectAccess::OriginPort);
}

    public static CodeConnectAccess CreateHttpAndOriginPortAccess()
{
    return new CodeConnectAccess(Uri.UriSchemeHttp, CodeConnectAccess.OriginPort);
}

Remarks

The Scheme property is set using the allowScheme parameter. The scheme is converted to lowercase. The value of Scheme controls the scheme that executing code can use to connect to a network resource.

The Port property is set using the allowPort parameter. The value of Port controls the port that executing code can use to connect to a network resource.

Applies to