mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Genericize conversions from instance/expressions to XML
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.Iris.Asm;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace Microsoft.Iris.DecompXml.Mock;
|
||||
|
||||
internal class IrisExpression : Expression
|
||||
{
|
||||
public virtual string Decompile(Decompiler decompiler) => ToString();
|
||||
|
||||
public static Expression ToExpression(object p)
|
||||
{
|
||||
return p switch
|
||||
{
|
||||
null => Constant(null),
|
||||
Expression expr => expr,
|
||||
Disassembler.RawConstantInfo constantInfo => new IrisConstantExpression(constantInfo.Value, constantInfo.Type),
|
||||
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Microsoft.Iris.Asm;
|
||||
using Microsoft.Iris.Markup;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Microsoft.Iris.DecompXml.Mock;
|
||||
|
||||
internal record IrisObject(object Object, TypeSchema Type)
|
||||
{
|
||||
public static IrisObject Create(object objIn, TypeSchema type, Decompiler decompiler)
|
||||
{
|
||||
object obj = objIn;
|
||||
|
||||
if (objIn is IrisObject irisObj)
|
||||
{
|
||||
return irisObj.Type is null
|
||||
? (irisObj with { Type = type })
|
||||
: irisObj;
|
||||
}
|
||||
|
||||
if (objIn is Disassembler.RawConstantInfo constantInfo)
|
||||
{
|
||||
obj = constantInfo.Value;
|
||||
type ??= constantInfo.Type;
|
||||
}
|
||||
|
||||
if (objIn is IReturnValueProvider hasReturnValue)
|
||||
{
|
||||
type ??= hasReturnValue.ReturnType;
|
||||
}
|
||||
|
||||
type ??= Disassembler.GuessTypeSchema(obj.GetType(), decompiler._loadResult);
|
||||
|
||||
return new(obj, type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user