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


C# Type.Count方法代码示例

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


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

示例1: HookupParameterBinding

    /// <summary>
    /// Method that implements parameter binding hookup to the global configuration object's
    /// ParameterBindingRules collection delegate.
    /// 
    /// This routine filters based on POST/PUT method status and simple parameter
    /// types.
    /// </summary>
    /// <example>
    /// GlobalConfiguration.Configuration.
    ///       .ParameterBindingRules
    ///       .Insert(0,SimplePostVariableParameterBinding.HookupParameterBinding);
    /// </example>    
    /// <param name="descriptor"></param>
    /// <returns></returns>
    public static HttpParameterBinding HookupParameterBinding(HttpParameterDescriptor descriptor)
    {
        //To see is it mark the flag
        if (descriptor.ActionDescriptor.GetCustomAttributes<System.Web.Http.MultiParameterSupportAttribute>().Count <= 0)
            return null;

        var supportedMethods = descriptor.ActionDescriptor.SupportedHttpMethods;

        // Only apply this binder on POST and PUT operations
        if (supportedMethods.Contains(HttpMethod.Post) ||
            supportedMethods.Contains(HttpMethod.Put))
        {
            var supportedTypes = new Type[] { typeof(string),
                                                typeof(int),
                                                typeof(int?),
                                                typeof(decimal),
                                                typeof(decimal?),
                                                typeof(double),
                                                typeof(double?),
                                                typeof(long),
                                                typeof(long?),
                                                typeof(bool),
                                                typeof(bool?),
                                                typeof(DateTime),
                                                typeof(DateTime?),
                                                typeof(byte[])
                                            };

            if (supportedTypes.Count(typ => typ == descriptor.ParameterType) > 0)
                return new SimplePostVariableParameterBinding(descriptor);
        }

        return null;
    }
开发者ID:DoraemonYu,项目名称:SimplePostVariableParameterBindingExtended,代码行数:48,代码来源:SimplePostModelBinding.cs

示例2: HasControl

 private bool HasControl(JArray controls, Type[] controlTypes)
 {
     foreach (JObject control in controls)
     {
         var type = (string)control["type"];
         if (controlTypes.Count(c => string.Compare(c.FullName, type, true) == 0) > 0)
         {
             return true;
         }
     }
     return false;
 }
开发者ID:san90279,项目名称:UK_OAS,代码行数:12,代码来源:CodeHelper.cs

示例3: DefineConstructor

            private void DefineConstructor(IParameterMetadataProvider ipmp, ReadOnlyCollection<AttributeAst> attributeAsts, bool isHidden, Reflection.MethodAttributes methodAttributes, Type[] parameterTypes)
            {
                bool isStatic = (methodAttributes & Reflection.MethodAttributes.Static) != 0;
                var ctor = isStatic
                    ? _typeBuilder.DefineTypeInitializer()
                    : _typeBuilder.DefineConstructor(methodAttributes, CallingConventions.Standard, parameterTypes);
                DefineCustomAttributes(ctor, attributeAsts, _parser, AttributeTargets.Constructor);
                if (isHidden)
                {
                    ctor.SetCustomAttribute(s_hiddenCustomAttributeBuilder);
                }
                var ilGenerator = ctor.GetILGenerator();

                if (!isStatic)
                {
                    ilGenerator.Emit(OpCodes.Ldarg_0); // load 'this' on stack for Stfld call

                    ilGenerator.Emit(OpCodes.Ldnull);
                    ilGenerator.Emit(OpCodes.Ldfld, _sessionStateKeeperField);
                    ilGenerator.EmitCall(OpCodes.Call, s_sessionStateKeeper_GetSessionState, null); // load 'sessionState' on stack for Stfld call

                    ilGenerator.Emit(OpCodes.Stfld, _sessionStateField);
                }

                DefineMethodBody(ipmp, ilGenerator, GetMetaDataName(ctor.Name, parameterTypes.Count()), isStatic, parameterTypes, typeof(void),
                    (i, n) => ctor.DefineParameter(i, ParameterAttributes.None, n));
            }
开发者ID:40a,项目名称:PowerShell,代码行数:27,代码来源:PSType.cs


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