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


C# ParameterInfo.Where方法代码示例

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


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

示例1: CheckIfParametersEquals

        private static bool CheckIfParametersEquals(ParameterInfo[] parameters, params Type[] targets)
        {
            if (parameters.Length != targets.Length)
                return false;

            return !parameters.Where((each, index) => each.ParameterType != targets[index]).Any();
        }
开发者ID:ktj007,项目名称:mmo,代码行数:7,代码来源:HandlerHelper.cs

示例2: IsMatch

        private static bool IsMatch(ParameterInfo[] parameters, Type[] parameterTypes)
        {
            if (parameterTypes == null)
                parameterTypes = EmptyTypes;

            if (parameters.Length != parameterTypes.Length)
                return false;

            return !parameters.Where((t, i) => t.ParameterType != parameterTypes[i]).Any();
        }
开发者ID:rudimk,项目名称:HAMMER,代码行数:10,代码来源:TypeExtensions.cs

示例3: CollectArguments

        /// <summary>
        /// Collect the arguments from given parameter types.
        /// </summary>
        /// <param name="dependencyResolver">The depenency resolver.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="resolutionContext">The resolution context.</param>
        /// <returns>The collected arguments.</returns>
        public object[] CollectArguments(Func<Type, object> dependencyResolver, ParameterInfo[] parameters, ResolutionContext resolutionContext)
        {
            var finalArguments = new List<object>();

            var dependencyParameters =
                parameters.Where(
                    p =>
                    resolutionContext.RegistrationContainer.HasRegistration(p.ParameterType)
                    ||
                    resolutionContext.RegistrationContainer.IsSupportedByRegistrationSource(p.ParameterType));

            Func<object, ParameterInfo, bool> argumentSelector = (argument, parameter) => parameter.ParameterType.IsInstanceOfType(argument);

            var runtimeArguments = resolutionContext.RuntimeArguments;
            var arguments = resolutionContext.Arguments;

            // Priority from heighest: Runtime arguments -> named / anonymous, Arguments -> named / anonymous / depdendency parameters.
            foreach (ParameterInfo parameter in parameters)
            {
                ParameterInfo localParameter = parameter;

                if (runtimeArguments.NamedArguments != null && runtimeArguments.NamedArguments.ContainsKey(parameter.Name))
                {
                    finalArguments.Add(runtimeArguments.NamedArguments[parameter.Name]);
                    continue;
                }

                if (runtimeArguments.AnonymousArguments != null && runtimeArguments.AnonymousArguments.Any(argument => argumentSelector(argument, localParameter)))
                {
                    finalArguments.Add(runtimeArguments.AnonymousArguments.FirstOrDefault(argument => argumentSelector(argument, localParameter)));
                    continue;
                }

                if (arguments.NamedArguments != null && arguments.NamedArguments.ContainsKey(parameter.Name))
                {
                    finalArguments.Add(arguments.NamedArguments[parameter.Name]);
                    continue;
                }

                if (arguments.AnonymousArguments != null && arguments.AnonymousArguments.Any(argument => argumentSelector(argument, localParameter)))
                {
                    finalArguments.Add(arguments.AnonymousArguments.FirstOrDefault(argument => argumentSelector(argument, localParameter)));
                    continue;
                }

                if (dependencyParameters.Contains(parameter))
                {
                    finalArguments.Add(dependencyResolver(parameter.ParameterType));
                    continue;
                }
            }

            return finalArguments.ToArray();
        }
开发者ID:peterbucher,项目名称:LightCore,代码行数:61,代码来源:ArgumentCollector.cs

示例4: WriteAttributeForEach

		//===========================================================================================
		private void WriteAttributeForEach(IndentedTextWriter writer, ParameterInfo[] allParameters)
		{
			ParameterInfo[] parameters = allParameters.Where(p => _GraphicsMagickNET.GetXsdAttributeType(p) != null).ToArray();
			if (parameters.Length == 0)
				return;

			parameters = parameters.OrderBy(p => p.Name).ToArray();

			writer.WriteLine("for each(XmlAttribute^ attribute in element->Attributes)");
			WriteStartColon(writer);

			if (parameters.DistinctBy(p => _GraphicsMagickNET.GetCppTypeName(p)).Count() == 1)
			{
				writer.Write("arguments[attribute->Name] = _Variables->GetValue<");
				writer.Write(_GraphicsMagickNET.GetCppTypeName(parameters[0]));
				writer.WriteLine(">(attribute);");
			}
			else
			{
				for (int i = 0; i < parameters.Length; i++)
				{
					string xsdName = _GraphicsMagickNET.GetXsdName(parameters[i]);

					if (i > 0)
						writer.Write("else ");

					writer.Write("if (attribute->Name == \"");
					writer.Write(xsdName);
					writer.WriteLine("\")");
					writer.Indent++;
					writer.Write("arguments[\"");
					writer.Write(xsdName);
					writer.Write("\"] = ");
					WriteGetAttributeValue(writer, _GraphicsMagickNET.GetCppTypeName(parameters[i]), xsdName);
					writer.Indent--;
				}
			}

			WriteEndColon(writer);
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:41,代码来源:CodeGenerator.cs

示例5: WriteAttributeForEach

    private void WriteAttributeForEach(ParameterInfo[] allParameters)
    {
      ParameterInfo[] parameters = allParameters.Where(p => MagickScriptTypes.GetXsdAttributeType(p) != null).ToArray();
      if (parameters.Length == 0)
        return;

      parameters = parameters.OrderBy(p => p.Name).ToArray();

      WriteLine("foreach (XmlAttribute attribute in element.Attributes)");
      WriteStartColon();

      if (parameters.DistinctBy(p => GetName(p)).Count() == 1)
      {
        Write("arguments[attribute.Name] = Variables.GetValue<");
        Write(GetName(parameters[0]));
        WriteLine(">(attribute);");
      }
      else
      {
        for (int i = 0; i < parameters.Length; i++)
        {
          string xsdName = MagickScriptTypes.GetXsdName(parameters[i]);

          if (i > 0)
            Write("else ");

          Write("if (attribute.Name == \"");
          Write(xsdName);
          WriteLine("\")");
          Indent++;
          Write("arguments[\"");
          Write(xsdName);
          Write("\"] = ");
          WriteGetAttributeValue(GetName(parameters[i]));
          Indent--;
        }
      }

      WriteEndColon();
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:40,代码来源:ScriptCodeGenerator.cs

示例6: EmitOutputParameters

		/// <summary>
		/// Copies fields from the temporary output parameters structure to the output parameters object specified by the caller.
		/// </summary>
		/// <param name="parameters">The list of parameters.</param>
		/// <param name="parameterWrapper">The local variable for the temporary object.</param>
		/// <param name="mIL">The ILGenerator to use.</param>
		private static void EmitOutputParameters(ParameterInfo[] parameters, LocalBuilder parameterWrapper, ILGenerator mIL)
		{
			foreach (var outputParameter in parameters.Where(p => p.IsOut))
			{
				mIL.Emit(OpCodes.Ldarg, outputParameter.Position + 1);
				mIL.Emit(OpCodes.Ldloc, parameterWrapper.LocalIndex);
				var fields = parameterWrapper.LocalType.GetFields();
				mIL.Emit(OpCodes.Ldfld, fields[outputParameter.Position]);
				mIL.Emit(OpCodes.Stobj, outputParameter.ParameterType.GetElementType());
			}
		}
开发者ID:ReinhardHsu,项目名称:Insight.Database,代码行数:17,代码来源:InterfaceGenerator.cs

示例7: ParametersMatch

 private static bool ParametersMatch(ParameterInfo[] methodParameters, object[] parameters)
 {
     return methodParameters.Length == parameters.Length
         && !methodParameters.Where((mp, i) => !mp.ParameterType.IsInstanceOfType(parameters[i])).Any();
 }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:5,代码来源:ConventionBasedChangeSetItemFilter.cs

示例8: WriteElementForEach

		//===========================================================================================
		private void WriteElementForEach(IndentedTextWriter writer, ParameterInfo[] allParameters)
		{
			ParameterInfo[] parameters = allParameters.Where(p => _GraphicsMagickNET.GetXsdAttributeType(p) == null).ToArray();
			if (parameters.Length == 0)
				return;

			writer.WriteLine("for each(XmlElement^ elem in element->SelectNodes(\"*\"))");
			WriteStartColon(writer);

			if (parameters.DistinctBy(p => _GraphicsMagickNET.GetCppTypeName(p)).Count() == 1)
			{
				writer.Write("arguments[elem->Name] = ");
				WriteCreateMethod(writer, _GraphicsMagickNET.GetCppTypeName(parameters[0]));
				writer.WriteLine("(elem);");
			}
			else
			{
				for (int i = 0; i < parameters.Length; i++)
				{
					string xsdName = _GraphicsMagickNET.GetXsdName(parameters[i]);

					if (i > 0)
						writer.Write("else ");

					writer.Write("if (elem->Name == \"");
					writer.Write(xsdName);
					writer.WriteLine("\")");
					writer.Indent++;
					writer.Write("arguments[\"");
					writer.Write(xsdName);
					writer.Write("\"] = ");
					WriteCreateMethod(writer, _GraphicsMagickNET.GetCppTypeName(parameters[i]));
					writer.WriteLine("(elem);");
					writer.Indent--;
				}
			}

			WriteEndColon(writer);
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:40,代码来源:CodeGenerator.cs

示例9: WriteElementForEach

    private void WriteElementForEach(ParameterInfo[] allParameters)
    {
      ParameterInfo[] parameters = allParameters.Where(p => MagickScriptTypes.GetXsdAttributeType(p) == null).ToArray();
      if (parameters.Length == 0)
        return;

      WriteLine("foreach (XmlElement elem in element.SelectNodes(\"*\"))");
      WriteStartColon();

      if (parameters.DistinctBy(p => GetName(p)).Count() == 1)
      {
        Write("arguments[elem.Name] = ");
        WriteCreateMethod(GetName(parameters[0]));
        WriteLine("(elem);");
      }
      else
      {
        for (int i = 0; i < parameters.Length; i++)
        {
          string xsdName = MagickScriptTypes.GetXsdName(parameters[i]);

          if (i > 0)
            Write("else ");

          Write("if (elem.Name == \"");
          Write(xsdName);
          WriteLine("\")");
          Indent++;
          Write("arguments[\"");
          Write(xsdName);
          Write("\"] = ");
          WriteCreateMethod(GetName(parameters[i]));
          WriteLine("(elem);");
          Indent--;
        }
      }

      WriteEndColon();
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:39,代码来源:ScriptCodeGenerator.cs

示例10: PrepareParams

 protected override ParameterInfo[] PrepareParams(ParameterInfo[] parameters)
 {
     return parameters.Where(p => p.ParameterType != typeof(System.Web.Mvc.FormCollection) && !p.ParameterType.IsSubclassOf(typeof(System.Web.Mvc.FormCollection))).ToArray();
 }
开发者ID:shalves,项目名称:Ext.NET.Community,代码行数:4,代码来源:MvcDirectMethod.cs


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