mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-07 07:00:33 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
53
server/tso.common/Utils/ValuePointer.cs
Executable file
53
server/tso.common/Utils/ValuePointer.cs
Executable file
|
@ -0,0 +1,53 @@
|
|||
using System.Reflection;
|
||||
|
||||
namespace FSO.Common.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Helps UI controls like lists refer to a data service value
|
||||
/// for labels such that when updates come in the labels update
|
||||
/// </summary>
|
||||
public class ValuePointer
|
||||
{
|
||||
private object Item;
|
||||
private PropertyInfo Field;
|
||||
|
||||
public ValuePointer(object item, string field)
|
||||
{
|
||||
this.Item = item;
|
||||
this.Field = item.GetType().GetProperty(field);
|
||||
}
|
||||
|
||||
public object Get()
|
||||
{
|
||||
return Field.GetValue(Item);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var value = Get();
|
||||
if(value != null)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static T Get<T>(object value)
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
if(value is ValuePointer)
|
||||
{
|
||||
return (T)((ValuePointer)value).Get();
|
||||
}
|
||||
|
||||
return (T)value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue