共用方式為


HostProtectionAttribute.Resources 屬性

定義

取得或設定旗標,指定可能會對主機有害的功能分類。

public:
 property System::Security::Permissions::HostProtectionResource Resources { System::Security::Permissions::HostProtectionResource get(); void set(System::Security::Permissions::HostProtectionResource value); };
public System.Security.Permissions.HostProtectionResource Resources { get; set; }
member this.Resources : System.Security.Permissions.HostProtectionResource with get, set
Public Property Resources As HostProtectionResource

屬性值

HostProtectionResource

HostProtectionResource 值的位元組合。 預設為 None

範例

下列程式碼範例說明屬性搭配 Resources 屬性的使用 HostProtectionAttribute 方式。 此範例是針對 類別提供的較大範例的 HostProtectionAttribute 一部分。

// Use the enumeration flags to indicate that this method exposes shared state and 
// self-affecting process management.
// Either of the following attribute statements can be used to set the 
// resource flags.
// Exit the sample when an exception is thrown.

[HostProtection(SharedState=true,SelfAffectingProcessMgmt=true)]
[HostProtection(Resources=HostProtectionResource::SharedState|
HostProtectionResource::SelfAffectingProcessMgmt)]
static void Exit( String^ Message, int Code )
{
   Console::WriteLine( "\nFAILED: {0} {1}", Message, Code );
   Environment::ExitCode = Code;
   Environment::Exit( Code );
}
// Use the enumeration flags to indicate that this method exposes 
// shared state and self-affecting process management.
// Either of the following attribute statements can be used to set the
// resource flags.
[HostProtectionAttribute(SharedState = true, 
    SelfAffectingProcessMgmt = true)]
[HostProtectionAttribute(Resources = HostProtectionResource.SharedState |
     HostProtectionResource.SelfAffectingProcessMgmt)]
private static void Exit(string Message, int Code)
{
    // Exit the sample when an exception is thrown.
    Console.WriteLine("\nFAILED: " + Message + " " + Code.ToString());
    Environment.ExitCode = Code;
    Environment.Exit(Code);
}
' Use the enumeration flags to indicate that this method exposes 
' shared state and self-affecting process management.
' Either of the following attribute statements can be used to set the 
' resource flags.
<HostProtectionAttribute(SharedState := True, _
    SelfAffectingProcessMgmt := True), _
    HostProtectionAttribute( _
    Resources := HostProtectionResource.SharedState Or _
    HostProtectionResource.SelfAffectingProcessMgmt)> _
Private Shared Sub [Exit](ByVal Message As String, ByVal Code As Integer)

    ' Exit the sample when an exception is thrown.
    Console.WriteLine((ControlChars.Lf & "FAILED: " & Message & " " & _
        Code.ToString()))
    Environment.ExitCode = Code
    Environment.Exit(Code)
End Sub

備註

HostProtectionResource 標會指定方法或類別所公開的資源,這些資源對主機可能有害。

適用於

另請參閱