示例#1
0
        public void CheckRegisteredTypes()
        {
            System.Collections.Generic.IEnumerable <Type> types = Enumerable.Empty <Type>();
            try
            {
                types = typeof(ResXEditorKnownEditors).Assembly.GetTypes()
                        .Where(x => x.IsSubclassOf(typeof(ResXEditorBinding)) && !x.IsAbstract);
            } catch (Exception e)
            {
            }

            foreach (var type in types)
            {
                var editorBinding = (ResXEditorBinding)Activator.CreateInstance(type);
                ResXEditorKnownEditors.RegisterKnownTypes(editorBinding.TypesHandled);
            }

            foreach (var type in defaultKnownTypes)
            {
                Assert.IsTrue(ResXEditorKnownEditors.IsKnownType(type));
            }

            foreach (var type in types)
            {
                var editorBinding = (ResXEditorBinding)Activator.CreateInstance(type);
                ResXEditorKnownEditors.UnregisterKnownTypes(editorBinding.TypesHandled);
            }

            foreach (var type in defaultKnownTypes)
            {
                Assert.IsFalse(ResXEditorKnownEditors.IsKnownType(type));
            }
        }
示例#2
0
        public void CheckRefCounting()
        {
            ResXEditorKnownEditors.RegisterKnownTypes(new[] { typeof(string) });
            ResXEditorKnownEditors.RegisterKnownTypes(new[] { typeof(string) });

            Assert.IsTrue(ResXEditorKnownEditors.IsKnownType(typeof(string).AssemblyQualifiedName));
            ResXEditorKnownEditors.UnregisterKnownTypes(new[] { typeof(string) });
            Assert.IsTrue(ResXEditorKnownEditors.IsKnownType(typeof(string).AssemblyQualifiedName));
            ResXEditorKnownEditors.UnregisterKnownTypes(new[] { typeof(string) });
            Assert.IsFalse(ResXEditorKnownEditors.IsKnownType(typeof(string).AssemblyQualifiedName));
        }
示例#3
0
 protected override bool SkipNode(ResXNode node) => ResXEditorKnownEditors.IsKnownType(node.TypeName);