Catel.Runtime.Serialization.Xml.DataContractSerializerFactory.XmlSerializerTypeInfo.IsTypeSerializable C# (CSharp) Méthode

IsTypeSerializable() public méthode

Determines whether the specified type is serializable.
The is null.
public IsTypeSerializable ( Type type ) : bool
type System.Type The type.
Résultat bool
            public bool IsTypeSerializable(Type type)
            {
                return _isTypeSerializableCache.GetFromCacheOrFetch(type, () =>
                {
                    if (type.IsAbstractEx())
                    {
                        return false;
                    }

                    if (type.IsInterfaceEx())
                    {
                        return false;
                    }

                    if (type.IsEnumEx())
                    {
                        return true;
                    }

                    if (IsSpecialCollectionType(type))
                    {
                        return true;
                    }

                    // Should have an empty constructor
                    if (type.GetConstructorEx(new Type[0]) == null)
                    {
                        return false;
                    }

                    // Type must be public
                    if (!type.IsPublicEx() && !type.IsNestedPublicEx())
                    {
                        return false;
                    }

                    // TODO: Add more checks?

                    return true;
                });
            }