本文整理汇总了C#中IAttribute.AttributeBuilder方法的典型用法代码示例。如果您正苦于以下问题:C# IAttribute.AttributeBuilder方法的具体用法?C# IAttribute.AttributeBuilder怎么用?C# IAttribute.AttributeBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAttribute
的用法示例。
在下文中一共展示了IAttribute.AttributeBuilder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAttribute
/// <summary>
/// Gets a custom attribute from cache or build it.
/// </summary>
private static Attribute GetAttribute(IAttribute attr)
{
Attribute result;
lock (dataLock)
{
result = loadedAttributes.Get(attr);
if (result != null) return result;
}
// Not found, build it
var builder = attr.AttributeBuilder();
result = (Attribute) builder.Invoke(null, new[] { attr.Annotation() });
// Store in loaded map
lock (dataLock)
{
loadedAttributes.Put(attr, result);
}
return result;
}
示例2: GetAttribute
/// <summary>
/// Gets a custom attribute from cache or build it.
/// </summary>
private static Attribute GetAttribute(IAttribute attr)
{
Attribute result;
result = loadedAttributes.Get(attr);
if (result != null) return result;
// Not found, build it
var builder = attr.AttributeBuilder();
try
{
result = (Attribute)builder.Invoke(null, new[] { attr.Annotation() });
}
catch (TargetInvocationException ex)
{
Log.E("dot42", string.Format("unable create attribute from annotation. build class '{0}' / method '{1}'",
builder.DeclaringClass.FullName, builder.Name), ex.InnerException);
result = new Attribute();
}
catch (Exception ex)
{
Log.E("dot42", string.Format("unable create attribute from annotation. build class '{0}' / method '{1}'",
builder.DeclaringClass.FullName,builder.Name), ex);
result = new Attribute();
}
loadedAttributes.Put(attr, result);
return result;
}