当前位置: 首页>>代码示例>>C#>>正文


C# Cecil.CustomAttributeArgument类代码示例

本文整理汇总了C#中Mono.Cecil.CustomAttributeArgument的典型用法代码示例。如果您正苦于以下问题:C# CustomAttributeArgument类的具体用法?C# CustomAttributeArgument怎么用?C# CustomAttributeArgument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CustomAttributeArgument类属于Mono.Cecil命名空间,在下文中一共展示了CustomAttributeArgument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateExpressionFor

		static CodeExpression CreateExpressionFor (CustomAttributeArgument argument)
		{
			if (IsSystemType (argument.Type))
				return new CodeTypeOfExpression (GetCodeTypeReference ((TypeReference) argument.Value));

			return new CodePrimitiveExpression (argument.Value);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:7,代码来源:DomCecilAttribute.cs

示例2: GetValue

		static object GetValue(IProjectContent pc, IEntity member, CustomAttributeArgument argument)
		{
			if (argument.Value is TypeReference)
				return CreateType(pc, member, (TypeReference)argument.Value);
			else
				return argument.Value;
		}
开发者ID:kleinux,项目名称:SharpDevelop,代码行数:7,代码来源:CecilReader.cs

示例3: CopyCustomAttributeArg

 private CustomAttributeArgument CopyCustomAttributeArg(CustomAttributeArgument yourArgument)
 {
     var type = FixTypeReference(yourArgument.Type);
     var value = yourArgument.Value;
     if (value is CustomAttributeArgument) {
         value = CopyCustomAttributeArg((CustomAttributeArgument) value);
     } else if (value is TypeReference) {
         value = FixTypeReference((TypeReference) value);
     }
     return new CustomAttributeArgument(type, value);
 }
开发者ID:GregRos,项目名称:Patchwork,代码行数:11,代码来源:ModifyExisting.cs

示例4: CopyCustomAttributeNamedArguments

        public static void CopyCustomAttributeNamedArguments(Collection<Mono.Cecil.CustomAttributeNamedArgument> source,
            Collection<Mono.Cecil.CustomAttributeNamedArgument> target, ReferenceResolver resolver)
        {
            foreach (var namedArgument in source)
            {
                var argumentType = resolver.ReferenceType(namedArgument.Argument.Type);
                CustomAttributeArgument argument = new CustomAttributeArgument(argumentType, namedArgument.Argument.Value);

                target.Add(new Mono.Cecil.CustomAttributeNamedArgument(namedArgument.Name, argument));
            }
        }
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:11,代码来源:MetadataBuilderHelper.cs

示例5: TryGetPropertyArgument

		static bool TryGetPropertyArgument (ICustomAttribute attribute, string name, out CustomAttributeArgument argument)
		{
			foreach (var namedArg in attribute.Properties) {
				if (namedArg.Name == name) {
					argument = namedArg.Argument;
					return true;
				}
			}

			argument = default (CustomAttributeArgument);
			return false;
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:12,代码来源:SuppressMessageEngine.cs

示例6: AddObsoleteAttribute

    void AddObsoleteAttribute(AttributeData attributeData, Collection<CustomAttribute> customAttributes)
    {
        var customAttribute = new CustomAttribute(ObsoleteConstructorReference);

        var message = ConvertToMessage(attributeData);
        var messageArgument = new CustomAttributeArgument(ModuleDefinition.TypeSystem.String, message);
        customAttribute.ConstructorArguments.Add(messageArgument);

        var isError = GetIsError(attributeData);
        var isErrorArgument = new CustomAttributeArgument(ModuleDefinition.TypeSystem.Boolean, isError);
        customAttribute.ConstructorArguments.Add(isErrorArgument);

        customAttributes.Add(customAttribute);
    }
开发者ID:Fody,项目名称:Obsolete,代码行数:14,代码来源:AttributeFixer.cs

示例7: AddAttribute

        public void AddAttribute(Type attributeType, Type[] ctorParamTypes, object[] paramArguments)
        {
            var internalAttributeCtor = attributeType.GetConstructor(ctorParamTypes);
            var internalAttributeCtorRef = TargetModule.Import(internalAttributeCtor);
            var internalAttribute = new CustomAttribute(internalAttributeCtorRef);

            for (int i = 0; i < ctorParamTypes.Count(); i++)
            {
                var paramType = internalAttributeCtorRef.Parameters[i].ParameterType;
                var internalAttributeArgument = new CustomAttributeArgument(paramType, paramArguments[i]);
                internalAttribute.ConstructorArguments.Add(internalAttributeArgument);
            }

            TargetModule.Assembly.CustomAttributes.Add(internalAttribute);
        }
开发者ID:FloodProject,项目名称:flood,代码行数:15,代码来源:AssemblyWeaver.cs

示例8: AddCustomAttribute

        protected void AddCustomAttribute(MethodDefinition methodDefinition, ModuleDefinition moduleWithAttributeType, 
      CustomAttributeArgument ctorArgument)
        {
            ArgumentUtility.CheckNotNull ("methodDefinition", methodDefinition);
              ArgumentUtility.CheckNotNull ("moduleWithAttributeType", moduleWithAttributeType);

              var attributeCtor = MakeCtorAndReference ( methodDefinition.DeclaringType.Module, moduleWithAttributeType);
              if (attributeCtor.Parameters.Count != 1)
            throw new InvalidOperationException ("There is no custom attribute ctor available that takes one parameter!");

              var customAttribute = new CustomAttribute (attributeCtor);
              customAttribute.ConstructorArguments.Add (ctorArgument);

              if (!methodDefinition.CustomAttributes.Any (att => att.Constructor.FullName == attributeCtor.FullName))
            methodDefinition.CustomAttributes.Add (customAttribute);
        }
开发者ID:rubicon-oss,项目名称:AssemblyTransformer,代码行数:16,代码来源:MarkingAttributeStrategy.cs

示例9: GetCustomAttributeArgumentReferences

 private IEnumerable<ProjectReference> GetCustomAttributeArgumentReferences(
     CustomAttributeArgument customAttributeArgument, AuditEntryParameters parameters)
 {
     TypeDefinition typeDefinition = customAttributeArgument.Value is TypeReference
             ? (customAttributeArgument.Value as TypeReference).Resolve()
             : customAttributeArgument.Type.Resolve();
     if (typeDefinition != null && !parameters.IsTypeChecked(typeDefinition))
     {
         ProjectReference projectReference = parameters.FindProjectReference(typeDefinition.Scope);
         if (projectReference != null)
             yield return projectReference;
         foreach(var pr in
                 m_interfacesTypeWorker.Execute(typeDefinition, parameters))
             yield return pr;
         foreach(var pr in
                 m_classTypeHierarchyWorker.Execute(typeDefinition, parameters))
             yield return pr;
         parameters.AddToCheckedTypes(typeDefinition);
     }
 }
开发者ID:MishaUliutin,项目名称:RemoveUnusedRef,代码行数:20,代码来源:TypesAttributesEntry.cs

示例10: FixCustomAttributeArgument

		protected CustomAttributeArgument FixCustomAttributeArgument(ModuleDefinition module, CustomAttributeArgument argument)
		{
			var value = argument.Value;

			if (value is TypeReference)
				value = module.Import(value as TypeReference);

			if (value is CustomAttributeArgument[])
			{
				var arguments = value as CustomAttributeArgument[];
				for (var i = 0; i < arguments.Length; i++)
					arguments[i] = FixCustomAttributeArgument(module, arguments[i]);
			}

			// Used for wrapped CustomAttributeArgument[]
			if (argument.Type.Module == null)
				argument.Type = module.TypeSystem.LookupType(argument.Type.Namespace, argument.Type.Name);

			return new CustomAttributeArgument(module.Import(argument.Type), value);
		}
开发者ID:KitoHo,项目名称:Reflexil,代码行数:20,代码来源:CustomAttributeForm.cs

示例11: FixPlatformVersion

 private CustomAttributeArgument FixPlatformVersion(CustomAttributeArgument caa)
 {
     return new CustomAttributeArgument(FixPlatformVersion(caa.Type), caa.Value);
 }
开发者ID:Fininvest,项目名称:il-repack,代码行数:4,代码来源:PlatformFixer.cs

示例12: WriteArrayValues

 private void WriteArrayValues(CustomAttributeArgument[] array)
 {
     for (int i = 0; i < array.Length; i++)
     {
         if (array[i].Value is bool)
         {
             WriteBooleanLiteral((bool)array[i].Value);
         }
         else if (array[i].Value is string)
         {
             WriteStringLiteral((string)array[i].Value);
         }
         else if (array[i].Value is CustomAttributeArgument[])
         {
             WriteArrayValues(array[i].Value as CustomAttributeArgument[]);
         }
         else
         {
             WriteLiteral(array[i].Value.ToString());
         }
         if (i < array.Length - 1)
         {
             WriteSpace();
         }
     }
 }
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:26,代码来源:IntermediateLanguageAttributeWriter.cs

示例13: MarkIfType

		void MarkIfType (CustomAttributeArgument argument)
		{
			var at = argument.Type;
			if (at.IsArray) {
				var et = at.GetElementType ();
				if (et.Namespace != "System" || et.Name != "Type")
					return;

				MarkType (et);
				if (argument.Value == null)
					return;

				foreach (var cac in (CustomAttributeArgument[]) argument.Value)
					MarkWithResolvedScope ((TypeReference) cac.Value);
			} else if (at.Namespace == "System" && at.Name == "Type") {
				MarkType (argument.Type);
				MarkWithResolvedScope ((TypeReference) argument.Value);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:19,代码来源:MarkStep.cs

示例14: ReadConstantValue

		public IConstantValue ReadConstantValue(CustomAttributeArgument arg)
		{
			object value = arg.Value;
			if (value is CustomAttributeArgument) {
				// Cecil uses this representation for boxed values
				arg = (CustomAttributeArgument)value;
				value = arg.Value;
			}
			ITypeReference type = ReadTypeReference(arg.Type);
			CustomAttributeArgument[] array = value as CustomAttributeArgument[];
			if (array != null) {
				// TODO: write unit test for this
				// TODO: are multi-dimensional arrays possible as well?
				throw new NotImplementedException();
			}
			
			TypeReference valueType = value as TypeReference;
			if (valueType != null)
				value = ReadTypeReference(valueType);
			return new SimpleConstantValue(type, value);
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:21,代码来源:CecilLoader.cs

示例15: ToString

		public static string ToString(CustomAttributeArgument argument)
		{
			return argument.Value.ToString();
		}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:4,代码来源:OperandDisplayHelper.cs


注:本文中的Mono.Cecil.CustomAttributeArgument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。