<Member Name="Remove(System.Object)" />
<Member Name="RemoveAt(System.Int32)" />
</Type>
- <Type Status="ImplRoot" Name="System.Runtime.InteropServices.WindowsRuntime.ICustomPropertyProvider" Condition="FEATURE_COMINTEROP">
- <Member Name="GetCustomProperty(System.String)" />
- <Member Name="GetIndexedProperty(System.String,System.Type)" />
- <Member Name="GetStringRepresentation" />
- <Member MemberType="Property" Name="Type" />
- <Member Name="get_Type" />
- </Type>
<Type Status="ImplRoot" Name="System.Runtime.InteropServices.WindowsRuntime.CLRIReferenceImpl<T>" Condition="FEATURE_COMINTEROP">
<Member Name="UnboxHelper(System.Object)" />
</Type>
namespace System.Runtime.InteropServices.WindowsRuntime
{
// Provides access to a System.Collections.Generic.KeyValuePair<K, V> via the IKeyValuePair<K, V> WinRT interface.
- internal sealed class CLRIKeyValuePairImpl<K, V> : IKeyValuePair<K, V>
+ internal sealed class CLRIKeyValuePairImpl<K, V> : IKeyValuePair<K, V>,
+ IGetProxyTarget
{
private readonly KeyValuePair<K, V> _pair;
{
return _pair.ToString();
}
+
+ object IGetProxyTarget.GetTarget()
+ {
+ return _pair;
+ }
+
}
}
namespace System.Runtime.InteropServices.WindowsRuntime
{
- internal sealed class CLRIReferenceImpl<T> : CLRIPropertyValueImpl, IReference<T>, ICustomPropertyProvider
+ internal sealed class CLRIReferenceImpl<T> : CLRIPropertyValueImpl, IReference<T>, IGetProxyTarget
{
private T _value;
}
}
- [Pure]
- ICustomProperty ICustomPropertyProvider.GetCustomProperty(string name)
+ object IGetProxyTarget.GetTarget()
{
- // _value should not be null
- return ICustomPropertyProviderImpl.CreateProperty((object)_value, name);
+ return (object)_value;
}
- [Pure]
- ICustomProperty ICustomPropertyProvider.GetIndexedProperty(string name, Type indexParameterType)
- {
- // _value should not be null
- return ICustomPropertyProviderImpl.CreateIndexedProperty((object)_value, name, indexParameterType);
- }
-
- [Pure]
- string ICustomPropertyProvider.GetStringRepresentation()
- {
- // _value should not be null
- return ((object)_value).ToString();
- }
-
- Type ICustomPropertyProvider.Type
- {
- [Pure]
- get
- {
- // _value should not be null
- return ((object)_value).GetType();
- }
- }
-
// We have T in an IReference<T>. Need to QI for IReference<T> with the appropriate GUID, call
// the get_Value property, allocate an appropriately-sized managed object, marshal the native object
// to the managed object, and free the native method. Also we want the return value boxed (aka normal value type boxing).
}
// T can be any WinRT-compatible type
- internal sealed class CLRIReferenceArrayImpl<T> : CLRIPropertyValueImpl,
+ internal sealed class CLRIReferenceArrayImpl<T> : CLRIPropertyValueImpl,
+ IGetProxyTarget,
IReferenceArray<T>,
- ICustomPropertyProvider,
IList // Jupiter data binding needs IList/IEnumerable
{
private T[] _value;
}
}
- [Pure]
- ICustomProperty ICustomPropertyProvider.GetCustomProperty(string name)
- {
- // _value should not be null
- return ICustomPropertyProviderImpl.CreateProperty((object)_value, name);
- }
-
- [Pure]
- ICustomProperty ICustomPropertyProvider.GetIndexedProperty(string name, Type indexParameterType)
- {
- // _value should not be null
- return ICustomPropertyProviderImpl.CreateIndexedProperty((object)_value, name, indexParameterType);
- }
-
- [Pure]
- string ICustomPropertyProvider.GetStringRepresentation()
- {
- // _value should not be null
- return ((object)_value).ToString();
- }
-
- Type ICustomPropertyProvider.Type
- {
- [Pure]
- get
- {
- // _value should not be null
- return ((object)_value).GetType();
- }
- }
-
//
// IEnumerable methods. Used by data-binding in Jupiter when you try to data bind
// against a managed array
return _list.IsSynchronized;
}
}
+
+ object IGetProxyTarget.GetTarget()
+ {
+ return (object)_value;
+ }
// We have T in an IReferenceArray<T>. Need to QI for IReferenceArray<T> with the appropriate GUID, call
// the get_Value property, allocate an appropriately-sized managed object, marshal the native object
namespace System.Runtime.InteropServices.WindowsRuntime
{
- [ComImport]
- [Guid("7C925755-3E48-42B4-8677-76372267033F")]
- [WindowsRuntimeImport]
- internal interface ICustomPropertyProvider
- {
- [Pure]
- ICustomProperty GetCustomProperty(string name);
-
- [Pure]
- ICustomProperty GetIndexedProperty(string name, Type indexParameterType);
-
- [Pure]
- string GetStringRepresentation();
-
- Type Type
- {
- [Pure]
- get;
- }
- }
//
- // Implementation helpers
+ // ICustomProperty Implementation helpers
//
internal static class ICustomPropertyProviderImpl
{
Contract.Requires(target != null);
Contract.Requires(propertyName != null);
+ IGetProxyTarget proxy = target as IGetProxyTarget;
+ if (proxy != null)
+ target = proxy.GetTarget();
+
// Only return public instance/static properties
PropertyInfo propertyInfo = target.GetType().GetProperty(
propertyName,
Contract.Requires(target != null);
Contract.Requires(propertyName != null);
+ IGetProxyTarget proxy = target as IGetProxyTarget;
+ if (proxy != null)
+ target = proxy.GetTarget();
+
// Only return public instance/static properties
PropertyInfo propertyInfo = target.GetType().GetProperty(
propertyName,
[System.Security.SecurityCritical]
static internal unsafe void GetType(object target, TypeNameNative *pIndexedParamType)
{
+ IGetProxyTarget proxy = target as IGetProxyTarget;
+ if (proxy != null)
+ target = proxy.GetTarget();
+
SystemTypeMarshaler.ConvertToNative(target.GetType(), pIndexedParamType);
}
}
//
//
internal class ICustomPropertyProviderProxy<T1, T2> : IGetProxyTarget,
- ICustomPropertyProvider,
ICustomQueryInterface,
IEnumerable, // IBindableIterable -> IBindableIterable/IIterable<T>
IBindableVector, // IBindableVector -> IBindableVector/IVector<T>
return new ICustomPropertyProviderProxy<T1, T2>(target, supportFlags);
}
- //
- // ICustomPropertyProvider implementation
- //
- ICustomProperty ICustomPropertyProvider.GetCustomProperty(string name)
- {
- return ICustomPropertyProviderImpl.CreateProperty(_target, name);
- }
-
- ICustomProperty ICustomPropertyProvider.GetIndexedProperty(string name, Type indexParameterType)
- {
- return ICustomPropertyProviderImpl.CreateIndexedProperty(_target, name, indexParameterType);
- }
-
- string ICustomPropertyProvider.GetStringRepresentation()
- {
- return WindowsRuntime.IStringableHelper.ToString(_target);
- }
-
- Type ICustomPropertyProvider.Type
- {
- get
- {
- return _target.GetType();
- }
- }
//
// override ToString() to make sure callers get correct IStringable.ToString() behavior in native code
{
internal static string ToString(object obj)
{
+ IGetProxyTarget proxy = obj as IGetProxyTarget;
+ if (proxy != null)
+ obj = proxy.GetTarget();
+
// Check whether the type implements IStringable.
IStringable stringableType = obj as IStringable;
if (stringableType != null)