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)); } }
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)); }
protected override bool SkipNode(ResXNode node) => ResXEditorKnownEditors.IsKnownType(node.TypeName);