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


C# System.GetParameters方法代码示例

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


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

示例1: HasTestCasesFor

        public bool HasTestCasesFor(System.Reflection.MethodInfo method)
        {
            if (method.GetParameters().Length == 0)
                return false;

            foreach (ParameterInfo parameter in method.GetParameters())
                if (!dataPointProvider.HasDataFor(parameter))
                    return false;

            return true;
        }
开发者ID:rmterra,项目名称:AutoTest.Net,代码行数:11,代码来源:CombinatorialTestCaseProvider.cs

示例2: GetInstance

        public override object GetInstance(System.Reflection.ConstructorInfo constructor, object[] parameters = null)
        {
            if (cache.ContainsKey(constructor.DeclaringType))
            {
                return cache[constructor.DeclaringType];
            }

            var dependencies = constructor.GetParameters();
            if (dependencies.Count() == 0)
            {
                var instance = Activator.CreateInstance(constructor.DeclaringType);
                cache.Add(constructor.DeclaringType, instance);

                return instance;
            }
            else
            {
                if (parameters == null || parameters.Count() != dependencies.Count())
                {
                    throw new Exception("Incorrect number of parameters to invoke instance.");
                }

                var instance = constructor.Invoke(parameters);
                cache.Add(constructor.DeclaringType, instance);

                return instance;
            }
        }
开发者ID:stesta,项目名称:Injectamundo,代码行数:28,代码来源:SingletonLifestyle.cs

示例3: LogicalMethodInfo

 private LogicalMethodInfo(System.Reflection.MethodInfo beginMethodInfo, System.Reflection.MethodInfo endMethodInfo, WebMethod webMethod)
 {
     this.methodInfo = beginMethodInfo;
     this.endMethodInfo = endMethodInfo;
     this.methodName = beginMethodInfo.Name.Substring(5);
     if (webMethod != null)
     {
         this.binding = webMethod.binding;
         this.attribute = webMethod.attribute;
         this.declaration = webMethod.declaration;
     }
     ParameterInfo[] parameters = beginMethodInfo.GetParameters();
     if (((parameters.Length < 2) || (parameters[parameters.Length - 1].ParameterType != typeof(object))) || (parameters[parameters.Length - 2].ParameterType != typeof(AsyncCallback)))
     {
         throw new InvalidOperationException(Res.GetString("WebMethodMissingParams", new object[] { beginMethodInfo.DeclaringType.FullName, beginMethodInfo.Name, typeof(AsyncCallback).FullName, typeof(object).FullName }));
     }
     this.stateParam = parameters[parameters.Length - 1];
     this.callbackParam = parameters[parameters.Length - 2];
     this.inParams = GetInParameters(beginMethodInfo, parameters, 0, parameters.Length - 2, true);
     ParameterInfo[] paramInfos = endMethodInfo.GetParameters();
     this.resultParam = paramInfos[0];
     this.outParams = GetOutParameters(endMethodInfo, paramInfos, 1, paramInfos.Length - 1, true);
     this.parameters = new ParameterInfo[this.inParams.Length + this.outParams.Length];
     this.inParams.CopyTo(this.parameters, 0);
     this.outParams.CopyTo(this.parameters, this.inParams.Length);
     this.retType = endMethodInfo.ReturnType;
     this.isVoid = this.retType == typeof(void);
     this.attributes = new Hashtable();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:LogicalMethodInfo.cs

示例4: CreateParameters

        /// <summary>
        /// 创建一个ParameterCollection
        /// </summary>
        /// <param name="method"></param>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public static ParameterCollection CreateParameters(System.Reflection.MethodInfo method, string jsonString)
        {
            if (!string.IsNullOrEmpty(jsonString))
            {
                JObject obj = JObject.Parse(jsonString);
                if (obj.Count > 0)
                {
                    var pis = method.GetParameters();
                    object[] parameters = new object[pis.Length];
                    var index = 0;
                    foreach (var p in pis)
                    {
                        var property = obj.Properties().SingleOrDefault(o => string.Compare(o.Name, p.Name, true) == 0);
                        if (property != null)
                        {
                            //获取Json值
                            string value = property.Value.ToString(Newtonsoft.Json.Formatting.None);
                            object jsonValue = CoreHelper.ConvertJsonValue(p.ParameterType, value);
                            parameters[index] = jsonValue;
                        }

                        index++;
                    }

                    //创建参数集合
                    return CreateParameters(method, parameters);
                }
            }

            //如果json检测不通过,返回空的参数集合
            return new ParameterCollection();
        }
开发者ID:rajayaseelan,项目名称:mysoftsolution,代码行数:38,代码来源:IoCHelper.cs

示例5: IsValidForRequest

        public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
        {
            var methodParams = methodInfo.GetParameters();

            foreach (var parameterInfo in methodParams)
            {
                if (parameterInfo.HasDefaultValue)
                {
                    continue;
                }

                var paramType = parameterInfo.ParameterType;
                if (!IsSimpleType(paramType))
                {
                    continue;
                }

                var value = controllerContext.Controller.ValueProvider.GetValue(parameterInfo.Name);
                if (value == null || value.AttemptedValue == null || !CanParse(value.AttemptedValue, paramType, value.Culture))
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:sgaikwad,项目名称:mvcapplication,代码行数:26,代码来源:NonNullableParametersAttribute.cs

示例6: GetArgsString

 private StringBuilder GetArgsString(System.Reflection.MethodInfo method)
 {
     var sb = new StringBuilder();
     foreach (var arg in method.GetParameters())
         sb.Append(string.Format("{0} {1}, ", arg.ParameterType.Name, arg.Name));
     return sb;
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyCommandScript.cs

示例7: CompositionException

		public CompositionException(System.Reflection.MethodBase Method,string message, System.Exception innerException):this(String.Format("{0}\r\nAssembly:{1}\r\n{2}:{3}\r\nArgs:\r\n",message,Method.ReflectedType.AssemblyQualifiedName,Method.MemberType.ToString(),Method.Name),innerException)
		{
			System.Reflection.ParameterInfo[] parameters = Method.GetParameters();
			for(int i = 0; i<parameters.Length; i++)
			{
				_message = String.Format("{0}\t{1}({2})\r\n",_message,parameters[i].Name,parameters[i].ParameterType.ToString());
			}
		}
开发者ID:dialectsoftware,项目名称:DialectSoftware.Composition,代码行数:8,代码来源:CompositionException.cs

示例8: GenerateMethodCall

        protected override void GenerateMethodCall(StringBuilder js, System.Reflection.MethodInfo method, string Controller, bool documentate)
        {
            var jsattribute = method.DeclaringType.GetCustomAttributes(typeof(JsActionAttribute), false).First() as JsActionAttribute;

            if (groups.Count(str => string.IsNullOrEmpty(str) == false) > 0 && jsattribute.Groups.Split(',').Intersect(groups).Count() == 0)
                return;

            var pars = method.GetParameters();

            var parameters = string.Join(",", pars.Select(m => m.Name));
            if (parameters.Length > 0)
                parameters += ',';
            js.AppendFormat("{0}:function({1}options)", method.Name, parameters);

            pars.FirstOrDefault(m =>
            {
                if (m.ParameterType.IsGenericType)
                    ComplexTypeList.Value.Add(m.ParameterType.GetGenericArguments().First());
                else if (this.FindIEnumerable(m.ParameterType) == null && m.ParameterType != typeof(DateTime) && m.ParameterType != typeof(DateTimeOffset) && m.ParameterType.IsPrimitive == false)
                    ComplexTypeList.Value.Add(m.ParameterType);
                return false;
            });

            js.Append('{');
            if (documentate)
            {
                //Method can be empty.
                this.DocumentateTheFunction(js, method);
                js.Append("},");
                return;

            }
            string url = RouteTable.Routes.GetVirtualPath(this.requestContext, new RouteValueDictionary(new { httproute = "", controller = Controller })).VirtualPath;

            StringBuilder jsondata = new StringBuilder();

            foreach (var parameter in pars)
            {
                jsondata.AppendFormat("{0}:{0},", parameter.Name);
            }

            if (jsondata.Length > 0)
                jsondata.Remove(jsondata.Length - 1, 1);

            string requestmethod = string.Empty;

            if (method.Name.StartsWith("GET", StringComparison.InvariantCultureIgnoreCase))
                requestmethod = "GET";
            else if (method.Name.StartsWith("POST", StringComparison.InvariantCultureIgnoreCase))
                requestmethod = "POST";
            else if (method.Name.StartsWith("PUT", StringComparison.InvariantCultureIgnoreCase))
                requestmethod = "PUT";
            else if (method.Name.StartsWith("DELETE", StringComparison.InvariantCultureIgnoreCase))
                requestmethod = "DELETE";

            js.AppendFormat("var opts={{success:trd,url:\"{0}\",async:{4},cache:{3},type:\"{1}\",data:$.toDictionary({{{2}}})}};", url, requestmethod, jsondata, jsattribute.CacheRequest == true ? "true" : "false", jsattribute.Async == true ? "true" : "false");
            js.Append("jQuery.extend(opts,options);return jQuery.ajax(opts);},");
        }
开发者ID:ericziko,项目名称:JsAction,代码行数:58,代码来源:JsActionWebApiHandler.cs

示例9: MethodToString

 private static string MethodToString(System.Reflection.MethodInfo method)
 {
   return (method.ReturnType == null ? "void" : method.ReturnType.Name)
     + " "
     + method.Name
     + "("
     + method.GetParameters()
             .GroupConcat(", ", p => (p.IsOut ? "out " : "") + p.ParameterType.Name + " " + p.Name + (p.IsOptional ? " = " + (p.DefaultValue ?? "null").ToString() : ""))
     + ")";
 }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:10,代码来源:ImportXsltHelper.cs

示例10: Method

 public Method(System.Reflection.MethodInfo theMethod) {
     method = theMethod;
     var methodArguments = method.GetParameters();
     arguments = new Argument[methodArguments.Length];
     for (var i = 0; i < methodArguments.Length; ++i) {
         arguments[i] = new Argument();
         arguments[i].name = methodArguments[i].Name;
         arguments[i].type = methodArguments[i].ParameterType;
     }
 }
开发者ID:GregWeil,项目名称:ResearchProjectGSAS,代码行数:10,代码来源:StateMachineUtilities.cs

示例11: Execute

        public Result Execute(ICommunicationObject client, string service, System.Reflection.MethodBase method, params object[] data)
        {


            RemoteInvokeArgs info = new RemoteInvokeArgs();
            info.Interface = service;
            int index = method.Name.LastIndexOf('.');
            index = index>0?(index+1):0;
            info.Method = method.Name.Substring(index, method.Name.Length - index);
            info.Parameters = data;
            info.CommunicationObject = client;
            info.ParameterInfos = method.GetParameters();
            foreach (System.Reflection.ParameterInfo pi in method.GetParameters())
            {
                info.ParameterTypes.Add(pi.ParameterType.Name);
            }
            return Handler.Execute(info);

        }
开发者ID:kueiwa,项目名称:EC.Clients,代码行数:19,代码来源:ProxyFactory.cs

示例12: SetRefParameters

        /// <summary>
        /// 设置ParameterCollection值
        /// </summary>
        /// <param name="method"></param>
        /// <param name="collection"></param>
        /// <param name="parameters"></param>
        public static void SetRefParameters(System.Reflection.MethodInfo method, ParameterCollection collection, object[] parameters)
        {
            int index = 0;
            foreach (var p in method.GetParameters())
            {
                if (p.ParameterType.IsByRef)
                    collection[p.Name] = parameters[index];

                index++;
            }
        }
开发者ID:rajayaseelan,项目名称:mysoftsolution,代码行数:17,代码来源:IoCHelper.cs

示例13: SetRefParameterValues

        /// <summary>
        /// 设置参数值
        /// </summary>
        /// <param name="method"></param>
        /// <param name="collection"></param>
        /// <param name="parameters"></param>
        public static void SetRefParameterValues(System.Reflection.MethodInfo method, ParameterCollection collection, object[] parameters)
        {
            var index = 0;
            foreach (var p in method.GetParameters())
            {
                //给参数赋值
                if (p.ParameterType.IsByRef)
                    parameters[index] = collection[p.Name];

                index++;
            }
        }
开发者ID:rajayaseelan,项目名称:mysoftsolution,代码行数:18,代码来源:IoCHelper.cs

示例14: CompileTimeValidate

        public override bool CompileTimeValidate(System.Reflection.MethodBase method)
        {
            var parameters = method.GetParameters().ToArray();
            for (var i = 0; i < parameters.Length; i++)
                if (this._arguments[i] != parameters[i].ParameterType)
                {
                    var msg = string.Format(ArgumentValidationAspect._INVALID_ARGUMENT, _paramNames);
                    throw new ArgumentException(msg, parameters[i].Name);
                }

            return true;
        }
开发者ID:Kakyo,项目名称:XYZ,代码行数:12,代码来源:ArgumentValidationAspect.cs

示例15: BuilderMethod

 private void BuilderMethod(System.Reflection.MethodInfo method)
 {
     List<string> ps = new List<string>();
     List<string> tps = new List<string>();
     ParameterInfo[] pis = method.GetParameters();
     foreach (ParameterInfo pi in method.GetParameters())
     {
         tps.Add(pi.Name);
         string pt = "";
        if (pi.IsRetval)
             pt = "ref";
         if (pi.IsOut)
             pt = "out";
         ps.Add(string.Format(" {0} {1} {2}", pt, GetTypeName(pi.ParameterType), pi.Name));
     }
     mCode.AppendFormat("public {0} {1}({2})\r\n", method.ReturnType.FullName == "System.Void" ? "void" :GetTypeName( method.ReturnType),
         method.Name, ps.Count == 0 ? "" : string.Join(",", ps.ToArray()));
     mCode.AppendLine("{");
     foreach (ParameterInfo pi in method.GetParameters())
     {
         if (pi.IsOut)
             mCode.AppendFormat("{0}=default({1});\r\n", pi.Name,  GetTypeName( pi.ParameterType));
     }
     mCode.AppendFormat("Result result = ProxyFactory.CursorFactory.Execute(this,\"{1}\",System.Reflection.MethodInfo.GetCurrentMethod(),{0});",
         tps.Count == 0 ? "new object[0]" : string.Join(",", tps.ToArray()),mInterfaceType.Name);
     for (int i = 0; i < ps.Count; i++)
     {
         if (ps[i].IndexOf("ref") >= 0 || ps[i].IndexOf("out")>=0)
         {
             mCode.AppendFormat("{0}=({1})result[\"{0}\"];", tps[i], GetTypeName( pis[i].ParameterType));
         }
     }
     if (method.ReturnType.FullName != "System.Void")
     {
         mCode.AppendFormat("return ({0})result.Data;\r\n",GetTypeName( method.ReturnType));
     }
     mCode.AppendLine("}");
 }
开发者ID:qcjxberin,项目名称:ec,代码行数:38,代码来源:ProxyBuilder.cs


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