本文整理汇总了C#中ICustomAttributeProvider类的典型用法代码示例。如果您正苦于以下问题:C# ICustomAttributeProvider类的具体用法?C# ICustomAttributeProvider怎么用?C# ICustomAttributeProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICustomAttributeProvider类属于命名空间,在下文中一共展示了ICustomAttributeProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetKnownTypes
public static IEnumerable<Type> GetKnownTypes(ICustomAttributeProvider provider)
{
System.Collections.Generic.List<System.Type> knownTypes =
new System.Collections.Generic.List<System.Type>();
//// Add any types to include here.
//return knownTypes;
Type[] types = Assembly.Load("SMT_FB_EFModel").GetTypes();
for (int i = 0; i < types.Length; i++)
{
if ((types[i].BaseType == typeof(EntityObject)) || typeof(VisitUserBase).IsAssignableFrom(types[i]))
{
knownTypes.Add(types[i]);
}
}
//List<Type> typesO = knownTypes.ToList();
//typesO.ForEach(item =>
//{
// knownTypes.Add(typeof(List<>).MakeGenericType(new Type[] { item }));
//});
knownTypes.Add(typeof(AuditResult));
knownTypes.Add(typeof(SaveResult));
knownTypes.Add(typeof(VirtualAudit));
knownTypes.Add(typeof(SMT.SaaS.BLLCommonServices.FlowWFService.SubmitData));
return knownTypes;
}
开发者ID:JuRogn,项目名称:OA,代码行数:29,代码来源:Common.cs
示例2: ProcessAttributes
public virtual void ProcessAttributes(IMetaData metaData, ICustomAttributeProvider attributeProvider)
{
foreach(AttributeProcessor processor in AttributeProcessors)
{
processor.Process(metaData, attributeProvider, this.Config);
}
}
开发者ID:vfioox,项目名称:ENULib,代码行数:7,代码来源:TypeDataRepository.cs
示例3: FromCustomAttributeProvider
public static IEnumerable<UsesLibraryAttribute> FromCustomAttributeProvider(ICustomAttributeProvider provider)
{
var attrs = provider.GetCustomAttributes ("Android.App.UsesLibraryAttribute");
foreach (var attr in attrs) {
UsesLibraryAttribute self;
string[] extra = null;
if (attr.ConstructorArguments.Count == 1) {
self = new UsesLibraryAttribute (
(string) attr.ConstructorArguments [0].Value);
extra = new[]{"Name"};
} else if (attr.ConstructorArguments.Count == 2) {
self = new UsesLibraryAttribute (
(string) attr.ConstructorArguments [0].Value,
(bool) attr.ConstructorArguments [1].Value);
extra = new[]{"Name", "Required"};
} else {
self = new UsesLibraryAttribute ();
extra = new string[0];
}
self.specified = mapping.Load (self, attr);
foreach (var e in extra)
self.specified.Add (e);
yield return self;
}
}
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:29,代码来源:UsesLibraryAttribute.Partial.cs
示例4: FromCustomAttributeProvider
public static IEnumerable<UsesFeatureAttribute> FromCustomAttributeProvider(ICustomAttributeProvider provider)
{
var attrs = provider.GetCustomAttributes ("Android.App.UsesFeatureAttribute");
foreach (var attr in attrs) {
UsesFeatureAttribute self = new UsesFeatureAttribute ();
if (attr.HasProperties) {
// handle the case where the user sets additional properties
self.specified = mapping.Load (self, attr);
if (self.specified.Contains("GLESVersion") && self.GLESVersion==0) {
throw new InvalidOperationException("Invalid value '0' for UsesFeatureAttribute.GLESVersion.");
}
}
if (attr.HasConstructorArguments) {
// in this case the user used one of the Consructors to pass arguments and possibly properties
// so we only create the specified list if its not been created already
if (self.specified == null)
self.specified = new List<string>();
foreach(var arg in attr.ConstructorArguments) {
if (arg.Value.GetType() == typeof(string)) {
self.specified.Add("Name");
self.Name = (string)arg.Value;
}
}
}
yield return self;
}
}
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:29,代码来源:UsesFeatureAttribute.Partial.cs
示例5: SoapAttributes
/// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public SoapAttributes(ICustomAttributeProvider provider) {
object[] attrs = provider.GetCustomAttributes(false);
for (int i = 0; i < attrs.Length; i++) {
if (attrs[i] is SoapIgnoreAttribute || attrs[i] is ObsoleteAttribute) {
this.soapIgnore = true;
break;
}
else if (attrs[i] is SoapElementAttribute) {
this.soapElement = (SoapElementAttribute)attrs[i];
}
else if (attrs[i] is SoapAttributeAttribute) {
this.soapAttribute = (SoapAttributeAttribute)attrs[i];
}
else if (attrs[i] is SoapTypeAttribute) {
this.soapType = (SoapTypeAttribute)attrs[i];
}
else if (attrs[i] is SoapEnumAttribute) {
this.soapEnum = (SoapEnumAttribute)attrs[i];
}
else if (attrs[i] is DefaultValueAttribute) {
this.soapDefaultValue = ((DefaultValueAttribute)attrs[i]).Value;
}
}
if (soapIgnore) {
this.soapElement = null;
this.soapAttribute = null;
this.soapType = null;
this.soapEnum = null;
this.soapDefaultValue = null;
}
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:35,代码来源:soapattributes.cs
示例6: AssertDescriptorMatches
void AssertDescriptorMatches(ILookup<string, SecurityAttributeDescriptor> descriptors, string signature, ICustomAttributeProvider element)
{
if (descriptors.Contains(signature))
AssertContainsAttribute(element, descriptors[signature].Single().AttributeTypeName);
else
AssertContainsNoAttribute(element);
}
开发者ID:tigerhu67,项目名称:monobuildtools,代码行数:7,代码来源:AssemblySecurityVerifier.cs
示例7: AttributeSet
public AttributeSet(ICustomAttributeProvider attributeProvider)
{
this.attributes = attributeProvider
.GetCustomAttributes(true)
.Cast<Attribute>()
.ToArray();
}
开发者ID:MatanShahar,项目名称:IntelliSun,代码行数:7,代码来源:AttributeSet.cs
示例8: TemplateBuilder
internal TemplateBuilder (ICustomAttributeProvider prov)
{
object[] ats = prov.GetCustomAttributes (typeof(TemplateContainerAttribute), true);
if (ats.Length > 0) {
containerAttribute = (TemplateContainerAttribute) ats [0];
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:TemplateBuilder.cs
示例9: GetAttributes
public IEnumerable<ValidationAttribute> GetAttributes(ICustomAttributeProvider attributeProvider)
{
return attributeProvider
.GetAttributes<ValidationAttribute>()
.Select(attr => container.BuildUp(attr.GetType(), attr))
.Cast<ValidationAttribute>();
}
开发者ID:tmont,项目名称:portoa,代码行数:7,代码来源:BuildUpAttributeProvider.cs
示例10: CreateSubstituteRequest
private static object CreateSubstituteRequest(ICustomAttributeProvider request, SubstituteAttribute attribute)
{
var parameter = request as ParameterInfo;
if (parameter != null)
{
return new SubstituteRequest(parameter.ParameterType);
}
var property = request as PropertyInfo;
if (property != null)
{
return new SubstituteRequest(property.PropertyType);
}
var field = request as FieldInfo;
if (field != null)
{
return new SubstituteRequest(field.FieldType);
}
throw new NotSupportedException(
string.Format(
CultureInfo.CurrentCulture,
"{0} is applied to an unsupported code element {1}",
attribute, request));
}
开发者ID:RyanLiu99,项目名称:AutoFixture,代码行数:26,代码来源:SubstituteAttributeRelay.cs
示例11: GetBinderFromAttributes
internal static IModelBinder GetBinderFromAttributes(ICustomAttributeProvider element, Func<string> errorMessageAccessor)
{
// this method is used to get a custom binder based on the attributes of the element passed to it.
// it will return null if a binder cannot be detected based on the attributes alone.
var attrs = (CustomModelBinderAttribute[]) element.GetCustomAttributes(typeof (CustomModelBinderAttribute), true /* inherit */);
if (attrs == null)
{
return null;
}
switch (attrs.Length)
{
case 0:
return null;
case 1:
var binder = attrs[0].GetBinder();
return binder;
default:
var errorMessage = errorMessageAccessor();
throw new InvalidOperationException(errorMessage);
}
}
开发者ID:jdhardy,项目名称:ironrubymvc,代码行数:25,代码来源:RubyModelBinders.cs
示例12: ResolveType
public static TypeDefinition ResolveType(string type, ICustomAttributeProvider provider, IAssemblyResolver resolver)
{
if (provider == null)
throw new ArgumentException ("Type resolution support requires an AssemblyDefinition or TypeDefinition.", "provider");
if (resolver == null)
throw new ArgumentException ("Type resolution support requires a IAssemblyResolver.", "resolver");
// `type` is either a "bare" type "Foo.Bar", or an
// assembly-qualified type "Foo.Bar, AssemblyName [Version=...]?".
//
// Bare types are looked up via `provider`; assembly-qualified types are
// looked up via `resolver`
int c = type.IndexOf (',');
string typeName = c < 0 ? type : type.Substring (0, c);
string assmName = c < 0 ? null : type.Substring (c+1);
AssemblyDefinition assembly = assmName == null ? null : resolver.Resolve (assmName);
if (assembly == null) {
assembly = provider as AssemblyDefinition;
if (assembly == null) {
TypeDefinition decl = (TypeDefinition) provider;
assembly = decl.Module.Assembly;
}
}
var ret = assembly.Modules.Cast<ModuleDefinition> ()
.Select (md => md.Types.FirstOrDefault (t => t.FullName == typeName))
.FirstOrDefault (td => td != null);
if (ret == null)
throw new ArgumentException ("Type not found: " + type, "type");
return ret;
}
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:33,代码来源:ManifestDocumentElement.cs
示例13: GetInvalidSuppressMessageAttributeErrorsCore
private static IEnumerable<string> GetInvalidSuppressMessageAttributeErrorsCore(ICustomAttributeProvider target, string name, string targetType, IEnumerable<Exemption> exemptions) {
foreach (SuppressMessageAttribute attr in target.GetCustomAttributes(typeof(SuppressMessageAttribute), false).OfType<SuppressMessageAttribute>()) {
if (String.IsNullOrWhiteSpace(attr.Justification) && !IsExempt(exemptions, attr.CheckId, name, targetType)) {
yield return FormatErrorMessage(attr, name, targetType);
}
}
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:7,代码来源:SuppressMessageUtil.cs
示例14: ProcessExports
void ProcessExports(ICustomAttributeProvider provider)
{
if (provider == null)
return;
if (!provider.HasCustomAttributes)
return;
var attributes = provider.CustomAttributes;
for (int i = 0; i < attributes.Count; i++) {
var attribute = attributes [i];
switch (attribute.Constructor.DeclaringType.FullName) {
case "Java.Interop.ExportAttribute":
Annotations.Mark (provider);
if (!attribute.HasProperties)
break;
var throwsAtt = attribute.Properties.FirstOrDefault (p => p.Name == "Throws");
var thrownTypesArgs = throwsAtt.Argument.Value != null ? (CustomAttributeArgument []) throwsAtt.Argument.Value : null;
if (thrownTypesArgs != null)
foreach (var attArg in thrownTypesArgs)
Annotations.Mark (((TypeReference) attArg.Value).Resolve ());
break;
case "Java.Interop.ExportFieldAttribute":
Annotations.Mark (provider);
break;
default:
continue;
}
if (provider is MemberReference)
Annotations.Mark (((MemberReference) provider).DeclaringType.Resolve ());
if (provider is MethodDefinition)
Annotations.SetAction (((MethodDefinition) provider), MethodAction.ForceParse);
}
}
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:34,代码来源:PreserveExportedTypes.cs
示例15: Create
/// <summary>
/// Create annotations for all included attributes
/// </summary>
public static void Create(AssemblyCompiler compiler, ICustomAttributeProvider attributeProvider,
IAnnotationProvider annotationProvider, DexTargetPackage targetPackage, bool customAttributesOnly = false)
{
if (!attributeProvider.HasCustomAttributes)
return;
var annotations = new List<Annotation>();
foreach (var attr in attributeProvider.CustomAttributes)
{
var attributeType = attr.AttributeType.Resolve();
if (!attributeType.HasIgnoreAttribute())
{
Create(compiler, attr, attributeType, annotations, targetPackage);
}
}
if (annotations.Count > 0)
{
// Create 1 IAttributes annotation
var attrsAnnotation = new Annotation { Visibility = AnnotationVisibility.Runtime };
attrsAnnotation.Type = compiler.GetDot42InternalType("IAttributes").GetClassReference(targetPackage);
attrsAnnotation.Arguments.Add(new AnnotationArgument("Attributes", annotations.ToArray()));
annotationProvider.Annotations.Add(attrsAnnotation);
}
if (!customAttributesOnly)
{
// Add annotations specified using AnnotationAttribute
foreach (var attr in attributeProvider.CustomAttributes.Where(IsAnnotationAttribute))
{
var annotationType = (TypeReference) attr.ConstructorArguments[0].Value;
var annotationClass = annotationType.GetClassReference(targetPackage, compiler.Module);
annotationProvider.Annotations.Add(new Annotation(annotationClass, AnnotationVisibility.Runtime));
}
}
}
开发者ID:jakesays,项目名称:dot42,代码行数:36,代码来源:AnnotationBuilder.cs
示例16: OfProvider
public IEnumerable<TypeReference> OfProvider(ICustomAttributeProvider provider)
{
if (provider == null)
throw new ArgumentNullException("provider");
return provider.CustomAttributes.Select(x => x.AttributeType);
}
开发者ID:scaredfinger,项目名称:SharpDependencies,代码行数:7,代码来源:FindTypeReferencesInCustomAttributes.cs
示例17: Get
public static JsonRpcHelpAttribute Get(ICustomAttributeProvider attributeProvider)
{
if (attributeProvider == null)
return null;
return (JsonRpcHelpAttribute) CustomAttribute.Get(attributeProvider, typeof(JsonRpcHelpAttribute));
}
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:7,代码来源:JsonRpcHelpAttribute.cs
示例18: GetPseudoCustomAttributes
internal static object[] GetPseudoCustomAttributes (ICustomAttributeProvider obj, Type attributeType) {
object[] pseudoAttrs = null;
/* FIXME: Add other types */
if (obj is MonoMethod)
pseudoAttrs = ((MonoMethod)obj).GetPseudoCustomAttributes ();
else if (obj is FieldInfo)
pseudoAttrs = ((FieldInfo)obj).GetPseudoCustomAttributes ();
else if (obj is ParameterInfo)
pseudoAttrs = ((ParameterInfo)obj).GetPseudoCustomAttributes ();
else if (obj is Type)
pseudoAttrs = ((Type)obj).GetPseudoCustomAttributes ();
if ((attributeType != null) && (pseudoAttrs != null)) {
for (int i = 0; i < pseudoAttrs.Length; ++i)
if (attributeType.IsAssignableFrom (pseudoAttrs [i].GetType ()))
if (pseudoAttrs.Length == 1)
return pseudoAttrs;
else
return new object [] { pseudoAttrs [i] };
return new object [0];
}
else
return pseudoAttrs;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:25,代码来源:MonoCustomAttrs.Original.cs
示例19: IsValidParameter
public static bool IsValidParameter(Type type, ICustomAttributeProvider attributeProvider, bool allowReferences)
{
object[] attributes = System.ServiceModel.Description.ServiceReflector.GetCustomAttributes(attributeProvider, typeof(MarshalAsAttribute), true);
foreach (MarshalAsAttribute attr in attributes)
{
UnmanagedType marshalAs = attr.Value;
if (marshalAs == UnmanagedType.IDispatch ||
marshalAs == UnmanagedType.Interface ||
marshalAs == UnmanagedType.IUnknown)
{
return allowReferences;
}
}
XsdDataContractExporter exporter = new XsdDataContractExporter();
if (!exporter.CanExport(type))
{
return false;
}
return true;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:ComPlusTypeValidator.cs
示例20: Check
/// <summary>
/// Check customer attributes
/// </summary>
private void Check(ICustomAttributeProvider provider, string context)
{
foreach (var ca in provider.CustomAttributes)
{
Check(ca.AttributeType, context);
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:Checker.cs
注:本文中的ICustomAttributeProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论