ReflectionPermission.FromXml 메서드
XML 인코딩을 사용하여 지정된 상태로 사용 권한을 다시 만듭니다.
네임스페이스: System.Security.Permissions
어셈블리: mscorlib(mscorlib.dll)
구문
‘선언
Public Overrides Sub FromXml ( _
esd As SecurityElement _
)
‘사용 방법
Dim instance As ReflectionPermission
Dim esd As SecurityElement
instance.FromXml(esd)
public override void FromXml (
SecurityElement esd
)
public:
virtual void FromXml (
SecurityElement^ esd
) override
public void FromXml (
SecurityElement esd
)
public override function FromXml (
esd : SecurityElement
)
매개 변수
- esd
사용 권한을 다시 만드는 데 사용할 XML 인코딩입니다.
예외
예외 형식 | 조건 |
---|---|
esd 매개 변수가 Null 참조(Visual Basic의 경우 Nothing)인 경우 |
|
esd 매개 변수가 올바른 사용 권한 요소가 아닌 경우 - 또는 - esd 매개 변수의 버전 번호가 잘못된 경우 |
예제
Private Function ToFromXmlDemo() As Boolean
Dim returnValue As Boolean = True
Dim reflection1 As ReflectionPermissionFlag
Dim reflectionPerm1, reflectionPerm2 As ReflectionPermission
Dim reflectionGen1 As New ReflectionGenerator()
Dim reflectionGen2 As New ReflectionGenerator()
reflectionGen1.ResetIndex()
While reflectionGen1.CreateReflection(reflection1)
reflectionPerm1 = New ReflectionPermission(reflection1)
Console.WriteLine("********************************************************" & ControlChars.Lf)
reflectionGen2.ResetIndex()
Try
reflectionPerm2 = New ReflectionPermission(PermissionState.None)
reflectionPerm2.FromXml(reflectionPerm1.ToXml())
Console.WriteLine(("Result of ToFromXml = " & reflectionPerm2.ToString()))
Catch e As Exception
Console.WriteLine(("ToFromXml failed :" & reflectionPerm1.ToString() & e.ToString()))
End Try
ContinueWhile1:
End While
Return returnValue
End Function 'ToFromXmlDemo
private bool ToFromXmlDemo()
{
bool returnValue = true;
ReflectionPermissionFlag reflection1;
ReflectionPermission reflectionPerm1, reflectionPerm2;
ReflectionGenerator reflectionGen1 = new ReflectionGenerator();
ReflectionGenerator reflectionGen2 = new ReflectionGenerator();
reflectionGen1.ResetIndex();
while (reflectionGen1.CreateReflection(out reflection1))
{
reflectionPerm1 = new ReflectionPermission(reflection1);
Console.WriteLine("********************************************************\n");
reflectionGen2.ResetIndex();
try
{
reflectionPerm2 = new ReflectionPermission(PermissionState.None);
reflectionPerm2.FromXml(reflectionPerm1.ToXml());
Console.WriteLine("Result of ToFromXml = " +
reflectionPerm2.ToString());
}
catch (Exception e)
{
Console.WriteLine("ToFromXml failed :" + reflectionPerm1.ToString() + e);
continue;
}
}
return returnValue;
}
bool ToFromXmlDemo()
{
bool returnValue = true;
ReflectionPermissionFlag reflection1;
ReflectionPermission^ reflectionPerm1;
ReflectionPermission^ reflectionPerm2;
ReflectionGenerator^ reflectionGen1 = gcnew ReflectionGenerator;
ReflectionGenerator^ reflectionGen2 = gcnew ReflectionGenerator;
reflectionGen1->ResetIndex();
while ( reflectionGen1->CreateReflection( &reflection1 ) )
{
reflectionPerm1 = gcnew ReflectionPermission( reflection1 );
Console::WriteLine( "********************************************************\n" );
reflectionGen2->ResetIndex();
try
{
reflectionPerm2 = gcnew ReflectionPermission( PermissionState::None );
reflectionPerm2->FromXml( reflectionPerm1->ToXml() );
Console::WriteLine( "Result of ToFromXml = {0}", reflectionPerm2 );
}
catch ( Exception^ e )
{
Console::WriteLine( "ToFromXml failed : {0}{1}", reflectionPerm1, e );
continue;
}
}
return returnValue;
}
public:
private boolean ToFromXmlDemo()
{
boolean returnValue = true;
ReflectionPermissionFlag reflection1[] =
new ReflectionPermissionFlag[1];
ReflectionPermission reflectionPerm1[] =
new ReflectionPermission[1];
ReflectionPermission reflectionPerm2[] =
new ReflectionPermission[1];
ReflectionGenerator reflectionGen1 =
new ReflectionGenerator();
ReflectionGenerator reflectionGen2 =
new ReflectionGenerator();
reflectionGen1.ResetIndex();
while(reflectionGen1.CreateReflection(reflectionPerm1, reflection1)) {
if (reflectionPerm1[0] == null) {
continue ;
}
Console.WriteLine("**************************************"
+ "******************\n");
reflectionGen2.ResetIndex();
try {
reflectionPerm2[0] =
new ReflectionPermission(PermissionState.None);
reflectionPerm2[0].FromXml(reflectionPerm1[0].ToXml());
Console.WriteLine(("Result of ToFromXml = "
+ reflectionPerm2[0].ToString()));
}
catch(System.Exception e) {
Console.WriteLine(("ToFromXml failed :"
+ reflectionPerm1[0].ToString() + e));
continue ;
}
}
return returnValue ;
} //ToFromXmlDemo
플랫폼
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에서 지원
참고 항목
참조
ReflectionPermission 클래스
ReflectionPermission 멤버
System.Security.Permissions 네임스페이스