/// <summary> /// Should the property be removed from serialization? /// </summary> /// <param name = "info"></param> /// <param name = "property"></param> /// <returns> /// true if the property: /// - is in the PropertiesToIgnore, /// - contains ExcludeFromSerializationAttribute, /// - does not have it's set or get accessor /// - is indexer /// </returns> protected virtual bool IgnoreProperty(Serialization.Serializing.TypeInfo info, PropertyInfo property) { // Soll die Eigenschaft ignoriert werden if (PropertiesToIgnore.Contains(info.Type, property.Name)) { return(true); } if (ContainsExcludeFromSerializationAttribute(property)) { return(true); } if (!property.CanRead || !property.CanWrite) { return(true); } ParameterInfo[] indexParameters = property.GetIndexParameters(); if (indexParameters.Length > 0) { // Indexer return(true); } return(false); }
/// <summary> /// Gives all properties back which: /// - are public /// - are not static /// - does not contain ExcludeFromSerializationAttribute /// - have their set and get accessors /// - are not indexers /// </summary> /// <param name = "typeInfo"></param> /// <returns></returns> public IList <PropertyInfo> GetProperties(Serialization.Serializing.TypeInfo typeInfo) { // Search in cache var propertyInfos = Cache.TryGetPropertyInfos(typeInfo.Type); if (propertyInfos != null) { return(propertyInfos); } // Creating infos PropertyInfo[] properties = GetAllProperties(typeInfo.Type); var result = new List <PropertyInfo>(); foreach (PropertyInfo property in properties) { if (!IgnoreProperty(typeInfo, property)) { result.Add(property); } } // adding result to Cache Cache.Add(typeInfo.Type, result); return(result); }