Reformat files
This commit is contained in:
parent
dd21ff0023
commit
30f3aa983b
3
Conn.cs
3
Conn.cs
@ -89,7 +89,8 @@ public class Conn
|
||||
|
||||
public virtual void recieve( object obj )
|
||||
{
|
||||
if( m_proc != null ) m_proc.process( obj );
|
||||
if( m_proc != null )
|
||||
m_proc.process( obj );
|
||||
}
|
||||
|
||||
Socket m_socket;
|
||||
|
||||
3
Log.cs
3
Log.cs
@ -278,7 +278,8 @@ namespace lib
|
||||
return '*';
|
||||
case LogType.Fatal:
|
||||
return '*';
|
||||
default: return '?';
|
||||
default:
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
Scr.cs
6
Scr.cs
@ -48,7 +48,8 @@ static public class scr
|
||||
{
|
||||
var success = m_en.MoveNext();
|
||||
|
||||
if( !success ) return false;
|
||||
if( !success )
|
||||
return false;
|
||||
|
||||
while( !m_pred( m_en.Current ) && ( success = m_en.MoveNext() ) )
|
||||
{
|
||||
@ -181,7 +182,8 @@ static public class scr
|
||||
|
||||
public static ImmutableList<PropertyInfo> GetAllProperties( Type t )
|
||||
{
|
||||
if( s_propCache.TryGetValue( t, out var info ) ) return info;
|
||||
if( s_propCache.TryGetValue( t, out var info ) )
|
||||
return info;
|
||||
|
||||
var list = new List<PropertyInfo>();
|
||||
|
||||
|
||||
@ -55,7 +55,8 @@ namespace lib
|
||||
protected SerializableDictionary( SerializationInfo info, StreamingContext context )
|
||||
{
|
||||
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{i}" ), typeof(KeyValuePair<TKey, TVal>));
|
||||
this.Add( kvp.Key, kvp.Value );
|
||||
}
|
||||
@ -66,7 +67,8 @@ namespace lib
|
||||
{
|
||||
info.AddValue( "ItemCount", this.Count );
|
||||
int itemIdx = 0;
|
||||
foreach (KeyValuePair<TKey, TVal> kvp in this) {
|
||||
foreach( KeyValuePair<TKey, TVal> kvp in this )
|
||||
{
|
||||
info.AddValue( String.Format( $"Item{itemIdx}" ), kvp, typeof( KeyValuePair<TKey, TVal> ) );
|
||||
itemIdx++;
|
||||
}
|
||||
@ -78,7 +80,8 @@ namespace lib
|
||||
void IXmlSerializable.WriteXml( System.Xml.XmlWriter writer )
|
||||
{
|
||||
//writer.WriteStartElement(DictionaryNodeName);
|
||||
foreach (KeyValuePair<TKey, TVal> kvp in this) {
|
||||
foreach( KeyValuePair<TKey, TVal> kvp in this )
|
||||
{
|
||||
writer.WriteStartElement( ItemNodeName );
|
||||
writer.WriteStartElement( KeyNodeName );
|
||||
KeySerializer.Serialize( writer, kvp.Key );
|
||||
@ -93,17 +96,20 @@ namespace lib
|
||||
|
||||
void IXmlSerializable.ReadXml( System.Xml.XmlReader reader )
|
||||
{
|
||||
if (reader.IsEmptyElement) {
|
||||
if( reader.IsEmptyElement )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Move past container
|
||||
if (!reader.Read()){
|
||||
if( !reader.Read() )
|
||||
{
|
||||
throw new XmlException( "Error in Deserialization of Dictionary" );
|
||||
}
|
||||
|
||||
//reader.ReadStartElement(DictionaryNodeName);
|
||||
while (reader.NodeType != XmlNodeType.EndElement) {
|
||||
while( reader.NodeType != XmlNodeType.EndElement )
|
||||
{
|
||||
reader.ReadStartElement( ItemNodeName );
|
||||
reader.ReadStartElement( KeyNodeName );
|
||||
TKey key = (TKey)KeySerializer.Deserialize(reader);
|
||||
@ -131,7 +137,8 @@ namespace lib
|
||||
{
|
||||
get
|
||||
{
|
||||
if (valueSerializer == null) {
|
||||
if( valueSerializer == null )
|
||||
{
|
||||
valueSerializer = new XmlSerializer( typeof( TVal ) );
|
||||
}
|
||||
return valueSerializer;
|
||||
@ -142,7 +149,8 @@ namespace lib
|
||||
{
|
||||
get
|
||||
{
|
||||
if (keySerializer == null) {
|
||||
if( keySerializer == null )
|
||||
{
|
||||
keySerializer = new XmlSerializer( typeof( TKey ) );
|
||||
}
|
||||
return keySerializer;
|
||||
|
||||
27
Utilities.cs
27
Utilities.cs
@ -202,7 +202,8 @@ namespace lib
|
||||
/// <returns>The byte array.</returns>
|
||||
public static byte[] ToByteArray<T>( T[] source ) where T : struct
|
||||
{
|
||||
if (source == null) return null;
|
||||
if( source == null )
|
||||
return null;
|
||||
|
||||
var buffer = new byte[SizeOf<T>() * source.Length];
|
||||
|
||||
@ -446,7 +447,8 @@ namespace lib
|
||||
{
|
||||
for( var i = 0; i < array.Length; i++ )
|
||||
{
|
||||
if (i > 0) text.Append(separator);
|
||||
if( i > 0 )
|
||||
text.Append( separator );
|
||||
text.Append( array[i] );
|
||||
}
|
||||
}
|
||||
@ -470,7 +472,8 @@ namespace lib
|
||||
for( var i = 0; i < elementList.Count; i++ )
|
||||
{
|
||||
var element = elementList[i];
|
||||
if (i > 0) text.Append(separator);
|
||||
if( i > 0 )
|
||||
text.Append( separator );
|
||||
text.Append( element );
|
||||
}
|
||||
return text.ToString();
|
||||
@ -493,7 +496,8 @@ namespace lib
|
||||
for( var i = 0; i < elementList.Count; i++ )
|
||||
{
|
||||
var element = elementList[i];
|
||||
if (i > 0) text.Append(separator);
|
||||
if( i > 0 )
|
||||
text.Append( separator );
|
||||
text.Append( element );
|
||||
}
|
||||
return text.ToString();
|
||||
@ -656,17 +660,22 @@ namespace lib
|
||||
/// <returns>True if lists are identical (but no necessarely of the same time). False otherwise.</returns>
|
||||
public static bool Compare<TKey, TValue>( IDictionary<TKey, TValue> first, IDictionary<TKey, TValue> second )
|
||||
{
|
||||
if (ReferenceEquals(first, second)) return true;
|
||||
if (ReferenceEquals(first, null) || ReferenceEquals(second, null)) return false;
|
||||
if (first.Count != second.Count) return false;
|
||||
if( ReferenceEquals( first, second ) )
|
||||
return true;
|
||||
if( ReferenceEquals( first, null ) || ReferenceEquals( second, null ) )
|
||||
return false;
|
||||
if( first.Count != second.Count )
|
||||
return false;
|
||||
|
||||
var comparer = EqualityComparer<TValue>.Default;
|
||||
|
||||
foreach( var keyValue in first )
|
||||
{
|
||||
TValue secondValue;
|
||||
if (!second.TryGetValue(keyValue.Key, out secondValue)) return false;
|
||||
if (!comparer.Equals(keyValue.Value, secondValue)) return false;
|
||||
if( !second.TryGetValue( keyValue.Key, out secondValue ) )
|
||||
return false;
|
||||
if( !comparer.Equals( keyValue.Value, secondValue ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that all keys in second are in first
|
||||
|
||||
@ -545,7 +545,8 @@ namespace lib
|
||||
|
||||
if( length < 0 )
|
||||
{
|
||||
if( fi == null ) return;
|
||||
if( fi == null )
|
||||
return;
|
||||
|
||||
fi.SetValue( obj, null );
|
||||
|
||||
@ -585,7 +586,8 @@ namespace lib
|
||||
{
|
||||
int val = reader.ReadInt32();
|
||||
|
||||
if( fi == null ) return;
|
||||
if( fi == null )
|
||||
return;
|
||||
|
||||
if( !fi.FieldType.IsEnum )
|
||||
{
|
||||
@ -603,7 +605,8 @@ namespace lib
|
||||
{
|
||||
float val = reader.ReadSingle();
|
||||
|
||||
if( fi == null ) return;
|
||||
if( fi == null )
|
||||
return;
|
||||
|
||||
fi.SetValue( obj, val );
|
||||
}
|
||||
@ -612,7 +615,8 @@ namespace lib
|
||||
{
|
||||
double val = reader.ReadDouble();
|
||||
|
||||
if( fi == null ) return;
|
||||
if( fi == null )
|
||||
return;
|
||||
|
||||
fi.SetValue( obj, val );
|
||||
}
|
||||
@ -621,7 +625,8 @@ namespace lib
|
||||
{
|
||||
char val = reader.ReadChar();
|
||||
|
||||
if( fi == null ) return;
|
||||
if( fi == null )
|
||||
return;
|
||||
|
||||
fi.SetValue( obj, val );
|
||||
}
|
||||
@ -630,7 +635,8 @@ namespace lib
|
||||
{
|
||||
string val = reader.ReadString();
|
||||
|
||||
if( fi == null ) return;
|
||||
if( fi == null )
|
||||
return;
|
||||
|
||||
fi.SetValue( obj, val );
|
||||
}
|
||||
@ -639,7 +645,8 @@ namespace lib
|
||||
{
|
||||
bool val = reader.ReadBoolean();
|
||||
|
||||
if( fi == null ) return;
|
||||
if( fi == null )
|
||||
return;
|
||||
|
||||
fi.SetValue( obj, val );
|
||||
}
|
||||
|
||||
@ -51,22 +51,26 @@ namespace lib
|
||||
//{
|
||||
//}
|
||||
|
||||
SerializationBinder IFormatter.Binder {
|
||||
SerializationBinder IFormatter.Binder
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
ISurrogateSelector IFormatter.SurrogateSelector {
|
||||
ISurrogateSelector IFormatter.SurrogateSelector
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public StreamingContext Context {
|
||||
public StreamingContext Context
|
||||
{
|
||||
get { return m_context; }
|
||||
set { m_context = value; }
|
||||
}
|
||||
|
||||
public IDataContractSurrogate DataContractSurrogate {
|
||||
public IDataContractSurrogate DataContractSurrogate
|
||||
{
|
||||
get { return m_surrogate; }
|
||||
set { m_surrogate = value; }
|
||||
}
|
||||
@ -82,7 +86,8 @@ namespace lib
|
||||
}
|
||||
*/
|
||||
|
||||
public SerializationMode Mode {
|
||||
public SerializationMode Mode
|
||||
{
|
||||
get { return m_mode; }
|
||||
}
|
||||
|
||||
|
||||
@ -118,7 +118,8 @@ public class XmlFormatter2 : IFormatter
|
||||
|
||||
////lib.log.info( "What to deserialize {0}", doc.OuterXml.ToString() );
|
||||
|
||||
if( t == null ) return Deserialize( doc.DocumentElement );
|
||||
if( t == null )
|
||||
return Deserialize( doc.DocumentElement );
|
||||
|
||||
return Deserialize( doc.DocumentElement, t );
|
||||
}
|
||||
@ -145,7 +146,8 @@ public class XmlFormatter2 : IFormatter
|
||||
{
|
||||
type = a.GetType( typename );
|
||||
|
||||
if(type != null) break;
|
||||
if( type != null )
|
||||
break;
|
||||
}
|
||||
|
||||
if( type == null )
|
||||
@ -267,7 +269,8 @@ public class XmlFormatter2 : IFormatter
|
||||
var typename = elem.GetAttribute( "t" );
|
||||
finalType = FindType( typename );
|
||||
|
||||
if( finalType == null ) finalType = type;
|
||||
if( finalType == null )
|
||||
finalType = type;
|
||||
}
|
||||
|
||||
object obj = createObject( finalType, refInt );
|
||||
|
||||
@ -244,7 +244,8 @@ namespace res
|
||||
{
|
||||
if( ResCache<T>.s_cache.TryGetValue( filename, out var wr ) )
|
||||
{
|
||||
if( wr.TryGetTarget(out var v) ) return v;
|
||||
if( wr.TryGetTarget( out var v ) )
|
||||
return v;
|
||||
|
||||
lib.Log.info( $"{filename} was in cache, but its been dropped, reloading." );
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user