Пример #1
0
 /// <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;
 }
Пример #2
0
 /// <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;
 }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
 private bool IsSet(TypeSelectorIncludeFlags compareFlag)
 {
     return ((this.flags & compareFlag) == compareFlag);
 }
Пример #11
0
 /// <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;
 }
Пример #12
0
 private bool IsSet(TypeSelectorIncludeFlags compareFlag)
 {
     return((this.flags & compareFlag) == compareFlag);
 }
Пример #13
0
 /// <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;
 }