mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-06 22:50:30 -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
54
server/tso.common/Utils/DotPath.cs
Executable file
54
server/tso.common/Utils/DotPath.cs
Executable file
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace FSO.Common.Utils
|
||||
{
|
||||
public static class DotPath
|
||||
{
|
||||
public static PropertyInfo[] CompileDotPath(Type sourceType, string sourcePath)
|
||||
{
|
||||
//Dot path
|
||||
var path = sourcePath.Split(new char[] { '.' });
|
||||
var properties = new PropertyInfo[path.Length];
|
||||
|
||||
var currentType = sourceType;
|
||||
for (int i = 0; i < path.Length; i++)
|
||||
{
|
||||
var property = currentType.GetProperty(path[i]);
|
||||
properties[i] = property;
|
||||
currentType = property.PropertyType;
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static object GetDotPathValue(object source, PropertyInfo[] path)
|
||||
{
|
||||
if (source == null) { return null; }
|
||||
|
||||
var currentValue = source;
|
||||
for (var i = 0; i < path.Length; i++)
|
||||
{
|
||||
currentValue = path[i].GetValue(currentValue, null);
|
||||
if (currentValue == null) { return null; }
|
||||
}
|
||||
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
public static void SetDotPathValue(object source, PropertyInfo[] path, object value)
|
||||
{
|
||||
if (source == null) { return; }
|
||||
|
||||
var currentValue = source;
|
||||
for (var i = 0; i < path.Length - 1; i++)
|
||||
{
|
||||
currentValue = path[i].GetValue(currentValue, null);
|
||||
if (currentValue == null) { return; }
|
||||
}
|
||||
|
||||
var member = path[path.Length - 1];
|
||||
member.SetValue(currentValue, value, null);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue