Updates to SharpLib

This commit is contained in:
Marc Hernandez 2021-06-17 01:47:52 -07:00
parent 26716c6648
commit 2844950af3
22 changed files with 2380 additions and 2494 deletions

5
.gitignore vendored
View File

@ -1,7 +1,3 @@
###################################
# Git ignore file for Molyjam2012 #
###################################
#Folders #Folders
Library/ Library/
Temp/ Temp/
@ -12,6 +8,7 @@ Release/
run/ run/
bin/ bin/
obj/ obj/
.vs/
#Project/User Preference Files #Project/User Preference Files
*.pidb *.pidb

View File

@ -147,28 +147,28 @@ namespace lib
} }
else else
{ {
Log.error( String.Format( $"No attributes in node while loading file {filename}" ) ); log.error( String.Format( $"No attributes in node while loading file {filename}" ) );
} }
} }
else else
{ {
Log.error( String.Format( $"Incorrect key {node.Name} found while loading file {filename}" ) ); log.error( String.Format( $"Incorrect key {node.Name} found while loading file {filename}" ) );
} }
} }
} }
else else
{ {
if( keyMI == null ) if( keyMI == null )
Log.error( String.Format( $"Key type conversion not found for type {keyType}" ) ); log.error( String.Format( $"Key type conversion not found for type {keyType}" ) );
if( valMI == null ) if( valMI == null )
Log.error( String.Format( $"Val type conversion not found for type {valType}" ) ); log.error( String.Format( $"Val type conversion not found for type {valType}" ) );
} }
} }
else else
{ {
Log.error( String.Format( $"No dictionary element found while loading file {filename}" ) ); log.error( String.Format( $"No dictionary element found while loading file {filename}" ) );
} }
} }

4
Id.cs
View File

@ -13,7 +13,7 @@ namespace lib
{ {
public struct Id<T> : IComparable, IFormattable, IConvertible, IComparable<ulong>, IEquatable<ulong> public struct Id<T>: IComparable, IFormattable, IConvertible, IComparable<ulong>, IEquatable<ulong>
{ {
public const ulong Min = 0uL; public const ulong Min = 0uL;
public const ulong Max = 18446744073709551615uL; public const ulong Max = 18446744073709551615uL;
@ -29,7 +29,7 @@ namespace lib
s_rand.NextBytes( buf ); s_rand.NextBytes( buf );
var newId = BitConverter.ToUInt64( buf, 0 ); var newId = BitConverter.ToUInt64(buf, 0);
return new Id<T> { m_value = newId }; return new Id<T> { m_value = newId };
} }

View File

@ -23,6 +23,7 @@
<ItemGroup> <ItemGroup>
<Folder Include="Properties\" /> <Folder Include="Properties\" />
<Folder Include="reflect\" />
</ItemGroup> </ItemGroup>

View File

@ -22,6 +22,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma warning disable SA1405 // Debug.Assert must provide message text #pragma warning disable SA1405 // Debug.Assert must provide message text
using att; using att;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -88,12 +89,12 @@ namespace lib
{ {
if( !Directory.Exists( path ) ) if( !Directory.Exists( path ) )
{ {
lib.Log.info( $"Creating directory {path}" ); log.info( $"Creating directory {path}" );
Directory.CreateDirectory( path ); Directory.CreateDirectory( path );
} }
else else
{ {
lib.Log.debug( $"{path} already exists." ); log.debug( $"{path} already exists." );
} }
} }
@ -216,7 +217,7 @@ namespace lib
unsafe unsafe
{ {
fixed ( void* pBuffer = buffer ) fixed( void* pBuffer = buffer )
Interop.Write( pBuffer, source, 0, source.Length ); Interop.Write( pBuffer, source, 0, source.Length );
} }
return buffer; return buffer;
@ -339,7 +340,7 @@ namespace lib
{ {
unsafe unsafe
{ {
fixed ( void* pDest = destination ) fixed( void* pDest = destination )
{ {
Write( (IntPtr)pDest, data, offset, count ); Write( (IntPtr)pDest, data, offset, count );
} }

View File

@ -45,7 +45,7 @@ namespace att
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter )] AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter )]
public sealed class CanBeNullAttribute : Attribute public sealed class CanBeNullAttribute: Attribute
{ {
} }
} }

View File

@ -19,7 +19,7 @@ namespace att
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter )] AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter )]
public sealed class NotNullAttribute : Attribute public sealed class NotNullAttribute: Attribute
{ {
} }
} }

View File

@ -6,7 +6,7 @@ using System.Reflection;
namespace lib namespace lib
{ {
public class DescAttribute : Attribute public class DescAttribute: Attribute
{ {
public string Desc { get; private set; } public string Desc { get; private set; }
@ -17,7 +17,7 @@ namespace lib
} }
[Serializable] [Serializable]
public class ConfigCfg : Config public class ConfigCfg: Config
{ {
public readonly bool writeOutTemplateFiles = true; public readonly bool writeOutTemplateFiles = true;
} }
@ -83,7 +83,7 @@ namespace lib
try try
{ {
FileStream fs = new FileStream( filename, FileMode.Open, FileAccess.Read ); FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
XmlFormatter2 formatter = new XmlFormatter2(); XmlFormatter2 formatter = new XmlFormatter2();
@ -93,13 +93,13 @@ namespace lib
} }
catch( FileNotFoundException ) catch( FileNotFoundException )
{ {
Type[] types = new Type[ 0 ]; Type[] types = new Type[0];
object[] parms = new object[ 0 ]; object[] parms = new object[0];
//types[ 0 ] = typeof( string ); //types[ 0 ] = typeof( string );
//parms[ 0 ] = filename; //parms[ 0 ] = filename;
ConstructorInfo cons = t?.GetConstructor( types ); ConstructorInfo cons = t?.GetConstructor(types);
try try
{ {
@ -107,7 +107,7 @@ namespace lib
} }
catch( Exception e ) catch( Exception e )
{ {
Log.error( $"Exception while creating config {t.ToString()}, Msg {e.Message}" ); log.error( $"Exception while creating config {t.ToString()}, Msg {e.Message}" );
} }
//cfg.SetFilename( filename ); //cfg.SetFilename( filename );
@ -116,11 +116,11 @@ namespace lib
{ {
var templateFile = $"templates/{filename}"; var templateFile = $"templates/{filename}";
var dirName = Path.GetDirectoryName( templateFile ); var dirName = Path.GetDirectoryName(templateFile);
lib.Util.checkAndAddDirectory( dirName ); lib.Util.checkAndAddDirectory( dirName );
lib.Log.info( $"Writing out template config of type {t?.Name} in {templateFile}" ); log.info( $"Writing out template config of type {t?.Name} in {templateFile}" );
Config.save( cfg, templateFile ); Config.save( cfg, templateFile );
} }
@ -136,7 +136,7 @@ namespace lib
static public void save( Config cfg, String filename ) static public void save( Config cfg, String filename )
{ {
FileStream fs = new FileStream( filename, FileMode.Create, FileAccess.Write ); FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
XmlFormatter2 formatter = new XmlFormatter2(); XmlFormatter2 formatter = new XmlFormatter2();

View File

@ -8,38 +8,10 @@ using System.Collections.Immutable;
using System.Reflection; using System.Reflection;
//using System.Threading.Tasks; //using System.Threading.Tasks;
namespace lib static public class log
{ {
[Flags]
public enum LogTypeNew
{
Invalid = 0,
// Frequency
FrequencyBase = 1,
FrequencyBits = 2,
FrequencyMask = ( ( 1 << FrequencyBits ) - 1 ) << FrequencyBase,
Detail = 0b01 << FrequencyBase,
Normal = 0b10 << FrequencyBase,
Overview = 0b11 << FrequencyBase,
// Type
TypeBase = FrequencyBase + FrequencyBits,
TypeBits = 3,
TypeMask = ( ( 1 << TypeBits ) - 1 ) << TypeBase,
Startup = 0b001 << TypeBase,
Running = 0b010 << TypeBase,
Shutdown = 0b011 << TypeBase,
Error = 0b101 << TypeBase,
}
[Flags] [Flags]
public enum LogType public enum LogType
{ {
@ -67,7 +39,7 @@ namespace lib
static ImmutableDictionary<string, string> m_shortname = ImmutableDictionary<string, string>.Empty; static ImmutableDictionary<int, string> s_shortname = ImmutableDictionary<int, string>.Empty;
public LogEvent( LogType logType, string msg, string path, int line, string member, string cat, object obj ) public LogEvent( LogType logType, string msg, string path, int line, string member, string cat, object obj )
@ -76,17 +48,18 @@ namespace lib
//Cache the automatic category names //Cache the automatic category names
if( string.IsNullOrEmpty( cat ) ) if( string.IsNullOrEmpty( cat ) )
{ {
if( m_shortname.TryGetValue( path, out var autoCat ) ) var pathHash = path.GetHashCode();
if( s_shortname.TryGetValue( pathHash, out var autoCat ) )
{ {
cat = autoCat; cat = autoCat;
} }
else else
{ {
var pathPieces = path.Split('\\'); var pathPieces = path.Split( '\\' );
var lastDir = pathPieces[pathPieces.Length - 2]; var lastDir = pathPieces[ pathPieces.Length - 2 ];
ImmutableInterlocked.AddOrUpdate( ref m_shortname, path, lastDir, ( key, value ) => { return lastDir; } ); ImmutableInterlocked.AddOrUpdate( ref s_shortname, pathHash, lastDir, ( key, value ) => { return lastDir; } );
cat = lastDir; cat = lastDir;
} }
@ -107,11 +80,9 @@ namespace lib
public class Log : TraceListener
{
static public void create( string filename ) static public void create( string filename )
{ {
s_log = new Log( filename ); createLog( filename );
} }
@ -121,25 +92,11 @@ namespace lib
var evt = CreateLogEvent( LogType.Info, msg, "System", null ); var evt = CreateLogEvent( LogType.Info, msg, "System", null );
s_log.writeToAll( evt ); writeToAll( evt );
s_log.stop(); stop();
s_log = null;
} }
static public Log s_log;
/*
static public Log log
{
get
{
return s_log;
}
}
*/
static LogEvent CreateLogEvent( LogType logType, string msg, string cat, object obj, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static LogEvent CreateLogEvent( LogType logType, string msg, string cat, object obj, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
@ -154,59 +111,62 @@ namespace lib
// Forwards. // Forwards.
static public void fatal( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static public void fatal( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
log( msg, LogType.Fatal, path, line, member, cat, obj ); logBase( msg, LogType.Fatal, path, line, member, cat, obj );
} }
static public void error( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static public void error( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
log( msg, LogType.Error, path, line, member, cat, obj ); logBase( msg, LogType.Error, path, line, member, cat, obj );
} }
static public void warn( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static public void warn( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
log( msg, LogType.Warn, path, line, member, cat, obj ); logBase( msg, LogType.Warn, path, line, member, cat, obj );
} }
static public void info( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static public void info( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
log( msg, LogType.Info, path, line, member, cat, obj ); logBase( msg, LogType.Info, path, line, member, cat, obj );
} }
static public void high( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static public void high( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
log( msg, LogType.High, path, line, member, cat, obj ); logBase( msg, LogType.High, path, line, member, cat, obj );
} }
static public void debug( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static public void debug( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
log( msg, LogType.Debug, path, line, member, cat, obj ); logBase( msg, LogType.Debug, path, line, member, cat, obj );
} }
static public void trace( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" ) static public void trace( string msg, string cat = "", object obj = null, [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
log( msg, LogType.Trace, path, line, member, cat, obj ); logBase( msg, LogType.Trace, path, line, member, cat, obj );
} }
static public void log( string msg, LogType type = LogType.Debug, string path = "", int line = -1, string member = "", string cat = "unk", object obj = null ) static object s_lock = new object();
static public void logBase( string msg, LogType type = LogType.Debug, string path = "", int line = -1, string member = "", string cat = "unk", object obj = null )
{ {
// @@@@@ TODO Get rid of this lock. // @@@@@ TODO Get rid of this lock.
var evt = new LogEvent( type, msg, path, line, member, cat, obj ); var evt = new LogEvent( type, msg, path, line, member, cat, obj );
lock( s_log ) lock( s_lock )
{ {
s_log.writeToAll( evt ); writeToAll( evt );
} }
} }
static public void logProps( object obj, string header, LogType type = LogType.Debug, string cat = "", string prefix = "" ) static public void logProps( object obj, string header, LogType type = LogType.Debug, string cat = "", string prefix = "", [CallerFilePath] string path = "", [CallerLineNumber] int line = -1, [CallerMemberName] string member = "" )
{ {
var list = scr.GetAllProperties( obj.GetType() ); var list = refl.GetAllProperties( obj.GetType() );
lock( s_log ) lock( s_lock )
{ {
var evt = CreateLogEvent( type, header, cat, obj ); var evt = new LogEvent( type, header, path, line, member, cat, obj );
//var evt = CreateLogEvent( type, header, cat, obj );
s_log.writeToAll( evt ); writeToAll( evt );
foreach( var pi in list ) foreach( var pi in list )
{ {
@ -214,11 +174,11 @@ namespace lib
{ {
var v = pi.GetValue( obj ); var v = pi.GetValue( obj );
log( $"{prefix}{pi.Name} = {v}", type, cat ); logBase( $"{prefix}{pi.Name} = {v}", type, path, line, member, cat );
} }
catch( Exception ex ) catch( Exception ex )
{ {
log( $"Exception processing {pi.Name} {ex.Message}", LogType.Error, "log" ); logBase( $"Exception processing {pi.Name} {ex.Message}", LogType.Error, "log" );
} }
} }
@ -231,25 +191,30 @@ namespace lib
if( !value.Equals( notExpectedValue ) ) if( !value.Equals( notExpectedValue ) )
{ {
lib.Log.info( $"Properly got {value}{trueString}" ); log.info( $"Properly got {value}{trueString}" );
} }
else else
{ {
lib.Log.warn( $"Got {notExpectedValue} instead of {value}{falseString}" ); log.warn( $"Got {notExpectedValue} instead of {value}{falseString}" );
} }
} }
private Log( string filename ) static private void createLog( string filename )
{ {
//TODO: Fix this so itll work without a directory.
Directory.CreateDirectory( Path.GetDirectoryName( filename ) );
m_stream = new FileStream( filename, FileMode.Append, FileAccess.Write ); string dir = Path.GetDirectoryName( filename );
m_writer = new StreamWriter( m_stream );
m_errorStream = new FileStream( filename + ".error", FileMode.Append, FileAccess.Write ); if( dir.Length > 0 )
m_errorWriter = new StreamWriter( m_errorStream ); {
Directory.CreateDirectory( dir );
}
s_stream = new FileStream( filename, FileMode.Append, FileAccess.Write );
s_writer = new StreamWriter( s_stream );
s_errorStream = new FileStream( filename + ".error", FileMode.Append, FileAccess.Write );
s_errorWriter = new StreamWriter( s_errorStream );
//Debug.Listeners.Add( this ); //Debug.Listeners.Add( this );
@ -260,59 +225,31 @@ namespace lib
writeToAll( evt ); writeToAll( evt );
} }
public override void Write( string msg ) /*
{ static public override void Write( string msg ) {
WriteLine( msg ); WriteLine( msg );
} }
public override void WriteLine( string msg ) static public override void WriteLine( string msg ) {
{
error( msg ); error( msg );
//base.WriteLine( msg ); //base.WriteLine( msg );
} }
void stop()
{
m_writer.Close();
m_stream.Close();
m_errorWriter.Close();
m_errorStream.Close();
}
public void addDelegate( Log_delegate cb )
{
m_delegates.Add( cb );
}
/*
private void writeFileAndLine( StackTrace st )
{
StackFrame frame = st.GetFrame( 1 );
string srcFile = frame.GetFileName();
string srcLine = frame.GetFileLineNumber().Tostring();
Console.WriteLine( $"{srcFile} ({srcLine}):" );
}
private void writeStack( StackTrace st )
{
for( int i=0; i<st.FrameCount; ++i )
{
StackFrame frame = st.GetFrame( i );
string srcFile = frame.GetFileName();
string srcLine = frame.GetFileLineNumber().Tostring();
if( srcFile != null )
{
Console.WriteLine( $"{srcFile} ({srcLine})" );
}
}
}
*/ */
static void stop()
{
s_writer.Close();
s_stream.Close();
s_errorWriter.Close();
s_errorStream.Close();
}
static public void addDelegate( Log_delegate cb )
{
s_delegates.Add( cb );
}
public static char getSymbol( LogType type ) public static char getSymbol( LogType type )
{ {
switch( type ) switch( type )
@ -336,7 +273,7 @@ namespace lib
} }
} }
private void writeToAll( LogEvent evt ) static private void writeToAll( LogEvent evt )
{ {
try try
{ {
@ -345,31 +282,23 @@ namespace lib
{ {
char sym = getSymbol( evt.LogType ); char sym = getSymbol( evt.LogType );
var truncatedCat = evt.Cat.Substring(0, Math.Min( 8, evt.Cat.Length ) ); var truncatedCat = evt.Cat.Substring( 0, Math.Min( 8, evt.Cat.Length ) );
string finalLine = string.Format( "{0,-8}{1}| {2}", truncatedCat, sym, evt.Msg ); string finalLine = string.Format( "{0,-8}{1}| {2}", truncatedCat, sym, evt.Msg );
//Console.WriteLine( finalMsg ); //Console.WriteLine( finalMsg );
//Console.Out.Write( finalMsg ); //Console.Out.Write( finalMsg );
/* s_writer.WriteLine( finalLine );
foreach( var l_obj in Debug.Listeners )
{
var l = l_obj as TraceListener;
if( l != null && l != this )
{
l.WriteLine( finalMsg );
}
}
*/
m_writer.WriteLine( finalLine ); Console.WriteLine( finalLine );
m_writer.Flush(); Debug.WriteLine( finalLine );
foreach( Log_delegate cb in m_delegates ) s_writer.Flush();
foreach( Log_delegate cb in s_delegates )
{ {
//lock( cb )
{ {
cb( evt ); cb( evt );
} }
@ -378,71 +307,29 @@ namespace lib
} }
catch( Exception ex ) catch( Exception ex )
{ {
//oops. Console.WriteLine( "EXCEPTION DURING LOGGING" );
//int dummy = 0; Console.WriteLine( "EXCEPTION DURING LOGGING" );
Console.WriteLine( "EXCEPTION DURING LOGGING" );
Console.WriteLine( "EXCEPTION DURING LOGGING" );
Console.WriteLine( "EXCEPTION DURING LOGGING" );
Console.WriteLine( $"Exception {ex}" );
Debug.WriteLine( "EXCEPTION DURING LOGGING" );
Debug.WriteLine( "EXCEPTION DURING LOGGING" );
Debug.WriteLine( "EXCEPTION DURING LOGGING" );
Debug.WriteLine( "EXCEPTION DURING LOGGING" );
Debug.WriteLine( "EXCEPTION DURING LOGGING" );
Debug.WriteLine( $"Exception {ex}" );
} }
} }
/* private static Stream s_stream;
private void error_i( string msg, object obj ) private static StreamWriter s_writer;
{
//var t = Task.Run( () => {
StackTrace st = new StackTrace( true );
writeStack( st ); private static Stream s_errorStream;
private static StreamWriter s_errorWriter;
string msgPrint = msg; private static ArrayList s_delegates = new ArrayList();
if( args.Length > 0 )
{
msgPrint = string.Format( msg, args );
}
writeToAll( "error", "log", msgPrint );
//} );
}
private void warn_i( string msg, object obj )
{
//var t = Task.Run( () => {
StackTrace st = new StackTrace( true );
writeStack( st );
string msgPrint = msg;
if( args.Length > 0 )
{
msgPrint = string.Format( msg, args );
}
writeToAll( "warn", "log", msgPrint );
//});
}
private void info_i( string msg, object obj )
{
//var t = Task.Run( () => {
StackTrace st = new StackTrace( true );
string msgPrint = msg;
if( args.Length > 0 )
{
msgPrint = string.Format( msg, args );
}
writeToAll( "info", "log", msgPrint );
//} );
}
*/
private Stream m_stream;
private StreamWriter m_writer;
private Stream m_errorStream;
private StreamWriter m_errorWriter;
private ArrayList m_delegates = new ArrayList();
}

View File

@ -36,9 +36,9 @@ namespace math
/// Represents a unit independant angle using a single-precision floating-point /// Represents a unit independant angle using a single-precision floating-point
/// internal representation. /// internal representation.
/// </summary> /// </summary>
[DataStyle(DataStyle.Compact)] [DataStyle( DataStyle.Compact )]
[DataContract] [DataContract]
public struct AngleSingle : IComparable, IComparable<AngleSingle>, IEquatable<AngleSingle>, IFormattable public struct AngleSingle: IComparable, IComparable<AngleSingle>, IEquatable<AngleSingle>, IFormattable
{ {
/// <summary> /// <summary>
/// A value that specifies the size of a single degree. /// A value that specifies the size of a single degree.
@ -81,16 +81,16 @@ namespace math
/// </summary> /// </summary>
/// <param name="angle">A unit dependant measure of the angle.</param> /// <param name="angle">A unit dependant measure of the angle.</param>
/// <param name="type">The type of unit the angle argument is.</param> /// <param name="type">The type of unit the angle argument is.</param>
public AngleSingle(float angle, AngleType type) public AngleSingle( float angle, AngleType type )
{ {
switch (type) switch( type )
{ {
case AngleType.Revolution: case AngleType.Revolution:
radians = MathUtil.RevolutionsToRadians(angle); radians = MathUtil.RevolutionsToRadians( angle );
break; break;
case AngleType.Degree: case AngleType.Degree:
radians = MathUtil.DegreesToRadians(angle); radians = MathUtil.DegreesToRadians( angle );
break; break;
case AngleType.Radian: case AngleType.Radian:
@ -98,7 +98,7 @@ namespace math
break; break;
case AngleType.Gradian: case AngleType.Gradian:
radians = MathUtil.GradiansToRadians(angle); radians = MathUtil.GradiansToRadians( angle );
break; break;
default: default:
@ -113,7 +113,7 @@ namespace math
/// </summary> /// </summary>
/// <param name="arcLength">The measure of the arc.</param> /// <param name="arcLength">The measure of the arc.</param>
/// <param name="radius">The radius of the circle.</param> /// <param name="radius">The radius of the circle.</param>
public AngleSingle(float arcLength, float radius) public AngleSingle( float arcLength, float radius )
{ {
radians = arcLength / radius; radians = arcLength / radius;
} }
@ -125,9 +125,9 @@ namespace math
{ {
float newangle = (float)Math.IEEERemainder(radians, MathUtil.TwoPi); float newangle = (float)Math.IEEERemainder(radians, MathUtil.TwoPi);
if (newangle <= -MathUtil.Pi) if( newangle <= -MathUtil.Pi )
newangle += MathUtil.TwoPi; newangle += MathUtil.TwoPi;
else if (newangle > MathUtil.Pi) else if( newangle > MathUtil.Pi )
newangle -= MathUtil.TwoPi; newangle -= MathUtil.TwoPi;
radians = newangle; radians = newangle;
@ -140,7 +140,7 @@ namespace math
{ {
float newangle = radians % MathUtil.TwoPi; float newangle = radians % MathUtil.TwoPi;
if (newangle < 0.0) if( newangle < 0.0 )
newangle += MathUtil.TwoPi; newangle += MathUtil.TwoPi;
radians = newangle; radians = newangle;
@ -152,8 +152,8 @@ namespace math
[DataMemberIgnore] [DataMemberIgnore]
public float Revolutions public float Revolutions
{ {
get { return MathUtil.RadiansToRevolutions(radians); } get { return MathUtil.RadiansToRevolutions( radians ); }
set { radians = MathUtil.RevolutionsToRadians(value); } set { radians = MathUtil.RevolutionsToRadians( value ); }
} }
/// <summary> /// <summary>
@ -162,8 +162,8 @@ namespace math
[DataMemberIgnore] [DataMemberIgnore]
public float Degrees public float Degrees
{ {
get { return MathUtil.RadiansToDegrees(radians); } get { return MathUtil.RadiansToDegrees( radians ); }
set { radians = MathUtil.DegreesToRadians(value); } set { radians = MathUtil.DegreesToRadians( value ); }
} }
/// <summary> /// <summary>
@ -179,15 +179,15 @@ namespace math
{ {
float degrees = MathUtil.RadiansToDegrees(radians); float degrees = MathUtil.RadiansToDegrees(radians);
if (degrees < 0) if( degrees < 0 )
{ {
float degreesfloor = (float)Math.Ceiling(degrees); float degreesfloor = (float)Math.Ceiling(degrees);
return (degrees - degreesfloor) * 60.0f; return ( degrees - degreesfloor ) * 60.0f;
} }
else else
{ {
float degreesfloor = (float)Math.Floor(degrees); float degreesfloor = (float)Math.Floor(degrees);
return (degrees - degreesfloor) * 60.0f; return ( degrees - degreesfloor ) * 60.0f;
} }
} }
set set
@ -196,7 +196,7 @@ namespace math
float degreesfloor = (float)Math.Floor(degrees); float degreesfloor = (float)Math.Floor(degrees);
degreesfloor += value / 60.0f; degreesfloor += value / 60.0f;
radians = MathUtil.DegreesToRadians(degreesfloor); radians = MathUtil.DegreesToRadians( degreesfloor );
} }
} }
@ -213,14 +213,14 @@ namespace math
{ {
float degrees = MathUtil.RadiansToDegrees(radians); float degrees = MathUtil.RadiansToDegrees(radians);
if (degrees < 0) if( degrees < 0 )
{ {
float degreesfloor = (float)Math.Ceiling(degrees); float degreesfloor = (float)Math.Ceiling(degrees);
float minutes = (degrees - degreesfloor) * 60.0f; float minutes = (degrees - degreesfloor) * 60.0f;
float minutesfloor = (float)Math.Ceiling(minutes); float minutesfloor = (float)Math.Ceiling(minutes);
return (minutes - minutesfloor) * 60.0f; return ( minutes - minutesfloor ) * 60.0f;
} }
else else
{ {
@ -229,7 +229,7 @@ namespace math
float minutes = (degrees - degreesfloor) * 60.0f; float minutes = (degrees - degreesfloor) * 60.0f;
float minutesfloor = (float)Math.Floor(minutes); float minutesfloor = (float)Math.Floor(minutes);
return (minutes - minutesfloor) * 60.0f; return ( minutes - minutesfloor ) * 60.0f;
} }
} }
set set
@ -242,7 +242,7 @@ namespace math
minutesfloor += value / 60.0f; minutesfloor += value / 60.0f;
degreesfloor += minutesfloor / 60.0f; degreesfloor += minutesfloor / 60.0f;
radians = MathUtil.DegreesToRadians(degreesfloor); radians = MathUtil.DegreesToRadians( degreesfloor );
} }
} }
@ -262,8 +262,8 @@ namespace math
[DataMemberIgnore] [DataMemberIgnore]
public float Milliradians public float Milliradians
{ {
get { return radians / (Milliradian * MathUtil.TwoPi); } get { return radians / ( Milliradian * MathUtil.TwoPi ); }
set { radians = value * (Milliradian * MathUtil.TwoPi); } set { radians = value * ( Milliradian * MathUtil.TwoPi ); }
} }
/// <summary> /// <summary>
@ -272,8 +272,8 @@ namespace math
[DataMemberIgnore] [DataMemberIgnore]
public float Gradians public float Gradians
{ {
get { return MathUtil.RadiansToGradians(radians); } get { return MathUtil.RadiansToGradians( radians ); }
set { radians = MathUtil.GradiansToRadians(value); } set { radians = MathUtil.GradiansToRadians( value ); }
} }
/// <summary> /// <summary>
@ -313,7 +313,7 @@ namespace math
[DataMemberIgnore] [DataMemberIgnore]
public bool IsOblique public bool IsOblique
{ {
get { return WrapPositive(this).radians != MathUtil.PiOverTwo; } get { return WrapPositive( this ).radians != MathUtil.PiOverTwo; }
} }
/// <summary> /// <summary>
@ -352,7 +352,7 @@ namespace math
[DataMemberIgnore] [DataMemberIgnore]
public AngleSingle Complement public AngleSingle Complement
{ {
get { return new AngleSingle(MathUtil.PiOverTwo - radians, AngleType.Radian); } get { return new AngleSingle( MathUtil.PiOverTwo - radians, AngleType.Radian ); }
} }
/// <summary> /// <summary>
@ -361,7 +361,7 @@ namespace math
[DataMemberIgnore] [DataMemberIgnore]
public AngleSingle Supplement public AngleSingle Supplement
{ {
get { return new AngleSingle(MathUtil.Pi - radians, AngleType.Radian); } get { return new AngleSingle( MathUtil.Pi - radians, AngleType.Radian ); }
} }
/// <summary> /// <summary>
@ -369,7 +369,7 @@ namespace math
/// </summary> /// </summary>
/// <param name="value">A math.AngleSingle to wrap.</param> /// <param name="value">A math.AngleSingle to wrap.</param>
/// <returns>The math.AngleSingle that is wrapped.</returns> /// <returns>The math.AngleSingle that is wrapped.</returns>
public static AngleSingle Wrap(AngleSingle value) public static AngleSingle Wrap( AngleSingle value )
{ {
value.Wrap(); value.Wrap();
return value; return value;
@ -380,7 +380,7 @@ namespace math
/// </summary> /// </summary>
/// <param name="value">A math.AngleSingle to wrap.</param> /// <param name="value">A math.AngleSingle to wrap.</param>
/// <returns>The math.AngleSingle that is wrapped.</returns> /// <returns>The math.AngleSingle that is wrapped.</returns>
public static AngleSingle WrapPositive(AngleSingle value) public static AngleSingle WrapPositive( AngleSingle value )
{ {
value.WrapPositive(); value.WrapPositive();
return value; return value;
@ -392,9 +392,9 @@ namespace math
/// <param name="left">The first math.AngleSingle instance to compare.</param> /// <param name="left">The first math.AngleSingle instance to compare.</param>
/// <param name="right">The second math.AngleSingle instance to compare.</param> /// <param name="right">The second math.AngleSingle instance to compare.</param>
/// <returns>The smaller of the two given math.AngleSingle instances.</returns> /// <returns>The smaller of the two given math.AngleSingle instances.</returns>
public static AngleSingle Min(AngleSingle left, AngleSingle right) public static AngleSingle Min( AngleSingle left, AngleSingle right )
{ {
if (left.radians < right.radians) if( left.radians < right.radians )
return left; return left;
return right; return right;
@ -406,9 +406,9 @@ namespace math
/// <param name="left">The first math.AngleSingle instance to compare.</param> /// <param name="left">The first math.AngleSingle instance to compare.</param>
/// <param name="right">The second math.AngleSingle instance to compare.</param> /// <param name="right">The second math.AngleSingle instance to compare.</param>
/// <returns>The greater of the two given math.AngleSingle instances.</returns> /// <returns>The greater of the two given math.AngleSingle instances.</returns>
public static AngleSingle Max(AngleSingle left, AngleSingle right) public static AngleSingle Max( AngleSingle left, AngleSingle right )
{ {
if (left.radians > right.radians) if( left.radians > right.radians )
return left; return left;
return right; return right;
@ -420,9 +420,9 @@ namespace math
/// <param name="left">The first object to add.</param> /// <param name="left">The first object to add.</param>
/// <param name="right">The second object to add.</param> /// <param name="right">The second object to add.</param>
/// <returns>The value of the two objects added together.</returns> /// <returns>The value of the two objects added together.</returns>
public static AngleSingle Add(AngleSingle left, AngleSingle right) public static AngleSingle Add( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians + right.radians, AngleType.Radian); return new AngleSingle( left.radians + right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -431,9 +431,9 @@ namespace math
/// <param name="left">The first object to subtract.</param> /// <param name="left">The first object to subtract.</param>
/// <param name="right">The second object to subtract.</param> /// <param name="right">The second object to subtract.</param>
/// <returns>The value of the two objects subtracted.</returns> /// <returns>The value of the two objects subtracted.</returns>
public static AngleSingle Subtract(AngleSingle left, AngleSingle right) public static AngleSingle Subtract( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians - right.radians, AngleType.Radian); return new AngleSingle( left.radians - right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -442,9 +442,9 @@ namespace math
/// <param name="left">The first object to multiply.</param> /// <param name="left">The first object to multiply.</param>
/// <param name="right">The second object to multiply.</param> /// <param name="right">The second object to multiply.</param>
/// <returns>The value of the two objects multiplied together.</returns> /// <returns>The value of the two objects multiplied together.</returns>
public static AngleSingle Multiply(AngleSingle left, AngleSingle right) public static AngleSingle Multiply( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians * right.radians, AngleType.Radian); return new AngleSingle( left.radians * right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -453,9 +453,9 @@ namespace math
/// <param name="left">The numerator object.</param> /// <param name="left">The numerator object.</param>
/// <param name="right">The denominator object.</param> /// <param name="right">The denominator object.</param>
/// <returns>The value of the two objects divided.</returns> /// <returns>The value of the two objects divided.</returns>
public static AngleSingle Divide(AngleSingle left, AngleSingle right) public static AngleSingle Divide( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians / right.radians, AngleType.Radian); return new AngleSingle( left.radians / right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -463,7 +463,7 @@ namespace math
/// </summary> /// </summary>
public static AngleSingle ZeroAngle public static AngleSingle ZeroAngle
{ {
get { return new AngleSingle(0.0f, AngleType.Radian); } get { return new AngleSingle( 0.0f, AngleType.Radian ); }
} }
/// <summary> /// <summary>
@ -471,7 +471,7 @@ namespace math
/// </summary> /// </summary>
public static AngleSingle RightAngle public static AngleSingle RightAngle
{ {
get { return new AngleSingle(MathUtil.PiOverTwo, AngleType.Radian); } get { return new AngleSingle( MathUtil.PiOverTwo, AngleType.Radian ); }
} }
/// <summary> /// <summary>
@ -479,7 +479,7 @@ namespace math
/// </summary> /// </summary>
public static AngleSingle StraightAngle public static AngleSingle StraightAngle
{ {
get { return new AngleSingle(MathUtil.Pi, AngleType.Radian); } get { return new AngleSingle( MathUtil.Pi, AngleType.Radian ); }
} }
/// <summary> /// <summary>
@ -487,7 +487,7 @@ namespace math
/// </summary> /// </summary>
public static AngleSingle FullRotationAngle public static AngleSingle FullRotationAngle
{ {
get { return new AngleSingle(MathUtil.TwoPi, AngleType.Radian); } get { return new AngleSingle( MathUtil.TwoPi, AngleType.Radian ); }
} }
/// <summary> /// <summary>
@ -497,7 +497,7 @@ namespace math
/// <param name="left">The first object to compare.</param> /// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param> /// <param name="right">The second object to compare.</param>
/// <returns>True if the left and right parameters have the same value; otherwise, false.</returns> /// <returns>True if the left and right parameters have the same value; otherwise, false.</returns>
public static bool operator ==(AngleSingle left, AngleSingle right) public static bool operator ==( AngleSingle left, AngleSingle right )
{ {
return left.radians == right.radians; return left.radians == right.radians;
} }
@ -509,7 +509,7 @@ namespace math
/// <param name="left">The first object to compare.</param> /// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param> /// <param name="right">The second object to compare.</param>
/// <returns>True if the left and right parameters do not have the same value; otherwise, false.</returns> /// <returns>True if the left and right parameters do not have the same value; otherwise, false.</returns>
public static bool operator !=(AngleSingle left, AngleSingle right) public static bool operator !=( AngleSingle left, AngleSingle right )
{ {
return left.radians != right.radians; return left.radians != right.radians;
} }
@ -521,7 +521,7 @@ namespace math
/// <param name="left">The first object to compare.</param> /// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param> /// <param name="right">The second object to compare.</param>
/// <returns>True if left is less than right; otherwise, false.</returns> /// <returns>True if left is less than right; otherwise, false.</returns>
public static bool operator <(AngleSingle left, AngleSingle right) public static bool operator <( AngleSingle left, AngleSingle right )
{ {
return left.radians < right.radians; return left.radians < right.radians;
} }
@ -533,7 +533,7 @@ namespace math
/// <param name="left">The first object to compare.</param> /// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param> /// <param name="right">The second object to compare.</param>
/// <returns>True if left is greater than right; otherwise, false.</returns> /// <returns>True if left is greater than right; otherwise, false.</returns>
public static bool operator >(AngleSingle left, AngleSingle right) public static bool operator >( AngleSingle left, AngleSingle right )
{ {
return left.radians > right.radians; return left.radians > right.radians;
} }
@ -545,7 +545,7 @@ namespace math
/// <param name="left">The first object to compare.</param> /// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param> /// <param name="right">The second object to compare.</param>
/// <returns>True if left is less than or equal to right; otherwise, false.</returns> /// <returns>True if left is less than or equal to right; otherwise, false.</returns>
public static bool operator <=(AngleSingle left, AngleSingle right) public static bool operator <=( AngleSingle left, AngleSingle right )
{ {
return left.radians <= right.radians; return left.radians <= right.radians;
} }
@ -557,7 +557,7 @@ namespace math
/// <param name="left">The first object to compare.</param> /// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param> /// <param name="right">The second object to compare.</param>
/// <returns>True if left is greater than or equal to right; otherwise, false.</returns> /// <returns>True if left is greater than or equal to right; otherwise, false.</returns>
public static bool operator >=(AngleSingle left, AngleSingle right) public static bool operator >=( AngleSingle left, AngleSingle right )
{ {
return left.radians >= right.radians; return left.radians >= right.radians;
} }
@ -568,7 +568,7 @@ namespace math
/// </summary> /// </summary>
/// <param name="value">A math.AngleSingle object.</param> /// <param name="value">A math.AngleSingle object.</param>
/// <returns>The value of the value parameter.</returns> /// <returns>The value of the value parameter.</returns>
public static AngleSingle operator +(AngleSingle value) public static AngleSingle operator +( AngleSingle value )
{ {
return value; return value;
} }
@ -578,9 +578,9 @@ namespace math
/// </summary> /// </summary>
/// <param name="value">A math.AngleSingle object.</param> /// <param name="value">A math.AngleSingle object.</param>
/// <returns>The negated value of the value parameter.</returns> /// <returns>The negated value of the value parameter.</returns>
public static AngleSingle operator -(AngleSingle value) public static AngleSingle operator -( AngleSingle value )
{ {
return new AngleSingle(-value.radians, AngleType.Radian); return new AngleSingle( -value.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -589,9 +589,9 @@ namespace math
/// <param name="left">The first object to add.</param> /// <param name="left">The first object to add.</param>
/// <param name="right">The second object to add.</param> /// <param name="right">The second object to add.</param>
/// <returns>The value of the two objects added together.</returns> /// <returns>The value of the two objects added together.</returns>
public static AngleSingle operator +(AngleSingle left, AngleSingle right) public static AngleSingle operator +( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians + right.radians, AngleType.Radian); return new AngleSingle( left.radians + right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -600,9 +600,9 @@ namespace math
/// <param name="left">The first object to subtract</param> /// <param name="left">The first object to subtract</param>
/// <param name="right">The second object to subtract.</param> /// <param name="right">The second object to subtract.</param>
/// <returns>The value of the two objects subtracted.</returns> /// <returns>The value of the two objects subtracted.</returns>
public static AngleSingle operator -(AngleSingle left, AngleSingle right) public static AngleSingle operator -( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians - right.radians, AngleType.Radian); return new AngleSingle( left.radians - right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -611,9 +611,9 @@ namespace math
/// <param name="left">The first object to multiply.</param> /// <param name="left">The first object to multiply.</param>
/// <param name="right">The second object to multiply.</param> /// <param name="right">The second object to multiply.</param>
/// <returns>The value of the two objects multiplied together.</returns> /// <returns>The value of the two objects multiplied together.</returns>
public static AngleSingle operator *(AngleSingle left, AngleSingle right) public static AngleSingle operator *( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians * right.radians, AngleType.Radian); return new AngleSingle( left.radians * right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -622,9 +622,9 @@ namespace math
/// <param name="left">The numerator object.</param> /// <param name="left">The numerator object.</param>
/// <param name="right">The denominator object.</param> /// <param name="right">The denominator object.</param>
/// <returns>The value of the two objects divided.</returns> /// <returns>The value of the two objects divided.</returns>
public static AngleSingle operator /(AngleSingle left, AngleSingle right) public static AngleSingle operator /( AngleSingle left, AngleSingle right )
{ {
return new AngleSingle(left.radians / right.radians, AngleType.Radian); return new AngleSingle( left.radians / right.radians, AngleType.Radian );
} }
/// <summary> /// <summary>
@ -640,20 +640,20 @@ namespace math
/// to the other. If the value is greater than zero, the current instance is /// to the other. If the value is greater than zero, the current instance is
/// greater than the other. /// greater than the other.
/// </returns> /// </returns>
public int CompareTo(object other) public int CompareTo( object other )
{ {
if (other == null) if( other == null )
return 1; return 1;
if (!(other is AngleSingle)) if( !( other is AngleSingle ) )
throw new ArgumentException("Argument must be of type Angle.", "other"); throw new ArgumentException( "Argument must be of type Angle.", "other" );
float radians = ((AngleSingle)other).radians; float radians = ((AngleSingle)other).radians;
if (this.radians > radians) if( this.radians > radians )
return 1; return 1;
if (this.radians < radians) if( this.radians < radians )
return -1; return -1;
return 0; return 0;
@ -672,12 +672,12 @@ namespace math
/// to the other. If the value is greater than zero, the current instance is /// to the other. If the value is greater than zero, the current instance is
/// greater than the other. /// greater than the other.
/// </returns> /// </returns>
public int CompareTo(AngleSingle other) public int CompareTo( AngleSingle other )
{ {
if (this.radians > other.radians) if( this.radians > other.radians )
return 1; return 1;
if (this.radians < other.radians) if( this.radians < other.radians )
return -1; return -1;
return 0; return 0;
@ -692,7 +692,7 @@ namespace math
/// Returns true if this math.AngleSingle object and another have the same value; /// Returns true if this math.AngleSingle object and another have the same value;
/// otherwise, false. /// otherwise, false.
/// </returns> /// </returns>
public bool Equals(AngleSingle other) public bool Equals( AngleSingle other )
{ {
return this == other; return this == other;
} }
@ -705,7 +705,7 @@ namespace math
/// </returns> /// </returns>
public override string ToString() public override string ToString()
{ {
return string.Format(CultureInfo.CurrentCulture, MathUtil.RadiansToDegrees(radians).ToString("0.##°")); return string.Format( CultureInfo.CurrentCulture, MathUtil.RadiansToDegrees( radians ).ToString( "0.##°" ) );
} }
/// <summary> /// <summary>
@ -715,12 +715,12 @@ namespace math
/// <returns> /// <returns>
/// A <see cref="string"/> that represents this instance. /// A <see cref="string"/> that represents this instance.
/// </returns> /// </returns>
public string ToString(string format) public string ToString( string format )
{ {
if (format == null) if( format == null )
return ToString(); return ToString();
return string.Format(CultureInfo.CurrentCulture, $"{MathUtil.RadiansToDegrees(radians).ToString(format, CultureInfo.CurrentCulture)}°" ); return string.Format( CultureInfo.CurrentCulture, $"{MathUtil.RadiansToDegrees( radians ).ToString( format, CultureInfo.CurrentCulture )}°" );
} }
/// <summary> /// <summary>
@ -730,9 +730,9 @@ namespace math
/// <returns> /// <returns>
/// A <see cref="string"/> that represents this instance. /// A <see cref="string"/> that represents this instance.
/// </returns> /// </returns>
public string ToString(IFormatProvider formatProvider) public string ToString( IFormatProvider formatProvider )
{ {
return string.Format(formatProvider, MathUtil.RadiansToDegrees(radians).ToString("0.##°")); return string.Format( formatProvider, MathUtil.RadiansToDegrees( radians ).ToString( "0.##°" ) );
} }
/// <summary> /// <summary>
@ -743,12 +743,12 @@ namespace math
/// <returns> /// <returns>
/// A <see cref="string"/> that represents this instance. /// A <see cref="string"/> that represents this instance.
/// </returns> /// </returns>
public string ToString(string format, IFormatProvider formatProvider) public string ToString( string format, IFormatProvider formatProvider )
{ {
if (format == null) if( format == null )
return ToString(formatProvider); return ToString( formatProvider );
return string.Format(formatProvider, "{0}°", MathUtil.RadiansToDegrees(radians).ToString(format, CultureInfo.CurrentCulture)); return string.Format( formatProvider, "{0}°", MathUtil.RadiansToDegrees( radians ).ToString( format, CultureInfo.CurrentCulture ) );
} }
/// <summary> /// <summary>
@ -757,7 +757,7 @@ namespace math
/// <returns>A 32-bit signed integer hash code.</returns> /// <returns>A 32-bit signed integer hash code.</returns>
public override int GetHashCode() public override int GetHashCode()
{ {
return (int)(BitConverter.DoubleToInt64Bits(radians) % int.MaxValue); return (int)( BitConverter.DoubleToInt64Bits( radians ) % int.MaxValue );
} }
/// <summary> /// <summary>
@ -771,9 +771,9 @@ namespace math
/// its value is equal to the value of the current math.Angle /// its value is equal to the value of the current math.Angle
/// object; otherwise, false. /// object; otherwise, false.
/// </returns> /// </returns>
public override bool Equals(object obj) public override bool Equals( object obj )
{ {
return (obj is AngleSingle) && (this == (AngleSingle)obj); return ( obj is AngleSingle ) && ( this == (AngleSingle)obj );
} }
} }
} }

View File

@ -10,7 +10,7 @@ namespace mod
{ {
[Serializable] [Serializable]
public class Config : lib.Config public class Config: lib.Config
{ {
public String name = "Generic"; public String name = "Generic";
} }
@ -33,13 +33,13 @@ namespace mod
[Serializable] [Serializable]
public class FluidConfig : Config public class FluidConfig: Config
{ {
public String type = "none"; public String type = "none";
} }
public class FluidBase : Base public class FluidBase: Base
{ {
public new FluidConfig Cfg { get { return (FluidConfig)base.Cfg; } } public new FluidConfig Cfg { get { return (FluidConfig)base.Cfg; } }
@ -65,7 +65,7 @@ namespace mod
[Serializable] [Serializable]
public class SystemConfig : Config public class SystemConfig: Config
{ {
public String type = "none"; public String type = "none";
} }

View File

@ -28,7 +28,7 @@ namespace lib
} }
public class NewEveryCall<T> : ISerDes<T> where T : IFormatter, new() public class NewEveryCall<T>: ISerDes<T> where T : IFormatter, new()
{ {
public T getInstance() public T getInstance()
{ {
@ -75,7 +75,7 @@ namespace lib
} }
catch( System.Xml.XmlException ex ) catch( System.Xml.XmlException ex )
{ {
lib.Log.error( $"Outer Exception {ex.Message}" ); log.error( $"Outer Exception {ex.Message}" );
} }
return obj; return obj;
@ -92,8 +92,8 @@ namespace lib
formatter.Serialize( ms, obj ); formatter.Serialize( ms, obj );
//var str = System.Text.Encoding.Default.GetString( mm_buffer, 0, (int)ms.Position ); //var str = System.Text.Encoding.Default.GetString( mm_buffer, 0, (int)ms.Position );
//lib.Log.info( $"Sent data {str} of length {ms.Position}" ); //log.info( $"Sent data {str} of length {ms.Position}" );
//lib.Log.info( $"Sent {obj}" ); //log.info( $"Sent {obj}" );
byte[] byteSize = BitConverter.GetBytes( (uint)ms.Position ); byte[] byteSize = BitConverter.GetBytes( (uint)ms.Position );
m_streamNet.Write( byteSize, 0, 4 ); m_streamNet.Write( byteSize, 0, 4 );
@ -103,7 +103,7 @@ namespace lib
} }
catch( Exception e ) catch( Exception e )
{ {
lib.Log.warn( $"Exception sending obj {obj} of {e}" ); log.warn( $"Exception sending obj {obj} of {e}" );
throw; throw;
} }
} }

View File

@ -43,14 +43,14 @@ namespace lib.Net
}; };
[Serializable] [Serializable]
public class CreateEntity : Admin public class CreateEntity: Admin
{ {
} }
[Serializable] [Serializable]
public class MoveEntity : Admin public class MoveEntity: Admin
{ {
} }
@ -69,7 +69,7 @@ namespace lib.Net
[Serializable] [Serializable]
public class EntityPos : EntityBase public class EntityPos: EntityBase
{ {
public EntityPos( int id, float x, float y, float z ) : public EntityPos( int id, float x, float y, float z ) :
base( id ) base( id )
@ -85,7 +85,7 @@ namespace lib.Net
} }
[Serializable] [Serializable]
public class EntityDesc : EntityBase public class EntityDesc: EntityBase
{ {
public EntityDesc( int id ) : public EntityDesc( int id ) :
base( id ) base( id )

View File

@ -14,7 +14,7 @@ using System.Threading.Tasks;
static public class scr static public class refl
{ {
public class PredEnumerator public class PredEnumerator
@ -30,7 +30,7 @@ static public class scr
} }
} }
public class PredEnumerator<T> : PredEnumerator, IEnumerator<T> public class PredEnumerator<T>: PredEnumerator, IEnumerator<T>
{ {
public T Current => m_en.Current; public T Current => m_en.Current;
@ -105,7 +105,7 @@ static public class scr
} }
public class PredEnumerable<T> : IEnumerable<T> public class PredEnumerable<T>: IEnumerable<T>
{ {
public PredEnumerable( PredEnumerator<T> en ) public PredEnumerable( PredEnumerator<T> en )
{ {
@ -132,7 +132,7 @@ static public class scr
BindingFlags.DeclaredOnly | BindingFlags.DeclaredOnly |
BindingFlags.NonPublic | BindingFlags.NonPublic |
BindingFlags.Public | BindingFlags.Public |
BindingFlags.Instance); BindingFlags.Instance );
var en = PredEnumerator.Create<FieldInfo>( fieldArr.AsEnumerable<FieldInfo>(), fa => fa.GetCustomAttribute( typeof( NonSerializedAttribute ) ) == null ); var en = PredEnumerator.Create<FieldInfo>( fieldArr.AsEnumerable<FieldInfo>(), fa => fa.GetCustomAttribute( typeof( NonSerializedAttribute ) ) == null );

View File

@ -16,7 +16,7 @@ namespace res
[Serializable] [Serializable]
public class Ref : lib.I_Serialize public class Ref: lib.I_Serialize
{ {
public string filename { get { return m_filename; } } public string filename { get { return m_filename; } }
@ -51,7 +51,7 @@ namespace res
} }
[Serializable] [Serializable]
public class Ref<T> : Ref where T : class public class Ref<T>: Ref where T : class
{ {
public T res => m_res != null ? m_res : m_res = Mgr.load<T>( filename ); public T res => m_res != null ? m_res : m_res = Mgr.load<T>( filename );
@ -114,7 +114,7 @@ namespace res
} }
class LoadHolder<T> : LoadHolder class LoadHolder<T>: LoadHolder
{ {
public LoadHolder( Load<T> _dlgtLoad ) public LoadHolder( Load<T> _dlgtLoad )
{ {
@ -247,10 +247,10 @@ namespace res
if( wr.TryGetTarget( out var v ) ) if( wr.TryGetTarget( out var v ) )
return v; return v;
lib.Log.info( $"{filename} was in cache, but its been dropped, reloading." ); log.info( $"{filename} was in cache, but its been dropped, reloading." );
} }
lib.Log.warn( $"Block Loading {filename}." ); log.warn( $"Block Loading {filename}." );
var newV = actualLoad<T>( filename ); var newV = actualLoad<T>( filename );
@ -268,7 +268,7 @@ namespace res
if( wr.TryGetTarget( out var v ) ) if( wr.TryGetTarget( out var v ) )
return v; return v;
lib.Log.error( $"{filename} was in cache, but its been dropped, reloading." ); log.error( $"{filename} was in cache, but its been dropped, reloading." );
} }
} }
@ -291,19 +291,19 @@ namespace res
//Done loading //Done loading
if( !ImmutableInterlocked.TryRemove( ref s_loading, filename, out var oldEvt ) ) if( !ImmutableInterlocked.TryRemove( ref s_loading, filename, out var oldEvt ) )
{ {
lib.Log.error( $"Error removing loading event for {filename}" ); log.error( $"Error removing loading event for {filename}" );
} }
if( alreadyAdded ) if( alreadyAdded )
{ {
lib.Log.error( $"Key {filename} already existed, though it shouldnt." ); log.error( $"Key {filename} already existed, though it shouldnt." );
} }
return v; return v;
} }
else else
{ {
lib.Log.error( $"Loader could not be found for type {typeof( T )}" ); log.error( $"Loader could not be found for type {typeof( T )}" );
return ResCache<T>.s_default; return ResCache<T>.s_default;
} }

View File

@ -11,7 +11,7 @@ using System.Security.Permissions;
namespace lib namespace lib
{ {
[Serializable] [Serializable]
public class SerializableDictionary<TKey, TVal> : Dictionary<TKey, TVal>, IXmlSerializable, ISerializable public class SerializableDictionary<TKey, TVal>: Dictionary<TKey, TVal>, IXmlSerializable, ISerializable
{ {
#region Constants #region Constants
private const string DictionaryNodeName = "Dictionary"; private const string DictionaryNodeName = "Dictionary";

View File

@ -12,7 +12,7 @@ namespace lib
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public class VersionFormatter : IFormatter public class VersionFormatter: IFormatter
{ {
public enum ETypes public enum ETypes
{ {

View File

@ -17,7 +17,7 @@ using System.Reflection;
namespace lib namespace lib
{ {
//Old, use 2 now. //Old, use 2 now.
class XmlFormatter : IFormatter class XmlFormatter: IFormatter
{ {
StreamingContext m_context; StreamingContext m_context;
//SerializationMode m_mode; //SerializationMode m_mode;
@ -230,7 +230,7 @@ namespace lib
} }
else //More than 1. else //More than 1.
{ {
//Log.error( "Too many fields named the same thing" ); //log.error( "Too many fields named the same thing" );
} }
} }
} }

View File

@ -29,12 +29,12 @@ namespace lib
} }
public class XmlFormatter2Cfg : Config public class XmlFormatter2Cfg: Config
{ {
public readonly Datastructure datastructure = Datastructure.Full; public readonly Datastructure datastructure = Datastructure.Full;
} }
public class XmlFormatter2 : IFormatter public class XmlFormatter2: IFormatter
{ {
public StreamingContext Context { get; set; } public StreamingContext Context { get; set; }
@ -95,10 +95,10 @@ namespace lib
{ {
//lib.log.info( "DeserializeKnownType( Stream stream, Type t ) {0} {1}", m_rndVal, m_alreadySerialized.Count ); //lib.log.info( "DeserializeKnownType( Stream stream, Type t ) {0} {1}", m_rndVal, m_alreadySerialized.Count );
XmlTextReader reader = new XmlTextReader( stream ); XmlTextReader reader = new XmlTextReader(stream);
//reader.Settings = System.Text.Encoding.ASCII; //reader.Settings = System.Text.Encoding.ASCII;
object obj = Deserialize( reader, t ); object obj = Deserialize(reader, t);
//lib.log.info( "DeserializeKnownType END( Stream stream, Type t ) {0} {1}", m_rndVal, m_alreadySerialized.Count ); //lib.log.info( "DeserializeKnownType END( Stream stream, Type t ) {0} {1}", m_rndVal, m_alreadySerialized.Count );
return obj; return obj;
} }
@ -128,7 +128,7 @@ namespace lib
{ {
//lib.log.info( "object Deserialize( XmlElement elem ) {0} {1}", m_rndVal, m_alreadySerialized.Count ); //lib.log.info( "object Deserialize( XmlElement elem ) {0} {1}", m_rndVal, m_alreadySerialized.Count );
string typename = elem.HasAttribute( "t" ) ? elem.GetAttribute( "t" ) : elem.Name; string typename = elem.HasAttribute("t") ? elem.GetAttribute("t") : elem.Name;
return Deserialize( elem, typename ); return Deserialize( elem, typename );
} }
@ -160,7 +160,7 @@ namespace lib
private object Deserialize( XmlElement elem, Type type, object enclosing = null ) private object Deserialize( XmlElement elem, Type type, object enclosing = null )
{ {
TypeCode typeCode = Type.GetTypeCode( type ); TypeCode typeCode = Type.GetTypeCode(type);
if( typeCode != TypeCode.Object ) if( typeCode != TypeCode.Object )
{ {
@ -170,7 +170,7 @@ namespace lib
{ {
if( !type.IsArray ) if( !type.IsArray )
{ {
object obj = DeserializeObject( elem, type ); object obj = DeserializeObject(elem, type);
if( obj is I_Serialize ) if( obj is I_Serialize )
{ {
@ -193,7 +193,7 @@ namespace lib
{ {
mm_types[0] = t; mm_types[0] = t;
var fn = GetType().GetMethod( "GetDefaultGeneric" ).MakeGenericMethod( mm_types ); var fn = GetType().GetMethod("GetDefaultGeneric").MakeGenericMethod(mm_types);
return fn.Invoke( this, null ); return fn.Invoke( this, null );
} }
@ -205,7 +205,7 @@ namespace lib
private object DeserializeConcrete( XmlElement elem, Type type ) private object DeserializeConcrete( XmlElement elem, Type type )
{ {
string val = elem.GetAttribute( "v" ); string val = elem.GetAttribute("v");
if( !type.IsEnum ) if( !type.IsEnum )
{ {
@ -244,7 +244,7 @@ namespace lib
foreach( Assembly a in ass ) foreach( Assembly a in ass )
{ {
Type t = a.GetType( shortname ); Type t = a.GetType(shortname);
if( t != null ) if( t != null )
{ {
@ -255,25 +255,25 @@ namespace lib
return null; return null;
} }
private Type[] mm_consType = new Type[ 2 ]; private Type[] mm_consType = new Type[2];
private object[] mm_args = new object[ 2 ]; private object[] mm_args = new object[2];
private object DeserializeObject( XmlElement elem, Type type ) private object DeserializeObject( XmlElement elem, Type type )
{ {
string refString = elem.GetAttribute( "ref" ); string refString = elem.GetAttribute("ref");
int refInt = refString.Length > 0 ? Convert.ToInt32( refString ) : -1; int refInt = refString.Length > 0 ? Convert.ToInt32(refString) : -1;
var finalType = type; var finalType = type;
if( elem.HasAttribute( "t" ) ) if( elem.HasAttribute( "t" ) )
{ {
var typename = elem.GetAttribute( "t" ); var typename = elem.GetAttribute("t");
finalType = FindType( typename ); finalType = FindType( typename );
if( finalType == null ) if( finalType == null )
finalType = type; finalType = type;
} }
object obj = createObject( finalType, refInt ); object obj = createObject(finalType, refInt);
if( obj is IList ) if( obj is IList )
{ {
@ -282,7 +282,7 @@ namespace lib
return DeserializeList( elem, type, list ); return DeserializeList( elem, type, list );
} }
Type typeISerializable = typeof( ISerializable ); Type typeISerializable = typeof(ISerializable);
if( obj is ISerializable ) // type.IsSubclassOf( typeISerializable ) ) if( obj is ISerializable ) // type.IsSubclassOf( typeISerializable ) )
{ {
@ -290,7 +290,7 @@ namespace lib
//ISerializable ser = obj as ISerializable; //ISerializable ser = obj as ISerializable;
var serInfo = new SerializationInfo( finalType, new FormatterConverter() ); var serInfo = new SerializationInfo(finalType, new FormatterConverter());
//var serInfoForTypes = new SerializationInfo( type, new FormatterConverter() ); //var serInfoForTypes = new SerializationInfo( type, new FormatterConverter() );
@ -302,13 +302,13 @@ namespace lib
String name = node.Name; String name = node.Name;
String childType = node.GetAttribute( "t" ); String childType = node.GetAttribute("t");
name = scr.TypeToIdentifier( name ); name = refl.TypeToIdentifier( name );
XmlElement childElem = getNamedChild( allChildren, name ); XmlElement childElem = getNamedChild(allChildren, name);
var des = Deserialize( childElem, childType ); var des = Deserialize(childElem, childType);
serInfo.AddValue( name, des, des.GetType() ); serInfo.AddValue( name, des, des.GetType() );
} }
@ -323,7 +323,7 @@ namespace lib
mm_consType[0] = typeof( SerializationInfo ); mm_consType[0] = typeof( SerializationInfo );
mm_consType[1] = typeof( StreamingContext ); mm_consType[1] = typeof( StreamingContext );
ConstructorInfo serCons = finalType.GetConstructor( BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, mm_consType, null ); ConstructorInfo serCons = finalType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, mm_consType, null);
mm_args[0] = serInfo; mm_args[0] = serInfo;
mm_args[1] = Context; mm_args[1] = Context;
@ -343,7 +343,7 @@ namespace lib
{ {
String name = serMember.Name; String name = serMember.Name;
name = scr.TypeToIdentifier( name ); name = refl.TypeToIdentifier( name );
XmlElement childElem = getNamedChild( allChildren, name ); XmlElement childElem = getNamedChild( allChildren, name );
@ -355,7 +355,7 @@ namespace lib
{ {
XmlNodeList allChildren = elem.ChildNodes; XmlNodeList allChildren = elem.ChildNodes;
var fields = scr.GetAllFields( type ); var fields = refl.GetAllFields(type);
//MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context ); //MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context );
@ -364,20 +364,20 @@ namespace lib
String name = childFi.Name; String name = childFi.Name;
name = scr.TypeToIdentifier( name ); name = refl.TypeToIdentifier( name );
XmlElement childElem = getNamedChild( allChildren, name ); XmlElement childElem = getNamedChild(allChildren, name);
if( childElem != null ) if( childElem != null )
{ {
object childObj = Deserialize( childElem, childFi.FieldType, obj ); object childObj = Deserialize(childElem, childFi.FieldType, obj);
childFi.SetValue( obj, childObj ); childFi.SetValue( obj, childObj );
} }
else if( fields.Count == 1 ) else if( fields.Count == 1 )
{ {
object childObj = Deserialize( elem, childFi.FieldType, obj ); object childObj = Deserialize(elem, childFi.FieldType, obj);
childFi.SetValue( obj, childObj ); childFi.SetValue( obj, childObj );
} }
@ -403,7 +403,7 @@ namespace lib
{ {
if( arrNodeList.Item( i ) is XmlElement ) if( arrNodeList.Item( i ) is XmlElement )
{ {
XmlElement arrElem = (XmlElement)arrNodeList.Item( i ); XmlElement arrElem = (XmlElement)arrNodeList.Item(i);
list.Add( Deserialize( arrElem, genT[0] ) ); list.Add( Deserialize( arrElem, genT[0] ) );
} }
@ -416,20 +416,20 @@ namespace lib
{ {
Type typeElem = type.GetElementType(); Type typeElem = type.GetElementType();
string refString = elem.GetAttribute( "ref" ); string refString = elem.GetAttribute("ref");
int refInt = refString.Length > 0 ? Convert.ToInt32( refString ) : -1; int refInt = refString.Length > 0 ? Convert.ToInt32(refString) : -1;
XmlNodeList arrNodeList = elem.ChildNodes; XmlNodeList arrNodeList = elem.ChildNodes;
int length = arrNodeList.Count; int length = arrNodeList.Count;
Array arr = createArray( typeElem, refInt, length ); Array arr = createArray(typeElem, refInt, length);
for( int i = 0; i < arr.Length; ++i ) for( int i = 0; i < arr.Length; ++i )
{ {
if( arrNodeList.Item( i ) is XmlElement ) if( arrNodeList.Item( i ) is XmlElement )
{ {
XmlElement arrElem = (XmlElement)arrNodeList.Item( i ); XmlElement arrElem = (XmlElement)arrNodeList.Item(i);
arr.SetValue( Deserialize( arrElem, typeElem ), i ); arr.SetValue( Deserialize( arrElem, typeElem ), i );
} }
@ -440,14 +440,14 @@ namespace lib
private object createObject( string typename, int refInt ) private object createObject( string typename, int refInt )
{ {
Type type = Type.GetType( typename ); Type type = Type.GetType(typename);
return createObject( type, refInt ); return createObject( type, refInt );
} }
private object createObject( Type type, int refInt ) private object createObject( Type type, int refInt )
{ {
TypeCode tc = Type.GetTypeCode( type ); TypeCode tc = Type.GetTypeCode(type);
if( m_cfg.datastructure == Datastructure.Full && refInt > 0 && m_alreadySerialized.ContainsKey( refInt ) ) if( m_cfg.datastructure == Datastructure.Full && refInt > 0 && m_alreadySerialized.ContainsKey( refInt ) )
{ {
@ -472,14 +472,14 @@ namespace lib
} }
catch( Exception exInner ) catch( Exception exInner )
{ {
lib.Log.error( $"Got exception {exInner.Message} trying to make an uninitialized object" ); log.error( $"Got exception {exInner.Message} trying to make an uninitialized object" );
} }
} }
if( obj == null ) if( obj == null )
{ {
lib.Log.warn( $"Could not create object of type {type.Name}" ); log.warn( $"Could not create object of type {type.Name}" );
return obj; return obj;
} }
@ -495,14 +495,14 @@ namespace lib
private Array createArray( string elemTypename, int refInt, int length ) private Array createArray( string elemTypename, int refInt, int length )
{ {
Type elemType = Type.GetType( elemTypename ); Type elemType = Type.GetType(elemTypename);
return createArray( elemType, refInt, length ); return createArray( elemType, refInt, length );
} }
private Array createArray( Type elemType, int refInt, int length ) private Array createArray( Type elemType, int refInt, int length )
{ {
TypeCode elemTC = Type.GetTypeCode( elemType ); TypeCode elemTC = Type.GetTypeCode(elemType);
if( m_cfg.datastructure == Datastructure.Full && refInt > 0 && m_alreadySerialized.ContainsKey( refInt ) ) if( m_cfg.datastructure == Datastructure.Full && refInt > 0 && m_alreadySerialized.ContainsKey( refInt ) )
{ {
@ -510,7 +510,7 @@ namespace lib
} }
else else
{ {
Array arr = Array.CreateInstance( elemType, length ) ; Array arr = Array.CreateInstance(elemType, length);
if( m_cfg.datastructure == Datastructure.Full ) if( m_cfg.datastructure == Datastructure.Full )
{ {
@ -545,7 +545,7 @@ namespace lib
m_alreadySerialized.Clear(); m_alreadySerialized.Clear();
m_objectID = new ObjectIDGenerator(); m_objectID = new ObjectIDGenerator();
XmlTextWriter writer = new XmlTextWriter( stream, System.Text.Encoding.ASCII ); XmlTextWriter writer = new XmlTextWriter(stream, System.Text.Encoding.ASCII);
writer.Formatting = Formatting.Indented; writer.Formatting = Formatting.Indented;
@ -573,7 +573,7 @@ namespace lib
{ {
Type type = root.GetType(); Type type = root.GetType();
TypeCode typeCode = Type.GetTypeCode( type ); TypeCode typeCode = Type.GetTypeCode(type);
if( typeCode != TypeCode.Object ) if( typeCode != TypeCode.Object )
{ {
@ -626,7 +626,7 @@ namespace lib
bool first; bool first;
long refInt = m_objectID.GetId( root, out first ); long refInt = m_objectID.GetId(root, out first);
if( m_cfg.datastructure == Datastructure.Full ) if( m_cfg.datastructure == Datastructure.Full )
{ {
@ -644,13 +644,13 @@ namespace lib
Type type = root.GetType(); Type type = root.GetType();
//* //*
Type typeISerializable = typeof( ISerializable ); Type typeISerializable = typeof(ISerializable);
if( root is ISerializable ) // type.IsSubclassOf( typeISerializable ) ) if( root is ISerializable ) // type.IsSubclassOf( typeISerializable ) )
{ {
ISerializable ser = root as ISerializable; ISerializable ser = root as ISerializable;
var serInfo = new SerializationInfo( type, new FormatterConverter() ); var serInfo = new SerializationInfo(type, new FormatterConverter());
ser.GetObjectData( serInfo, Context ); ser.GetObjectData( serInfo, Context );
@ -660,7 +660,7 @@ namespace lib
{ {
String name = serMember.Name; String name = serMember.Name;
name = scr.TypeToIdentifier( name ); name = refl.TypeToIdentifier( name );
Serialize( writer, serMember.Value, name, true ); Serialize( writer, serMember.Value, name, true );
} }
@ -672,14 +672,14 @@ namespace lib
else else
//*/ //*/
{ {
var fields = scr.GetAllFields( type ); var fields = refl.GetAllFields(type);
//MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context ); //MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context );
foreach( var childFi in fields ) foreach( var childFi in fields )
{ {
object[] objs = childFi.GetCustomAttributes( typeof( NonSerializedAttribute ), true ); object[] objs = childFi.GetCustomAttributes(typeof(NonSerializedAttribute), true);
if( objs.Length > 0 ) if( objs.Length > 0 )
{ {
@ -688,7 +688,7 @@ namespace lib
String name = childFi.Name; String name = childFi.Name;
name = scr.TypeToIdentifier( name ); name = refl.TypeToIdentifier( name );
Serialize( writer, childFi.GetValue( root ), name, false ); Serialize( writer, childFi.GetValue( root ), name, false );
} }
@ -708,7 +708,7 @@ namespace lib
bool first; bool first;
long refInt = m_objectID.GetId( root, out first ); long refInt = m_objectID.GetId(root, out first);
if( m_cfg.datastructure == Datastructure.Full ) if( m_cfg.datastructure == Datastructure.Full )
{ {

View File

@ -6,7 +6,7 @@ using System.Threading;
namespace lib namespace lib
{ {
public class MicroStopwatch : System.Diagnostics.Stopwatch public class MicroStopwatch: System.Diagnostics.Stopwatch
{ {
readonly double _microSecPerTick readonly double _microSecPerTick
= 1000000D / System.Diagnostics.Stopwatch.Frequency; = 1000000D / System.Diagnostics.Stopwatch.Frequency;
@ -189,7 +189,7 @@ namespace lib
/// <summary> /// <summary>
/// MicroTimer Event Argument class /// MicroTimer Event Argument class
/// </summary> /// </summary>
public class MicroTimerEventArgs : EventArgs public class MicroTimerEventArgs: EventArgs
{ {
// Simple counter, number times timed event (callback function) executed // Simple counter, number times timed event (callback function) executed
public int TimerCount { get; private set; } public int TimerCount { get; private set; }