Exemplo n.º 1
0
        private static void Example8()
        {
            var baseScope = new BaseScope();
            baseScope.ICanBeTaken = 4;
            baseScope.GetAllOfThem();

            var assemblyScope = new AssemblyScope();
            assemblyScope.GetWhatYouCan();

            var inheritanceScope = new InheritanceScope();
            inheritanceScope.GetSomeOfThem();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获取已加载至当前应用程序中指定程序集作用范围内的程序集 <see cref="Assembly"/> 集合。
 /// </summary>
 /// <param name="scope">一个 <see cref="AssemblyScope"/> 枚举值,表示指定的程序集作用范围。</param>
 /// <returns>已加载至当前应用程序中指定程序集作用范围内的程序集 <see cref="Assembly"/> 集合所构成的一个数组。</returns>
 public static Assembly[] GetAssemblies(AssemblyScope scope)
 {
     List<Assembly> list = new List<Assembly>();
     if (scope.HasFlag(AssemblyScope.Calling))
     {
         list.Add(Assembly.GetCallingAssembly());
     }
     if (scope.HasFlag(AssemblyScope.Entry))
     {
         list.Add(Assembly.GetEntryAssembly());
     }
     if (scope.HasFlag(AssemblyScope.Executing))
     {
         list.Add(Assembly.GetExecutingAssembly());
     }
     if (scope.HasFlag(AssemblyScope.Global))
     {
         list.AddRange(AppDomain.CurrentDomain.GetAssemblies());
     }
     return list.Distinct().ToArray();
 }
Exemplo n.º 3
0
 /// <summary>
 /// 获取当前类型在指定应用程序集范围的所有子类或接口实现类。
 /// </summary>
 /// <param name="_this">当前 <see cref="System.Type"/> 对象。</param>
 /// <param name="scope">指定的应用程序集范围</param>
 /// <returns>当前类型在指定应用程序集范围的所有子类或接口实现类。</returns>
 public static Type[] GetSubClass(this Type _this, AssemblyScope scope)
 {
     return Types.GetTypes(scope).Where(type => type != _this && type.IsInhertOrImplementOf(_this)).ToArray();
 }
 /// <summary>
 /// 以当前枚举值作为应用程序集作用范围内参数获取已加载至当前应用程序中的程序集中定义的所有类型 <see cref="System.Type"/> 的命名空间所构成的一个数组。
 /// </summary>
 /// <param name="_this">表示应用程序集的作用范围枚举的 <see cref="AssemblyScope"/> 枚举值。</param>
 /// <returns>以当前枚举值作为应用程序集作用范围内参数获取已加载至当前应用程序中的程序集中定义的所有类型 <see cref="System.Type"/> 的命名空间所构成的一个数组。</returns>
 public static string[] GetNamespaces(AssemblyScope _this)
 {
     return Assemblies.GetNamespaces(_this);
 }
 /// <summary>
 /// 以当前枚举值作为应用程序集作用范围内参数获取已加载至当前应用程序中的程序集中定义的所有公共类型 <see cref="System.Type"/> 集合所构成的一个数组。
 /// </summary>
 /// <param name="_this">表示应用程序集的作用范围枚举的 <see cref="AssemblyScope"/> 枚举值。</param>
 /// <returns>以当前枚举值作为应用程序集作用范围内参数获取已加载至当前应用程序中的程序集中定义的所有公共类型 <see cref="System.Type"/> 集合所构成的一个数组。</returns>
 public static Type[] GetPublicTypes(AssemblyScope _this)
 {
     return Assemblies.GetPublicTypes(_this);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 获取已加载至当前应用程序中指定程序集作用范围内的程序集中定义的所有公共类型 <see cref="System.Type"/> 集合所构成的一个数组。
 /// </summary>
 /// <param name="scope">一个 <see cref="AssemblyScope"/> 枚举值,表示指定的程序集作用范围。</param>
 /// <returns>已加载至当前应用程序中指定程序集作用范围内的程序集中定义的所有公共类型 <see cref="System.Type"/> 集合所构成的一个数组。</returns>
 public static Type[] GetPublicTypes(AssemblyScope scope)
 {
     return GetAssemblies(scope).SelectMany(assembly => assembly.ExportedTypes).Distinct().ToArray();
 }
Exemplo n.º 7
0
 /// <summary>
 /// 获取已加载至当前应用程序中指定程序集作用范围内的程序集中定义的所有类型 <see cref="System.Type"/> 集合所构成的一个数组。
 /// </summary>
 /// <param name="scope">一个 <see cref="AssemblyScope"/> 枚举值,表示指定的程序集作用范围。</param>
 /// <returns>已加载至当前应用程序中指定程序集作用范围内的程序集中定义的所有类型 <see cref="System.Type"/> 集合所构成的一个数组。</returns>
 public static Type[] GetTypes(AssemblyScope scope)
 {
     return GetAssemblies(scope).SelectMany(assembly => GetTypes(assembly)).Distinct().ToArray();
 }
Exemplo n.º 8
0
 /// <summary>
 /// 获取已加载至当前应用程序中指定程序集作用范围内的程序集中定义的所有类型 <see cref="System.Type"/> 的命名空间所构成的一个数组。
 /// </summary>
 /// <param name="scope">一个 <see cref="AssemblyScope"/> 枚举值,表示指定的程序集作用范围。</param>
 /// <returns>已加载至当前应用程序中指定程序集作用范围内的程序集中定义的所有类型 <see cref="System.Type"/> 的命名空间所构成的一个数组。</returns>
 public static string[] GetNamespaces(AssemblyScope scope)
 {
     return GetAssemblies(scope).SelectMany(assembly => GetNamespaces(assembly)).Distinct().ToArray();
 }