本文整理汇总了C#中System.Reflection.MemberInfo.IsStatic方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.IsStatic方法的具体用法?C# MemberInfo.IsStatic怎么用?C# MemberInfo.IsStatic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.IsStatic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindIntroducedField
/// <summary>
/// Finds the introduced field.
/// </summary>
/// <param name="advice">The advice.</param>
/// <param name="adviceMemberInfo">The advice member information.</param>
/// <param name="advisedType">Type of the advised.</param>
/// <returns></returns>
/// <exception cref="System.InvalidOperationException">Internal error, can not find matching introduced field</exception>
internal static FieldInfo FindIntroducedField(IAdvice advice, MemberInfo adviceMemberInfo, Type advisedType)
{
var introducedFieldType = GetIntroducedType(adviceMemberInfo);
var adviceType = advice.GetType();
var introducedFieldName = IntroductionRules.GetName(adviceType.Namespace, adviceType.Name, adviceMemberInfo.Name);
var linkID = string.Format("{0}:{1}", adviceType.AssemblyQualifiedName, adviceMemberInfo.Name);
const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
var introducedField = FindIntroducedFieldByName(advisedType, introducedFieldName, linkID, bindingFlags)
?? FindIntroducedFieldByTypeAndAvailability(advisedType, introducedFieldType, adviceMemberInfo.IsStatic(), null, bindingFlags)
?? FindIntroducedFieldByTypeAndAvailability(advisedType, introducedFieldType, adviceMemberInfo.IsStatic(), linkID, bindingFlags);
if (introducedField == null)
throw new InvalidOperationException("Internal error, can not find matching introduced field");
var introducedFieldAttribute = introducedField.GetCustomAttribute<IntroducedFieldAttribute>();
introducedFieldAttribute.LinkID = linkID;
return introducedField;
}
示例2: CreateInvocationContext
/// <summary>
/// Creates the invocation context.
/// </summary>
/// <returns>The invokation context or null, if can't be handled by Dynamitey.</returns>
/// <param name="device">Target device.</param>
/// <param name="info">Field, property or method info.</param>
private static InvokeContext CreateInvocationContext(object device, MemberInfo info)
{
if(info.IsStatic())
{
if(info is FieldInfo || info is PropertyInfo)
{
//FieldInfo not supported in Dynamitey
return null;
}
return InvokeContext.CreateStatic(device.GetType());
}
var propertyInfo = info as PropertyInfo;
if(propertyInfo != null)
{
//private properties not supported in Dynamitey
if((propertyInfo.CanRead && propertyInfo.GetGetMethod(true).IsPrivate)
|| (propertyInfo.CanWrite && propertyInfo.GetSetMethod(true).IsPrivate))
{
return null;
}
}
return InvokeContext.CreateContext(device, info.ReflectedType);
}