2021-03-31 16:42:58 -05:00
|
|
|
// Decompiled with JetBrains decompiler
|
|
|
|
|
// Type: Microsoft.Iris.Markup.MarkupMethodSchema
|
|
|
|
|
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
|
|
|
|
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
|
|
|
|
// Assembly location: C:\Program Files\Zune\UIX.dll
|
|
|
|
|
|
|
|
|
|
using Microsoft.Iris.Markup.UIX;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Iris.Markup
|
|
|
|
|
{
|
|
|
|
|
internal abstract class MarkupMethodSchema : MethodSchema
|
|
|
|
|
{
|
|
|
|
|
private string _name;
|
|
|
|
|
private TypeSchema _returnType;
|
|
|
|
|
private TypeSchema[] _parameterTypes;
|
|
|
|
|
private string[] _parameterNames;
|
|
|
|
|
protected uint _codeOffset = uint.MaxValue;
|
|
|
|
|
private int _virtualId = -1;
|
|
|
|
|
private bool _isVirtualThunk;
|
|
|
|
|
public static readonly string[] s_emptyStringArray = new string[0];
|
|
|
|
|
public static readonly MarkupMethodSchema[] EmptyMethodList = new MarkupMethodSchema[0];
|
|
|
|
|
|
|
|
|
|
public static MarkupMethodSchema Build(
|
|
|
|
|
TypeSchema markupTypeBase,
|
|
|
|
|
MarkupTypeSchema owner,
|
|
|
|
|
string name,
|
|
|
|
|
TypeSchema returnType,
|
|
|
|
|
TypeSchema[] parameterTypes,
|
|
|
|
|
string[] parameterNames,
|
|
|
|
|
bool isVirtualThunk)
|
|
|
|
|
{
|
2021-03-31 17:15:06 -05:00
|
|
|
MarkupMethodSchema markupMethodSchema = null;
|
2021-03-31 16:42:58 -05:00
|
|
|
if (markupTypeBase == ClassSchema.Type || markupTypeBase == EffectSchema.Type)
|
2021-03-31 17:15:06 -05:00
|
|
|
markupMethodSchema = new ClassMethodSchema((ClassTypeSchema)owner, name, returnType, parameterTypes, parameterNames);
|
2021-03-31 16:42:58 -05:00
|
|
|
else if (markupTypeBase == UISchema.Type)
|
2021-03-31 17:15:06 -05:00
|
|
|
markupMethodSchema = new UIClassMethodSchema((UIClassTypeSchema)owner, name, returnType, parameterTypes, parameterNames);
|
2021-03-31 16:42:58 -05:00
|
|
|
markupMethodSchema._isVirtualThunk = isVirtualThunk;
|
|
|
|
|
return markupMethodSchema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MarkupMethodSchema Build(
|
|
|
|
|
TypeSchema markupTypeBase,
|
|
|
|
|
MarkupTypeSchema owner,
|
|
|
|
|
string name,
|
|
|
|
|
TypeSchema returnType,
|
|
|
|
|
TypeSchema[] parameterTypes,
|
|
|
|
|
string[] parameterNames)
|
|
|
|
|
{
|
2021-03-31 17:20:20 -05:00
|
|
|
return Build(markupTypeBase, owner, name, returnType, parameterTypes, parameterNames, false);
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MarkupMethodSchema BuildVirtualThunk(
|
|
|
|
|
TypeSchema markupTypeBase,
|
|
|
|
|
MarkupMethodSchema virtualMethod)
|
|
|
|
|
{
|
2021-03-31 17:20:20 -05:00
|
|
|
return Build(markupTypeBase, (MarkupTypeSchema)virtualMethod.Owner, virtualMethod.Name, virtualMethod.ReturnType, virtualMethod.ParameterTypes, virtualMethod.ParameterNames, true);
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected MarkupMethodSchema(
|
|
|
|
|
MarkupTypeSchema owner,
|
|
|
|
|
string name,
|
|
|
|
|
TypeSchema returnType,
|
|
|
|
|
TypeSchema[] parameterTypes,
|
|
|
|
|
string[] parameterNames)
|
2021-03-31 17:15:06 -05:00
|
|
|
: base(owner)
|
2021-03-31 16:42:58 -05:00
|
|
|
{
|
2021-04-02 19:10:51 -05:00
|
|
|
_name = name;
|
|
|
|
|
_returnType = returnType;
|
|
|
|
|
_parameterTypes = parameterTypes;
|
|
|
|
|
_parameterNames = parameterNames;
|
|
|
|
|
for (int index = 0; index < _parameterNames.Length; ++index)
|
|
|
|
|
_parameterNames[index] = NotifyService.CanonicalizeString(_parameterNames[index]);
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public override string Name => _name;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public override TypeSchema[] ParameterTypes => _parameterTypes;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public string[] ParameterNames => _parameterNames;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public override TypeSchema ReturnType => _returnType;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
|
|
|
|
public override bool IsStatic => false;
|
|
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public bool IsVirtual => _virtualId >= 0;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public int VirtualId => _virtualId;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public bool IsVirtualThunk => _isVirtualThunk;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public uint CodeOffset => _codeOffset;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public void SetCodeOffset(uint codeOffset) => _codeOffset = codeOffset;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
public void SetVirtualId(int virtualId) => _virtualId = virtualId;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
|
|
|
|
public override object Invoke(object instance, object[] parameters)
|
|
|
|
|
{
|
2021-04-02 19:10:51 -05:00
|
|
|
IMarkupTypeBase markupTypeBase = GetMarkupTypeBase(instance);
|
2021-03-31 16:42:58 -05:00
|
|
|
if (markupTypeBase == null)
|
2021-03-31 17:15:06 -05:00
|
|
|
return null;
|
2021-04-02 19:10:51 -05:00
|
|
|
return _isVirtualThunk ? CallVirt(markupTypeBase, parameters) : CallDirect(markupTypeBase, parameters);
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private object CallVirt(IMarkupTypeBase markupInstance, object[] parameters)
|
|
|
|
|
{
|
|
|
|
|
MarkupTypeSchema typeSchema = (MarkupTypeSchema)markupInstance.TypeSchema;
|
2021-03-31 17:15:06 -05:00
|
|
|
MarkupMethodSchema markupMethodSchema = null;
|
2021-03-31 16:42:58 -05:00
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
foreach (MarkupMethodSchema virtualMethod in typeSchema.VirtualMethods)
|
|
|
|
|
{
|
2021-04-02 19:10:51 -05:00
|
|
|
if (virtualMethod.VirtualId == _virtualId)
|
2021-03-31 16:42:58 -05:00
|
|
|
{
|
|
|
|
|
markupMethodSchema = virtualMethod;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (markupMethodSchema == null)
|
|
|
|
|
typeSchema = (MarkupTypeSchema)typeSchema.Base;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return markupMethodSchema.CallDirect(markupInstance, parameters);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-02 19:10:51 -05:00
|
|
|
private object CallDirect(IMarkupTypeBase markupInstance, object[] parameters) => markupInstance.RunScript(_codeOffset, false, new ParameterContext(_parameterNames, parameters));
|
2021-03-31 16:42:58 -05:00
|
|
|
|
|
|
|
|
protected abstract IMarkupTypeBase GetMarkupTypeBase(object instance);
|
|
|
|
|
}
|
|
|
|
|
}
|