本文整理汇总了C#中System.CodeDom.CodeMemberEvent类的典型用法代码示例。如果您正苦于以下问题:C# CodeMemberEvent类的具体用法?C# CodeMemberEvent怎么用?C# CodeMemberEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeMemberEvent类属于System.CodeDom命名空间,在下文中一共展示了CodeMemberEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventInfo
/// <summary>
/// Constructor.
/// </summary>
/// <param name="tag">Tag</param>
/// <param name="className">Class name</param>
public EventInfo(CodeMemberEvent tag, string className)
: base(tag, className)
{
Trace.Assert(tag != null);
name = tag.Name;
lineNumber = tag.LinePragma.LineNumber;
}
示例2: ToCodeDom
public override CodeTypeMember ToCodeDom()
{
CodeMemberEvent e = new CodeMemberEvent();
base.ToCodeDom(e);
e.Name = this.Conformer.NormalizeMember(this.Name,this.Attributes);
e.Type = this.Type.TypeReference;
return e;
}
示例3: Constructor0_Deny_Unrestricted
public void Constructor0_Deny_Unrestricted ()
{
CodeMemberEvent cme = new CodeMemberEvent ();
Assert.AreEqual (0, cme.ImplementationTypes.Count, "ImplementationTypes");
Assert.IsNull (cme.PrivateImplementationType, "PrivateImplementationType");
cme.PrivateImplementationType = new CodeTypeReference ("System.Int32");
Assert.AreEqual ("System.Void", cme.Type.BaseType, "Type");
cme.Type = new CodeTypeReference ("System.Void");
}
示例4: Event
public static CodeMemberEvent Event(CodeTypeReference delegateType, MemberAttributes ma, string name)
{
var c = new CodeMemberEvent
{
Name = name,
Attributes = ma,
Type = delegateType,
};
return c;
}
示例5: TypescriptMemberEvent
public TypescriptMemberEvent(
IExpressionFactory expressionFactory,
ITypescriptTypeMapper typescriptTypeMapper,
CodeMemberEvent member,
CodeGeneratorOptions options)
{
_expressionFactory = expressionFactory;
_typescriptTypeMapper = typescriptTypeMapper;
_member = member;
_options = options;
}
示例6: DesignTimeEventInfo
internal DesignTimeEventInfo(DesignTimeType declaringType, CodeMemberEvent codeDomEvent)
{
if (declaringType == null)
{
throw new ArgumentNullException("Declaring Type");
}
if (codeDomEvent == null)
{
throw new ArgumentNullException("codeDomEvent");
}
this.declaringType = declaringType;
this.codeDomEvent = codeDomEvent;
this.name = Helper.EnsureTypeName(codeDomEvent.Name);
this.memberAttributes = codeDomEvent.Attributes;
this.addMethod = null;
this.removeMethod = null;
}
示例7: Compile
public System.CodeDom.CodeTypeMember Compile()
{
CodeMemberEvent memberEvent = new CodeMemberEvent();
memberEvent.Type = new CodeTypeReference(type.Target);
memberEvent.Name = name;
memberEvent.Attributes = memberAttribute;
for( int pos = 0; pos < comments.Count; pos++ ) {
// TODO loop in comments.Count
memberEvent.Comments.Add(new CodeCommentStatement(comments[pos]));
}
for( int pos = 0; pos < attributes.Count; pos++ ) {
// TODO loop in attributes
memberEvent.CustomAttributes.Add(new CodeAttributeDeclaration(attributes[pos].name));
}
return memberEvent;
}
示例8: AddPropertyChanging
public static void AddPropertyChanging(CodeTypeDeclaration declaration)
{
CodeMemberEvent changingEvent = new CodeMemberEvent();
changingEvent.Name = "PropertyChanging";
changingEvent.Type = new CodeTypeReference(typeof(PropertyChangingEventHandler));
changingEvent.Attributes = MemberAttributes.Public;
declaration.Members.Add(changingEvent);
CodeMemberMethod changingMethod = new CodeMemberMethod();
changingMethod.Name = "OnPropertyChanging";
changingMethod.ReturnType = new CodeTypeReference(typeof(void));
changingMethod.Attributes = MemberAttributes.Family;
changingMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "propertyName"));
changingMethod.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerNonUserCodeAttribute))));
changingMethod.Statements.Add(new CodeConditionStatement(
new CodeBinaryOperatorExpression(
new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "PropertyChanging"),
CodeBinaryOperatorType.IdentityInequality,
new CodePrimitiveExpression(null)
),
new CodeStatement[] {
new CodeExpressionStatement(
new CodeMethodInvokeExpression(
new CodeThisReferenceExpression(),
"PropertyChanging",
new CodeExpression[] {
new CodeThisReferenceExpression(),
new CodeObjectCreateExpression(
typeof(PropertyChangingEventArgs),
new CodeExpression[] {
new CodeArgumentReferenceExpression("propertyName")
}
)
}
)
)
}
));
declaration.Members.Add(changingMethod);
}
示例9: CreateEventDefinition
public static CodeTypeMember CreateEventDefinition(
this INamedTypeSymbol typeToWrap,
WrapsAttrNameChangeView eventNameChangeView,
IList<string> namespaces
)
{
IEventSymbol wrappedEventInfo =
typeToWrap.GetMembers(eventNameChangeView.Name).FirstOrDefault() as IEventSymbol;
ITypeSymbol eventTypeSymbol = wrappedEventInfo.Type;
CodeTypeReference eventTypeReference = eventTypeSymbol.GetTypeReference(namespaces);
CodeMemberEvent codeEvent = new CodeMemberEvent
{
Name = eventNameChangeView.WrapperName,
Type = eventTypeReference,
Attributes = wrappedEventInfo.GetFlags(eventNameChangeView.TheEncapsulationLevel)
};
return codeEvent;
}
示例10: Emit
// Builds a codedom event and attaches it to the given type.
// It seems that there is a codedom bug: you can't make events static.
public static void Emit(CodeTypeDeclaration codeType, Event e)
{
// Create the codedom event and attach to the codedom type.
var codeEvent = new CodeMemberEvent();
codeType.Members.Add(codeEvent);
// Assign a name
codeEvent.Name = e.Name;
// Assign the type.
codeEvent.Type = new CodeTypeReference(e.DelegateName);
// Translate the accessibility
MemberAttributes memberAttributes = MemberAttributes.Public;
switch (e.Accessibility)
{
case Accessibility.Internal:
memberAttributes = MemberAttributes.FamilyAndAssembly;
break;
case Accessibility.Private:
memberAttributes = MemberAttributes.Private;
break;
case Accessibility.Protected:
memberAttributes = MemberAttributes.Family;
break;
case Accessibility.Public:
memberAttributes = MemberAttributes.Public;
break;
}
// This is bugged in codedom: no effect.
if (e.IsShared)
memberAttributes |= MemberAttributes.Static;
codeEvent.Attributes = memberAttributes;
}
示例11: GenerateEvent
static CodeTypeMember GenerateEvent(EventDefinition eventDefinition)
{
var @event = new CodeMemberEvent
{
Name = eventDefinition.Name,
Attributes = MemberAttributes.Public | MemberAttributes.Final,
CustomAttributes = CreateCustomAttributes(eventDefinition),
Type = CreateCodeTypeReference(eventDefinition.EventType)
};
return @event;
}
示例12: GenerateEvent
protected override void GenerateEvent(CodeMemberEvent e, CodeTypeDeclaration c) {
if (IsCurrentDelegate || IsCurrentEnum) return;
if (e.CustomAttributes.Count > 0) {
GenerateAttributes(e.CustomAttributes);
}
if (e.PrivateImplementationType == null) {
OutputMemberAccessModifier(e.Attributes);
}
Output.Write("event ");
string name = e.Name;
if (e.PrivateImplementationType != null) {
name = e.PrivateImplementationType.BaseType + "." + name;
}
OutputTypeNamePair(e.Type, name);
Output.WriteLine(";");
}
示例13: ValidateEvent
private void ValidateEvent(CodeMemberEvent e) {
if (e.CustomAttributes.Count > 0) {
ValidateAttributes(e.CustomAttributes);
}
if (e.PrivateImplementationType != null) {
ValidateTypeReference(e.Type);
ValidateIdentifier(e,"Name",e.Name);
}
ValidateTypeReferences(e.ImplementationTypes);
}
示例14: GenerateEvent
protected override void GenerateEvent (CodeMemberEvent eventRef, CodeTypeDeclaration declaration)
{
if (IsCurrentDelegate || IsCurrentEnum) {
return;
}
OutputAttributes (eventRef.CustomAttributes, null, false);
if (eventRef.PrivateImplementationType == null) {
OutputMemberAccessModifier (eventRef.Attributes);
}
Output.Write ("event ");
if (eventRef.PrivateImplementationType != null) {
OutputTypeNamePair (eventRef.Type,
eventRef.PrivateImplementationType.BaseType + "." +
eventRef.Name);
} else {
OutputTypeNamePair (eventRef.Type, GetSafeName (eventRef.Name));
}
Output.WriteLine (';');
}
示例15: GenerateEvent
protected override void GenerateEvent(CodeMemberEvent e, CodeTypeDeclaration c)
{
Output.WriteLine("[CodeMemberEvent: {0}]", e.ToString());
}