本文整理汇总了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);
}
示例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);
}
示例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");
}
示例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);
}
}
}
示例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 ();
}
示例7: Constructor1_NullItem
public void Constructor1_NullItem ()
{
CodeAttributeArgument[] arguments = new CodeAttributeArgument[] {
new CodeAttributeArgument (), null };
CodeAttributeArgumentCollection coll = new CodeAttributeArgumentCollection (
arguments);
}
示例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]);
}
}
示例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;
}
示例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 ();
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
}
示例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]);
}
}