Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ExtendedProtectionPolicyTypeConverter.cs
Go to the documentation of this file.
7
9
11{
12 public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
13 {
14 if (!(destinationType == typeof(InstanceDescriptor)))
15 {
16 return base.CanConvertTo(context, destinationType);
17 }
18 return true;
19 }
20
21 [UnsupportedOSPlatform("browser")]
22 public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
23 {
24 if (destinationType == typeof(InstanceDescriptor) && value is ExtendedProtectionPolicy extendedProtectionPolicy)
25 {
26 Type[] types;
27 object[] arguments;
28 if (extendedProtectionPolicy.PolicyEnforcement == PolicyEnforcement.Never)
29 {
30 types = new Type[1] { typeof(PolicyEnforcement) };
31 arguments = new object[1] { PolicyEnforcement.Never };
32 }
33 else
34 {
35 types = new Type[3]
36 {
37 typeof(PolicyEnforcement),
38 typeof(ProtectionScenario),
39 typeof(ICollection)
40 };
41 object[] array = null;
42 ServiceNameCollection? customServiceNames = extendedProtectionPolicy.CustomServiceNames;
43 if (customServiceNames != null && customServiceNames.Count > 0)
44 {
45 array = new object[extendedProtectionPolicy.CustomServiceNames.Count];
46 ((ICollection)extendedProtectionPolicy.CustomServiceNames).CopyTo((Array)array, 0);
47 }
48 arguments = new object[3] { extendedProtectionPolicy.PolicyEnforcement, extendedProtectionPolicy.ProtectionScenario, array };
49 }
50 ConstructorInfo constructor = typeof(ExtendedProtectionPolicy).GetConstructor(types);
51 return new InstanceDescriptor(constructor, arguments);
52 }
53 return base.ConvertTo(context, culture, value, destinationType);
54 }
55}
void ICollection. CopyTo(Array array, int index)
override? object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)