本文整理汇总了C#中System.Reflection.MemberInfo类的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo类的具体用法?C# MemberInfo怎么用?C# MemberInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberInfo类属于System.Reflection命名空间,在下文中一共展示了MemberInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetObjectData
public static object [] GetObjectData (object obj, MemberInfo [] members)
{
if (obj == null)
throw new ArgumentNullException ("obj");
if (members == null)
throw new ArgumentNullException ("members");
int n = members.Length;
object [] result = new object [n];
for (int i = 0; i < n; i++) {
MemberInfo member = members [i];
if (member == null)
throw new ArgumentNullException (String.Format ("members[{0}]", i));
if (member.MemberType != MemberTypes.Field)
throw new SerializationException (
String.Format ("members [{0}] is not a field.", i));
FieldInfo fi = member as FieldInfo; // members must be fields
result [i] = fi.GetValue (obj);
}
return result;
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:25,代码来源:FormatterServices.cs
示例2: GetMemberModifiers
public string GetMemberModifiers(MemberInfo memberInfo)
{
ArgumentUtility.CheckNotNull ("memberInfo", memberInfo);
switch (memberInfo.MemberType)
{
case MemberTypes.Method:
case MemberTypes.Constructor:
return GetMethodModifiers (memberInfo, memberInfo);
case MemberTypes.Field:
return GetFieldModifiers ((FieldInfo)memberInfo);
case MemberTypes.Property:
var propertyInfo = (PropertyInfo) memberInfo;
return GetMethodModifiers (propertyInfo.GetGetMethod (true) ?? propertyInfo.GetSetMethod (true), memberInfo);
case MemberTypes.Event:
var eventInfo = (EventInfo) memberInfo;
return GetMethodModifiers (eventInfo.GetAddMethod (true), memberInfo);
case MemberTypes.NestedType:
return _typeModifierUtility.GetTypeModifiers ((Type) memberInfo);
case MemberTypes.Custom:
case MemberTypes.TypeInfo:
return "TODO special MemberTypes";
default:
throw new Exception ("unknown member type");
}
}
开发者ID:re-motion,项目名称:Mixins-XRef,代码行数:31,代码来源:MemberModifierUtility.cs
示例3: IsSerializableMember
public static bool IsSerializableMember(MemberInfo member)
{
if (member.MemberType == MemberTypes.Method)
return false;
var field = member as FieldInfo;
if (field != null)
{
if (IsSerializableFieldPredicate != null)
return IsSerializableFieldPredicate(field);
return DefaultIsSerializableField(field);
}
var property = member as PropertyInfo;
if (property != null)
{
if (IsSerializablePropertyPredicate != null)
return IsSerializablePropertyPredicate(property);
return DefaultIsSerializableProperty(property);
}
return false;
}
开发者ID:flatlineteam,项目名称:relic-rush,代码行数:25,代码来源:X20Logic.cs
示例4: MemberMetadata
public MemberMetadata(MemberInfo memberInfo)
{
_type = MemberType.None;
_memberType = null;
_mi = null;
_fp = null;
memberInfo.ThrowIfNull("memberInfo", "Parameter cannot be null.");
switch (memberInfo.MemberType)
{
case MemberTypes.Field:
_type = MemberType.Field;
_mi = memberInfo;
_memberType = (memberInfo as FieldInfo).FieldType;
break;
case MemberTypes.Property:
_type = MemberType.Property;
_memberType = (memberInfo as PropertyInfo).PropertyType;
_fp = new FastReflection.FastProperty((memberInfo as PropertyInfo), true);
_mi = memberInfo;
break;
default:
break;
}
}
开发者ID:OleksandrKulchytskyi,项目名称:Sharedeployed,代码行数:25,代码来源:MemberMetadata.cs
示例5: UpdateDefaultValue
private static void UpdateDefaultValue(MemberInfo memberInfo, MetaProperty info)
{
var defaultAttribute = memberInfo.GetCustomAttribute<DefaultValueAttribute>();
if (defaultAttribute == null) return;
info.DefaultValue = defaultAttribute.Value;
}
开发者ID:s-KaiNet,项目名称:Untech.SharePoint,代码行数:7,代码来源:MetaProperty.cs
示例6: MemberListBinding
internal MemberListBinding(MemberInfo member, ReadOnlyCollection<ElementInit> initializers)
#pragma warning disable 618
: base(MemberBindingType.ListBinding, member)
{
#pragma warning restore 618
Initializers = initializers;
}
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:MemberListBinding.cs
示例7: GetProviderObjectFromMember
private object GetProviderObjectFromMember(MemberInfo member)
{
object providerObject = null;
object instance = null;
switch (member.MemberType)
{
case MemberTypes.Property:
PropertyInfo providerProperty = member as PropertyInfo;
MethodInfo getMethod = providerProperty.GetGetMethod(true);
if (!getMethod.IsStatic)
//instance = ProviderCache.GetInstanceOf(providerType);
instance = Reflect.Construct(providerType, providerArgs);
providerObject = providerProperty.GetValue(instance, null);
break;
case MemberTypes.Method:
MethodInfo providerMethod = member as MethodInfo;
if (!providerMethod.IsStatic)
//instance = ProviderCache.GetInstanceOf(providerType);
instance = Reflect.Construct(providerType, providerArgs);
providerObject = providerMethod.Invoke(instance, null);
break;
case MemberTypes.Field:
FieldInfo providerField = member as FieldInfo;
if (!providerField.IsStatic)
//instance = ProviderCache.GetInstanceOf(providerType);
instance = Reflect.Construct(providerType, providerArgs);
providerObject = providerField.GetValue(instance);
break;
}
return providerObject;
}
开发者ID:Buildstarted,项目名称:ContinuousTests,代码行数:35,代码来源:ProviderInfo.cs
示例8: SourceInfo
public SourceInfo(string source, string arg, MemberInfo memberInfo, Type type, CodeGenerator ilg) {
this.Source = source;
this.Arg = arg ?? source;
this.MemberInfo = memberInfo;
this.Type = type;
this.ILG = ilg;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:SourceInfo.cs
示例9: CanBeRouteParameter
protected virtual bool CanBeRouteParameter(MemberInfo info)
{
return (info.MemberType == MemberTypes.Field || info.MemberType == MemberTypes.Property)
&& !info.HasCustomAttribute<ExcludeFromRouteAttribute>()
&& IsValidForRoute(info.GetMemberType());
}
开发者ID:Deson621,项目名称:MvcPowerTools,代码行数:7,代码来源:OneModelInHandlerConvention.cs
示例10: PersistAggregationInfo
public PersistAggregationInfo(object aggregatedObject,string[] keyMapping,MemberInfo mi)
{
p_aggregatedObject=aggregatedObject;
p_mi=mi;
foreach(string mapping in keyMapping)
p_alKeyMapping.Add(new KeyMappingInfo(mapping));
}
开发者ID:flyingoverclouds,项目名称:sfinx,代码行数:7,代码来源:PersistAggregationInfo.cs
示例11: ComputedIndex
public ComputedIndex(DocumentMapping mapping, MemberInfo[] members)
{
_members = members;
var field = mapping.FieldFor(members);
_locator = field.SqlLocator.Replace("d.", "");
_table = mapping.Table;
}
开发者ID:phillip-haydon,项目名称:marten,代码行数:7,代码来源:ComputedIndex.cs
示例12: ConvertArgs
protected ISqlExpression[] ConvertArgs(MemberInfo member, ISqlExpression[] args)
{
if (member is MethodInfo)
{
var method = (MethodInfo)member;
if (method.DeclaringType.IsGenericType)
args = args.Concat(method.DeclaringType.GetGenericArguments().Select(t => (ISqlExpression)SqlDataType.GetDataType(t))).ToArray();
if (method.IsGenericMethod)
args = args.Concat(method.GetGenericArguments().Select(t => (ISqlExpression)SqlDataType.GetDataType(t))).ToArray();
}
if (ArgIndices != null)
{
var idxs = new ISqlExpression[ArgIndices.Length];
for (var i = 0; i < ArgIndices.Length; i++)
idxs[i] = args[ArgIndices[i]];
return idxs;
}
return args;
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:25,代码来源:SqlFunctionAttribute.cs
示例13: GetPropertyMap
public static PropertyMap GetPropertyMap(this IMappingEngine mappingEngine, MemberInfo sourceMemberInfo, Type destinationMemberType)
{
var typeMap = mappingEngine.ConfigurationProvider.FindTypeMapFor(sourceMemberInfo.DeclaringType, destinationMemberType);
if (typeMap == null)
{
const string MessageFormat = "Missing map from {0} to {1}. " +
"Create using Mapper.CreateMap<{0}, {1}>.";
var message = string.Format(MessageFormat, sourceMemberInfo.DeclaringType.Name, destinationMemberType.Name);
throw new InvalidOperationException(message);
}
var propertyMap = typeMap.GetPropertyMaps()
.FirstOrDefault(pm => pm.CanResolveValue() &&
pm.SourceMember != null && pm.SourceMember.Name == sourceMemberInfo.Name);
if (propertyMap == null)
{
const string MessageFormat = "Missing property map from {0} to {1} for {2} property. " +
"Create using Mapper.CreateMap<{0}, {1}>.";
var message = string.Format(MessageFormat, sourceMemberInfo.DeclaringType.Name, destinationMemberType.Name,
sourceMemberInfo.Name);
throw new InvalidOperationException(message);
}
return propertyMap;
}
开发者ID:DeanMilojevic,项目名称:AutoMapper,代码行数:26,代码来源:QueryMapperHelper.cs
示例14: BindingExpression
/// <summary>
/// Initializes a new instance of the <see cref="MonoMobile.Views.BindingExpression"/> class.
/// </summary>
/// <param name='binding'>
/// Binding.
/// </param>
/// <param name='targetProperty'>
/// ViewModel.<targetProperty>.
/// </param>
/// <param name='target'>
/// ViewModel to hock into.
/// </param>
/// <exception cref='ArgumentNullException'>
/// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> .
/// </exception>
public BindingExpression(Binding binding, MemberInfo targetProperty, object target)
{
if (binding == null)
throw new ArgumentNullException("binding");
if (targetProperty == null)
throw new ArgumentNullException("targetProperty");
if (target == null)
throw new ArgumentNullException("target");
Binding = binding;
Binding.Target = target;
TargetProperty = targetProperty;
if(string.IsNullOrEmpty(binding.TargetPath))
{
binding.TargetPath = targetProperty.Name;
}
object viewSource = Binding.Source;
_ViewProperty = viewSource.GetType().GetNestedMember(ref viewSource, Binding.SourcePath, true);
Binding.ViewSource = viewSource;
SourceProperty = _ViewProperty;
var dataContext = viewSource as IDataContext;
if (dataContext != null && dataContext.DataContext != null)
{
var source = dataContext.DataContext;
SourceProperty = source.GetType().GetNestedMember(ref source, Binding.SourcePath, true);
Binding.Source = source;
}
}
开发者ID:rhwilburn,项目名称:MVVM-for-Mono,代码行数:48,代码来源:BindingExpression.cs
示例15: IsEncryptedMember
bool IsEncryptedMember(MemberInfo arg)
{
var propertyInfo = arg as PropertyInfo;
if (propertyInfo != null)
{
if (propertyInfo.GetIndexParameters().Length > 0)
{
if (conventions.IsEncryptedProperty(propertyInfo))
{
throw new Exception("Cannot encrypt or decrypt indexed properties that return a WireEncryptedString.");
}
return false;
}
return conventions.IsEncryptedProperty(propertyInfo);
}
var fieldInfo = arg as FieldInfo;
if (fieldInfo != null)
{
return fieldInfo.FieldType == typeof(WireEncryptedString);
}
return false;
}
开发者ID:ninocrudele,项目名称:NServiceBus,代码行数:26,代码来源:EncryptionMutator.cs
示例16: HandleResult
/// <summary>
/// This method supports the Fluorine infrastructure and is not intended to be used directly from your code.
/// </summary>
/// <param name="invocationManager"></param>
/// <param name="memberInfo"></param>
/// <param name="obj"></param>
/// <param name="arguments"></param>
/// <param name="result"></param>
public void HandleResult(IInvocationManager invocationManager, MemberInfo memberInfo, object obj, object[] arguments, object result)
{
if( result is DataSet )
{
DataSet dataSet = result as DataSet;
ASObject asoResult = new ASObject(_remoteClass);
#if !(NET_1_1)
foreach (KeyValuePair<object, object> entry in invocationManager.Properties)
#else
foreach(DictionaryEntry entry in invocationManager.Properties)
#endif
{
if( entry.Key is DataTable )
{
DataTable dataTable = entry.Key as DataTable;
if( dataSet.Tables.IndexOf(dataTable) != -1 )
{
if( !dataTable.ExtendedProperties.ContainsKey("alias") )
asoResult[dataTable.TableName] = entry.Value;
else
asoResult[ dataTable.ExtendedProperties["alias"] as string ] = entry.Value;
}
}
}
invocationManager.Result = asoResult;
}
}
开发者ID:RanadeepPolavarapu,项目名称:LoLNotes,代码行数:36,代码来源:DataSetTypeAttribute.cs
示例17: GetAttributes
/// <summary>
/// Returns the attributes on <paramref name="member"/> that this convention applies to.
/// </summary>
/// <param name="member"></param>
/// <returns></returns>
public Attribute[] GetAttributes(MemberInfo member)
{
if (member == null)
{
throw Error.ArgumentNull("member");
}
Attribute[] attributes =
member
.GetCustomAttributes(inherit: true)
.OfType<Attribute>()
.Where(AttributeFilter)
.ToArray();
if (!AllowMultiple && attributes.Length > 1)
{
throw Error.InvalidOperation(
SRResources.MultipleAttributesFound,
member.Name,
member.ReflectedType.Name,
attributes.First().GetType().Name);
}
return attributes;
}
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:30,代码来源:AttributeConvention.cs
示例18: MapCallInfo
public MapCallInfo(Type targetType, Type[] genericTypes, Flags bindingFlags, MemberTypes memberTypes, string name, Type[] parameterTypes, MemberInfo memberInfo, bool isReadOperation, Type sourceType, MemberTypes sourceMemberTypes, MemberTypes targetMemberTypes, string[] names) : base(targetType, genericTypes, bindingFlags, memberTypes, name, parameterTypes, memberInfo, isReadOperation)
{
SourceType = sourceType;
SourceMemberTypes = sourceMemberTypes;
TargetMemberTypes = targetMemberTypes;
Names = names;
}
开发者ID:devworker55,项目名称:Mammatus,代码行数:7,代码来源:MapCallInfo.cs
示例19: ArrayArgumentHandler
public ArrayArgumentHandler(Object aObj, MemberInfo aInfo, Type aType, int aMin, int aMax)
: base(aObj, aInfo, aType, aMin, aMax)
{
elementType = type.GetElementType();
listType = typeof(List<>).MakeGenericType(new Type[] { elementType });
list = listType.GetConstructor(new Type[] { }).Invoke(null);
}
开发者ID:JonasDralle,项目名称:InstallDirChanger,代码行数:7,代码来源:ArrayArgumentHandler.cs
示例20: ComponentAsIdMapper
public ComponentAsIdMapper(System.Type componentType, MemberInfo declaringTypeMember, HbmCompositeId id, HbmMapping mapDoc)
{
this.id = id;
this.mapDoc = mapDoc;
[email protected] = componentType.GetShortClassName(mapDoc);
accessorPropertyMapper = new AccessorPropertyMapper(declaringTypeMember.DeclaringType, declaringTypeMember.Name, x => id.access = x);
}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:7,代码来源:ComponentAsIdMapper.cs
注:本文中的System.Reflection.MemberInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论