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


C# MemberInfo.IsStatic方法代码示例

本文整理汇总了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;
 }
开发者ID:csuffyy,项目名称:MrAdvice,代码行数:24,代码来源:Invocation.Introduction.cs

示例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);
 }
开发者ID:emul8,项目名称:emul8,代码行数:29,代码来源:MonitorCommands.cs


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