本文整理汇总了C#中System.RuntimeTypeHandle.IsSupportIInspectable方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeTypeHandle.IsSupportIInspectable方法的具体用法?C# RuntimeTypeHandle.IsSupportIInspectable怎么用?C# RuntimeTypeHandle.IsSupportIInspectable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.RuntimeTypeHandle
的用法示例。
在下文中一共展示了RuntimeTypeHandle.IsSupportIInspectable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComInterfaceToComObjectInternal_NoCache
/// <summary>
/// Returns the existing RCW or create a new RCW from the COM interface pointer
/// NOTE: This does not do any unboxing at all.
/// </summary>
/// <param name="expectedContext">
/// The current context of this thread. If it is passed and is not Default, we'll check whether the
/// returned RCW from cache matches this expected context. If it is not a match (from a different
/// context, and is not free threaded), we'll go ahead ignoring the cached entry, and create a new
/// RCW instead - which will always end up in the current context
/// We'll skip the check if current == ContextCookie.Default.
/// </param>
private static object ComInterfaceToComObjectInternal_NoCache(
IntPtr pComItf,
IntPtr pComIdentityIUnknown,
RuntimeTypeHandle interfaceType,
RuntimeTypeHandle classTypeInSignature,
ContextCookie expectedContext,
CreateComObjectFlags flags,
out string className
)
{
className = null;
//
// Lookup RCW in global RCW cache based on the identity IUnknown
//
__ComObject comObject = ComObjectCache.Lookup(pComIdentityIUnknown);
if (comObject != null)
{
bool useThisComObject = true;
if (!expectedContext.IsDefault)
{
//
// Make sure the returned RCW matches the context we specify (if any)
//
if (!comObject.IsFreeThreaded &&
!comObject.ContextCookie.Equals(expectedContext))
{
//
// This is a mismatch.
// We only care about context for WinRT factory RCWs (which is the only place we are
// passing in the context right now).
// When we get back a WinRT factory RCW created in a different context. This means the
// factory is a singleton, and the returned IActivationFactory could be either one of
// the following:
// 1) A raw pointer, and it acts like a free threaded object
// 2) A proxy that is used across different contexts. It might maintain a list of contexts
// that it is marshaled to, and will fail to be called if it is not marshaled to this
// context yet.
//
// In this case, it is unsafe to use this RCW in this context and we should proceed
// to create a duplicated one instead. It might make sense to have a context-sensitive
// RCW cache but I don't think this case will be common enough to justify it
//
// @TODO: Check for DCOM proxy as well
useThisComObject = false;
}
}
if (useThisComObject)
{
//
// We found one - AddRef and return
//
comObject.AddRef();
return comObject;
}
}
string winrtClassName = null;
bool isSealed = false;
if (!classTypeInSignature.IsNull())
{
isSealed = classTypeInSignature.IsSealed();
}
//
// Only look at runtime class name if the class type in signature is not sealed
// NOTE: In the case of System.Uri, we are not pass the class type, only the interface
//
if (!isSealed &&
(flags & CreateComObjectFlags.SkipTypeResolutionAndUnboxing) == 0)
{
IntPtr pInspectable;
bool needRelease = false;
if (interfaceType.IsSupportIInspectable())
{
//
// Use the interface pointer as IInspectable as we know it is indeed a WinRT interface that
// derives from IInspectable
//
pInspectable = pComItf;
}
else if ((flags & CreateComObjectFlags.IsWinRTObject) != 0)
//.........这里部分代码省略.........