예제 #1
0
        public void TestSerialization()
        {
            UniqueIDCache.ClearIdCache();
            TransformKeyedCollection objectToSerialize = new TransformKeyedCollection();
            StringCaseTransform      transform1        = new StringCaseTransform();

            transform1.ID         = "tx0001";
            transform1.StringCase = StringCaseType.Title;

            GetDNComponentTransform transform2 = new GetDNComponentTransform();

            transform2.ID             = "tx0002";
            transform2.RdnFormat      = RdnFormat.ValueOnly;
            transform2.ComponentIndex = 1;

            objectToSerialize.Add(transform1);
            objectToSerialize.Add(transform2);
            UniqueIDCache.ClearIdCache();

            TransformKeyedCollection deserializedObject = (TransformKeyedCollection)UnitTestControl.XmlSerializeRoundTrip <TransformKeyedCollection>(objectToSerialize);

            Assert.AreEqual(objectToSerialize.Count, deserializedObject.Count);
            Assert.AreEqual(objectToSerialize[0].ID, transform1.ID);
            Assert.AreEqual(objectToSerialize[1].ID, transform2.ID);
        }
        public TransformCollectionViewModel(TransformKeyedCollection model)
            : base()
        {
            this.model = model;
            this.SetCollectionViewModel((IList)this.model, t => this.ViewModelResolver(t));

            this.Commands.AddItem("AddTransform", t => this.AddTransform());

            this.IgnorePropertyHasChanged.Add("DisplayName");
            this.DisplayIcon     = new BitmapImage(new Uri("pack://application:,,,/Lithnet.Transforms.Presentation;component/Resources/transforms.png", UriKind.Absolute));;
            this.OnModelRemoved += TransformCollectionViewModel_OnModelRemoved;

            foreach (var type in typeof(Transform).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Transform)) && !t.IsAbstract))
            {
                this.PasteableTypes.Add(type);
            }
        }