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 );
|
||||
}
|
||||
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;
|
||||
@ -70,11 +70,11 @@ public class Conn
|
||||
var ms = new MemoryStream( 1024 );
|
||||
formatter.Serialize( ms, obj );
|
||||
|
||||
//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 {0}", obj );
|
||||
//var str = System.Text.Encoding.Default.GetString( mm_buffer, 0, (int)ms.Position );
|
||||
//lib.Log.info( $"Sent data {str} of length {ms.Position}" );
|
||||
//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( ms.GetBuffer(), 0, (int)ms.Position );
|
||||
|
||||
|
||||
10
Helpers.cs
10
Helpers.cs
@ -147,28 +147,28 @@ namespace lib
|
||||
}
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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 )
|
||||
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
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
private void writeFileAndLine( StackTrace st )
|
||||
{
|
||||
@ -244,7 +244,7 @@ namespace lib
|
||||
string srcFile = frame.GetFileName();
|
||||
string srcLine = frame.GetFileLineNumber().Tostring();
|
||||
|
||||
Console.WriteLine( "{0} ({1}):", srcFile, srcLine );
|
||||
Console.WriteLine( $"{srcFile} ({srcLine}):" );
|
||||
}
|
||||
|
||||
private void writeStack( StackTrace st )
|
||||
@ -258,7 +258,7 @@ namespace lib
|
||||
|
||||
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");
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,7 @@ namespace lib
|
||||
info.AddValue("ItemCount", this.Count);
|
||||
int itemIdx = 0;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ namespace lib
|
||||
{
|
||||
if( !Directory.Exists( path ) )
|
||||
{
|
||||
lib.Log.info( "Creating directory {0}", path );
|
||||
lib.Log.info( $"Creating directory {path}" );
|
||||
Directory.CreateDirectory( path );
|
||||
}
|
||||
|
||||
|
||||
@ -271,8 +271,7 @@ public class XmlFormatter2 : IFormatter
|
||||
|
||||
String childType = node.GetAttribute( "t" );
|
||||
|
||||
name = name.Replace( '+', '-' );
|
||||
name = name.Replace( '`', '_' );
|
||||
name = scr.TypeToIdentifier( name );
|
||||
|
||||
XmlElement childElem = getNamedChild( allChildren, name );
|
||||
|
||||
@ -302,40 +301,39 @@ public class XmlFormatter2 : IFormatter
|
||||
objUnOnDeser.OnDeserialization( objUnOnDeser );
|
||||
}
|
||||
|
||||
/*
|
||||
ser.GetObjectData( serInfo, Context );
|
||||
/*
|
||||
ser.GetObjectData( serInfo, Context );
|
||||
|
||||
//var serEnum = ;
|
||||
//var serEnum = ;
|
||||
|
||||
foreach( var serMember in serInfo )
|
||||
{
|
||||
String name = serMember.Name;
|
||||
foreach( var serMember in serInfo )
|
||||
{
|
||||
String name = serMember.Name;
|
||||
|
||||
name = name.Replace( '+', '-' );
|
||||
name = name.Replace( '`', '_' );
|
||||
name = scr.TypeToIdentifier( name );
|
||||
|
||||
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;
|
||||
|
||||
for( int i = 0; i < miArr.Length; ++i )
|
||||
{
|
||||
FieldInfo childFi = (FieldInfo)miArr[ i ];
|
||||
var fields = scr.GetAllFields( type );
|
||||
|
||||
String name = childFi.Name;
|
||||
//MemberInfo[] miArr = FormatterServices.GetSerializableMembers( type, Context );
|
||||
|
||||
name = name.Replace( '+', '-' );
|
||||
name = name.Replace( '`', '_' );
|
||||
foreach( var childFi in fields )
|
||||
{
|
||||
|
||||
XmlElement childElem = getNamedChild( allChildren, name );
|
||||
String name = childFi.Name;
|
||||
|
||||
name = scr.TypeToIdentifier( name );
|
||||
|
||||
XmlElement childElem = getNamedChild( allChildren, name );
|
||||
|
||||
|
||||
if( childElem != null )
|
||||
@ -344,7 +342,7 @@ public class XmlFormatter2 : IFormatter
|
||||
|
||||
childFi.SetValue( obj, childObj );
|
||||
}
|
||||
else if( miArr.Length == 1 )
|
||||
else if( fields.Count == 1 )
|
||||
{
|
||||
object childObj = Deserialize( elem, childFi.FieldType, obj );
|
||||
|
||||
@ -593,10 +591,9 @@ public class XmlFormatter2 : IFormatter
|
||||
{
|
||||
String name = serMember.Name;
|
||||
|
||||
name = name.Replace( '+', '-' );
|
||||
name = name.Replace( '`', '_' );
|
||||
name = scr.TypeToIdentifier( name );
|
||||
|
||||
Serialize( writer, serMember.Value, name, true );
|
||||
Serialize( writer, serMember.Value, name, true );
|
||||
}
|
||||
|
||||
//var sc = new SerializationContext(
|
||||
@ -606,11 +603,12 @@ public class XmlFormatter2 : IFormatter
|
||||
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 );
|
||||
|
||||
@ -621,10 +619,9 @@ public class XmlFormatter2 : IFormatter
|
||||
|
||||
String name = childFi.Name;
|
||||
|
||||
name = name.Replace( '+', '-' );
|
||||
name = name.Replace( '`', '_' );
|
||||
name = scr.TypeToIdentifier( name );
|
||||
|
||||
Serialize( writer, childFi.GetValue( root ), name, false );
|
||||
Serialize( writer, childFi.GetValue( root ), name, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -720,7 +720,7 @@ namespace math
|
||||
if (format == null)
|
||||
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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user