Esempio n. 1
0
        // property deserialization defaults

        /// <summary>
        /// Returns true if the given property should be deserialized.
        ///
        /// Override to tweak behavior.
        /// </summary>
        protected virtual bool ShouldDeserialize(TypeInfo forType, PropertyInfo property)
        {
            if (property.SetMethod == null)
            {
                return(false);
            }

            var ignoreDataMember = property.GetCustomAttribute <IgnoreDataMemberAttribute>();

            if (ignoreDataMember != null)
            {
                return(false);
            }

            var dataMember = property.GetCustomAttribute <DataMemberAttribute>();

            if (dataMember != null)
            {
                return(true);
            }

            return
                (property.SetMethod != null &&
                 property.SetMethod.IsPublic &&
                 !property.SetMethod.IsStatic &&
                 property.SetMethod.GetParameters().Length == 1 &&
                 DeserializableMember.GetDefaultParser(property.SetMethod.GetParameters()[0].ParameterType.GetTypeInfo()) != null);
        }
Esempio n. 2
0
 /// <summary>
 /// Returns the default cell parsing method for the given type, if any.
 ///
 /// Override to tweak behavior.
 /// </summary>
 protected virtual MethodInfo GetCellParsingMethodFor(int columnNumber, string columName, TypeInfo targetType)
 => DeserializableMember.GetDefaultParser(targetType);
Esempio n. 3
0
 private static MethodInfo GetParser(TypeInfo forType)
 => DeserializableMember.GetDefaultParser(forType);