本文整理汇总了C#中MemberAttributes类的典型用法代码示例。如果您正苦于以下问题:C# MemberAttributes类的具体用法?C# MemberAttributes怎么用?C# MemberAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberAttributes类属于命名空间,在下文中一共展示了MemberAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Method
public static CodeMemberMethod Method(this CodeTypeDeclaration decleration, MemberAttributes attributes,
Type returnType, string name)
{
var method = new CodeMemberMethod() {Name = name, Attributes = attributes};
decleration.Members.Add(method);
return method;
}
示例2: ConvertToMethodAttributes
internal static MethodAttributes ConvertToMethodAttributes(MemberAttributes memberAttributes)
{
MethodAttributes methodAttributes = MethodAttributes.ReuseSlot;
// convert access attributes
if ((memberAttributes & MemberAttributes.AccessMask) == MemberAttributes.Assembly)
methodAttributes |= MethodAttributes.Assembly;
else if ((memberAttributes & MemberAttributes.AccessMask) == MemberAttributes.Family)
methodAttributes |= MethodAttributes.Family;
else if ((memberAttributes & MemberAttributes.AccessMask) == MemberAttributes.FamilyAndAssembly)
methodAttributes |= MethodAttributes.FamANDAssem;
else if ((memberAttributes & MemberAttributes.AccessMask) == MemberAttributes.FamilyOrAssembly)
methodAttributes |= MethodAttributes.FamORAssem;
else if ((memberAttributes & MemberAttributes.AccessMask) == MemberAttributes.Private)
methodAttributes |= MethodAttributes.Private;
else if ((memberAttributes & MemberAttributes.AccessMask) == MemberAttributes.Public)
methodAttributes |= MethodAttributes.Public;
// covert scope attributes
if ((memberAttributes & MemberAttributes.ScopeMask) == MemberAttributes.Abstract)
methodAttributes |= MethodAttributes.Abstract;
else if ((memberAttributes & MemberAttributes.ScopeMask) == MemberAttributes.Final)
methodAttributes |= MethodAttributes.Final;
else if ((memberAttributes & MemberAttributes.ScopeMask) == MemberAttributes.Static)
methodAttributes |= MethodAttributes.Static;
//else if ((memberAttributes & MemberAttributes.ScopeMask) == MemberAttributes.Override)
// methodAttributes |= MethodAttributes.ReuseSlot;//
// convert vtable slot
if ((memberAttributes & MemberAttributes.VTableMask) == MemberAttributes.New)
methodAttributes |= MethodAttributes.NewSlot;
//if ((memberAttributes & MemberAttributes.VTableMask) == MemberAttributes.Overloaded)
// methodAttributes |= MethodAttributes.HideBySig; //
return methodAttributes;
}
示例3: AddProperty
public static CodeMemberProperty AddProperty(this CodeTypeMember member,
string propertyType, MemberAttributes ma, string name)
{
var classCode = member.GetDeclaration();
return classCode.AddProperty(propertyType, ma, name);
}
示例4: CheckClass
/// <summary>
/// Checks the class.
/// </summary>
/// <param name="codeType">The code type.</param>
/// <param name="name">The class name.</param>
/// <param name="modifiers">The class modifiers.</param>
/// <param name="members">The count of members in the <paramref name="codeType"/>.</param>
/// <param name="baseTypes">The class base types.</param>
public static void CheckClass(CodeTypeDeclaration codeType, string name, MemberAttributes modifiers, int members, params string[] baseTypes)
{
Assert.IsTrue(codeType.IsClass,
String.Format(CultureInfo.CurrentCulture, Settings.Default.IsNotClass, codeType.Name));
Assert.AreEqual(name, codeType.Name, Settings.Default.InvalidName);
Assert.AreEqual(modifiers, codeType.Attributes,
String.Format(CultureInfo.CurrentCulture, Settings.Default.InvalidAccessModifier, name));
if (baseTypes != null)
{
Assert.AreEqual(baseTypes.Length, codeType.BaseTypes.Count,
String.Format(CultureInfo.CurrentCulture, Settings.Default.WrongNumberBaseTypes, name));
for (int i = 0; i < baseTypes.Length; i++)
{
Assert.AreEqual(baseTypes[i], codeType.BaseTypes[i].BaseType,
String.Format(CultureInfo.CurrentCulture, Settings.Default.InvalidBaseType, name));
}
}
else
{
Assert.AreEqual(0, codeType.BaseTypes.Count,
String.Format(CultureInfo.CurrentCulture, Settings.Default.WrongNumberBaseTypes, name));
}
Assert.AreEqual(members, codeType.Members.Count,
String.Format(CultureInfo.CurrentCulture, Settings.Default.WrongNumberMembers, name));
}
示例5: AddFieldDeclaration
internal static CodeMemberField AddFieldDeclaration(CodeTypeDeclaration type, MemberAttributes memberAttribute, string fieldType, string fieldName)
{
CodeMemberField cmf = new CodeMemberField(fieldType, fieldName);
cmf.Attributes = memberAttribute;
type.Members.Add(cmf);
return cmf;
}
示例6: AddEvent
public static CodeMemberEvent AddEvent(this CodeTypeMember member,
Type delegateType, MemberAttributes ma, string name)
{
var classCode = member.GetDeclaration();
return classCode.AddEvent(delegateType, ma, name);
}
示例7: CreateInterface
public static CodeTypeDeclaration CreateInterface (string name, MemberAttributes attribute) {
CodeTypeDeclaration ct = new CodeTypeDeclaration (name);
ct.Attributes = attribute;
ct.IsInterface = true;
return ct;
}
示例8: ConvModifiers
MemberAttributes ConvModifiers(TypeMemberModifiers modifier, MemberAttributes defaultVisibility)
{
MemberAttributes attr = 0;
if ((modifier & TypeMemberModifiers.Abstract) == TypeMemberModifiers.Abstract)
attr |= MemberAttributes.Abstract;
if ((modifier & TypeMemberModifiers.Final) == TypeMemberModifiers.Final)
attr |= MemberAttributes.Const;
if ((modifier & TypeMemberModifiers.Internal) == TypeMemberModifiers.Internal)
attr |= MemberAttributes.Assembly;
if ((modifier & TypeMemberModifiers.Override) == TypeMemberModifiers.Override)
attr |= MemberAttributes.Override;
if ((modifier & TypeMemberModifiers.Private) == TypeMemberModifiers.Private)
attr |= MemberAttributes.Private;
if ((modifier & TypeMemberModifiers.Protected) == TypeMemberModifiers.Protected)
attr |= MemberAttributes.Family;
if ((modifier & TypeMemberModifiers.Public) == TypeMemberModifiers.Public)
attr |= MemberAttributes.Public;
if ((modifier & TypeMemberModifiers.Static) == TypeMemberModifiers.Static)
attr |= MemberAttributes.Static;
if ((modifier & TypeMemberModifiers.Virtual) != TypeMemberModifiers.Virtual)
attr |= MemberAttributes.Final;
if ((modifier & TypeMemberModifiers.VisibilityMask) == TypeMemberModifiers.None)
attr |= defaultVisibility;
return attr;
}
示例9: Struct
public static CodeTypeDeclaration Struct(string structName, MemberAttributes attributes)
{
return new CodeTypeDeclaration(structName)
{
Attributes = attributes,
IsStruct = true
};
}
示例10: DesignConnection
public DesignConnection(string connectionName, System.Data.Design.ConnectionString cs, string provider)
{
this.properties = new HybridDictionary();
this.modifier = MemberAttributes.Assembly;
this.name = connectionName;
this.connectionStringObject = cs;
this.provider = provider;
}
示例11: AddGetProperty
public static CodeMemberProperty AddGetProperty(this CodeTypeMember member,
string propertyType, MemberAttributes ma, string name,
params CodeStatement[] statements)
{
var classCode = member.GetDeclaration();
return classCode.AddGetProperty(propertyType, ma, name, statements);
}
示例12: Interface
public static CodeTypeDeclaration Interface(string interfaceName, MemberAttributes attributes)
{
return new CodeTypeDeclaration(interfaceName)
{
Attributes = attributes,
IsInterface = true
};
}
示例13: DrawType
public virtual void DrawType(XBaseWindow window)
{
XBaseWindow.DoButton("Type", ()=> {
XCodeTypeTemplate.SelectType(x => type = x);
});
memberAttribute = (MemberAttributes)XBaseWindow.CreateEnumPopup( memberAttribute );
}
示例14: Enum
public static CodeTypeDeclaration Enum(string enumName, MemberAttributes attributes)
{
return new CodeTypeDeclaration(enumName)
{
Attributes = attributes,
IsEnum = true
};
}
示例15: CreateClass
public static CodeTypeDeclaration CreateClass (string name, MemberAttributes attribute,
CodeTypeReference[] baseTypes) {
CodeTypeDeclaration ct = new CodeTypeDeclaration (name);
ct.Attributes = attribute;
ct.BaseTypes.AddRange (baseTypes);
ct.IsClass = true;
return ct;
}