GetType() private method

private GetType ( ) : Type
return Type
Beispiel #1
0
        // Serialize a multicast delegate object.
        internal static void SerializeMulticast
            (SerializationInfo info, MulticastDelegate del)
        {
            DelegateEntry entry, next;
            int           index = 0;

            // Serialize the first entry on the multicast list.
            entry = Serialize(info, index++, del.GetType(), del.target,
                              MethodBase.GetMethodFromHandle(del.method));

            // Serialize the rest of the multicast chain.
            del = del.prev;
            while (del != null)
            {
                next = Serialize
                           (info, index++, del.GetType(), del.target,
                           MethodBase.GetMethodFromHandle(del.method));
                entry.delegateEntry = next;
                entry = next;
                del   = del.prev;
            }
        }
	// Serialize a multicast delegate object.
	internal static void SerializeMulticast
				(SerializationInfo info, MulticastDelegate del)
			{
				DelegateEntry entry, next;
				int index = 0;

				// Serialize the first entry on the multicast list.
				entry = Serialize(info, index++, del.GetType(), del.target,
								  MethodBase.GetMethodFromHandle(del.method));

				// Serialize the rest of the multicast chain.
				del = del.prev;
				while(del != null)
				{
					next = Serialize
						(info, index++, del.GetType(), del.target,
						 MethodBase.GetMethodFromHandle(del.method));
					entry.delegateEntry = next;
					entry = next;
					del = del.prev;
				}
			}
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            int targetIndex = 0;

            Object[] invocationList = _invocationList as Object[];
            if (invocationList == null)
            {
                MethodInfo method = Method;
                // A MethodInfo object can be a RuntimeMethodInfo, a RefEmit method (MethodBuilder, etc), or a DynamicMethod
                // One can only create delegates on RuntimeMethodInfo and DynamicMethod.
                // If it is not a RuntimeMethodInfo (must be a DynamicMethod) or if it is an unmanaged function pointer, throw
                if (!(method is RuntimeMethodInfo) || IsUnmanagedFunctionPtr())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }

                // We can't deal with secure delegates either.
                if (!InvocationListLogicallyNull() && !_invocationCount.IsNull() && !_methodPtrAux.IsNull())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }

                DelegateSerializationHolder.GetDelegateSerializationInfo(info, this.GetType(), Target, method, targetIndex);
            }
            else
            {
                DelegateSerializationHolder.DelegateEntry nextDe = null;
                int invocationCount = (int)_invocationCount;
                for (int i = invocationCount; --i >= 0;)
                {
                    MulticastDelegate d      = (MulticastDelegate)invocationList[i];
                    MethodInfo        method = d.Method;
                    // If it is not a RuntimeMethodInfo (must be a DynamicMethod) or if it is an unmanaged function pointer, skip
                    if (!(method is RuntimeMethodInfo) || IsUnmanagedFunctionPtr())
                    {
                        continue;
                    }

                    // We can't deal with secure delegates either.
                    if (!d.InvocationListLogicallyNull() && !d._invocationCount.IsNull() && !d._methodPtrAux.IsNull())
                    {
                        continue;
                    }

                    DelegateSerializationHolder.DelegateEntry de = DelegateSerializationHolder.GetDelegateSerializationInfo(info, d.GetType(), d.Target, method, targetIndex++);
                    if (nextDe != null)
                    {
                        nextDe.Entry = de;
                    }

                    nextDe = de;
                }
                // if nothing was serialized it is a delegate over a DynamicMethod, so just throw
                if (nextDe == null)
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
            }
        }
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            int targetIndex = 0;

            object[] objArray = this._invocationList as object[];
            if (objArray == null)
            {
                MethodInfo method = base.Method;
                if (((method is DynamicMethod) || (method is DynamicMethod.RTDynamicMethod)) || this.IsUnmanagedFunctionPtr())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
                if ((this._invocationList != null) && !this._invocationCount.IsNull())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
                DelegateSerializationHolder.GetDelegateSerializationInfo(info, base.GetType(), base.Target, method, targetIndex);
            }
            else
            {
                DelegateSerializationHolder.DelegateEntry entry = null;
                int index = (int)this._invocationCount;
                while (--index >= 0)
                {
                    MulticastDelegate delegate2 = (MulticastDelegate)objArray[index];
                    MethodInfo        info3     = delegate2.Method;
                    if (((!(info3 is DynamicMethod) && !(info3 is DynamicMethod.RTDynamicMethod)) && !this.IsUnmanagedFunctionPtr()) && ((delegate2._invocationList == null) || delegate2._invocationCount.IsNull()))
                    {
                        DelegateSerializationHolder.DelegateEntry entry2 = DelegateSerializationHolder.GetDelegateSerializationInfo(info, delegate2.GetType(), delegate2.Target, info3, targetIndex++);
                        if (entry != null)
                        {
                            entry.Entry = entry2;
                        }
                        entry = entry2;
                    }
                }
                if (entry == null)
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
            }
        }
Beispiel #5
0
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            Delegate[] invocationList = m_helperObject as Delegate[];
            if (invocationList == null)
            {
                if (Method == null)
                {
                    throw new SerializationException(SR.DelegateSer_InsufficientMetadata);
                }

                DelegateSerializationHolder.GetDelegateSerializationInfo(info, this.GetType(), Target, Method, 0);
            }
            else
            {
                int targetIndex = 0;
                DelegateSerializationHolder.DelegateEntry previousEntry = null;
                int invocationCount = (int)m_extraFunctionPointerOrData;
                for (int i = invocationCount; --i >= 0;)
                {
                    MulticastDelegate d = (MulticastDelegate)invocationList[i];

                    if (d.Method == null)
                    {
                        throw new SerializationException(SR.DelegateSer_InsufficientMetadata);
                    }

                    DelegateSerializationHolder.DelegateEntry de = DelegateSerializationHolder.GetDelegateSerializationInfo(info, d.GetType(), d.Target, d.Method, targetIndex++);
                    if (previousEntry != null)
                    {
                        previousEntry.NextEntry = de;
                    }

                    previousEntry = de;
                }
            }
        }
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            int targetIndex = 0;

            Object[] invocationList = _invocationList as Object[];
            if (invocationList == null)
            {
                MethodInfo method = Method;
                // if it is a delegate over a DynamicMethod or an unmanaged function pointer, throw
                if (method is System.Reflection.Emit.DynamicMethod || method is System.Reflection.Emit.DynamicMethod.RTDynamicMethod || IsUnmanagedFunctionPtr())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }

                // We can't deal with secure delegates either.
                if (_invocationList != null && !_invocationCount.IsNull())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }

                DelegateSerializationHolder.GetDelegateSerializationInfo(info, this.GetType(), Target, method, targetIndex);
            }
            else
            {
                DelegateSerializationHolder.DelegateEntry nextDe = null;
                int invocationCount = (int)_invocationCount;
                for (int i = invocationCount; --i >= 0;)
                {
                    MulticastDelegate d      = (MulticastDelegate)invocationList[i];
                    MethodInfo        method = d.Method;
                    if (method is System.Reflection.Emit.DynamicMethod || method is System.Reflection.Emit.DynamicMethod.RTDynamicMethod || IsUnmanagedFunctionPtr())
                    {
                        continue;
                    }

                    // We can't deal with secure delegates either.
                    if (d._invocationList != null && !d._invocationCount.IsNull())
                    {
                        continue;
                    }

                    DelegateSerializationHolder.DelegateEntry de = DelegateSerializationHolder.GetDelegateSerializationInfo(info, d.GetType(), d.Target, method, targetIndex++);
                    if (nextDe != null)
                    {
                        nextDe.Entry = de;
                    }

                    nextDe = de;
                }
                // if nothing was serialized it is a delegate over a DynamicMethod, so just throw
                if (nextDe == null)
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
            }
        }
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            int targetIndex = 0;

            object[] objArray = this._invocationList as object[];
            if (objArray == null)
            {
                MethodInfo method = this.Method;
                if (!(method is RuntimeMethodInfo) || this.IsUnmanagedFunctionPtr())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
                if (!this.InvocationListLogicallyNull() && !this._invocationCount.IsNull() && !this._methodPtrAux.IsNull())
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
                DelegateSerializationHolder.GetDelegateSerializationInfo(info, this.GetType(), this.Target, method, targetIndex);
            }
            else
            {
                DelegateSerializationHolder.DelegateEntry delegateEntry = (DelegateSerializationHolder.DelegateEntry)null;
                int index = (int)this._invocationCount;
                while (--index >= 0)
                {
                    MulticastDelegate multicastDelegate = (MulticastDelegate)objArray[index];
                    MethodInfo        method            = multicastDelegate.Method;
                    if (method is RuntimeMethodInfo && !this.IsUnmanagedFunctionPtr() && (multicastDelegate.InvocationListLogicallyNull() || multicastDelegate._invocationCount.IsNull() || multicastDelegate._methodPtrAux.IsNull()))
                    {
                        DelegateSerializationHolder.DelegateEntry serializationInfo = DelegateSerializationHolder.GetDelegateSerializationInfo(info, multicastDelegate.GetType(), multicastDelegate.Target, method, targetIndex++);
                        if (delegateEntry != null)
                        {
                            delegateEntry.Entry = serializationInfo;
                        }
                        delegateEntry = serializationInfo;
                    }
                }
                if (delegateEntry == null)
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType"));
                }
            }
        }