public override IEnumerable <IPropertyDescriptor> GetProperties(Type type)
 {
     return(innerTypeDescriptor.GetProperties(type)
            .Where(p => p.Property.GetCustomAttributes(typeof(YamlIgnoreAttribute), true).Length == 0)
            .Select(p =>
     {
         var alias = (YamlAliasAttribute)p.Property.GetCustomAttributes(typeof(YamlAliasAttribute), true).SingleOrDefault();
         return alias != null ? new PropertyDescriptor(p.Property, alias.Alias) : p;
     }));
 }
        protected virtual void SerializeProperties(object value, Type type, IObjectGraphVisitor visitor, int currentDepth)
        {
            visitor.VisitMappingStart(value, type, typeof(string), typeof(object));

            foreach (var propertyDescriptor in typeDescriptor.GetProperties(type))
            {
                var propertyValue = propertyDescriptor.Property.GetValue(value, null);

                if (visitor.EnterMapping(propertyDescriptor, propertyValue))
                {
                    Traverse(propertyDescriptor.Name, typeof(string), visitor, currentDepth);
                    Traverse(propertyValue, propertyDescriptor.Property.PropertyType, visitor, currentDepth);
                }
            }

            visitor.VisitMappingEnd(value, type);
        }
Exemple #3
0
 public IEnumerable <IPropertyDescriptor> GetProperties(Type type)
 {
     return(TypeDescriptor.GetProperties(type));
 }
 public override IEnumerable <IPropertyDescriptor> GetProperties(Type type)
 {
     return(innerTypeDescriptor.GetProperties(type)
            .Select(p => (IPropertyDescriptor) new PropertyDescriptor(p.Property, namingConvention.Apply(p.Name))));
 }