共用方式為


PolicyStatement 建構函式

定義

初始化 PolicyStatement 類別的新執行個體。

多載

PolicyStatement(PermissionSet)
已淘汰.

使用指定的 PolicyStatement 初始化 PermissionSet 類別的新執行個體。

PolicyStatement(PermissionSet, PolicyStatementAttribute)
已淘汰.

使用指定的 PolicyStatement 和屬性,初始化 PermissionSet 類別的新執行個體。

PolicyStatement(PermissionSet)

來源:
PolicyStatement.cs
來源:
PolicyStatement.cs
來源:
PolicyStatement.cs
來源:
PolicyStatement.cs

警告

Code Access Security is not supported or honored by the runtime.

使用指定的 PolicyStatement 初始化 PermissionSet 類別的新執行個體。

public:
 PolicyStatement(System::Security::PermissionSet ^ permSet);
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public PolicyStatement (System.Security.PermissionSet permSet);
public PolicyStatement (System.Security.PermissionSet permSet);
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet -> System.Security.Policy.PolicyStatement
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet -> System.Security.Policy.PolicyStatement
Public Sub New (permSet As PermissionSet)

參數

permSet
PermissionSet

要初始化新執行個體的 PermissionSet

屬性

範例

下列程式代碼範例示範建構函式的使用 PolicyStatement 方式。 此程式代碼範例是提供給 類別之較大範例的 PolicyStatement 一部分。

PermissionSet^ permissions = gcnew PermissionSet(
   PermissionState::Unrestricted );
permissions->AddPermission( gcnew SecurityPermission(
   SecurityPermissionFlag::Execution ) );
permissions->AddPermission( gcnew ZoneIdentityPermission(
   SecurityZone::MyComputer ) );

// Create a policy statement based on the newly created permission
// set.
PolicyStatement^ policyStatement = gcnew PolicyStatement(
   permissions );
PermissionSet permissions 
    = new PermissionSet(PermissionState.Unrestricted);
permissions.AddPermission(
    new SecurityPermission(SecurityPermissionFlag.Execution));
permissions.AddPermission(
    new ZoneIdentityPermission(SecurityZone.MyComputer));

// Create a policy statement based on the newly created permission
// set.
PolicyStatement policyStatement = new PolicyStatement(permissions);
Dim permissions As New PermissionSet(PermissionState.Unrestricted)

permissions.AddPermission( _
    New SecurityPermission(SecurityPermissionFlag.Execution))
permissions.AddPermission( _
    New ZoneIdentityPermission(SecurityZone.MyComputer))

' Instantiate a new policy statement with specified permission set.
Dim policyStatement As New PolicyStatement(permissions)

備註

警告

程式代碼啟用安全性 (CAS) 在所有版本的 .NET Framework 和 .NET 中已被取代。 最新版本的 .NET 不接受 CAS 批注,並在使用 CAS 相關 API 時產生錯誤。 開發人員應尋求替代方案來完成安全性工作。

適用於

PolicyStatement(PermissionSet, PolicyStatementAttribute)

來源:
PolicyStatement.cs
來源:
PolicyStatement.cs
來源:
PolicyStatement.cs
來源:
PolicyStatement.cs

警告

Code Access Security is not supported or honored by the runtime.

使用指定的 PolicyStatement 和屬性,初始化 PermissionSet 類別的新執行個體。

public:
 PolicyStatement(System::Security::PermissionSet ^ permSet, System::Security::Policy::PolicyStatementAttribute attributes);
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public PolicyStatement (System.Security.PermissionSet permSet, System.Security.Policy.PolicyStatementAttribute attributes);
public PolicyStatement (System.Security.PermissionSet permSet, System.Security.Policy.PolicyStatementAttribute attributes);
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet * System.Security.Policy.PolicyStatementAttribute -> System.Security.Policy.PolicyStatement
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet * System.Security.Policy.PolicyStatementAttribute -> System.Security.Policy.PolicyStatement
Public Sub New (permSet As PermissionSet, attributes As PolicyStatementAttribute)

參數

permSet
PermissionSet

要初始化新執行個體的 PermissionSet

attributes
PolicyStatementAttribute

PolicyStatementAttribute 值的位元組合。

屬性

範例

下列程式代碼範例示範建構函式的使用 PolicyStatement 方式。 此程式代碼範例是提供給 類別之較大範例的 PolicyStatement 一部分。

PermissionSet^ permissions = gcnew PermissionSet(
   PermissionState::Unrestricted );
permissions->AddPermission( gcnew SecurityPermission(
   SecurityPermissionFlag::Execution ) );
permissions->AddPermission( gcnew ZoneIdentityPermission(
   SecurityZone::MyComputer ) );

PolicyStatementAttribute levelFinalAttribute =
   PolicyStatementAttribute::LevelFinal;

// Create a new policy statement with the specified permission set.
// The LevelFinal attribute is set to prevent the evaluation of lower
// policy levels in a resolve operation.
PolicyStatement^ policyStatement = gcnew PolicyStatement(
   permissions,levelFinalAttribute );
PermissionSet permissions =
    new PermissionSet(PermissionState.Unrestricted);
permissions.AddPermission(
    new SecurityPermission(SecurityPermissionFlag.Execution));
permissions.AddPermission(
    new ZoneIdentityPermission(SecurityZone.MyComputer));

PolicyStatementAttribute levelFinalAttribute = 
    PolicyStatementAttribute.LevelFinal;

// Create a new policy statement with the specified permission set.
// The LevelFinal attribute is set to prevent the evaluation of lower
// policy levels in a resolve operation.
PolicyStatement policyStatement =
    new PolicyStatement(permissions, levelFinalAttribute);
Dim permissions As New PermissionSet(PermissionState.Unrestricted)
permissions.AddPermission( _
    New SecurityPermission(SecurityPermissionFlag.Execution))
permissions.AddPermission( _
    New ZoneIdentityPermission(SecurityZone.MyComputer))

Dim levelFinalAttribute As PolicyStatementAttribute
levelFinalAttribute = PolicyStatementAttribute.LevelFinal

' Instantiate a new policy statement with specified permission set
' and the LevelFinal attibute set allowing lower policy levels to be
' avoided in a resolve.
Dim policyStatement As _
    New PolicyStatement(permissions, levelFinalAttribute)

備註

警告

程式代碼啟用安全性 (CAS) 在所有版本的 .NET Framework 和 .NET 中已被取代。 最新版本的 .NET 不接受 CAS 批注,並在使用 CAS 相關 API 時產生錯誤。 開發人員應尋求替代方案來完成安全性工作。

適用於