-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kinda slow, and images don't work. but it's something
- Loading branch information
1 parent
71cfc9a
commit f3ee097
Showing
6 changed files
with
232 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Diagnostics; | ||
using ScryDotNet; | ||
|
||
namespace HSReflection.Util; | ||
|
||
[DebuggerDisplay("{Value}")] | ||
public class MonoWrapper | ||
{ | ||
public dynamic? Value { get; } | ||
|
||
public MonoWrapper(dynamic? value) | ||
{ | ||
Value = value!; | ||
} | ||
|
||
public MonoWrapper[] AsArray() => ((dynamic[])Value!).Select(v => new MonoWrapper(v)).ToArray(); | ||
|
||
public MonoWrapper? this[string key] | ||
{ | ||
get | ||
{ | ||
try | ||
{ | ||
switch (Value) | ||
{ | ||
case MonoObject mObj: | ||
Dictionary<string, object> mObjFields = mObj.getFields(); | ||
return mObjFields.Count == 0 | ||
? new MonoWrapper(mObj[key]) | ||
: new MonoWrapper(mObjFields[key]); | ||
case MonoStruct mStr: | ||
Dictionary<string, object> mStrFields = mStr.getFields(); | ||
return mStrFields.Count == 0 | ||
? new MonoWrapper(mStr[key]) | ||
: new MonoWrapper(mStrFields[key]); | ||
default: | ||
return null; | ||
} | ||
} | ||
catch | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
public static bool operator ==(MonoWrapper? obj1, MonoWrapper? obj2) => | ||
obj1?.Value is null | ||
? obj2?.Value is null | ||
: obj1.Equals(obj2); | ||
|
||
public static bool operator !=(MonoWrapper obj1, MonoWrapper obj2) => !(obj1 == obj2); | ||
|
||
// ReSharper disable once BaseObjectEqualsIsObjectEquals | ||
public override bool Equals(object? obj) => base.Equals(obj); | ||
|
||
public override int GetHashCode() => Value?.GetHashCode(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.