本文整理汇总了C#中FieldInfo.GetCustomAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# FieldInfo.GetCustomAttributes方法的具体用法?C# FieldInfo.GetCustomAttributes怎么用?C# FieldInfo.GetCustomAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.GetCustomAttributes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFor
/// <summary>
/// Gets the UTConnectorHint attached to the given field.
/// </summary>
public static UTConnectorHint GetFor(FieldInfo field)
{
var hints = field.GetCustomAttributes(typeof(UTConnectorHint), true);
if (hints.Length > 0) {
return (UTConnectorHint) hints[0];
}
return new UTConnectorHint();
}
示例2: BuildFieldsString
public static string BuildFieldsString(ref FieldInfo field)
{
string str = "no help";
object[] customAttributes = field.GetCustomAttributes(true);
for (int i = 0; i < (int)customAttributes.Length; i++)
{
object obj = customAttributes[i];
if (obj is ConsoleSystem.Help)
{
str = (obj as ConsoleSystem.Help).helpDescription;
}
}
return string.Concat(field.Name, " : ", str);
}
示例3: GetPropertyDrawerForField
public static PropertyDrawer GetPropertyDrawerForField(FieldInfo fInfo) {
var drawer = Reflector.GetCustomPropertyDrawerFor(fInfo.FieldType, typeof(AbilityPage).Assembly);
if (drawer != null) return drawer;
var attrs = fInfo.GetCustomAttributes(false);
if (attrs == null) return null;
for (int i = 0; i < attrs.Length; i++) {
drawer = Reflector.GetCustomPropertyDrawerFor(attrs[i].GetType(), typeof(AbilityPage).Assembly, typeof(EditorGUI).Assembly);
if (drawer != null) {
drawer.GetType()
.GetField("m_Attribute", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(drawer, attrs[i]);
return drawer;
}
}
return drawer;
}
示例4: ListField
/// <summary>
/// Binds a System.Collections.Generic.List of components to all the components of its type within the scope specified by the [Bind] attribute.
/// Does nothing if the field is already non-null.
/// </summary>
/// <param name="component">Component containing the field</param>
/// <param name="field">The field of the component to bind</param>
/// <param name="elementType">Type of elements of the list. Must be a subclass of BindingBehaviour.</param>
private static void ListField(MonoBehaviour component, FieldInfo field, Type elementType)
{
if (field.GetValue(component) == null)
{
var bindAttributes = field.GetCustomAttributes(typeof(BindAttribute), true);
switch (bindAttributes.Length)
{
case 0:
break;
case 1:
BindListField(field, (BindAttribute)bindAttributes[0], component, elementType);
break;
default:
throw new Exception(
String.Format("Multiple BindAttributes on field {0} of component {1}", field.Name, component.name));
}
}
}
示例5: IsVisible
/// <summary>
/// Checks if the given field should be rendered or not.
/// </summary>
protected virtual bool IsVisible(FieldInfo field)
{
var delegateResult = rendererDelegate != null ? rendererDelegate.IsVisible (field) : UTVisibilityDecision.Undetermined;
if (delegateResult == UTVisibilityDecision.Undetermined) {
var hide = field.GetCustomAttributes (typeof(HideInInspector), true);
return hide.Length == 0;
}
return delegateResult == UTVisibilityDecision.Visible;
}
示例6: FieldPropertyDescriptor
public FieldPropertyDescriptor(FieldInfo field) : base(field.Name,
(Attribute[])field.GetCustomAttributes(typeof(Attribute), true))
{
_field = field;
}
示例7: GetFor
/// <summary>
/// Gets the inspector hint annotation attached to a field. If no inspector hint is attached, a default hint is returned.
/// </summary>
/// <returns>
/// The attached inspector hint.
/// </returns>
/// <param name='info'>
/// The field information object.
/// </param>
public static UTInspectorHint GetFor(FieldInfo info)
{
var hints = info.GetCustomAttributes (typeof(UTInspectorHint), true);
if (hints.Length > 0) {
var hint = (UTInspectorHint)hints [0];
return hint;
}
return Default;
}
示例8: RequiresUnityPro
public static bool RequiresUnityPro(FieldInfo fieldInfo)
{
return fieldInfo.GetCustomAttributes(typeof(UTRequiresUnityPro), true).Length > 0;
}
示例9: GetFor
/// <summary>
/// Gets the UTDoc attached to the given field.
/// </summary>
/// <returns>
/// The UTDoc or a new UTDoc using a default title and description, if there is no UTDoc on the field.
/// </returns>
public static UTDoc GetFor(FieldInfo field)
{
var docs = field.GetCustomAttributes(typeof(UTDoc), false);
return CheckAndFix(docs, ObjectNames.NicifyVariableName(field.Name));
}