Various fixes
This commit is contained in:
parent
4c02eaea75
commit
0e98d66d06
12
Conn.cs
12
Conn.cs
@ -52,9 +52,9 @@ public class Conn
|
|||||||
{
|
{
|
||||||
obj = formatter.Deserialize( stream );
|
obj = formatter.Deserialize( stream );
|
||||||
}
|
}
|
||||||
catch( System.Xml.XmlException e )
|
catch( System.Xml.XmlException ex )
|
||||||
{
|
{
|
||||||
lib.Log.error( "Outer Exception {0}", e.ToString() );
|
lib.Log.error( $"Outer Exception {ex.Message}" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
@ -70,11 +70,11 @@ public class Conn
|
|||||||
var ms = new MemoryStream( 1024 );
|
var ms = new MemoryStream( 1024 );
|
||||||
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 {0} of length {1}", str, ms.Position );
|
//lib.Log.info( $"Sent data {str} of length {ms.Position}" );
|
||||||
//lib.Log.info( "Sent {0}", obj );
|
//lib.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 );
|
||||||
m_streamNet.Write( ms.GetBuffer(), 0, (int)ms.Position );
|
m_streamNet.Write( ms.GetBuffer(), 0, (int)ms.Position );
|
||||||
|
|
||||||
|
|||||||
10
Helpers.cs
10
Helpers.cs
@ -147,28 +147,28 @@ namespace lib
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.error( String.Format( "No attributes in node while loading file {0}", filename ) );
|
Log.error( String.Format( $"No attributes in node while loading file {filename}" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.error( String.Format( "Incorrect key {0} found while loading file {1}", node.Name, 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 {0}", 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 {0}", 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 {0}", filename ) );
|
Log.error( String.Format( $"No dictionary element found while loading file {filename}" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
Log.cs
6
Log.cs
@ -235,7 +235,7 @@ namespace lib
|
|||||||
{
|
{
|
||||||
m_delegates.Add( cb );
|
m_delegates.Add( cb );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private void writeFileAndLine( StackTrace st )
|
private void writeFileAndLine( StackTrace st )
|
||||||
{
|
{
|
||||||
@ -244,7 +244,7 @@ namespace lib
|
|||||||
string srcFile = frame.GetFileName();
|
string srcFile = frame.GetFileName();
|
||||||
string srcLine = frame.GetFileLineNumber().Tostring();
|
string srcLine = frame.GetFileLineNumber().Tostring();
|
||||||
|
|
||||||
Console.WriteLine( "{0} ({1}):", srcFile, srcLine );
|
Console.WriteLine( $"{srcFile} ({srcLine}):" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeStack( StackTrace st )
|
private void writeStack( StackTrace st )
|
||||||
@ -258,7 +258,7 @@ namespace lib
|
|||||||
|
|
||||||
if( srcFile != null )
|
if( srcFile != null )
|
||||||
{
|
{
|
||||||
Console.WriteLine( "{0} ({1})", srcFile, srcLine );
|
Console.WriteLine( $"{srcFile} ({srcLine})" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
Scr.cs
11
Scr.cs
@ -200,4 +200,15 @@ static public class scr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//SLOW
|
||||||
|
static public string TypeToIdentifier( string typename )
|
||||||
|
{
|
||||||
|
return typename.Replace( '<', '_' ).Replace( '>', '_' ).Replace( ',', '_' ).Replace( ' ', '_' ).Replace( '.', '_' ).Replace( '+', '_' ).Replace( '[', '_' ).Replace( ']', '_' ).Replace( '$', '_' ).Replace( ':', '_' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ namespace lib
|
|||||||
{
|
{
|
||||||
int itemCount = info.GetInt32("ItemCount");
|
int itemCount = info.GetInt32("ItemCount");
|
||||||
for (int i = 0; i < itemCount; i++) {
|
for (int i = 0; i < itemCount; i++) {
|
||||||
KeyValuePair<TKey, TVal> kvp = (KeyValuePair<TKey, TVal>)info.GetValue(String.Format("Item{0}", i), typeof(KeyValuePair<TKey, TVal>));
|
KeyValuePair<TKey, TVal> kvp = (KeyValuePair<TKey, TVal>)info.GetValue(String.Format( $"Item{i}" ), typeof(KeyValuePair<TKey, TVal>));
|
||||||
this.Add(kvp.Key, kvp.Value);
|
this.Add(kvp.Key, kvp.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ namespace lib
|
|||||||
info.AddValue("ItemCount", this.Count);
|
info.AddValue("ItemCount", this.Count);
|
||||||
int itemIdx = 0;
|
int itemIdx = 0;
|
||||||
foreach (KeyValuePair<TKey, TVal> kvp in this) {
|
foreach (KeyValuePair<TKey, TVal> kvp in this) {
|
||||||
info.AddValue(String.Format("Item{0}", itemIdx), kvp, typeof(KeyValuePair<TKey, TVal>));
|
info.AddValue(String.Format( $"Item{itemIdx}" ), kvp, typeof(KeyValuePair<TKey, TVal>));
|
||||||
itemIdx++;
|
itemIdx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,7 @@ namespace lib
|
|||||||
{
|
{
|
||||||
if( !Directory.Exists( path ) )
|
if( !Directory.Exists( path ) )
|
||||||
{
|
{
|
||||||
lib.Log.info( "Creating directory {0}", path );
|
lib.Log.info( $"Creating directory {path}" );
|
||||||
Directory.CreateDirectory( path );
|
Directory.CreateDirectory( path );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -271,8 +271,7 @@ public class XmlFormatter2 : IFormatter
|
|||||||
|
|
||||||
String childType = node.GetAttribute( "t" );
|
String childType = node.GetAttribute( "t" );
|
||||||
|
|
||||||
name = name.Replace( '+', '-' );
|
name = scr.TypeToIdentifier( name );
|
||||||
name = name.Replace( '`', '_' );
|
|
||||||
|
|
||||||
XmlElement childElem = getNamedChild( allChildren, name );
|
XmlElement childElem = getNamedChild( allChildren, name );
|
||||||
|
|
||||||
@ -302,40 +301,39 @@ public class XmlFormatter2 : IFormatter
|
|||||||
objUnOnDeser.OnDeserialization( objUnOnDeser );
|
objUnOnDeser.OnDeserialization( objUnOnDeser );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ser.GetObjectData( serInfo, Context );
|
ser.GetObjectData( serInfo, Context );
|
||||||
|
|
||||||
//var serEnum = ;
|
//var serEnum = ;
|
||||||
|
|
||||||
foreach( var serMember in serInfo )
|
foreach( var serMember in serInfo )
|
||||||
{
|
{
|
||||||
String name = serMember.Name;
|
String name = serMember.Name;
|
||||||
|
|
||||||
name = name.Replace( '+', '-' );
|
name = scr.TypeToIdentifier( name );
|
||||||
name = name.Replace( '`', '_' );
|
|
||||||
|
|
||||||
XmlElement childElem = getNamedChild( allChildren, name );
|
XmlElement childElem = getNamedChild( allChildren, name );
|
||||||
|
|
||||||
var des = Deserialize( childElem, name );
|
var des = Deserialize( childElem, name );
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
*/
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
MemberInfo[] miArr = FormatterServices.GetSerializableMembers( finalType );
|
|
||||||
|
|
||||||
XmlNodeList allChildren = elem.ChildNodes;
|
XmlNodeList allChildren = elem.ChildNodes;
|
||||||
|
|
||||||
for( int i = 0; i < miArr.Length; ++i )
|
var fields = scr.GetAllFields( type );
|
||||||
{
|
|
||||||
FieldInfo childFi = (FieldInfo)miArr[ i ];
|
|
||||||
|
|
||||||
String name = childFi.Name;
|
//MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context );
|
||||||
|
|
||||||
name = name.Replace( '+', '-' );
|
foreach( var childFi in fields )
|
||||||
name = name.Replace( '`', '_' );
|
{
|
||||||
|
|
||||||
XmlElement childElem = getNamedChild( allChildren, name );
|
String name = childFi.Name;
|
||||||
|
|
||||||
|
name = scr.TypeToIdentifier( name );
|
||||||
|
|
||||||
|
XmlElement childElem = getNamedChild( allChildren, name );
|
||||||
|
|
||||||
|
|
||||||
if( childElem != null )
|
if( childElem != null )
|
||||||
@ -344,7 +342,7 @@ public class XmlFormatter2 : IFormatter
|
|||||||
|
|
||||||
childFi.SetValue( obj, childObj );
|
childFi.SetValue( obj, childObj );
|
||||||
}
|
}
|
||||||
else if( miArr.Length == 1 )
|
else if( fields.Count == 1 )
|
||||||
{
|
{
|
||||||
object childObj = Deserialize( elem, childFi.FieldType, obj );
|
object childObj = Deserialize( elem, childFi.FieldType, obj );
|
||||||
|
|
||||||
@ -593,10 +591,9 @@ public class XmlFormatter2 : IFormatter
|
|||||||
{
|
{
|
||||||
String name = serMember.Name;
|
String name = serMember.Name;
|
||||||
|
|
||||||
name = name.Replace( '+', '-' );
|
name = scr.TypeToIdentifier( name );
|
||||||
name = name.Replace( '`', '_' );
|
|
||||||
|
|
||||||
Serialize( writer, serMember.Value, name, true );
|
Serialize( writer, serMember.Value, name, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
//var sc = new SerializationContext(
|
//var sc = new SerializationContext(
|
||||||
@ -606,11 +603,12 @@ public class XmlFormatter2 : IFormatter
|
|||||||
else
|
else
|
||||||
//*/
|
//*/
|
||||||
{
|
{
|
||||||
MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context );
|
var fields = scr.GetAllFields( type );
|
||||||
|
|
||||||
for( int i = 0; i < miArr.Length; ++i )
|
//MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context );
|
||||||
|
|
||||||
|
foreach( var childFi in fields )
|
||||||
{
|
{
|
||||||
FieldInfo childFi = (FieldInfo)miArr[ i ];
|
|
||||||
|
|
||||||
object[] objs = childFi.GetCustomAttributes( typeof( NonSerializedAttribute ), true );
|
object[] objs = childFi.GetCustomAttributes( typeof( NonSerializedAttribute ), true );
|
||||||
|
|
||||||
@ -621,10 +619,9 @@ public class XmlFormatter2 : IFormatter
|
|||||||
|
|
||||||
String name = childFi.Name;
|
String name = childFi.Name;
|
||||||
|
|
||||||
name = name.Replace( '+', '-' );
|
name = scr.TypeToIdentifier( name );
|
||||||
name = name.Replace( '`', '_' );
|
|
||||||
|
|
||||||
Serialize( writer, childFi.GetValue( root ), name, false );
|
Serialize( writer, childFi.GetValue( root ), name, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -720,7 +720,7 @@ namespace math
|
|||||||
if (format == null)
|
if (format == null)
|
||||||
return ToString();
|
return ToString();
|
||||||
|
|
||||||
return string.Format(CultureInfo.CurrentCulture, "{0}°", MathUtil.RadiansToDegrees(radians).ToString(format, CultureInfo.CurrentCulture));
|
return string.Format(CultureInfo.CurrentCulture, $"{MathUtil.RadiansToDegrees(radians).ToString(format, CultureInfo.CurrentCulture)}°" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user