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


C# IReflect类代码示例

本文整理汇总了C#中IReflect的典型用法代码示例。如果您正苦于以下问题:C# IReflect类的具体用法?C# IReflect怎么用?C# IReflect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: BuildLoggerInjectors

        private static IEnumerable<Action<IComponentContext, object>> BuildLoggerInjectors(IReflect componentType)
        {
            // look for settable properties of type "ILogger"
            var loggerProperties = componentType
                .GetProperties(BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance)
                .Select(p => new
                {
                    PropertyInfo = p,
                    p.PropertyType,
                    IndexParameters = p.GetIndexParameters(),
                    Accessors = p.GetAccessors(false)
                })
                // must be a logger
                .Where(x => x.PropertyType == typeof(ILogger))
                // must not be an indexer
                .Where(x => x.IndexParameters.Count() == 0)
                // must have get/set, or only set
                .Where(x => x.Accessors.Length != 1 || x.Accessors[0].ReturnType == typeof(void));

            // return an IEnumerable of actions that resolve a logger and assign the property
            return loggerProperties
                   .Select(entry => entry.PropertyInfo)
                   .Select(propertyInfo => (Action<IComponentContext, object>)((ctx, instance) =>
                   {
                       var propertyValue = ctx.Resolve<ILogger>(new TypedParameter(typeof(Type), componentType));
                       propertyInfo.SetValue(instance, propertyValue, null);
                   }));
        }
开发者ID:mikkoj,项目名称:LunchCrawler,代码行数:28,代码来源:LoggingInjectModule.cs

示例2: GetPropertyCaseInsensitive

        private static PropertyInfo GetPropertyCaseInsensitive(IReflect type, string propertyName)
        {
            // make the property reflection lookup case insensitive
            const BindingFlags bindingFlags = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

            return type.GetProperty(propertyName, bindingFlags);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:7,代码来源:DefaultRepositoryConventions.cs

示例3: AssignmentCompatible

 internal bool AssignmentCompatible(IReflect lhir, bool reportError){
   if (lhir == Typeob.Object || lhir == Typeob.Array || lhir is ArrayObject) return true;
   IReflect target_element_ir;
   if (lhir == Typeob.Array)
     target_element_ir = Typeob.Object;
   else if (lhir is TypedArray){
     TypedArray tArr = ((TypedArray)lhir);
     if (tArr.rank != 1){
       this.context.HandleError(JSError.TypeMismatch, reportError);
       return false;
     }
     target_element_ir = tArr.elementType;
   }else if (lhir is Type && ((Type)lhir).IsArray){
     Type t = ((Type)lhir);
     if (t.GetArrayRank() != 1){
       this.context.HandleError(JSError.TypeMismatch, reportError);
       return false;
     }
     target_element_ir = t.GetElementType();
   }else
     return false;
   for (int i = 0, n = this.elements.count; i < n; i++)
     if (!Binding.AssignmentCompatible(target_element_ir, this.elements[i], this.elements[i].InferType(null), reportError))
       return false;
   return true;
 }
开发者ID:ArildF,项目名称:masters,代码行数:26,代码来源:arrayliteral.cs

示例4: HtmlToClrEventProxy

 public HtmlToClrEventProxy(object sender, string eventName, EventHandler eventHandler)
 {
     this.eventHandler = eventHandler;
     this.eventName = eventName;
     System.Type type = typeof(HtmlToClrEventProxy);
     this.typeIReflectImplementation = type;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:HtmlToClrEventProxy.cs

示例5: InternalAccessibleObject

 internal InternalAccessibleObject(AccessibleObject accessibleImplemention)
 {
     this.publicIAccessible = accessibleImplemention;
     this.publicIEnumVariant = accessibleImplemention;
     this.publicIOleWindow = accessibleImplemention;
     this.publicIReflect = accessibleImplemention;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:InternalAccessibleObject.cs

示例6: GetDefaultMembers

 private static MemberInfo[] GetDefaultMembers(Type typ, IReflect objIReflect, ref string DefaultName)
 {
     MemberInfo[] nonGenericMembers;
     if (typ == objIReflect)
     {
         do
         {
             object[] customAttributes = typ.GetCustomAttributes(typeof(DefaultMemberAttribute), false);
             if ((customAttributes != null) && (customAttributes.Length != 0))
             {
                 DefaultName = ((DefaultMemberAttribute) customAttributes[0]).MemberName;
                 nonGenericMembers = GetNonGenericMembers(typ.GetMember(DefaultName, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase));
                 if ((nonGenericMembers != null) && (nonGenericMembers.Length != 0))
                 {
                     return nonGenericMembers;
                 }
                 DefaultName = "";
                 return null;
             }
             typ = typ.BaseType;
         }
         while (typ != null);
         DefaultName = "";
         return null;
     }
     nonGenericMembers = GetNonGenericMembers(objIReflect.GetMember("", BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase));
     if ((nonGenericMembers == null) || (nonGenericMembers.Length == 0))
     {
         DefaultName = "";
         return null;
     }
     DefaultName = nonGenericMembers[0].Name;
     return nonGenericMembers;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:LateBinding.cs

示例7: HtmlToClrEventProxy

        public HtmlToClrEventProxy(object sender, string eventName, EventHandler eventHandler) {
            this.eventHandler = eventHandler;
            this.eventName = eventName;

            Type htmlToClrEventProxyType = typeof(HtmlToClrEventProxy);
            typeIReflectImplementation = htmlToClrEventProxyType as IReflect;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:HtmlToClrEventProxy.cs

示例8: DefaultEnvironmentProvider

 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultEnvironmentProvider"/> class.
 /// </summary>
 /// <param name="supportedType">A <see cref="IReflect"/> of a object with the supported Environment Aliases on.</param>
 protected DefaultEnvironmentProvider(IReflect supportedType)
 {
     this.SupportedAliases = supportedType
         .GetFields(BindingFlags.Static | BindingFlags.Public)
         .Where(f => f.IsLiteral)
         .Select(a => a.GetValue(supportedType) as string)
         .ToArray();
 }
开发者ID:TruffleMuffin,项目名称:Decisions,代码行数:12,代码来源:DefaultEnvironmentProvider.cs

示例9: VsaNamedItemScope

 internal VsaNamedItemScope(Object hostObject, ScriptObject parent, VsaEngine engine)
   : base(parent){
   this.namedItem = hostObject;
   if ((this.reflectObj = hostObject as IReflect) == null)
     this.reflectObj = hostObject.GetType();
   this.recursive = false;
   this.engine = engine;
 }
开发者ID:ArildF,项目名称:masters,代码行数:8,代码来源:vsanameditemscope.cs

示例10: CompareTypes

        private static IEnumerable<string> CompareTypes(IReflect type1, IReflect type2, BindingFlags bindingFlags)
        {
            MethodInfo[] typeTMethodInfo = type1.GetMethods(bindingFlags);
            MethodInfo[] typeXMethodInfo = type2.GetMethods(bindingFlags);

            return typeTMethodInfo.Select(x => x.Name)
                                  .Except(typeXMethodInfo.Select(x => x.Name));
        }
开发者ID:CL0SeY,项目名称:RestSharp,代码行数:8,代码来源:InterfaceImplementationTests.cs

示例11: LookupResource

 public static string LookupResource(IReflect resourceManagerProvider, string resourceKey)
 {
     PropertyInfo property = resourceManagerProvider.GetProperty(resourceKey, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
     // Fallback with the key name
     if (property == null)
         return resourceKey;
     return (string) property.GetValue(null, null); // returns string directly from res file
 }
开发者ID:denkhaus,项目名称:WPG,代码行数:8,代码来源:LocalizationResourceHelper.cs

示例12: FormatPropertiesResolver

 public FormatPropertiesResolver(IReflect type, IPropertyFormatInfoProvider formatInfoProvider)
 {
     this.formatInfoProvider = formatInfoProvider;
     PropertiesFormat =
         type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
             .Where(prop => prop.CanRead)
             .Select(ConvertToPropertyFormat)
             .Where(pform => pform != null);
 }
开发者ID:black-virus,项目名称:local-nuget,代码行数:9,代码来源:FormatPropertiesResolver.cs

示例13: FindUserProperty

 private static PropertyInfo FindUserProperty(IReflect type)
 {
     //寻找类型为 "Localizer" 并且具有set方法的属性。
     return type
         .GetProperties(BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance)
         .Where(x => x.PropertyType == typeof(Localizer)) //必须是一个本地化委托
         .Where(x => !x.GetIndexParameters().Any()) //没有索引器
         .FirstOrDefault(x => x.GetAccessors(false).Length != 1 || x.GetAccessors(false)[0].ReturnType == typeof(void)); //必须具有set方法。
 }
开发者ID:l1183479157,项目名称:RabbitHub,代码行数:9,代码来源:LocalizationModule.cs

示例14: GetFieldByPropertyName

		private static FieldInfo GetFieldByPropertyName(IReflect viewModelType, string propertyName)
		{
			var charList = new List<char> { char.ToLower(propertyName[0]) };
			charList.AddRange(propertyName.Substring(1));
			var fieldName = new string(charList.ToArray());

			var field = viewModelType.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
			return field;
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:9,代码来源:ReflectionCache.cs

示例15: HtmlEventProxy

 // private CTOR
 private HtmlEventProxy(string eventName, IHTMLElement2 htmlElement, EventHandler eventHandler)
 {
     this.eventName = eventName;
     this.htmlElement = htmlElement;
     this.sender = this;
     this.eventHandler = eventHandler;
     Type type = typeof(HtmlEventProxy);
     this.typeIReflectImplementation = type;
 }
开发者ID:quitrk,项目名称:MiniDeskTube,代码行数:10,代码来源:HtmlEventProxy.cs


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