本文整理汇总了C#中System.Reflection.Assembly.GetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.GetAttributes方法的具体用法?C# Assembly.GetAttributes怎么用?C# Assembly.GetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Assembly
的用法示例。
在下文中一共展示了Assembly.GetAttributes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsInternalToDynamicProxy
/// <summary>
/// Determines whether this assembly has internals visible to dynamic proxy.
/// </summary>
/// <param name = "asm">The assembly to inspect.</param>
public bool IsInternalToDynamicProxy(Assembly asm)
{
using (var locker = internalsToDynProxyLock.ForReadingUpgradeable())
{
if (internalsToDynProxy.ContainsKey(asm))
{
return internalsToDynProxy[asm];
}
locker.Upgrade();
if (internalsToDynProxy.ContainsKey(asm))
{
return internalsToDynProxy[asm];
}
var internalsVisibleTo = asm.GetAttributes<InternalsVisibleToAttribute>();
var found = internalsVisibleTo.Any(attr => {
var parts = attr.AssemblyName.Split(',');
return parts.Length > 0
&& (parts[0] == this.moduleScope.StrongAssemblyName
|| parts[0] == this.moduleScope.WeakAssemblyName);
});
internalsToDynProxy.Add(asm, found);
return found;
}
}
示例2: GetAssemblyConfiguration
// ReSharper restore SuggestBaseTypeForParameter
// ReSharper disable SuggestBaseTypeForParameter
internal static Result<string> GetAssemblyConfiguration(Assembly callingAssembly)
{
var attributes = callingAssembly
.GetAttributes<AssemblyConfigurationAttribute>(true);
if (attributes.Length == 0)
return Result<string>.CreateError("Attribute is not present");
return Result.CreateSuccess(attributes[0].Configuration);
}
示例3: GetActionsFromAttributeProvider
public static ITestAction[] GetActionsFromAttributeProvider(Assembly attributeProvider)
{
if (attributeProvider == null)
return new ITestAction[0];
var actions = attributeProvider.GetAttributes<ITestAction>().ToList();
actions.Sort(SortByTargetDescending);
return actions.ToArray();
}
示例4: AddCompression
/// <summary>
/// Add a compression stream to the library. Zlib is the default.
/// </summary>
/// <param name="a">
/// The assembly containing the stream definition.
/// </param>
public static void AddCompression(Assembly a)
{
Log.Debug("Loading compression algorithms from {Assembly}", a.FullName);
IEnumerable<CompressionAttribute> tags = a.GetAttributes<CompressionAttribute>();
foreach (CompressionAttribute tag in tags)
{
Log.Debug("Loading algorithm {Algorithm}", tag.Algorithm);
RegisteredItems.Add(tag.Algorithm, tag.ClassType);
}
}
示例5: AddCompression
/// <summary>
/// Add a compression stream to the library. Zlib is the default.
/// </summary>
/// <param name="a">
/// The assembly containing the stream definition.
/// </param>
public static void AddCompression(Assembly a)
{
Logger.DebugFormat(typeof(CompressionRegistry), "Adding assembly {0}", a.FullName);
var tags = a.GetAttributes<CompressionAttribute>();
foreach (var tag in tags)
{
Logger.DebugFormat(typeof(CompressionRegistry), "Adding {0}", tag.Algorithm);
RegisteredItems.Add(tag.Algorithm, tag.ClassType);
}
}
示例6: ApplyAttributesToTest
/// <summary>
/// Modify a newly constructed test by applying any of NUnit's common
/// attributes, based on a supplied ICustomAttributeProvider, which is
/// usually the reflection element from which the test was constructed,
/// but may not be in some instances. The attributes retrieved are
/// saved for use in subsequent operations.
/// </summary>
/// <param name="provider">An object deriving from MemberInfo</param>
public void ApplyAttributesToTest(Assembly provider)
{
foreach (IApplyToTest iApply in provider.GetAttributes<IApplyToTest>())
iApply.ApplyToTest(this);
}