Пример #1
0
        protected BaseQmlMvvmTestsWithInstance()
        {
            InteropBehaviors.ClearQmlInteropBehaviors();
            InteropBehaviors.RegisterQmlInteropBehavior(new MvvmQmlInteropBehavior());

            RegisterType <T>();
            Instance = new T();
            TypeCreator.SetInstance(typeof(T), Instance);
        }
Пример #2
0
 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++;
         }
     }
 }
Пример #3
0
 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);
         }
     }
 }
Пример #4
0
 public override void Dispose()
 {
     InteropBehaviors.ClearQmlInteropBehaviors();
     base.Dispose();
 }
Пример #5
0
 /// <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);
 }