• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IReflect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: WriteObject

        void WriteObject(TextWriter writer, object value, IReflect type)
        {
            foreach (var property in type
                .GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                var propertyValue = property.GetValue(value, new object[] { });

                WriteTag(writer, propertyValue, property, null);
            }
        }
开发者ID:MrAntix,项目名称:Serializing,代码行数:10,代码来源:POXSerializer.serialize.cs


示例17: LuaMethodWrapper

		/*
		 * Constructs the wrapper for a known method name
		 */
		public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) 
		{
			this.translator=translator;
			this.methodName=methodName;
			this.targetType=targetType;
			if(targetType!=null)
				extractTarget=translator.typeChecker.getExtractor(targetType);
			this.bindingType=bindingType;
			members=targetType.UnderlyingSystemType.GetMember(methodName,MemberTypes.Method,bindingType|BindingFlags.Public|BindingFlags.NonPublic);
		}
开发者ID:viticm,项目名称:pap2,代码行数:13,代码来源:MethodWrapper.cs


示例18: VsaNamedItemScope

 internal VsaNamedItemScope(object hostObject, ScriptObject parent, VsaEngine engine) : base(parent)
 {
     this.namedItem = hostObject;
     this.reflectObj = hostObject as IReflect;
     if (this.reflectObj == null)
     {
         this.reflectObj = Globals.TypeRefs.ToReferenceContext(hostObject.GetType());
     }
     this.recursive = false;
     base.engine = engine;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:VsaNamedItemScope.cs


示例19: Bind

        static  Func<string, object> Bind(IReflect factory)
        {
            var method = factory.GetMethod("GetGrain", 
                BindingFlags.Public | BindingFlags.Static, null, 
                new[]{typeof(long), typeof(string)}, null);

            var argument = Expression.Parameter(typeof(string), "ext");
            var call = Expression.Call(method, new Expression[]{Expression.Constant(0L), argument});
            var lambda = Expression.Lambda<Func<string, object>>(call, argument);

            return lambda.Compile();
        }
开发者ID:hambroz,项目名称:Orleans.Bus,代码行数:12,代码来源:DynamicGrainFactory.cs


示例20: LuaMethodWrapper

 public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType)
 {
     this._LastCalledMethod = new MethodCache();
     this._Translator = translator;
     this._MethodName = methodName;
     this._TargetType = targetType;
     if (targetType != null)
     {
         this._ExtractTarget = translator.typeChecker.getExtractor(targetType);
     }
     this._BindingType = bindingType;
     this._Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, (bindingType | BindingFlags.Public) | BindingFlags.IgnoreCase);
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:13,代码来源:LuaMethodWrapper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IReflectClass类代码示例发布时间:2022-05-24
下一篇:
C# IReference类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap