本文整理汇总了C#中IReflect.GetFields方法的典型用法代码示例。如果您正苦于以下问题:C# IReflect.GetFields方法的具体用法?C# IReflect.GetFields怎么用?C# IReflect.GetFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReflect
的用法示例。
在下文中一共展示了IReflect.GetFields方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: injectMembers
private void injectMembers(IReflect type, object instance)
{
var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(x => x.CanWrite);
foreach (var propertyInfo in properties)
{
propertyInfo.SetValue(instance, _container.Resolve(propertyInfo.PropertyType), null);
}
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
foreach (var fieldsInfo in fields)
{
fieldsInfo.SetValue(instance, _container.Resolve(fieldsInfo.FieldType));
}
}
示例3: SetPublicFields
private static void SetPublicFields(IReflect type, object obj, Dictionary<Type, object> createdObjectReferences)
{
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
var objectGenerator = new ObjectGenerator();
foreach (var field in fields)
{
var fieldValue = objectGenerator.GenerateObject(field.FieldType, createdObjectReferences);
field.SetValue(obj, fieldValue);
}
}
示例4: GetConstants
private static IEnumerable<string> GetConstants(IReflect myType, BindingFlags flags)
{
var fields = myType.GetFields(flags);
foreach (var fieldInfo in fields)
{
var type = ToPrettyString(fieldInfo.FieldType);
if (!returnTypeDictionary.ContainsKey(type))
returnTypeDictionary[type] = new List<string>();
returnTypeDictionary[type].Add(fieldInfo.Name);
}
return fields.Select(x => x.Name).Distinct();
}
示例5: FindLocalizationFields
public static IEnumerable<FieldInfo> FindLocalizationFields(IReflect type)
{
return from field in type.GetFields(BindingFlags.Static | BindingFlags.Public)
where GetLocalizationAttribute(field) != null
select field;
}
示例6: GetFields
private IEnumerable<MemberInfo> GetFields(IReflect type)
{
return type
.GetFields(DefaultMembersSearchFlags)
.Where(x => !x.IsDefined(typeof(NonSerializedAttribute), false));
}
示例7: GetFields
private static IEnumerable<FieldInfo> GetFields(IReflect type)
{
return type.GetFields(Flags);
}
示例8: FieldInfoCache
private FieldInfoCache(IReflect type)
{
Fields = type.GetFields(SimpleReflection.BindingFlags);
_fields = Fields.ToDictionary(x => x.Name, StringComparer.Ordinal);
}