/// <summary> /// <para>Initialize a new instance of the <see cref="TypeSelectorUI"/> class.</para> /// </summary> /// <param name="currentType"> /// <para>The current <see cref="Type"/> selected.</para> /// </param> /// <param name="baseType"> /// <para>The <see cref="Type"/> to filter and verify when loading.</para> /// </param> /// <param name="flags"> /// <para>The flags for the editor.</para> /// </param> public TypeSelectorUI(Type currentType, Type baseType, TypeSelectorIncludeFlags flags) : this() { this.openFileDialog.DereferenceLinks = false; this.selector = new TypeSelector(currentType, baseType, flags, this.treeView); this.treeView.Select(); this.Text += baseType.FullName; }
public void IncludeAllInterfacesTest() { TypeSelectorIncludeFlags flags = TypeSelectorIncludeFlags.Interfaces; TypeSelector selector = new TypeSelector(null, typeof(MarshalByRefObject), flags, treeView); bool valid = selector.IsTypeValid(typeof(IComparable)); Assert.IsTrue(valid); }
public void ExcludeAbstractTypesTest() { TypeSelectorIncludeFlags flags = TypeSelectorIncludeFlags.Default; TypeSelector selector = new TypeSelector(null, typeof(MarshalByRefObject), flags, treeView); bool valid = selector.IsTypeValid(typeof(Stream)); Assert.IsFalse(valid); }
public void ExcludeBaseTypeTest() { TypeSelectorIncludeFlags flags = TypeSelectorIncludeFlags.Default; TypeSelector selector = new TypeSelector(null, typeof(Exception), flags, treeView); bool valid = selector.IsTypeValid(typeof(Exception)); Assert.IsFalse(valid); }
public void ExcludeNonPublicTypes() { TypeSelectorIncludeFlags flags = TypeSelectorIncludeFlags.Default; TypeSelector selector = new TypeSelector(null, typeof(MarshalByRefObject), flags, treeView); bool valid = selector.IsTypeValid(typeof(NonPublicClass)); Assert.IsFalse(valid); }
public void IncludeAbstractTypesTest() { TypeSelectorIncludeFlags flags = TypeSelectorIncludeFlags.AbstractTypes; TypeSelector selector = new TypeSelector(null, typeof(ITest), flags, treeView); bool valid = selector.IsTypeValid(typeof(AbstractTest)); Assert.IsTrue(valid); valid = selector.IsTypeValid(typeof(ITest2)); Assert.IsTrue(valid); }
public TypeSelector(Type currentType, Type baseType, TypeSelectorIncludeFlags flags, TreeView treeView) { if (treeView == null) { throw new ArgumentNullException("treeView"); } if (baseType == null) { throw new ArgumentNullException("typeToVerify"); } loadedAssemblies = new Hashtable(); this.treeView = treeView; this.currentType = currentType; this.baseType = baseType; this.flags = flags; this.includeAbstractTypes = IsSet(TypeSelectorIncludeFlags.AbstractTypes); this.includeAllInterfaces = IsSet(TypeSelectorIncludeFlags.Interfaces); this.includeNonPublicTypes = IsSet(TypeSelectorIncludeFlags.NonpublicTypes); this.includeBaseType = IsSet(TypeSelectorIncludeFlags.BaseType); LoadTypes(baseType); }
private bool IsSet(TypeSelectorIncludeFlags compareFlag) { return ((this.flags & compareFlag) == compareFlag); }
/// <summary> /// <para> /// Initializes a new instance of the <see cref="BaseTypeAttribute"/> class with the specified <see cref="Type"/> object and <see cref="TypeSelectorIncludeFlags"/>. /// </para> /// </summary> /// <param name="baseType"> /// <para>The <see cref="Type"/> to filter selections.</para> /// </param> /// <param name="flags"> /// <para>One of the <see cref="TypeSelectorIncludeFlags"/> values.</para> /// </param> public BaseTypeAttribute(Type baseType, TypeSelectorIncludeFlags flags) : base() { this.baseType = baseType; this.flags = flags; }
private bool IsSet(TypeSelectorIncludeFlags compareFlag) { return((this.flags & compareFlag) == compareFlag); }