Catel.Runtime.Serialization.Xml.DataContractSerializerFactory.IsTypeSerializable C# (CSharp) Method

IsTypeSerializable() protected method

Determines whether the specified type is serializable.
protected IsTypeSerializable ( Type type, XmlSerializerTypeInfo serializerTypeInfo ) : bool
type System.Type The type.
serializerTypeInfo XmlSerializerTypeInfo The serializer type information.
return bool
        protected virtual bool IsTypeSerializable(Type type, XmlSerializerTypeInfo serializerTypeInfo)
        {
            if (type == null)
            {
                return false;
            }

            // DataContract attribute
            if (AttributeHelper.IsDecoratedWithAttribute<DataContractAttribute>(type))
            {
                return true;
            }

#if NET
            // Implements ISerializable
            if (type.ImplementsInterfaceEx<ISerializable>())
            {
                return true;
            }
#endif

            // Implements IXmlSerializer
            if (type.ImplementsInterfaceEx<System.Xml.Serialization.IXmlSerializable>())
            {
                return true;
            }

            // Is ModelBase
            if (type.IsModelBase())
            {
                return true;
            }

            // IsSerializable
            return type.IsSerializableEx();
        }