本文整理汇总了C#中MemberInfo类的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo类的具体用法?C# MemberInfo怎么用?C# MemberInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberInfo类属于命名空间,在下文中一共展示了MemberInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromMemberInfo
public static VNodeInfo FromMemberInfo(MemberInfo member)
{
return new VNodeInfo(member.InstanceId, 0,
member.InternalTcpEndPoint, member.InternalSecureTcpEndPoint,
member.ExternalTcpEndPoint, member.ExternalSecureTcpEndPoint,
member.InternalHttpEndPoint, member.ExternalHttpEndPoint);
}
示例2: ShowAttributes
private static void ShowAttributes(MemberInfo attributeTarget)
{
Attribute[] attributes = Attribute.GetCustomAttributes(attributeTarget);
Console.WriteLine("Attributes applied to {0}: {1}",
attributeTarget.Name, (attributes.Length == 0 ? "None" : String.Empty));
foreach (Attribute attribute in attributes)
{
// Display the type of each applied attribute
Console.WriteLine(" {0}", attribute.GetType().ToString());
if (attribute is DefaultMemberAttribute)
Console.WriteLine(" MemberName={0}",
((DefaultMemberAttribute)attribute).MemberName);
if (attribute is ConditionalAttribute)
Console.WriteLine(" ConditionString={0}",
((ConditionalAttribute)attribute).ConditionString);
if (attribute is CLSCompliantAttribute)
Console.WriteLine(" IsCompliant={0}",
((CLSCompliantAttribute)attribute).IsCompliant);
DebuggerDisplayAttribute dda = attribute as DebuggerDisplayAttribute;
if (dda != null)
{
Console.WriteLine(" Value={0}, Name={1}, Target={2}",
dda.Value, dda.Name, dda.Target);
}
}
Console.WriteLine();
}
示例3: GetCustomAttributes
public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo target)
{
if (target == null)
throw new ArgumentNullException("target");
IList<CustomAttributeData> cad = GetCustomAttributes(target.Module, target.MetadataToken);
int pcaCount = 0;
Attribute[] a = null;
if (target is RuntimeType)
a = PseudoCustomAttribute.GetCustomAttributes((RuntimeType)target, typeof(object), false, out pcaCount);
else if (target is RuntimeMethodInfo)
a = PseudoCustomAttribute.GetCustomAttributes((RuntimeMethodInfo)target, typeof(object), false, out pcaCount);
else if (target is RuntimeFieldInfo)
a = PseudoCustomAttribute.GetCustomAttributes((RuntimeFieldInfo)target, typeof(object), out pcaCount);
if (pcaCount == 0)
return cad;
CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount];
cad.CopyTo(pca, pcaCount);
for (int i = 0; i < pcaCount; i++)
{
if (PseudoCustomAttribute.IsSecurityAttribute(a[i].GetType()))
continue;
pca[i] = new CustomAttributeData(a[i]);
}
return Array.AsReadOnly(pca);
}
示例4: ShouldShowField
/// <summary>
/// Additional checks for slot & item type
/// </summary>
/// <param name="memberData">Member info</param>
/// <returns>True if the field should be shown</returns>
protected override bool ShouldShowField(MemberInfo memberData)
{
if (!base.ShouldShowField(memberData))
return false;
var limitSlotsAttr = memberData.GetAttribute<ItemDatablockEquipmentSlotAttribute>();
if (limitSlotsAttr != null)
{
FieldInfo slotField = itemDatablock.GetType().GetField("equipmentSlot");
var datablockSlot = itemDatablock.GetFieldValue<ItemDatablock.Slot>(slotField);
foreach (ItemDatablock.Slot slot in limitSlotsAttr.slots)
{
if (datablockSlot == slot)
return true;
}
return false;
}
var limitTypeAttr = memberData.GetAttribute<ItemDatablockItemTypeAttribute>();
if (limitTypeAttr != null)
{
FieldInfo itemTypeField = itemDatablock.GetType().GetField("itemType");
var datablockType = itemDatablock.GetFieldValue<ItemDatablock.ItemType>(itemTypeField);
foreach (ItemDatablock.ItemType type in limitTypeAttr.types)
{
if (datablockType == type)
return true;
}
return false;
}
return true;
}
示例5: MemberToString
public static string MemberToString(MemberInfo member, object instance)
{
StringBuilder o = new StringBuilder();
XPathAttribute[] attrs = (XPathAttribute[]) member.GetCustomAttributes(typeof(XPathAttribute), true);
if (attrs.Length == 0)
return String.Empty;
o.AppendFormat("{0}: ", member.Name);
Type member_type;
if (member is PropertyInfo)
member_type = ((PropertyInfo)member).PropertyType;
else
member_type = ((FieldInfo)member).FieldType;
if (member_type.IsArray) {
object[] items = (object[])GetMemberValue(member, instance);
if (items != null) {
StringBuilder arr = new StringBuilder();
foreach (object item in items)
arr.AppendFormat("{0}{1}", (arr.Length == 0) ? "" : ", ",
DebugExtractInfo.ToString(item));
o.AppendFormat("[{0}]", arr);
}
else
o.Append("[]");
}
else
o.Append(DebugExtractInfo.ToString(GetMemberValue(member, instance)));
return o.ToString();
}
示例6: GetNarrative
private string GetNarrative()
{
MemberInfo mi = new MemberInfo(CurrentUserID);
DataSet dsNarrative = mi.GetNarrative(MemberMasterID, AssessmentID);
DataTable dtMemberInfo = new DataTable();
DataTable dtNarration = new DataTable();
string Narration = string.Empty;
if (dsNarrative.Tables.Count > 0)
{
dtMemberInfo = dsNarrative.Tables[0];
dtNarration = dsNarrative.Tables[1];
}
if (dtNarration.Rows.Count > 0)
{
Narration = dtNarration.Rows[0]["NARRATION"].ToString();
}
if (dtMemberInfo.Rows.Count > 0)
{
for (int i = 0; i < dtMemberInfo.Columns.Count; i++)
{
Narration = Narration.Replace(dtMemberInfo.Columns[i].ColumnName, dtMemberInfo.Rows[0][i].ToString());
}
}
return Narration;
}
示例7: GetObjectData
public static Object[] GetObjectData(Object obj, MemberInfo[] members)
{
if(obj == null)
{
throw new ArgumentNullException("obj");
}
if(members == null)
{
throw new ArgumentNullException("members");
}
Object[] data = new Object [members.Length];
int index;
for(index = 0; index < members.Length; ++index)
{
if(members[index] == null)
{
throw new ArgumentNullException
("members[" + index.ToString() + "]");
}
if(!(members[index] is FieldInfo))
{
throw new SerializationException
(_("Serialize_NotField"));
}
data[index] = ((FieldInfo)(members[index])).GetValue(obj);
}
return data;
}
示例8: AnalyzeMember
private Issue AnalyzeMember(MemberInfo memberInfo, SemanticModel model, ClassInfo classInfo)
{
foreach (BlockSyntax block in memberInfo.Blocks)
{
var identifiers = block.DescendantNodes().OfType<IdentifierNameSyntax>().ToList();
foreach (IdentifierNameSyntax identifierName in identifiers)
{
SymbolInfo identifierSymbol = model.GetSymbolInfo(identifierName);
//Does this symbol refer to a GuardedField?
GuardedFieldInfo foundGuardedField = classInfo.GuardedFields.FirstOrDefault(field => field.Symbol == identifierSymbol.Symbol);
if (foundGuardedField != null)
{
//We must be inside a lock statement
LockHierarchy controlFlowHierarchy = CreateLockHiearchyFromIdentifier(identifierName);
bool lockHierarchySatisfied = LockHierarchy.IsSatisfiedBy(foundGuardedField.DeclaredLockHierarchy, controlFlowHierarchy);
if (!lockHierarchySatisfied)
{
return new Issue(
ErrorCode.GUARDED_FIELD_ACCESSED_OUTSIDE_OF_LOCK,
identifierName,
identifierSymbol.Symbol);
}
}
}
}
return null;
}
示例9: MemberInfoDto
public MemberInfoDto(MemberInfo member)
{
InstanceId = member.InstanceId;
TimeStamp = member.TimeStamp;
State = member.State;
IsAlive = member.IsAlive;
InternalTcpIp = member.InternalTcpEndPoint.Address.ToString();
InternalTcpPort = member.InternalTcpEndPoint.Port;
InternalSecureTcpPort = member.InternalSecureTcpEndPoint == null ? 0 : member.InternalSecureTcpEndPoint.Port;
ExternalTcpIp = member.ExternalTcpEndPoint.Address.ToString();
ExternalTcpPort = member.ExternalTcpEndPoint.Port;
ExternalSecureTcpPort = member.ExternalSecureTcpEndPoint == null ? 0 : member.ExternalSecureTcpEndPoint.Port;
InternalHttpIp = member.InternalHttpEndPoint.Address.ToString();
InternalHttpPort = member.InternalHttpEndPoint.Port;
ExternalHttpIp = member.ExternalHttpEndPoint.Address.ToString();
ExternalHttpPort = member.ExternalHttpEndPoint.Port;
LastCommitPosition = member.LastCommitPosition;
WriterCheckpoint = member.WriterCheckpoint;
ChaserCheckpoint = member.ChaserCheckpoint;
EpochPosition = member.EpochPosition;
EpochNumber = member.EpochNumber;
EpochId = member.EpochId;
NodePriority = member.NodePriority;
}
示例10: GetColumnDbType
public override string GetColumnDbType(MappingEntity entity, MemberInfo member)
{
AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);
if (mm != null && mm.Column != null && !string.IsNullOrEmpty(mm.Column.DbType))
return mm.Column.DbType;
return null;
}
示例11: CreateControl
public override Lilium.Controls.Control CreateControl(MemberInfo memberInfo, object obj)
{
var fieldInfo = memberInfo as FieldInfo;
Func<string> func;
if(fieldInfo.FieldType == typeof(SharpDX.Vector3))
{
func = () =>
{
var vec = (SharpDX.Vector3)fieldInfo.GetValue(obj);
return vec.ToString("0.###");
};
}
else if(fieldInfo.FieldType == typeof(SharpDX.Vector4))
{
func = () =>
{
var vec = (SharpDX.Vector4)fieldInfo.GetValue(obj);
return vec.ToString("0.###");
};
}
else
{
func = ()=> fieldInfo.GetValue(obj).ToString();
}
return new Lilium.Controls.Label(memberInfo.Name, func);
}
示例12: RunField
void RunField(MemberInfo member, Assembly assembly)
{
var fieldInfo = (FieldInfo)member;
var context = _explorer.FindContexts(fieldInfo);
StartRun(CreateMap(assembly, new[] {context}));
}
示例13: GetFamilyMembers
public static List<FamilyMember> GetFamilyMembers(int MemberMasterID)
{
MemberInfo mInfo;
mInfo = new MemberInfo(MemberMasterID, 1);
List<FamilyMember> siblings = mInfo.familyMembers;
return siblings;
}
示例14: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
MemberMasterID = Int32.Parse(Request.QueryString["ID"]);
AssessmentID = Int32.Parse(Request.QueryString["AssessmentID"]);
mInfo = new MemberInfo(MemberMasterID, CurrentUserID);
Master.PageHeader = "Member HRA";
}
示例15: Create
public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
{
#if FEAT_IKVM
System.Collections.Generic.IList<CustomAttributeData> all = member.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
AttributeMap[] result = new AttributeMap[all.Count];
int index = 0;
foreach (CustomAttributeData attrib in all)
{
result[index++] = new AttributeDataMap(attrib);
}
return result;
#else
#if WINRT
Attribute[] all = System.Linq.Enumerable.ToArray(member.GetCustomAttributes(inherit));
#else
var all = member.GetCustomAttributes(inherit);
#endif
var result = new AttributeMap[all.Length];
for (var i = 0; i < all.Length; i++)
{
result[i] = new ReflectionAttributeMap((Attribute) all[i]);
}
return result;
#endif
}