Title: Added support for 'Do' attribute in XML Formatter
x) Introduced the 'Do' attribute to the XML formatter. x) The 'Do' attribute is now fetched and checked before filtering fields and properties. x) This change allows more granular control over serialization, as items marked with the 'Do' attribute will not be filtered out. x) Adjusted formatting in some areas for consistency.
This commit is contained in:
parent
b0b9496c4a
commit
b66bc4e5ed
@ -561,6 +561,7 @@ namespace lib
|
|||||||
string name = childFi.Name;
|
string name = childFi.Name;
|
||||||
|
|
||||||
var dontAtt = childFi.GetCustomAttributes<lib.Dont>();
|
var dontAtt = childFi.GetCustomAttributes<lib.Dont>();
|
||||||
|
var doAtt = childFi.GetCustomAttributes<lib.Do>();
|
||||||
|
|
||||||
string propName = "";
|
string propName = "";
|
||||||
|
|
||||||
@ -573,6 +574,8 @@ namespace lib
|
|||||||
var propInfo = narrowType.GetProperty( propName );
|
var propInfo = narrowType.GetProperty( propName );
|
||||||
|
|
||||||
dontAtt = propInfo.GetCustomAttributes<lib.Dont>();
|
dontAtt = propInfo.GetCustomAttributes<lib.Dont>();
|
||||||
|
|
||||||
|
doAtt = propInfo.GetCustomAttributes<lib.Do>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( dontAtt.Any() )
|
if( dontAtt.Any() )
|
||||||
@ -586,7 +589,7 @@ namespace lib
|
|||||||
name = refl.TypeToIdentifier( name );
|
name = refl.TypeToIdentifier( name );
|
||||||
|
|
||||||
// @@@ TODO This doesnt yet handle propNames!
|
// @@@ TODO This doesnt yet handle propNames!
|
||||||
if( FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) )
|
if( !doAtt.Any() && FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var useFieldName = true;
|
var useFieldName = true;
|
||||||
@ -641,9 +644,12 @@ namespace lib
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var doAtt = childPi.GetCustomAttributes<lib.Do>();
|
||||||
|
|
||||||
|
|
||||||
name = refl.TypeToIdentifier( name );
|
name = refl.TypeToIdentifier( name );
|
||||||
|
|
||||||
if( FilterField( filterProps, doImpls, whitelistProps, childPi as PropertyInfo, name ) )
|
if( !doAtt.Any() && FilterField( filterProps, doImpls, whitelistProps, childPi as PropertyInfo, name ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
XmlElement childElem = getNamedChild( allChildren, name );
|
XmlElement childElem = getNamedChild( allChildren, name );
|
||||||
@ -1338,6 +1344,7 @@ namespace lib
|
|||||||
{
|
{
|
||||||
string name = childFi.Name;
|
string name = childFi.Name;
|
||||||
var dontAtt = childFi.GetCustomAttributes<lib.Dont>();
|
var dontAtt = childFi.GetCustomAttributes<lib.Dont>();
|
||||||
|
var doAtt = childFi.GetCustomAttributes<lib.Do>();
|
||||||
|
|
||||||
string propName = "";
|
string propName = "";
|
||||||
if( name.StartsWith( "<" ) && name.EndsWith( "BackingField" ) )
|
if( name.StartsWith( "<" ) && name.EndsWith( "BackingField" ) )
|
||||||
@ -1349,6 +1356,7 @@ namespace lib
|
|||||||
var propInfo = narrowType.GetProperty( propName );
|
var propInfo = narrowType.GetProperty( propName );
|
||||||
|
|
||||||
dontAtt = propInfo.GetCustomAttributes<lib.Dont>();
|
dontAtt = propInfo.GetCustomAttributes<lib.Dont>();
|
||||||
|
doAtt = propInfo.GetCustomAttributes<lib.Do>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1363,7 +1371,7 @@ namespace lib
|
|||||||
if( name == "Fn" ) continue;
|
if( name == "Fn" ) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) )
|
if( !doAtt.Any() && FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
object[] objs = childFi.GetCustomAttributes( typeof( NonSerializedAttribute ), true );
|
object[] objs = childFi.GetCustomAttributes( typeof( NonSerializedAttribute ), true );
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user