本文整理汇总了C#中System.Reflection.Assembly.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.IsDefined方法的具体用法?C# Assembly.IsDefined怎么用?C# Assembly.IsDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Assembly
的用法示例。
在下文中一共展示了Assembly.IsDefined方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Explore
IEnumerable<Assembly> Explore(Assembly assembly)
{
if (!assembly.IsDefined(typeof(IoCAttribute)))
yield break;
yield return assembly;
foreach (var a in assembly
.GetReferencedAssemblies()
.Select(an => Assembly.Load(an))
.SelectMany(ra => Explore(ra)))
yield return a;
}
示例2: GetAttribute
/// <overloads>
/// Gets the specified object attributes
/// </overloads>
/// <summary>
/// Gets the specified object attributes for assembly as specified by type
/// </summary>
/// <param name="attributeType">The attribute Type for which the custom attributes are to be returned.</param>
/// <param name="assembly">the assembly in which the specified attribute is defined</param>
/// <returns>Attribute as Object or null if not found.</returns>
public static object GetAttribute(Type attributeType, Assembly assembly)
{
if (attributeType == null)
{
throw new ArgumentNullException("attributeType");
}
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
if (assembly.IsDefined(attributeType, false))
{
object[] attributes = assembly.GetCustomAttributes(attributeType, false);
return attributes[0];
}
return null;
}
示例3: IsDefined
public static bool IsDefined (Assembly element, Type attributeType, bool inherit)
{
CheckParameters (element, attributeType);
return element.IsDefined (attributeType, inherit);
}
示例4: ComputeNamespaces
void ComputeNamespaces (Assembly assembly, Type extensionType)
{
bool contains_extension_methods = extensionType != null && assembly.IsDefined (extensionType, false);
if (get_namespaces_method != null) {
string [] namespaces = (string []) get_namespaces_method.Invoke (assembly, null);
foreach (string ns in namespaces)
RegisterNamespace (ns);
if (!contains_extension_methods)
return;
}
foreach (Type t in assembly.GetTypes ()) {
if ((t.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute &&
contains_extension_methods && t.IsDefined (extensionType, false))
RegisterExtensionMethodClass (t);
if (get_namespaces_method == null)
RegisterNamespace (t.Namespace);
}
}
示例5: IsDefined
public static bool IsDefined (Assembly element, Type attributeType, bool inherit)
{
// Returns true is a custom attribute subclass of attributeType class/interface with no inheritance walk
if (element == null)
throw new ArgumentNullException(nameof(element));
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
Contract.EndContractBlock();
return element.IsDefined(attributeType, false);
}
示例6: IsDefined
public static bool IsDefined(Assembly element, Type attributeType, bool inherit)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
if (attributeType == null)
{
throw new ArgumentNullException("attributeType");
}
if (!attributeType.IsSubclassOf(typeof(Attribute)) && (attributeType != typeof(Attribute)))
{
throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
}
return element.IsDefined(attributeType, false);
}
示例7: IsSchemaAttributePresent
internal static bool IsSchemaAttributePresent(Assembly assembly)
{
return assembly.IsDefined(typeof(EdmSchemaAttribute), false /*inherit*/);
}
示例8: IsViewAssembly
public virtual bool IsViewAssembly(Assembly assembly)
{
return assembly.IsDefined(typeof(EntityViewGenerationAttribute), inherit: false);
}
示例9: HasAPTCABit
private static bool HasAPTCABit(Assembly assembly)
{
return assembly.IsDefined(typeof (AllowPartiallyTrustedCallersAttribute), false);
}
示例10: GetExtensionMethodNamespaces
public static void GetExtensionMethodNamespaces(Assembly assembly, List<string> namespaces)
{
if (assembly.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false))
{
foreach (Type tp in assembly.GetTypes())
{
// Check if type has defined "ExtensionAttribute"
if (tp.IsSealed && !tp.IsGenericType && !tp.IsNested &&
tp.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false))
{
if (!namespaces.Contains(tp.Namespace))
{
namespaces.Add(tp.Namespace);
}
}
}
}
}
示例11: CanParticipateInStartup
private bool CanParticipateInStartup(Assembly assembly)
{
return assembly.IsDefined(typeof(ParticipateInStartupAttribute), false)
|| _filters.Any(f => f(assembly));
}