本文整理汇总了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;
}
示例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));
}