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


C# CodeDom.CodeAttributeArgument类代码示例

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


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

示例1: GenerateClassAttributes

 protected override void GenerateClassAttributes()
 {
     base.GenerateClassAttributes();
     if ((base._sourceDataClass != null) && (this.Parser.OutputCacheParameters != null))
     {
         OutputCacheParameters outputCacheParameters = this.Parser.OutputCacheParameters;
         if (outputCacheParameters.Duration > 0)
         {
             CodeAttributeDeclaration declaration = new CodeAttributeDeclaration("System.Web.UI.PartialCachingAttribute");
             CodeAttributeArgument argument = new CodeAttributeArgument(new CodePrimitiveExpression(outputCacheParameters.Duration));
             declaration.Arguments.Add(argument);
             argument = new CodeAttributeArgument(new CodePrimitiveExpression(outputCacheParameters.VaryByParam));
             declaration.Arguments.Add(argument);
             argument = new CodeAttributeArgument(new CodePrimitiveExpression(outputCacheParameters.VaryByControl));
             declaration.Arguments.Add(argument);
             argument = new CodeAttributeArgument(new CodePrimitiveExpression(outputCacheParameters.VaryByCustom));
             declaration.Arguments.Add(argument);
             argument = new CodeAttributeArgument(new CodePrimitiveExpression(outputCacheParameters.SqlDependency));
             declaration.Arguments.Add(argument);
             argument = new CodeAttributeArgument(new CodePrimitiveExpression(this.Parser.FSharedPartialCaching));
             declaration.Arguments.Add(argument);
             if (MultiTargetingUtil.IsTargetFramework40OrAbove)
             {
                 argument = new CodeAttributeArgument("ProviderName", new CodePrimitiveExpression(this.Parser.Provider));
                 declaration.Arguments.Add(argument);
             }
             base._sourceDataClass.CustomAttributes.Add(declaration);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:UserControlCodeDomTreeGenerator.cs

示例2: CodeForNameIndexAttribute

 private static CodeAttributeDeclaration CodeForNameIndexAttribute(Type type, string name, int index)
 {
     CodeTypeReference indexAttributeType = new CodeTypeReference(type);
     CodeAttributeArgument nameAttribute = new CodeAttributeArgument(new CodePrimitiveExpression(name));
     CodeAttributeArgument indexAttribute = new CodeAttributeArgument(new CodePrimitiveExpression(index));
     return new CodeAttributeDeclaration(indexAttributeType, nameAttribute, indexAttribute);
 }
开发者ID:hsteinhilber,项目名称:white-project,代码行数:7,代码来源:CodeGenerationVisitor.cs

示例3: DynaAttributeDeclaration

 public DynaAttributeDeclaration(string AttributeName, object[] AttributeArguements)
 {
     CodeAttributeArgument[] caa = new CodeAttributeArgument[AttributeArguements.Length];
     for (int i = 0; i < caa.Length; i++)
         caa[i] = new CodeAttributeArgument(new CodePrimitiveExpression(AttributeArguements[i]));
     cad = new CodeAttributeDeclaration(AttributeName, caa);
 }
开发者ID:tenshino,项目名称:RainstormStudios,代码行数:7,代码来源:DynaSupplimental.cs

示例4: DefaultConstructor

		public void DefaultConstructor ()
		{
			CodeAttributeArgument caa = new CodeAttributeArgument ();
			Assert.IsNotNull (caa.Name, "#1");
			Assert.AreEqual (string.Empty, caa.Name, "#2");
			Assert.IsNull (caa.Value, "#3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeAttributeArgumentTest.cs

示例5: GenerateClassAttributes

    /*
     * Add metadata attributes to the class
     */
    protected override void GenerateClassAttributes() {

        base.GenerateClassAttributes();

        // If the user control has an OutputCache directive, generate
        // an attribute with the information about it.
        if (_sourceDataClass != null && Parser.OutputCacheParameters != null) {
            OutputCacheParameters cacheSettings = Parser.OutputCacheParameters;
            if (cacheSettings.Duration > 0) {
                CodeAttributeDeclaration attribDecl = new CodeAttributeDeclaration(
                    "System.Web.UI.PartialCachingAttribute");
                CodeAttributeArgument attribArg = new CodeAttributeArgument(
                    new CodePrimitiveExpression(cacheSettings.Duration));
                attribDecl.Arguments.Add(attribArg);
                attribArg = new CodeAttributeArgument(new CodePrimitiveExpression(cacheSettings.VaryByParam));
                attribDecl.Arguments.Add(attribArg);
                attribArg = new CodeAttributeArgument(new CodePrimitiveExpression(cacheSettings.VaryByControl));
                attribDecl.Arguments.Add(attribArg);
                attribArg = new CodeAttributeArgument(new CodePrimitiveExpression(cacheSettings.VaryByCustom));
                attribDecl.Arguments.Add(attribArg);
                attribArg = new CodeAttributeArgument(new CodePrimitiveExpression(cacheSettings.SqlDependency));
                attribDecl.Arguments.Add(attribArg);
                attribArg = new CodeAttributeArgument(new CodePrimitiveExpression(Parser.FSharedPartialCaching));
                attribDecl.Arguments.Add(attribArg);
                // Use the providerName argument only when targeting 4.0 and above.
                if (MultiTargetingUtil.IsTargetFramework40OrAbove) {
                    attribArg = new CodeAttributeArgument("ProviderName", new CodePrimitiveExpression(Parser.Provider));
                    attribDecl.Arguments.Add(attribArg);
                }

                _sourceDataClass.CustomAttributes.Add(attribDecl);
            }
        }
    }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:37,代码来源:UserControlCodeDomTreeGenerator.cs

示例6: Constructor0_Deny_Unrestricted

		public void Constructor0_Deny_Unrestricted ()
		{
			CodeAttributeArgument caa = new CodeAttributeArgument ();
			Assert.AreEqual (String.Empty, caa.Name, "Name");
			caa.Name = null;
			Assert.IsNull (caa.Value, "Value");
			caa.Value = new CodeExpression ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:CodeAttributeArgumentCas.cs

示例7: Constructor1_NullItem

		public void Constructor1_NullItem ()
		{
			CodeAttributeArgument[] arguments = new CodeAttributeArgument[] { 
				new CodeAttributeArgument (), null };

			CodeAttributeArgumentCollection coll = new CodeAttributeArgumentCollection (
				arguments);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:CodeAttributeArgumentCollectionTest.cs

示例8: AddRange

 /// <devdoc>
 /// <para>Copies the elements of an array to the end of the <see cref='System.CodeDom.CodeAttributeArgumentCollection'/>.</para>
 /// </devdoc>
 public void AddRange(CodeAttributeArgument[] value) {
     if (value == null) {
         throw new ArgumentNullException("value");
     }
     for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
         this.Add(value[i]);
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:11,代码来源:codeattributeargumentcollection.cs

示例9: Clone

 public static CodeAttributeArgument Clone(this CodeAttributeArgument argument)
 {
     if (argument == null) return null;
     CodeAttributeArgument a = new CodeAttributeArgument();
     a.Name = argument.Name;
     a.Value = argument.Value.Clone();
     return a;
 }
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:8,代码来源:CodeAttributeArgumentExtensions.cs

示例10: Constructor2_Deny_Unrestricted

		public void Constructor2_Deny_Unrestricted ()
		{
			CodeExpression value = new CodeExpression ();
			CodeAttributeArgument caa = new CodeAttributeArgument ("mono", value);
			Assert.AreEqual ("mono", caa.Name, "Name");
			caa.Name = String.Empty;
			Assert.AreSame (value, caa.Value, "Value");
			caa.Value = new CodeExpression ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CodeAttributeArgumentCas.cs

示例11: AddAttribute

        public void AddAttribute(CodeTypeMember member, string attributeType,
            string expression = null)
        {
            // Add [attributeType(expression)]
            var argument = new CodeAttributeArgument(new CodeSnippetExpression(expression));
            var attribute = new CodeAttributeDeclaration(attributeType, argument);

            member.CustomAttributes.Add(attribute);
        }
开发者ID:brendanhay,项目名称:Shared,代码行数:9,代码来源:CompilerService.cs

示例12: Constructor2_Deny_Unrestricted

		public void Constructor2_Deny_Unrestricted ()
		{
			CodeAttributeArgument[] args = new CodeAttributeArgument[1] { new CodeAttributeArgument () };
			CodeAttributeDeclaration cad = new CodeAttributeDeclaration ("mono", args);
			Assert.AreEqual (1, cad.Arguments.Count, "Arguments");
			Assert.AreEqual ("mono", cad.Name, "Name");
			cad.Name = null;
			Assert.AreEqual ("System.Void", cad.AttributeType.BaseType, "AttributeType.BaseType");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:CodeAttributeDeclarationCas.cs

示例13: AddXmlEnumAttribute

        private static void AddXmlEnumAttribute(CodeTypeMember member)
        {
            CodeTypeReference attributeType = new CodeTypeReference(typeof (XmlEnumAttribute));
            CodePrimitiveExpression argumentValue = new CodePrimitiveExpression(member.Name);
            CodeAttributeArgument argument = new CodeAttributeArgument(argumentValue);
            CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(attributeType, argument);

            member.CustomAttributes.Add(attribute);
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:9,代码来源:ImproveEnumFieldsCommand.cs

示例14: AddRootElementName

 private static void AddRootElementName(CodeTypeMember type)
 {
     foreach (CodeAttributeDeclaration attribute in type.CustomAttributes)
         if (attribute.Name == typeof (XmlRootAttribute).FullName)
         {
             CodePrimitiveExpression value = new CodePrimitiveExpression(type.Name);
             CodeAttributeArgument argument = new CodeAttributeArgument("", value);
             attribute.Arguments.Insert(0, argument);
         }
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:10,代码来源:ImproveTypeNamesCommand.cs

示例15: AddRange

		public void AddRange (CodeAttributeArgument [] value )
		{
			if (value == null) {
				throw new ArgumentNullException ("value");
			}

			for (int i = 0; i < value.Length; i++) {
				Add (value[i]);
			}
		}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:10,代码来源:CodeAttributeArgumentCollection.cs


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