2021-03-31 16:42:58 -05:00
|
|
|
// Decompiled with JetBrains decompiler
|
|
|
|
|
// Type: Microsoft.Iris.UI.Class
|
|
|
|
|
// 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.Library;
|
|
|
|
|
using Microsoft.Iris.Markup;
|
|
|
|
|
using Microsoft.Iris.Session;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Iris.UI
|
|
|
|
|
{
|
|
|
|
|
internal class Class :
|
|
|
|
|
DisposableObject,
|
|
|
|
|
INotifyObject,
|
|
|
|
|
IMarkupTypeBase,
|
|
|
|
|
IDisposableOwner,
|
|
|
|
|
ISchemaInfo
|
|
|
|
|
{
|
|
|
|
|
public const string ClassStateReservedSymbolName = "Class";
|
|
|
|
|
public const string ThisReservedSymbolName = "this";
|
|
|
|
|
private MarkupTypeSchema _typeSchema;
|
|
|
|
|
protected Dictionary<object, object> _storage;
|
|
|
|
|
private Vector<IDisposableObject> _disposables;
|
|
|
|
|
private MarkupListeners _listeners;
|
|
|
|
|
protected NotifyService _notifier = new NotifyService();
|
|
|
|
|
private ScriptRunScheduler _scriptRunScheduler = new ScriptRunScheduler();
|
|
|
|
|
private bool _scriptEnabled;
|
|
|
|
|
private static DeferredHandler s_executePendingScriptsHandler = new DeferredHandler(Class.ExecutePendingScripts);
|
|
|
|
|
|
|
|
|
|
public Class(MarkupTypeSchema type)
|
|
|
|
|
{
|
|
|
|
|
this._typeSchema = type;
|
|
|
|
|
this._storage = new Dictionary<object, object>(type.TotalPropertiesAndLocalsCount);
|
|
|
|
|
this._scriptEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDispose()
|
|
|
|
|
{
|
2021-03-31 17:15:06 -05:00
|
|
|
this._typeSchema.RunFinalEvaluates(this);
|
2021-03-31 16:42:58 -05:00
|
|
|
base.OnDispose();
|
|
|
|
|
this._scriptEnabled = false;
|
|
|
|
|
if (this._listeners != null)
|
|
|
|
|
{
|
2021-03-31 17:15:06 -05:00
|
|
|
this._listeners.Dispose(this);
|
|
|
|
|
this._listeners = null;
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
this._notifier.ClearListeners();
|
|
|
|
|
this._storage.Clear();
|
|
|
|
|
if (this._disposables == null)
|
|
|
|
|
return;
|
|
|
|
|
for (int index = 0; index < this._disposables.Count; ++index)
|
2021-03-31 17:15:06 -05:00
|
|
|
this._disposables[index].Dispose(this);
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RegisterDisposable(IDisposableObject disposable)
|
|
|
|
|
{
|
|
|
|
|
if (this._disposables == null)
|
|
|
|
|
this._disposables = new Vector<IDisposableObject>();
|
|
|
|
|
this._disposables.Add(disposable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UnregisterDisposable(ref IDisposableObject disposable)
|
|
|
|
|
{
|
|
|
|
|
if (this._disposables != null)
|
|
|
|
|
{
|
|
|
|
|
int index = this._disposables.IndexOf(disposable);
|
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
|
|
|
|
disposable = this._disposables[index];
|
|
|
|
|
this._disposables.RemoveAt(index);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-31 17:15:06 -05:00
|
|
|
public TypeSchema TypeSchema => _typeSchema;
|
2021-03-31 16:42:58 -05:00
|
|
|
|
|
|
|
|
public virtual void NotifyInitialized()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void INotifyObject.AddListener(Listener listener) => this._notifier.AddListener(listener);
|
|
|
|
|
|
|
|
|
|
public virtual object ReadSymbol(SymbolReference symbolRef)
|
|
|
|
|
{
|
2021-03-31 17:15:06 -05:00
|
|
|
object obj = null;
|
2021-03-31 16:42:58 -05:00
|
|
|
switch (symbolRef.Origin)
|
|
|
|
|
{
|
|
|
|
|
case SymbolOrigin.Properties:
|
|
|
|
|
case SymbolOrigin.Locals:
|
2021-03-31 17:15:06 -05:00
|
|
|
obj = this._storage[symbolRef.Symbol];
|
2021-03-31 16:42:58 -05:00
|
|
|
break;
|
|
|
|
|
case SymbolOrigin.Reserved:
|
|
|
|
|
if (symbolRef.Symbol == nameof(Class) || symbolRef.Symbol == "this")
|
|
|
|
|
{
|
2021-03-31 17:15:06 -05:00
|
|
|
obj = this;
|
2021-03-31 16:42:58 -05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void WriteSymbol(SymbolReference symbolRef, object value) => this.SetProperty(symbolRef.Symbol, value);
|
|
|
|
|
|
2021-03-31 17:15:06 -05:00
|
|
|
public virtual object GetProperty(string name) => this._storage[name];
|
2021-03-31 16:42:58 -05:00
|
|
|
|
|
|
|
|
public virtual void SetProperty(string name, object value)
|
|
|
|
|
{
|
2021-03-31 17:15:06 -05:00
|
|
|
if (this._storage.ContainsKey(name) && Utility.IsEqual(this._storage[name], value))
|
2021-03-31 16:42:58 -05:00
|
|
|
return;
|
2021-03-31 17:15:06 -05:00
|
|
|
this._storage[name] = value;
|
2021-03-31 16:42:58 -05:00
|
|
|
this._notifier.Fire(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MarkupListeners Listeners
|
|
|
|
|
{
|
|
|
|
|
get => this._listeners;
|
|
|
|
|
set => this._listeners = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dictionary<object, object> Storage => this._storage;
|
|
|
|
|
|
|
|
|
|
public void ScheduleScriptRun(uint scriptId, bool ignoreErrors)
|
|
|
|
|
{
|
|
|
|
|
if (!this._scriptRunScheduler.Pending)
|
2021-03-31 17:15:06 -05:00
|
|
|
DeferredCall.Post(DispatchPriority.Script, Class.s_executePendingScriptsHandler, this);
|
2021-03-31 16:42:58 -05:00
|
|
|
this._scriptRunScheduler.ScheduleRun(scriptId, ignoreErrors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ExecutePendingScripts(object args)
|
|
|
|
|
{
|
|
|
|
|
Class @class = (Class)args;
|
2021-03-31 17:15:06 -05:00
|
|
|
@class._scriptRunScheduler.Execute(@class);
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
|
2021-03-31 17:15:06 -05:00
|
|
|
public object RunScript(uint scriptId, bool ignoreErrors, ParameterContext parameterContext) => this._typeSchema.Run(this, scriptId, ignoreErrors, parameterContext);
|
2021-03-31 16:42:58 -05:00
|
|
|
|
|
|
|
|
public void NotifyScriptErrors()
|
|
|
|
|
{
|
|
|
|
|
this._scriptEnabled = false;
|
2021-03-31 17:15:06 -05:00
|
|
|
ErrorManager.ReportWarning("Script runtime failure: Scripting has been disabled for '{0}' due to runtime scripting errors", _typeSchema.Name);
|
2021-03-31 16:42:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ScriptEnabled => this._scriptEnabled;
|
|
|
|
|
|
|
|
|
|
public override string ToString() => this._typeSchema.ToString();
|
|
|
|
|
|
|
|
|
|
[Conditional("DEBUG")]
|
|
|
|
|
public void DEBUG_MarkInitialized()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|