本文整理汇总了C#中System.CodeDom.CodeAttributeDeclarationCollection类的典型用法代码示例。如果您正苦于以下问题:C# CodeAttributeDeclarationCollection类的具体用法?C# CodeAttributeDeclarationCollection怎么用?C# CodeAttributeDeclarationCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeAttributeDeclarationCollection类属于System.CodeDom命名空间,在下文中一共展示了CodeAttributeDeclarationCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor1_NullItem
public void Constructor1_NullItem ()
{
CodeAttributeDeclaration[] declarations = new CodeAttributeDeclaration[] {
new CodeAttributeDeclaration (), null };
CodeAttributeDeclarationCollection coll = new CodeAttributeDeclarationCollection (
declarations);
}
示例2: SetDescription
private void SetDescription(CodeAttributeDeclarationCollection customAttributes, string description)
{
customAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(DESCRIPTION_ATTR),
new CodeAttributeArgument(
new CodePrimitiveExpression(description))));
}
示例3: Clone
public static CodeAttributeDeclarationCollection Clone(this CodeAttributeDeclarationCollection collection)
{
if (collection == null) return null;
CodeAttributeDeclarationCollection c = new CodeAttributeDeclarationCollection();
foreach (CodeAttributeDeclaration attribute in collection)
c.Add(attribute.Clone());
return c;
}
示例4: Constructor0
public void Constructor0 ()
{
CodeAttributeDeclarationCollection coll = new CodeAttributeDeclarationCollection ();
Assert.IsFalse (((IList) coll).IsFixedSize, "#1");
Assert.IsFalse (((IList) coll).IsReadOnly, "#2");
Assert.AreEqual (0, coll.Count, "#3");
Assert.IsFalse (((ICollection) coll).IsSynchronized, "#4");
Assert.IsNotNull (((ICollection) coll).SyncRoot, "#5");
}
示例5: Translate
private AttributeList Translate(CodeAttributeDeclarationCollection attributes, AttributeList attributeList){
if (attributes == null) return null;
int n = attributes.Count;
if (attributeList == null)
if (n == 0) return null; else attributeList = new AttributeList(n);
for (int i = 0; i < n; i++)
attributeList.Add(this.Translate(attributes[i]));
return attributeList;
}
示例6: AddMappingMetadata
public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlTypeMapping member, string ns)
{
if (member.Namespace != ns && member.Namespace != "") {
CodeAttributeDeclaration ratt = new CodeAttributeDeclaration ("System.Xml.Serialization.XmlRoot");
ratt.Arguments.Add (MapCodeGenerator.GetArg (member.ElementName));
ratt.Arguments.Add (MapCodeGenerator.GetArg ("Namespace", member.Namespace));
ratt.Arguments.Add (MapCodeGenerator.GetArg ("IsNullable", member.IsNullable));
metadata.Add (ratt);
}
}
示例7: SetProperty
private void SetProperty(CodeAttributeDeclarationCollection customAttributes, string name, string value)
{
customAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(PROPERTY_ATTR),
new CodeAttributeArgument(
new CodePrimitiveExpression(name)),
new CodeAttributeArgument(
new CodePrimitiveExpression(value))));
}
示例8: SetCategories
private void SetCategories(CodeAttributeDeclarationCollection customAttributes, IEnumerable<string> categories)
{
foreach (var category in categories)
{
customAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(CATEGORY_ATTR),
new CodeAttributeArgument(
new CodePrimitiveExpression(category))));
}
}
示例9: AddRange
public void AddRange(CodeAttributeDeclarationCollection value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
int count = value.Count;
for (int i = 0; i < count; i++)
{
this.Add(value[i]);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:CodeAttributeDeclarationCollection.cs
示例10: AddMappingMetadata
public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, bool forceUseMemberName)
{
TypeData memType = member.TypeMapMember.TypeData;
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapElement");
if (forceUseMemberName || (member.ElementName != member.MemberName))
att.Arguments.Add (new CodeAttributeArgument (new CodePrimitiveExpression(member.ElementName)));
if (!TypeTranslator.IsDefaultPrimitiveTpeData (memType))
att.Arguments.Add (new CodeAttributeArgument ("DataType", new CodePrimitiveExpression(member.TypeName)));
if (att.Arguments.Count > 0)
metadata.Add (att);
}
示例11: AddIncludeMetadata
internal static void AddIncludeMetadata(CodeAttributeDeclarationCollection metadata, StructMapping mapping, Type type)
{
if (!mapping.IsAnonymousType)
{
for (StructMapping mapping2 = mapping.DerivedMappings; mapping2 != null; mapping2 = mapping2.NextDerivedMapping)
{
CodeAttributeDeclaration declaration = new CodeAttributeDeclaration(type.FullName);
declaration.Arguments.Add(new CodeAttributeArgument(new CodeTypeOfExpression(mapping2.TypeDesc.FullName)));
metadata.Add(declaration);
AddIncludeMetadata(metadata, mapping2, type);
}
}
}
示例12: Constructor1
public void Constructor1 ()
{
CodeAttributeDeclaration cad1 = new CodeAttributeDeclaration ();
CodeAttributeDeclaration cad2 = new CodeAttributeDeclaration ();
CodeAttributeDeclaration[] declarations = new CodeAttributeDeclaration[] { cad1, cad2 };
CodeAttributeDeclarationCollection coll = new CodeAttributeDeclarationCollection (
declarations);
Assert.AreEqual (2, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (cad1), "#2");
Assert.AreEqual (1, coll.IndexOf (cad2), "#3");
}
示例13: CreateAutoPropertyWithDataMemberAttribute
public CodeMemberProperty CreateAutoPropertyWithDataMemberAttribute(string type, string propertyName)
{
var attributes = new CodeAttributeDeclarationCollection { new CodeAttributeDeclaration("DataMember") };
var codeMemberProperty = new CodeMemberProperty
{
Name = propertyName,
HasGet = true,
HasSet = true,
CustomAttributes = attributes,
Attributes = MemberAttributes.Public,
Type = new CodeTypeReference(type)
};
return codeMemberProperty;
}
示例14: AddMemberMetadata
private void AddMemberMetadata(CodeAttributeDeclarationCollection metadata, MemberMapping member, bool forceUseMemberName)
{
if (member.Elements.Length != 0)
{
ElementAccessor accessor = member.Elements[0];
TypeMapping mapping = accessor.Mapping;
string str = Accessor.UnescapeName(accessor.Name);
bool flag = (str == member.Name) && !forceUseMemberName;
if ((!flag || mapping.TypeDesc.IsAmbiguousDataType) || accessor.IsNullable)
{
this.AddElementMetadata(metadata, flag ? null : str, mapping.TypeDesc.IsAmbiguousDataType ? mapping.TypeDesc : null, accessor.IsNullable);
}
}
}
示例15: AddElementMetadata
private void AddElementMetadata(CodeAttributeDeclarationCollection metadata, string elementName, TypeDesc typeDesc, bool isNullable)
{
CodeAttributeDeclaration declaration = new CodeAttributeDeclaration(typeof(SoapElementAttribute).FullName);
if (elementName != null)
{
declaration.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(elementName)));
}
if ((typeDesc != null) && typeDesc.IsAmbiguousDataType)
{
declaration.Arguments.Add(new CodeAttributeArgument("DataType", new CodePrimitiveExpression(typeDesc.DataType.Name)));
}
if (isNullable)
{
declaration.Arguments.Add(new CodeAttributeArgument("IsNullable", new CodePrimitiveExpression(true)));
}
metadata.Add(declaration);
}