protected BaseQmlMvvmTestsWithInstance() { InteropBehaviors.ClearQmlInteropBehaviors(); InteropBehaviors.RegisterQmlInteropBehavior(new MvvmQmlInteropBehavior()); RegisterType <T>(); Instance = new T(); TypeCreator.SetInstance(typeof(T), Instance); }
internal static void OnReferenceCreated(object obj, UInt64 objectId) { lock (_LockObject) { if (!_ObjectIdObjectLookup.ContainsKey(objectId)) { _ObjectIdObjectLookup[objectId] = new ObjectEntry(obj, 1); InteropBehaviors.OnObjectEntersNative(obj, objectId); } else { _ObjectIdObjectLookup[objectId].Counter++; } } }
internal static void OnReferenceReleased(UInt64 objectId) { lock (_LockObject) { if (!_ObjectIdObjectLookup.ContainsKey(objectId)) { throw new InvalidOperationException("Releasing a NetReference that hasn't been counted!"); } _ObjectIdObjectLookup[objectId].Counter--; //when there are no more QML references if (_ObjectIdObjectLookup[objectId].Counter == 0) { var obj = _ObjectIdObjectLookup[objectId].Obj; //remove object entry _ObjectIdObjectLookup.Remove(objectId); //and notify the behaviors InteropBehaviors.OnObjectLeavesNative(obj, objectId); } } }
public override void Dispose() { InteropBehaviors.ClearQmlInteropBehaviors(); base.Dispose(); }
/// <summary> /// Activates the MVVM behavior. /// This Behavior automatically connects INotifyPropertyChanged instances with appropriate signals on the QML side /// and triggers those signals whenever the PropertyChanged event of the INotifyPropertyChanged instances is triggered. /// /// Call this before any INotifyPropertyChanged type is registered! /// Otherwise the behavior might not include /// INotifyPropertyChanged types that were registered (implicitly or explicitly) before this call /// </summary> public static void ActivateMVVMBehavior() { InteropBehaviors.RegisterQmlInteropBehavior(new MvvmQmlInteropBehavior(), false); }