当前位置: 首页>>代码示例>>C#>>正文


C# Type.FindInterfaces方法代码示例

本文整理汇总了C#中System.Type.FindInterfaces方法的典型用法代码示例。如果您正苦于以下问题:C# Type.FindInterfaces方法的具体用法?C# Type.FindInterfaces怎么用?C# Type.FindInterfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Type的用法示例。


在下文中一共展示了Type.FindInterfaces方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TypesToGenerateForType

 public static IEnumerable<Type> TypesToGenerateForType(Type type)
 {
   foreach (var interfaceType in type.FindInterfaces((ignored, data) => true, null))
   {
     yield return interfaceType;
   }
   yield return type;
 }
开发者ID:machine,项目名称:machine.mta,代码行数:8,代码来源:MessageTypeHelpers.cs

示例2: RoleSet

 public RoleSet(Type _Class)
 {
     TypeFilter filter = new TypeFilter(RoleFilter);
     Type[] Roles = _Class.FindInterfaces(filter, (object)__RoleTypes);
     _Set = new HashSet<Type>();
     foreach (Type r in Roles) {
         _Set.Add(r);
     }
 }
开发者ID:lokeldigital,项目名称:CoolFramework,代码行数:9,代码来源:Roles.cs

示例3: TypeImplementsInterface

 public static bool TypeImplementsInterface(Type type, Type typeToImplement)
 {
     Type[] interfaces = type.FindInterfaces(
             (typ, obj) => typ == typeToImplement,
             type);
     if (interfaces != null && interfaces.Length > 0)
         return true;
     return false;
 }
开发者ID:adrianj,项目名称:AdriansLib,代码行数:9,代码来源:ObjectCollectionEditor.cs

示例4: InterfacePresentInType

        /// <summary>
        /// InterfacePresentInClass check that an inteface is implimented for the specific dll type
        /// </summary>
        /// <param name="checkType">The type to check i.e the class</param>
        /// <param name="compareType">The interface type</param>
        /// <returns>Returns true if the interface is implemented in the class</returns>
        public static bool InterfacePresentInType(Type checkType, Type compareType)
        {
            TypeFilter interfaceFilter = InterfaceFilter;
            Type[] list = checkType.FindInterfaces(interfaceFilter, compareType);
            if (list != null && list.Length > 0)
                return true;

            return false;
        }
开发者ID:jhuliano,项目名称:Aerolinea,代码行数:15,代码来源:ReflectionHelper.cs

示例5: FindCollectionInterface

 private static Type FindCollectionInterface(Type type)
 {
     Type[] array = type.FindInterfaces(new TypeFilter(CollectionUtils.IsCollectionInterface), null);
     if (array.Length == 1)
     {
         return array[0];
     }
     return null;
 }
开发者ID:KingpinBen,项目名称:Spin-Doctor,代码行数:9,代码来源:CollectionUtils.cs

示例6: ElementType

        private static Type ElementType(Type collectionType)
        {
            Debug.Assert(collectionType != null);
            Debug.Assert(typeof(IEnumerable).IsAssignableFrom(collectionType));

            Type[] stronglyTypedInterfaces = collectionType.FindInterfaces((m, c) => m.IsConstructedGenericType && m.GetGenericTypeDefinition() == typeof(IEnumerable<>), null);

            if (stronglyTypedInterfaces == null || stronglyTypedInterfaces.Length == 0 || stronglyTypedInterfaces.Length > 1)
            {
                return null;  // not a strongly typed collection, or a strongly typed collection of more than one thing (yikes)
            }

            return stronglyTypedInterfaces[0].GetGenericArguments()[0];
        }
开发者ID:Wahesh,项目名称:azure-batch-samples,代码行数:14,代码来源:PropertyDisplayModel.cs

示例7: GetInterfaceType

        private Type GetInterfaceType(Type type)
        {
            lock (_cacheLock)
            {
                Type interfaceType;

                if (!_cache.TryGetValue(type, out interfaceType))
                {
                    _cache[type] = interfaceType = type.FindInterfaces((t, o) => ((Type[])o).All(c => t == c || !t.IsAssignableFrom(c)), type.GetInterfaces()).Single();
                }

                return interfaceType;
            }
        }
开发者ID:ZoralLabs,项目名称:NES,代码行数:14,代码来源:EventConversionRunner.cs

示例8: FindGenericInterface

        public static Type FindGenericInterface(Type gType, Type gInterface)
        {
            // maybe gType is generic interface?
            if (gType.IsGenericType && gType.GetGenericTypeDefinition() == gInterface)
                return gType;

            string interfaceName = gInterface.Name;
            Type[] foundInterfaces = gType.FindInterfaces(Module.FilterTypeName, interfaceName);
            if (foundInterfaces != null)
                for (int i = 0; i < foundInterfaces.Length; i++) {
                    Type deff = foundInterfaces[i].GetGenericTypeDefinition();
                    if (deff == gInterface)
                        return foundInterfaces[i];
                }
            return null;
        }
开发者ID:Mariamfelicia,项目名称:nreco,代码行数:16,代码来源:TypeHelper.cs

示例9: IsCollectionType

		/// <summary>
		/// true if type is array, IEnumerable, etc
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		public static bool IsCollectionType(Type type)
		{
			if (type.IsArray) return true;
			if (type == typeof(IList)) return true; 
			if (type == typeof(string)) return false;

			if (type.IsGenericType)
			{
				if (type.GetGenericTypeDefinition() == typeof (IEnumerable<>)) return true;

				var types = type.FindInterfaces((typ, cri) => (
					typ.IsGenericType && typ.GetGenericTypeDefinition() == typeof(IEnumerable<>)), null);
				return types.Length != 0;
			}

			return false;
		}
开发者ID:Nanako-Kbs,项目名称:castlezmq,代码行数:22,代码来源:ReflectionUtils.cs

示例10: GetProperties

        public static PropertyInfo[] GetProperties(Type IType, Type clazz)
        {
            PropertyInfo[] pi = IType.GetProperties();
            Type[] interfaces = clazz.FindInterfaces(new TypeFilter(MyInterfaceFilter), IType);

            if (interfaces.Length == 0)
                return pi;

            PropertyInfo[] piChild = interfaces[0].GetProperties();
            if (piChild.Length == 0)
                return pi;

            PropertyInfo[] res = new PropertyInfo[pi.Length + piChild.Length];
            pi.CopyTo(res, 0);
            piChild.CopyTo(res, pi.Length);
            return res;
        }
开发者ID:Confirmit,项目名称:Portal,代码行数:17,代码来源:InterfaceHelper.cs

示例11: CollectMethodsToProxy

		protected void CollectMethodsToProxy(ArrayList methodList, Type type, bool onlyVirtuals)
		{
			CollectMethods(methodList, type, onlyVirtuals);

			if (type.IsInterface)
			{
				Type[] typeChain = type.FindInterfaces(new TypeFilter(NoFilter), null);

				foreach(Type interType in typeChain)
				{
					CollectMethods(methodList, interType, onlyVirtuals);
				}
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:14,代码来源:BaseProxyGenerator.cs

示例12: GetGenericInterfaceElementType

        /// <summary>
        /// Returns the "T" in the IQueryable of T implementation of type.
        /// </summary>
        /// <param name="type">Type to check.</param>
        /// <param name="typeFilter">filter against which the type is checked</param>
        /// <returns>
        /// The element type for the generic IQueryable interface of the type,
        /// or null if it has none or if it's ambiguous.
        /// </returns>
        internal static Type GetGenericInterfaceElementType(Type type, TypeFilter typeFilter)
        {
            Debug.Assert(type != null, "type != null");
            Debug.Assert(!type.IsGenericTypeDefinition, "!type.IsGenericTypeDefinition");

            if (typeFilter(type, null))
            {
                return type.GetGenericArguments()[0];
            }

            Type[] queriables = type.FindInterfaces(typeFilter, null);
            if (queriables != null && queriables.Length == 1)
            {
                return queriables[0].GetGenericArguments()[0];
            }
            else
            {
                return null;
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:29,代码来源:BaseServiceProvider.cs

示例13: FindInterfaceMethod

		private static MethodInfo FindInterfaceMethod( Type targetType, Type interfaceType, string name, Type[] parameterTypes )
		{
			if ( targetType.GetIsInterface() )
			{
				return targetType.FindInterfaces( ( type, _ ) => type == interfaceType, null ).Single().GetMethod( name, parameterTypes );
			}

			var map = targetType.GetInterfaceMap( interfaceType );

#if !SILVERLIGHT
			int index = Array.FindIndex( map.InterfaceMethods, method => method.Name == name && method.GetParameters().Select( p => p.ParameterType ).SequenceEqual( parameterTypes ) );
#else
			int index = map.InterfaceMethods.FindIndex( method => method.Name == name && method.GetParameters().Select( p => p.ParameterType ).SequenceEqual( parameterTypes ) );
#endif

			if ( index < 0 )
			{
#if DEBUG
				Contract.Assert( false, interfaceType + "::" + name + "(" + String.Join( ", ", parameterTypes.Select( t => t.ToString() ).ToArray() ) + ") is not found in " + targetType );
#endif
				return null;
			}
			else
			{
				return map.TargetMethods[ index ];
			}
		}
开发者ID:songotony,项目名称:RType-Client,代码行数:27,代码来源:ReflectionExtensions.cs

示例14: FindConstructionOfGenericInterfaceDefinition

        /// <summary>
        /// Finds and returns the constructed type of an interface 
        /// generic type definition if the type implements it. Otherwise
        /// returns a <c>null</c> reference.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">
        /// Either <paramref name="type"/> or <paramref name="genericTypeDefinition"/> 
        /// is a null reference.
        /// </exception>

        internal static Type FindConstructionOfGenericInterfaceDefinition(Type type, Type genericTypeDefinition)
        {
            if (type == null) throw new ArgumentNullException("type");
            if (genericTypeDefinition == null) throw new ArgumentNullException("genericTypeDefinition");

            Type[] interfaces = type.FindInterfaces(new TypeFilter(IsConstructionOfGenericInterfaceDefinition), genericTypeDefinition);
            return interfaces.Length == 0 ? null : interfaces[0];
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:18,代码来源:Reflector.cs

示例15: Select

        /// <summary>
        /// Selects the range of all the lists that are keyed on the type
        /// name given or the name of any parent class or interface. For
        /// example, giving typeof(string) will return any for
        /// "System.String" or "System.Object" and so on.
        /// </summary>
        public IList Select(Type type)
        {
            // Create a list
            ArrayList list = new ArrayList();

            // Ignore nulls (since that happens at the top-most object)
            if (type == null)
                return list;

            // Add this type's keys
            IList l = (IList) lists[type.FullName];

            if (l != null)
                list.AddRange(l);

            // Add the base types
            list.AddRange(Select(type.BaseType));

            // Add the interfaces, if any
            Type [] interfaces
                = type.FindInterfaces(new TypeFilter(FindAllTypes), null);

            foreach (Type iType in interfaces)
                list.AddRange(Select(iType));

            // Return the list
            return list;
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:34,代码来源:TypeChooser.cs


注:本文中的System.Type.FindInterfaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。