Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetInterfaceImplementation()

static RuntimeType System.Runtime.InteropServices.DynamicInterfaceCastableHelpers.GetInterfaceImplementation ( IDynamicInterfaceCastable castable,
RuntimeType interfaceType )
inlinestaticpackage

Definition at line 19 of file DynamicInterfaceCastableHelpers.cs.

20 {
21 RuntimeTypeHandle interfaceImplementation = castable.GetInterfaceImplementation(new RuntimeTypeHandle(interfaceType));
22 if (interfaceImplementation.Equals(default(RuntimeTypeHandle)))
23 {
24 throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, castable.GetType(), interfaceType));
25 }
26 RuntimeType runtimeType = interfaceImplementation.GetRuntimeType();
27 if (!runtimeType.IsInterface)
28 {
29 throw new InvalidOperationException(SR.Format(SR.IDynamicInterfaceCastable_NotInterface, runtimeType.ToString()));
30 }
31 if (!runtimeType.IsDefined(typeof(DynamicInterfaceCastableImplementationAttribute), inherit: false))
32 {
33 throw new InvalidOperationException(SR.Format(SR.IDynamicInterfaceCastable_MissingImplementationAttribute, runtimeType, "DynamicInterfaceCastableImplementationAttribute"));
34 }
35 if (!runtimeType.IsAssignableTo(interfaceType))
36 {
37 throw new InvalidOperationException(SR.Format(SR.IDynamicInterfaceCastable_DoesNotImplementRequested, runtimeType, interfaceType));
38 }
39 return runtimeType;
40 }

References System.RuntimeTypeHandle.Equals(), System.SR.Format(), System.Runtime.InteropServices.IDynamicInterfaceCastable.GetInterfaceImplementation(), System.RuntimeTypeHandle.GetRuntimeType(), System.SR.IDynamicInterfaceCastable_DoesNotImplementRequested, System.SR.IDynamicInterfaceCastable_MissingImplementationAttribute, System.SR.IDynamicInterfaceCastable_NotInterface, System.SR.InvalidCast_FromTo, System.Type.IsAssignableTo(), System.RuntimeType.IsDefined(), System.Type.IsInterface, and System.RuntimeType.ToString().