/// <summary>Gets all the serializable members for a class of the specified <see cref="T:System.Type" /> and in the provided <see cref="T:System.Runtime.Serialization.StreamingContext" />.</summary>
        /// <returns>An array of type <see cref="T:System.Reflection.MemberInfo" /> of the non-transient, non-static members.</returns>
        /// <param name="type">The type being serialized or cloned. </param>
        /// <param name="context">The context where the serialization occurs. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="type" /> parameter is null. </exception>
        /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter" />
        /// </PermissionSet>
        public static MemberInfo[] GetSerializableMembers(Type type, StreamingContext context)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            ArrayList arrayList = new ArrayList();

            for (Type type2 = type; type2 != null; type2 = type2.BaseType)
            {
                if (!type2.IsSerializable)
                {
                    string message = string.Format("Type {0} in assembly {1} is not marked as serializable.", type2, type2.Assembly.FullName);
                    throw new SerializationException(message);
                }
                FormatterServices.GetFields(type, type2, arrayList);
            }
            MemberInfo[] array = new MemberInfo[arrayList.Count];
            arrayList.CopyTo(array);
            return(array);
        }