Fix formatting
This commit is contained in:
parent
c18c106b72
commit
f965662031
@ -127,7 +127,27 @@ static public class refl
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string PrettyName( FieldInfo fi )
|
||||
{
|
||||
var name = fi.Name;
|
||||
if( name[0] != '<' )
|
||||
return name;
|
||||
|
||||
var gtIndex = name.IndexOf( '>' );
|
||||
|
||||
name = name.Substring( 1, gtIndex - 1 );
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public static void GetAllFields( Type t, List<FieldInfo> list )
|
||||
{
|
||||
GetAllFieldsRecursive( t, true, list );
|
||||
}
|
||||
|
||||
public static void GetAllFieldsRecursive( Type t, bool recurse, List<FieldInfo> list )
|
||||
{
|
||||
var fieldArr = t.GetFields(
|
||||
BindingFlags.DeclaredOnly |
|
||||
@ -139,11 +159,34 @@ static public class refl
|
||||
|
||||
list.AddRange( new PredEnumerable<FieldInfo>( en ) );
|
||||
|
||||
if( t.BaseType != null && t.BaseType != typeof( object ) )
|
||||
if( recurse && t.BaseType != null && t.BaseType != typeof( object ) )
|
||||
{
|
||||
GetAllFields( t.BaseType, list );
|
||||
}
|
||||
}
|
||||
public static void GetAllFieldsUntil( Type t, Type tooFar, List<FieldInfo> list )
|
||||
{
|
||||
var fieldArr = t.GetFields(
|
||||
BindingFlags.DeclaredOnly |
|
||||
BindingFlags.NonPublic |
|
||||
BindingFlags.Public |
|
||||
BindingFlags.Instance );
|
||||
|
||||
var en = PredEnumerator.Create<FieldInfo>( fieldArr.AsEnumerable<FieldInfo>(), fa => fa.GetCustomAttribute( typeof( NonSerializedAttribute ) ) == null );
|
||||
|
||||
list.AddRange( new PredEnumerable<FieldInfo>( en ) );
|
||||
|
||||
if( t.BaseType != null && t.BaseType != tooFar )
|
||||
{
|
||||
GetAllFields( t.BaseType, list );
|
||||
}
|
||||
}
|
||||
|
||||
public static ImmutableList<FieldInfo> GetAllFields<T>()
|
||||
{
|
||||
return GetAllFields( typeof( T ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static ImmutableList<FieldInfo> GetAllFields( Type t )
|
||||
|
||||
Loading…
Reference in New Issue
Block a user