Exemplo n.º 1
0
    public void TestSerializableEventsActionSucceeds()
    {
      var root = new OverrideSerializationRoot();
      var nonSerClass = new NonSerializedClass();

      Action<object, PropertyChangedEventArgs> h = (sender, eventArgs) => { nonSerClass.Do(); };
      var method = typeof (Action<object, PropertyChangedEventArgs>).GetMethod("Invoke");
      var delgate = (PropertyChangedEventHandler)(object)method.CreateDelegate(typeof (PropertyChangedEventHandler), h);
      root.PropertyChanged += delgate;

      Action<object, PropertyChangingEventArgs> h1 = (sender, eventArgs) => { nonSerClass.Do(); };
      var method1 = typeof(Action<object, PropertyChangingEventArgs>).GetMethod("Invoke");
      var delgate1 = (PropertyChangingEventHandler)(object)method1.CreateDelegate(typeof(PropertyChangingEventHandler), h1);
      root.PropertyChanging += delgate1;

      var b = new BinaryFormatterWrapper();
      b.Serialize(new MemoryStream(), root);
    }
Exemplo n.º 2
0
        public void TestSerializableEventsActionSucceeds()
        {
            IDataPortal <OverrideSerializationRoot> dataPortal = _testDIContext.CreateDataPortal <OverrideSerializationRoot>();

            var root        = OverrideSerializationRoot.NewOverrideSerializationRoot(dataPortal);
            var nonSerClass = new NonSerializedClass();

            Action <object, PropertyChangedEventArgs> h = (sender, eventArgs) => { nonSerClass.Do(); };
            var method  = typeof(Action <object, PropertyChangedEventArgs>).GetMethod("Invoke");
            var delgate = (PropertyChangedEventHandler)(object)method.CreateDelegate(typeof(PropertyChangedEventHandler), h);

            root.PropertyChanged += delgate;

            Action <object, PropertyChangingEventArgs> h1 = (sender, eventArgs) => { nonSerClass.Do(); };
            var method1  = typeof(Action <object, PropertyChangingEventArgs>).GetMethod("Invoke");
            var delgate1 = (PropertyChangingEventHandler)(object)method1.CreateDelegate(typeof(PropertyChangingEventHandler), h1);

            root.PropertyChanging += delgate1;

            // TODO: Would this test make sense if upgraded to MobileFormatter?
            //var b = new BinaryFormatterWrapper();
            //b.Serialize(new MemoryStream(), root);
        }