ResourcePermissionBase 클래스
코드 액세스 보안 권한을 제어할 수 있도록 합니다.
네임스페이스: System.Security.Permissions
어셈블리: System(system.dll)
구문
‘선언
<SerializableAttribute> _
Public MustInherit Class ResourcePermissionBase
Inherits CodeAccessPermission
Implements IUnrestrictedPermission
‘사용 방법
Dim instance As ResourcePermissionBase
[SerializableAttribute]
public abstract class ResourcePermissionBase : CodeAccessPermission, IUnrestrictedPermission
[SerializableAttribute]
public ref class ResourcePermissionBase abstract : public CodeAccessPermission, IUnrestrictedPermission
/** @attribute SerializableAttribute() */
public abstract class ResourcePermissionBase extends CodeAccessPermission implements IUnrestrictedPermission
SerializableAttribute
public abstract class ResourcePermissionBase extends CodeAccessPermission implements IUnrestrictedPermission
설명
참고
ResourcePermissionBase 클래스에서는 서수 정렬 규칙을 사용하여 문자열을 비교하며 이때 문자열의 대/소문자는 구분하지 않습니다.
상속자 참고 사항 ResourcePermissionBase에서 상속될 때 최소한 세 개의 생성자를 제공하고 두 개의 속성을 설정한 다음 셋째 속성을 제공해야 합니다. 필요한 생성자는 기본 생성자, PermissionState를 매개 변수로 사용하는 하나의 생성자 및 속성 값을 사용하는 만큼의 생성자입니다. 설정해야 할 속성은 PermissionAccessType 및 TagNames입니다. 필요한 셋째 속성은 사용 권한 항목을 반환하는 속성입니다. 이 클래스의 구현 예제는 PerformanceCounterPermission을 참조하십시오. PerformanceCounterPermission에서 TagNames 속성은 "Machine" 및 "Category" 전용으로 설정되고, PermissionAccessType 속성은 PerformanceCounterPermissionAccess의 형식 전용으로 설정되고, PermissionEntries 속성은 사용 권한 항목을 반환합니다.
예제
다음 예제는 ResourcePermissionBase 클래스에서 상속됩니다. 네 가지 종류의 생성자가 구현됩니다. 이 예제에서는 또한 MailslotPermissionEntry
라는 클래스를 구현합니다. PermissionAccessType 속성은 MailslotPermissionEntry
형식 전용으로 설정됩니다. TagNames 속성은 "Name" 및 "Machine" 전용으로 설정됩니다.
Imports System
Imports System.Security.Permissions
Imports System.Collections
<Serializable()> Public Class MailslotPermission
Inherits ResourcePermissionBase
Private innerCollection As ArrayList
Public Sub New()
SetNames()
End Sub 'New
Public Sub New(ByVal state As PermissionState)
MyBase.New(state)
SetNames()
End Sub 'New
Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String)
SetNames()
Me.AddPermissionAccess(New MailslotPermissionEntry(permissionAccess, name, machineName1))
End Sub 'New
Public Sub New(ByVal permissionAccessEntries() As MailslotPermissionEntry)
SetNames()
If permissionAccessEntries Is Nothing Then
Throw New ArgumentNullException("permissionAccessEntries")
End If
Dim index As Integer
While index < permissionAccessEntries.Length
Me.AddPermissionAccess(permissionAccessEntries(index))
End While
End Sub 'New
Public ReadOnly Property PermissionEntries() As ArrayList
Get
If Me.innerCollection Is Nothing Then
Me.innerCollection = New ArrayList()
End If
Me.innerCollection.InsertRange(0, MyBase.GetPermissionEntries())
Return Me.innerCollection
End Get
End Property
Friend Overloads Sub AddPermissionAccess(ByVal entry As MailslotPermissionEntry)
MyBase.AddPermissionAccess(entry.GetBaseEntry())
End Sub 'AddPermissionAccess
Friend Shadows Sub Clear()
MyBase.Clear()
End Sub 'Clear
Friend Overloads Sub RemovePermissionAccess(ByVal entry As MailslotPermissionEntry)
MyBase.RemovePermissionAccess(entry.GetBaseEntry())
End Sub 'RemovePermissionAccess
Private Sub SetNames()
Me.PermissionAccessType = GetType(MailslotPermissionAccess)
Me.TagNames = New String() {"Name", "Machine"}
End Sub 'SetNames
End Class 'MailslotPermission
<Flags()> Public Enum MailslotPermissionAccess
None = 0
Send = 2
Receive = 4 Or Send
End Enum 'MailslotPermissionAccess
<Serializable()> Public Class MailslotPermissionEntry
Private nameVar As String
Private machineNameVar As String
Private permissionAccessVar As MailslotPermissionAccess
Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String)
Me.permissionAccessVar = permissionAccess
Me.nameVar = name
Me.machineNameVar = machineName1
End Sub 'New
Friend Sub New(ByVal baseEntry As ResourcePermissionBaseEntry)
Me.permissionAccessVar = CType(baseEntry.PermissionAccess, MailslotPermissionAccess)
Me.nameVar = baseEntry.PermissionAccessPath(0)
Me.machineNameVar = baseEntry.PermissionAccessPath(1)
End Sub 'New
Public ReadOnly Property Name() As String
Get
Return Me.nameVar
End Get
End Property
Public ReadOnly Property MachineName() As String
Get
Return Me.machineNameVar
End Get
End Property
Public ReadOnly Property PermissionAccess() As MailslotPermissionAccess
Get
Return Me.permissionAccessVar
End Get
End Property
Friend Function GetBaseEntry() As ResourcePermissionBaseEntry
Dim baseEntry As New ResourcePermissionBaseEntry(CInt(Me.PermissionAccess), New String() {Me.Name, Me.MachineName})
Return baseEntry
End Function 'GetBaseEntry
End Class 'MailslotPermissionEntry
using System;
using System.Security.Permissions;
using System.Collections;
[Serializable()]
public class MailslotPermission: ResourcePermissionBase
{
private ArrayList innerCollection;
public MailslotPermission()
{
SetNames();
}
public MailslotPermission(PermissionState state):base(state)
{
SetNames();
}
public MailslotPermission(MailslotPermissionAccess permissionAccess, string name, string machineName)
{
SetNames();
this.AddPermissionAccess(new MailslotPermissionEntry(permissionAccess, name, machineName));
}
public MailslotPermission(MailslotPermissionEntry[] permissionAccessEntries)
{
SetNames();
if (permissionAccessEntries == null)
throw new ArgumentNullException("permissionAccessEntries");
for (int index = 0; index < permissionAccessEntries.Length; ++index)
this.AddPermissionAccess(permissionAccessEntries[index]);
}
public ArrayList PermissionEntries
{
get
{
if (this.innerCollection == null)
this.innerCollection = new ArrayList();
this.innerCollection.InsertRange(0,base.GetPermissionEntries());
return this.innerCollection;
}
}
internal void AddPermissionAccess(MailslotPermissionEntry entry)
{
base.AddPermissionAccess(entry.GetBaseEntry());
}
internal new void Clear()
{
base.Clear();
}
internal void RemovePermissionAccess(MailslotPermissionEntry entry)
{
base.RemovePermissionAccess(entry.GetBaseEntry());
}
private void SetNames()
{
this.PermissionAccessType = typeof(MailslotPermissionAccess);
this.TagNames = new string[]{"Name","Machine"};
}
}
[Flags]
public enum MailslotPermissionAccess
{
None = 0,
Send = 1 << 1,
Receive = 1 << 2 | Send,
}
[Serializable()]
public class MailslotPermissionEntry
{
private string name;
private string machineName;
private MailslotPermissionAccess permissionAccess;
public MailslotPermissionEntry(MailslotPermissionAccess permissionAccess, string name, string machineName)
{
this.permissionAccess = permissionAccess;
this.name = name;
this.machineName = machineName;
}
internal MailslotPermissionEntry(ResourcePermissionBaseEntry baseEntry)
{
this.permissionAccess = (MailslotPermissionAccess)baseEntry.PermissionAccess;
this.name = baseEntry.PermissionAccessPath[0];
this.machineName = baseEntry.PermissionAccessPath[1];
}
public string Name
{
get
{
return this.name;
}
}
public string MachineName
{
get
{
return this.machineName;
}
}
public MailslotPermissionAccess PermissionAccess
{
get
{
return this.permissionAccess;
}
}
internal ResourcePermissionBaseEntry GetBaseEntry()
{
ResourcePermissionBaseEntry baseEntry = new ResourcePermissionBaseEntry((int)this.PermissionAccess, new string[] {this.Name,this.MachineName});
return baseEntry;
}
}
#using <System.dll>
using namespace System;
using namespace System::Security::Permissions;
using namespace System::Collections;
[Flags]
public enum class MailslotPermissionAccess
{
None = 0,
Send = 1 << 1,
Receive = 1 << 2 | MailslotPermissionAccess::Send
};
[Serializable]
public ref class MailslotPermissionEntry
{
private:
String^ name;
String^ machineName;
MailslotPermissionAccess permissionAccess;
internal:
MailslotPermissionEntry( ResourcePermissionBaseEntry^ baseEntry )
{
this->permissionAccess = (MailslotPermissionAccess)baseEntry->PermissionAccess;
this->name = baseEntry->PermissionAccessPath[ 0 ]->ToString();
this->machineName = baseEntry->PermissionAccessPath[ 1 ]->ToString();
}
ResourcePermissionBaseEntry^ GetBaseEntry()
{
array<String^>^newStrings = {this->Name,this->MachineName};
ResourcePermissionBaseEntry^ baseEntry = gcnew ResourcePermissionBaseEntry( (int)(this->PermissionAccess),newStrings );
return baseEntry;
}
public:
MailslotPermissionEntry( MailslotPermissionAccess permissionAccess, String^ name, String^ machineName )
{
this->permissionAccess = permissionAccess;
this->name = name;
this->machineName = machineName;
}
property String^ Name
{
String^ get()
{
return this->name;
}
}
property String^ MachineName
{
String^ get()
{
return this->machineName;
}
}
property MailslotPermissionAccess PermissionAccess
{
MailslotPermissionAccess get()
{
return this->permissionAccess;
}
}
};
[Serializable]
public ref class MailslotPermission: public ResourcePermissionBase
{
private:
ArrayList^ innerCollection;
void SetNames()
{
this->PermissionAccessType = MailslotPermissionAccess::typeid;
array<String^>^newStrings = {"Name","Machine"};
this->TagNames = newStrings;
}
internal:
void AddPermissionAccess( MailslotPermissionEntry^ entry )
{
ResourcePermissionBase::AddPermissionAccess( entry->GetBaseEntry() );
}
void Clear()
{
ResourcePermissionBase::Clear();
}
void RemovePermissionAccess( MailslotPermissionEntry^ entry )
{
ResourcePermissionBase::RemovePermissionAccess( entry->GetBaseEntry() );
}
public:
MailslotPermission()
{
SetNames();
}
MailslotPermission( PermissionState state )
: ResourcePermissionBase( state )
{
SetNames();
}
MailslotPermission( MailslotPermissionAccess permissionAccess, String^ name, String^ machineName )
{
SetNames();
this->AddPermissionAccess( gcnew MailslotPermissionEntry( permissionAccess,name,machineName ) );
}
MailslotPermission( array<MailslotPermissionEntry^>^permissionAccessEntries )
{
SetNames();
if ( permissionAccessEntries == nullptr )
throw gcnew ArgumentNullException( "permissionAccessEntries" );
for ( int index = 0; index < permissionAccessEntries->Length; ++index )
this->AddPermissionAccess( permissionAccessEntries[ index ] );
}
property ArrayList^ PermissionEntries
{
ArrayList^ get()
{
if ( this->innerCollection == nullptr )
this->innerCollection = gcnew ArrayList;
this->innerCollection->InsertRange( 0, safe_cast<ICollection^>(ResourcePermissionBase::GetPermissionEntries()) );
return this->innerCollection;
}
}
};
import System.*;
import System.Security.Permissions.*;
import System.Collections.*;
/** @attribute Serializable()
*/
public class MailSlotPermission extends ResourcePermissionBase
{
private ArrayList innerCollection;
public MailSlotPermission()
{
SetNames();
} //MailSlotPermission
public MailSlotPermission(PermissionState state)
{
super(state);
SetNames();
} //MailSlotPermission
public MailSlotPermission(MailSlotPermissionAccess permissionAccess,
String name, String machineName)
{
SetNames();
this.AddPermissionAccess(new MailSlotPermissionEntry(permissionAccess,
name, machineName));
} //MailSlotPermission
public MailSlotPermission(MailSlotPermissionEntry permissionAccessEntries[])
{
SetNames();
if (permissionAccessEntries == null) {
throw new ArgumentNullException("permissionAccessEntries");
}
for (int index = 0; index < permissionAccessEntries.get_Length();
++index) {
this.AddPermissionAccess((MailSlotPermissionEntry)
permissionAccessEntries.get_Item(index));
}
} //MailSlotPermission
/** @property
*/
public ArrayList get_PermissionEntries()
{
if (this.innerCollection == null) {
this.innerCollection = new ArrayList();
}
this.innerCollection.InsertRange(0, super.GetPermissionEntries());
return this.innerCollection;
}
void AddPermissionAccess(MailSlotPermissionEntry entry)
{
super.AddPermissionAccess(entry.GetBaseEntry());
} //AddPermissionAccess
public void Clear()
{
super.Clear();
} //Clear
void RemovePermissionAccess(MailSlotPermissionEntry entry)
{
super.RemovePermissionAccess(entry.GetBaseEntry());
} //RemovePermissionAccess
private void SetNames()
{
this.set_PermissionAccessType(MailSlotPermissionAccess.class.ToType());
this.set_TagNames(new String[] { "Name", "Machine" });
} //SetNames
} //MailSlotPermission
public class MailSlotPermissionAccess
{
public static int None = 0;
public static int Send = 1 << 1;
public static int Receive = 1 << 2 | Send;
} //MailSlotPermissionAccess
/** @attribute Serializable()
*/
public class MailSlotPermissionEntry
{
private String name;
private String machineName;
private MailSlotPermissionAccess permissionAccess;
public MailSlotPermissionEntry(MailSlotPermissionAccess permissionAccess,
String name, String machineName)
{
this.permissionAccess = permissionAccess;
this.name = name;
this.machineName = machineName;
} //MailSlotPermissionEntry
MailSlotPermissionEntry(ResourcePermissionBaseEntry baseEntry)
{
this.permissionAccess =(MailSlotPermissionAccess)(Object)((
Int32)baseEntry.get_PermissionAccess());
this.name = baseEntry.get_PermissionAccessPath()[0];
this.machineName = baseEntry.get_PermissionAccessPath()[1];
} //MailSlotPermissionEntry
/** @property
*/
public String get_Name()
{
return this.name;
}//get_Name
/** @property
*/
public String get_MachineName()
{
return this.machineName;
}//get_MachineName
/** @property
*/
public MailSlotPermissionAccess get_PermissionAccess()
{
return this.permissionAccess;
}//get_PermissionAccess
ResourcePermissionBaseEntry GetBaseEntry()
{
ResourcePermissionBaseEntry baseEntry = new ResourcePermissionBaseEntry(
Convert.ToInt32((Int32)((Object)(this.get_PermissionAccess()))),
new String[] { this.get_Name(), this.get_MachineName() });
return baseEntry;
} //GetBaseEntry
} //MailSlotPermissionEntry
상속 계층 구조
System.Object
System.Security.CodeAccessPermission
System.Security.Permissions.ResourcePermissionBase
System.Diagnostics.EventLogPermission
System.Diagnostics.PerformanceCounterPermission
System.DirectoryServices.DirectoryServicesPermission
System.ServiceProcess.ServiceControllerPermission
스레드로부터의 안전성
이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.
플랫폼
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
참고 항목
참조
ResourcePermissionBase 멤버
System.Security.Permissions 네임스페이스