Пример #1
0
        /// <summary>
        /// This method is called from ComInterop.cs in the Unboxing code.
        /// </summary>
        /// <param name="wrapper">native winrt object or our own boxed KeyValuePair<K,V></param>
        /// <returns>unboxed value as object</returns>
        public static object Unbox(object wrapper)
        {
            CLRIKeyValuePairImpl <K, V> reference = wrapper as CLRIKeyValuePairImpl <K, V>;

            if (reference != null)
            {
                return(reference._pair);
            }
            else
            {
                // We could just have the native IKeyValuePair in which case we simply return wrapper as IKeyValuePair.
                global::Windows.Foundation.Collections.IKeyValuePair <K, V> iPair = wrapper as global::Windows.Foundation.Collections.IKeyValuePair <K, V>;
                return(new System.Collections.Generic.KeyValuePair <K, V>(iPair.get_Key(), iPair.get_Value()));
            }
        }
Пример #2
0
        /// <summary>
        /// Called by public object McgModule.Box(object obj, int boxingIndex) after allocating instance
        /// </summary>
        /// <param name="pairs">KeyValuePair<K,V>[]</param>
        /// <returns>IReferenceArrayImpl<K,V> instance</K></returns>
        public override object Initialize(object pairs)
        {
            _pairs = pairs;

            global::System.Collections.Generic.KeyValuePair <K, V>[] unboxedPairArray = pairs as global::System.Collections.Generic.KeyValuePair <K, V>[];

            object[] boxedKeyValuePairs = new object[unboxedPairArray.Length];

            for (int i = 0; i < unboxedPairArray.Length; i++)
            {
                boxedKeyValuePairs[i] = new CLRIKeyValuePairImpl <K, V>(ref unboxedPairArray[i]);
            }

            // Lets create the IReferenceArrayImpl of the type.
            return(new ReferenceArrayImpl <object>(boxedKeyValuePairs, PropertyType.InspectableArray));
        }
        // Token: 0x060064E8 RID: 25832 RVA: 0x00155168 File Offset: 0x00153368
        internal static object UnboxHelper(object wrapper)
        {
            CLRIKeyValuePairImpl <K, V> clrikeyValuePairImpl = (CLRIKeyValuePairImpl <K, V>)wrapper;

            return(clrikeyValuePairImpl._pair);
        }