• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cecil.CustomAttributeArgument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: MarkIfType

		void MarkIfType (CustomAttributeArgument argument)
		{
			if (argument.Type.FullName != "System.Type")
				return;

			MarkType (argument.Type);
			MarkType ((TypeReference) argument.Value);
		}
开发者ID:nuxleus,项目名称:mono,代码行数:8,代码来源:MarkStep.cs


示例17: addCustomAttributeArgument

 void addCustomAttributeArgument(CustomAttributeArgument arg)
 {
     pushMember(arg.Type);
 }
开发者ID:ldh0227,项目名称:de4dot,代码行数:4,代码来源:MemberRefFinder.cs


示例18: AnalyzeCustomAttributeArgs

 void AnalyzeCustomAttributeArgs(CustomAttributeArgument arg)
 {
     if (arg.Value is TypeReference)
     {
         TypeReference typeRef = arg.Value as TypeReference;
         bool has = false;
         foreach (var i in ivtMap)
             if (i.Key.Name.Name == typeRef.Scope.Name)
             {
                 has = true;
                 break;
             }
         if (has)
         {
             IAnnotationProvider type = (arg.Value as TypeReference).Resolve();
             if (type.Annotations[RenRef] != null)
                 (type.Annotations[RenRef] as List<IReference>).Add(new CustomAttributeTypeReference(arg.Value as TypeReference));
         }
     }
     else if (arg.Value is CustomAttributeArgument[])
         foreach (var i in arg.Value as CustomAttributeArgument[])
             AnalyzeCustomAttributeArgs(i);
 }
开发者ID:n017,项目名称:Confuser,代码行数:23,代码来源:NameAnalyzer.cs


示例19: UpdateAssembly

        private static void UpdateAssembly( HashSet<IAssemblyInfo> modified, IAssemblyInfo assemblyInfo )
        {
            foreach( var info in GetInternalVisibleToAttributes( assemblyInfo ).ToArray() )
            {
                if( info.ConstructorArguments.Count != ExpectedArgumentsNumber )
                {
                    Log.WarnFormat(
                        "Constructor of InternalVisibleToAttribute has not expected number of arguments. Actual: {0}, expected: {1}.",
                        info.ConstructorArguments.Count,
                        ExpectedArgumentsNumber );
                    continue;
                }

                var argument = GetConstructorArgument( assemblyInfo, info );
                if( argument == null )
                {
                    continue;
                }

                var originalAssemblyName = ( string )argument.Value.Value;

                var signedAssembly = GetMatchingSignedAssembly( modified, originalAssemblyName );

                if( signedAssembly == null )
                {
                    Log.WarnFormat(
                        "InternalVisibleToAttribute for assembly '{0}' will be removed.",
                        originalAssemblyName );
                    assemblyInfo.Assembly.CustomAttributes.Remove( info );
                    continue;
                }

                var assemblyName = string.Format(
                    "{0}, PublicKey={1}",
                    signedAssembly.Assembly.Name.Name,
                    GetPublicKeyToken( signedAssembly ) );
                var newArgument = new CustomAttributeArgument( argument.Value.Type, assemblyName );

                info.ConstructorArguments.Clear();
                info.ConstructorArguments.Add( newArgument );
            }
        }
开发者ID:rjasica,项目名称:sign,代码行数:42,代码来源:UpdateInternalVisibleToAttribute.cs


示例20: SwitchFramework

        public void SwitchFramework()
        {
            //            _asm.MainModule.RuntimeVersion = "";

            for (var x = 0; x < _asm.CustomAttributes.Count; x++)
            {
                if (_asm.CustomAttributes[x].AttributeType.Name == "TargetFrameworkAttribute")
                {
                    _asm.CustomAttributes[x].ConstructorArguments[0] = new CustomAttributeArgument(_asm.MainModule.Import(typeof(String)), ".NETFramework,Version=v4.5");

                    var cs = new CustomAttributeArgument(_asm.MainModule.Import(typeof(String)), ".NET Framework 4.5");
                    _asm.CustomAttributes[x].Properties[0] = new CustomAttributeNamedArgument("FrameworkDisplayName", cs);
                }
            }
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:15,代码来源:Injector.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cecil.EmbeddedResource类代码示例发布时间:2022-05-26
下一篇:
C# Cecil.CustomAttribute类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap