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


C# Type.Select方法代码示例

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


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

示例1: InstantiatePlugins

 public static Plugin[] InstantiatePlugins(Type[] types)
 {
     if (_logger.IsDebugEnabled)
     {
         _logger.Debug("Instantiating plugins: {0}", String.Join(",", types.Select(a => a.FullName)));
     }
     return types.Select(Activator.CreateInstance).Cast<Plugin>().ToArray();
 }
开发者ID:GasiorowskiPiotr,项目名称:EvilDuck.Web.Cms,代码行数:8,代码来源:PluginAssemblyLoader.cs

示例2: BuildMetadata

        public static LongLookup<MessageMetadata> BuildMetadata(IStructSizeCounter counter,
            Func<Type, int> messageIdGetter, Type[] structTypes)
        {
            var keys = structTypes.Select(GetKey).ToArray();

            var values =
                structTypes.Select(type => new MessageMetadata(messageIdGetter(type), (short) counter.GetSize(type),
                    (short) (int) Marshal.OffsetOf(type, Envelope.FieldName))).ToArray();

            var metadata = new LongLookup<MessageMetadata>(keys, values);
            return metadata;
        }
开发者ID:Scooletz,项目名称:RampUp,代码行数:12,代码来源:MessageMetadata.cs

示例3: MultipleSagaHandlersFoundException

 /// <summary>
 /// Constructs the exception with a reference to the message that could be handled by multiple saga handlers
 /// </summary>
 public MultipleSagaHandlersFoundException(object messageThatCouldBeHandledByMultipleSagaHandlers, Type[] sagaHandlerTypes)
     : base(string.Format("The message type {0} could be handled by multiple saga handlers: {1}. This is an error because it would require that multiple saga instances could be updated atomically, which is not possible with all saga persisters",
     messageThatCouldBeHandledByMultipleSagaHandlers.GetType(), string.Join(", ", sagaHandlerTypes.Select(t => t.ToString()))))
 {
     this.messageThatCouldBeHandledByMultipleSagaHandlers = messageThatCouldBeHandledByMultipleSagaHandlers;
     this.sagaHandlerTypes = sagaHandlerTypes;
 }
开发者ID:plillevold,项目名称:Rebus,代码行数:10,代码来源:MultipleSagaHandlersException.cs

示例4: LoadTypesAssignableFrom

        internal static AssemblyLoaderReflectionCriterion LoadTypesAssignableFrom(Type[] requiredTypes)
        {
            // any types provided must be converted to reflection-only
            // types, or they aren't comparable with other reflection-only 
            // types.
            requiredTypes = requiredTypes.Select(TypeUtils.ToReflectionOnlyType).ToArray();
            string[] complaints = new string[requiredTypes.Length];
            for (var i = 0; i < requiredTypes.Length; ++i)
            {
                complaints[i] = String.Format("Assembly contains no types assignable from {0}.", requiredTypes[i].FullName);
            }  

            return
                AssemblyLoaderReflectionCriterion.NewCriterion(
                    (Type type, out IEnumerable<string> ignored) =>
                    {
                        ignored = null;
                        foreach (var requiredType in requiredTypes)
                        {
                            if (requiredType.IsAssignableFrom(type))
                            {
                                //  we found a match! load the assembly.
                                return true;
                            }
                        }
                        return false;  
                    },
                    complaints);
        }
开发者ID:osjimenez,项目名称:orleans,代码行数:29,代码来源:AssemblyLoaderCriteria.cs

示例5: GetRuntimeTypesFilter

 /// <summary>
 /// Gets the filter for the classifiers based on the runtime types.
 /// </summary>
 /// <param name="runtimeTypes">The runtime types.</param>
 /// <returns>A predicate to filter the classifiers based on the provided runtime types.</returns>
 private static Func<IClassifier, bool> GetRuntimeTypesFilter(Type[] runtimeTypes)
 {
     var runtimeTypeInfos = runtimeTypes.Select(t => t.AsRuntimeTypeInfo()).ToList();
     return
         c =>
         c.Parts.OfType<IRuntimeTypeInfo>()
             .Any(info => runtimeTypeInfos.Contains(info));
 } 
开发者ID:raimu,项目名称:kephas,代码行数:13,代码来源:AspectForAttribute.cs

示例6: GetRuntimeTypesFilter

 /// <summary>
 /// Gets the filter for the classifiers based on the runtime types.
 /// </summary>
 /// <param name="runtimeTypes">The runtime types.</param>
 /// <returns>A predicate to filter the classifiers based on the provided runtime types.</returns>
 private static Func<IClassifier, bool> GetRuntimeTypesFilter(Type[] runtimeTypes)
 {
     var runtimeTypeInfos = runtimeTypes.Select(t => t.GetTypeInfo()).ToList();
     return
         c =>
         c.UnderlyingElementInfos.OfType<IRuntimeNamedElementInfo>()
             .Any(info => runtimeTypeInfos.Contains(info.RuntimeElement));
 } 
开发者ID:movileanubeniamin,项目名称:kephas,代码行数:13,代码来源:AspectForAttribute.cs

示例7: MultipleResourceTypesException

 public MultipleResourceTypesException(string requestedTypeName, Type[] types)
     : base(string.Format("There are mutiple types that can be created for requested type '{0}': '{1}'", 
         requestedTypeName, 
         string.Join(",", types.Select(x => x.FullName).ToArray())))
 {
     RequestedTypeName = requestedTypeName;
     Types = types;
 }
开发者ID:Predica,项目名称:FimClient,代码行数:8,代码来源:MultipleResourceTypesException.cs

示例8: MethodBaseInfo

 // TODO: replace binding flags by bool flags
 protected MethodBaseInfo(string name, Type declaringType, BindingFlags bindingFlags, Type[] genericArguments, Type[] parameterTypes, Dictionary<Type, TypeInfo> referenceTracker)
     : this(name, 
     TypeInfo.Create(referenceTracker, declaringType, includePropertyInfos: false, setMemberDeclaringTypes: false), 
     bindingFlags,
     ReferenceEquals(null, genericArguments) ? null : genericArguments.Select(x => TypeInfo.Create(referenceTracker, x, false, false)),
     ReferenceEquals(null, parameterTypes) ? null : parameterTypes.Select(x => TypeInfo.Create(referenceTracker, x, false, false)))
 {
 }
开发者ID:6bee,项目名称:aqua-core,代码行数:9,代码来源:MethodBaseInfo.cs

示例9: FilterRegisterItem

 public FilterRegisterItem(Type controllerType, ReflectedActionDescriptor actionDescriptor, Type[] filterTypes)
 {
     ControllerType = controllerType;
     ActionDescriptor = actionDescriptor;
     _actionParameterDescriptors = ActionDescriptor.GetParameters();
     FilterTypes = filterTypes;
     Filters = () => FilterTypes.Select(f => Activator.CreateInstance(f) as FilterAttribute);
 }
开发者ID:hardCTE,项目名称:EasyFrameWork,代码行数:8,代码来源:FilterRegisterItem.cs

示例10: LoadTypes

 private void LoadTypes(Type[] types)
 {
     _types = types;
     chklstMatchingTypes.Items.Clear();
     foreach (var type in types.Select(i => new DbeType(i)))
     {
         chklstMatchingTypes.Items.Add(type, true);
     }
 }
开发者ID:sathukorale,项目名称:libDatabaseHelper,代码行数:9,代码来源:frmMatchingTypes.cs

示例11: GetWrappingNameWithType

        private string GetWrappingNameWithType(Type[] types)
        {
            if (!_baseType.IsGenericType) return ClassNamePlaceHolder + _baseType.Name;

            var genericParamString = GetGenericParamString(types.Select(GetParameterName));
            var typeNameWithoutGenericParams = _baseType.Name.Split('`')[0];

            return string.Format("{0}{1}<{2}>", ClassNamePlaceHolder, typeNameWithoutGenericParams, genericParamString);
        }
开发者ID:pazjacket,项目名称:posaunehm-_-Friendly.PinInterface.Generator,代码行数:9,代码来源:TypeWrapper.cs

示例12: Generate

        public static CSharpCompilation Generate(Options options, Type[] types, ITestOutputHelper output = null)
        {
            // generate code from types

            var generator = new EntryCodeGenerator(options);
            generator.GenerateCode(types);
            var code = generator.CodeWriter.ToString();
            if (output != null)
            {
                var typeInfo = string.Join(", ", types.Select(t => t.Name));
                output.WriteLine($"***** Generated Code({typeInfo}) *****");
                output.WriteLine(code);
                output.WriteLine("");
            }

            // compile generated code

            output?.WriteLine($"***** Compile Code *****");

            var parseOption = new CSharpParseOptions(LanguageVersion.CSharp6, DocumentationMode.Parse, SourceCodeKind.Regular);
            var syntaxTrees = new[] { CSharpSyntaxTree.ParseText(code, parseOption, "Generated.cs") };
            var references = new[] { typeof(object), typeof(IInterfacedActor), typeof(InterfacedActor), typeof(IActorRef), typeof(IGreeter) }
                .Select(t => MetadataReference.CreateFromFile(t.Assembly.Location));

            var compilation = CSharpCompilation.Create(
               "Generated.dll",
               syntaxTrees: syntaxTrees,
               references: references,
               options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));

            using (var ms = new MemoryStream())
            {
                var result = compilation.Emit(ms);

                if (!result.Success)
                {
                    var failures = result.Diagnostics.Where(diagnostic =>
                        diagnostic.IsWarningAsError ||
                        diagnostic.Severity == DiagnosticSeverity.Error);

                    foreach (var diagnostic in failures)
                    {
                        var line = diagnostic.Location.GetLineSpan();
                        output?.WriteLine("{0}({1}): {2} {3}",
                            line.Path,
                            line.StartLinePosition.Line + 1,
                            diagnostic.Id,
                            diagnostic.GetMessage());
                    }
                }

                Assert.True(result.Success, "Build error!");
            }

            return compilation;
        }
开发者ID:SaladLab,项目名称:Akka.Interfaced,代码行数:56,代码来源:TestUtility.cs

示例13: TryReflectMethod

        internal static bool TryReflectMethod(out MethodInfo methodInfo, out UnityReflectionException exception, UnityObject reflectionTarget, string name, Type[] parameterTypes)
        {
            #if !NETFX_CORE
            methodInfo = null;

            Type type = reflectionTarget.GetType();
            BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy;

            if (parameterTypes != null) // Explicit matching
            {
                methodInfo = type.GetMethod(name, flags, null, parameterTypes, null);

                if (methodInfo == null)
                {
                    methodInfo = type.GetExtensionMethods()
                        .Where(extension => extension.Name == name)
                        .Where(extension => Enumerable.SequenceEqual(extension.GetParameters().Select(paramInfo => paramInfo.ParameterType), parameterTypes))
                        .FirstOrDefault();
                }

                if (methodInfo == null)
                {
                    exception = new UnityReflectionException(string.Format("No matching method found: '{0}.{1} ({2})'", type.Name, name, string.Join(", ", parameterTypes.Select(t => t.Name).ToArray())));
                    return false;
                }
            }
            else // Implicit matching
            {
                var normalMethods = type.GetMember(name, MemberTypes.Method, flags).OfType<MethodInfo>().ToList();
                var extensionMethods = type.GetExtensionMethods().Where(extension => extension.Name == name).ToList();
                var methods = new List<MethodInfo>();
                methods.AddRange(normalMethods);
                methods.AddRange(extensionMethods);

                if (methods.Count == 0)
                {
                    exception = new UnityReflectionException(string.Format("No matching method found: '{0}.{1}'", type.Name, name));
                    return false;
                }

                if (methods.Count > 1)
                {
                    exception = new UnityReflectionException(string.Format("Multiple method signatures found for '{0}.{1}'\nSpecify the parameter types explicitly.", type.FullName, name));
                    return false;
                }

                methodInfo = methods[0];
            }

            exception = null;
            return true;
            #else
            throw new Exception("Reflection is not supported in .NET Core.");
            #endif
        }
开发者ID:lazlo-bonin,项目名称:unity-reflection,代码行数:55,代码来源:UnityMemberHelper.cs

示例14: InvokeGeneric

        public object InvokeGeneric(object instance, string name, Type[] types, params object[] arguments) {
            Type instanceType = instance.GetType();

            string key = instanceType.FullName + ":" + name + ":" + string.Join(":", types.Select(t=>t.FullName));

            Func<object, object[], object> result = CachedMethods.GetOrAdd(key, a =>
            {
                return CreateMethod(instanceType, name, types);
            });

            return result(instance, arguments);
        }
开发者ID:neurospeech,项目名称:atoms-mvc.net,代码行数:12,代码来源:GenericMethods.cs

示例15: CreatesCorrectFixtures

        public void CreatesCorrectFixtures(Type testClass, Type[] fixtureTypes, InterfaceFixtureSetFactory sut)
        {
            var result = sut.CreateFixturesFor(Reflector.Wrap(testClass));
            Assert.IsType<FixtureSet>(result);
            var fixtureSet = (FixtureSet) result;

            Assert.That(fixtureSet.Fixtures, Matches.AllOf(fixtureTypes
                .Select(type =>
                {
                    var ifc = testClass.GetInterfaces().First(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IUseFixture<>) && x.GetGenericArguments()[0] == type);
                    return Has.Entry(Is.EqualTo(ifc.GetMethod("SetFixture", new[] {type})), Is.InstanceOf(type));
                })));
        }
开发者ID:fulviogabana,项目名称:xUnit.Paradigms,代码行数:13,代码来源:FixtureSetFactoryTests.cs


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