本文整理汇总了C#中CustomEventDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# CustomEventDeclaration类的具体用法?C# CustomEventDeclaration怎么用?C# CustomEventDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CustomEventDeclaration类属于命名空间,在下文中一共展示了CustomEventDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
var addAccessor = eventDeclaration.AddAccessor;
FindIssuesInNode(addAccessor, addAccessor.Body, "add accessor");
var removeAccessor = eventDeclaration.RemoveAccessor;
FindIssuesInNode(removeAccessor, removeAccessor.Body, "remove accessor");
}
示例2: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
if (eventDeclaration.Modifiers.HasFlag (Modifiers.Override))
return;
base.VisitCustomEventDeclaration(eventDeclaration);
CheckName(eventDeclaration, AffectedEntity.Event, eventDeclaration.NameToken, GetAccessibiltiy(eventDeclaration, Modifiers.Private));
}
示例3: Create
public static OverloadsCollection Create(IEmitter emitter, CustomEventDeclaration eventDeclaration, bool remove)
{
string key = eventDeclaration.GetHashCode().ToString() + remove.GetHashCode().ToString();
if (emitter.OverloadsCache.ContainsKey(key))
{
return emitter.OverloadsCache[key];
}
return new OverloadsCollection(emitter, eventDeclaration, remove);
}
示例4: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
var addAccessor = eventDeclaration.AddAccessor;
var removeAccessor = eventDeclaration.RemoveAccessor;
// don't warn on empty custom events
if (addAccessor.Body.Statements.Count == 0 && removeAccessor.Body.Statements.Count == 0)
return;
FindIssuesInAccessor(addAccessor, "add accessor");
FindIssuesInAccessor(removeAccessor, "remove accessor");
}
示例5: OverloadsCollection
private OverloadsCollection(IEmitter emitter, CustomEventDeclaration eventDeclaration, bool remove)
{
this.Emitter = emitter;
this.Name = eventDeclaration.Name;
this.JsName = Helpers.GetEventRef(eventDeclaration, emitter, remove, true);
this.AltJsName = Helpers.GetEventRef(eventDeclaration, emitter, !remove, true);
this.Inherit = !eventDeclaration.HasModifier(Modifiers.Static);
this.CancelChangeCase = true;
this.IsSetter = remove;
this.Static = eventDeclaration.HasModifier(Modifiers.Static);
this.Member = this.FindMember(eventDeclaration);
this.TypeDefinition = this.Member.DeclaringTypeDefinition;
this.Type = this.Member.DeclaringType;
this.InitMembers();
this.Emitter.OverloadsCache[eventDeclaration.GetHashCode().ToString() + remove.GetHashCode().ToString()] = this;
}
示例6: EmitPropertyMethod
protected virtual void EmitPropertyMethod(CustomEventDeclaration customEventDeclaration, Accessor accessor, bool remover)
{
if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
{
this.EnsureComma();
this.ResetLocals();
var prevMap = this.BuildLocalsMap();
var prevNamesMap = this.BuildLocalsNamesMap();
this.AddLocals(new ParameterDeclaration[] { new ParameterDeclaration { Name = "value" } }, accessor.Body);
XmlToJsDoc.EmitComment(this, this.CustomEventDeclaration);
var overloads = OverloadsCollection.Create(this.Emitter, customEventDeclaration, remover);
this.Write((remover ? "remove" : "add") + overloads.GetOverloadName());
this.WriteColon();
this.WriteFunction();
this.WriteOpenParentheses();
this.Write("value");
this.WriteCloseParentheses();
this.WriteSpace();
var script = this.Emitter.GetScript(accessor);
if (script == null)
{
accessor.Body.AcceptVisitor(this.Emitter);
}
else
{
this.BeginBlock();
foreach (var line in script)
{
this.Write(line);
this.WriteNewLine();
}
this.EndBlock();
}
this.ClearLocalsMap(prevMap);
this.ClearLocalsNamesMap(prevNamesMap);
this.Emitter.Comma = true;
}
}
示例7: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
FixAttributesAndDocComment(eventDeclaration);
FixOpenBrace(policy.EventBraceStyle, eventDeclaration.LBraceToken);
if (policy.IndentEventBody)
curIndent.Push(IndentType.Block);
if (!eventDeclaration.AddAccessor.IsNull) {
FixIndentation(eventDeclaration.AddAccessor);
if (!eventDeclaration.AddAccessor.Body.IsNull) {
if (!policy.AllowEventAddBlockInline || eventDeclaration.AddAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.AddAccessor.Body.RBraceToken.StartLocation.Line) {
FixOpenBrace(policy.EventAddBraceStyle, eventDeclaration.AddAccessor.Body.LBraceToken);
VisitBlockWithoutFixingBraces(eventDeclaration.AddAccessor.Body, policy.IndentBlocks);
FixClosingBrace(policy.EventAddBraceStyle, eventDeclaration.AddAccessor.Body.RBraceToken);
} else {
nextStatementIndent = " ";
VisitBlockWithoutFixingBraces(eventDeclaration.AddAccessor.Body, policy.IndentBlocks);
}
}
}
if (!eventDeclaration.RemoveAccessor.IsNull) {
FixIndentation(eventDeclaration.RemoveAccessor);
if (!eventDeclaration.RemoveAccessor.Body.IsNull) {
if (!policy.AllowEventRemoveBlockInline || eventDeclaration.RemoveAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.RemoveAccessor.Body.RBraceToken.StartLocation.Line) {
FixOpenBrace(policy.EventRemoveBraceStyle, eventDeclaration.RemoveAccessor.Body.LBraceToken);
VisitBlockWithoutFixingBraces(eventDeclaration.RemoveAccessor.Body, policy.IndentBlocks);
FixClosingBrace(policy.EventRemoveBraceStyle, eventDeclaration.RemoveAccessor.Body.RBraceToken);
} else {
nextStatementIndent = " ";
VisitBlockWithoutFixingBraces(eventDeclaration.RemoveAccessor.Body, policy.IndentBlocks);
}
}
}
if (policy.IndentEventBody)
curIndent.Pop();
FixClosingBrace(policy.EventBraceStyle, eventDeclaration.RBraceToken);
}
示例8: EmitPropertyMethod
protected virtual void EmitPropertyMethod(CustomEventDeclaration customEventDeclaration, Accessor accessor, bool remover)
{
if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
{
var overloads = OverloadsCollection.Create(this.Emitter, customEventDeclaration, remover);
this.Write((remover ? "remove" : "add") + overloads.GetOverloadName());
this.WriteOpenParentheses();
this.Write("value");
this.WriteColon();
var retType = BridgeTypes.ToJsName(customEventDeclaration.ReturnType, this.Emitter);
retType = EmitBlock.HandleType(retType);
this.Write(retType);
this.WriteCloseParentheses();
this.WriteColon();
this.Write("void");
this.WriteSemiColon();
this.WriteNewLine();
}
}
示例9: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration)
{
if (customEventDeclaration.HasModifier(Modifiers.Abstract))
{
return;
}
bool isStatic = customEventDeclaration.HasModifier(Modifiers.Static);
IDictionary<string, List<EntityDeclaration>> dict = isStatic
? CurrentType.StaticProperties
: CurrentType.InstanceProperties;
var key = customEventDeclaration.Name;
if (dict.ContainsKey(key))
{
dict[key].Add(customEventDeclaration);
}
else
{
dict.Add(key, new List<EntityDeclaration>(new[] { customEventDeclaration }));
}
}
示例10: ConvertEvent
EntityDeclaration ConvertEvent(IEvent ev)
{
if (this.UseCustomEvents) {
CustomEventDeclaration decl = new CustomEventDeclaration();
decl.Modifiers = GetMemberModifiers(ev);
decl.ReturnType = ConvertType(ev.ReturnType);
decl.Name = ev.Name;
decl.AddAccessor = ConvertAccessor(ev.AddAccessor, ev.Accessibility);
decl.RemoveAccessor = ConvertAccessor(ev.RemoveAccessor, ev.Accessibility);
return decl;
} else {
EventDeclaration decl = new EventDeclaration();
decl.Modifiers = GetMemberModifiers(ev);
decl.ReturnType = ConvertType(ev.ReturnType);
decl.Variables.Add(new VariableInitializer(ev.Name));
return decl;
}
}
示例11: VisitCustomEventDeclaration
public virtual void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration)
{
StartNode(customEventDeclaration);
WriteAttributes(customEventDeclaration.Attributes);
WriteModifiers(customEventDeclaration.ModifierTokens);
WriteKeyword(CustomEventDeclaration.EventKeywordRole);
customEventDeclaration.ReturnType.AcceptVisitor(this);
Space();
WritePrivateImplementationType(customEventDeclaration.PrivateImplementationType);
WriteIdentifier(customEventDeclaration.NameToken);
var braceHelper = OpenBrace(policy.EventBraceStyle, CodeBracesRangeFlags.EventBraces);
// output add/remove in their original order
int count = 0;
foreach (AstNode node in customEventDeclaration.Children) {
if (count-- <= 0) {
cancellationToken.ThrowIfCancellationRequested();
count = CANCEL_CHECK_LOOP_COUNT;
}
if (node.Role == CustomEventDeclaration.AddAccessorRole || node.Role == CustomEventDeclaration.RemoveAccessorRole) {
node.AcceptVisitor(this);
}
}
CloseBrace(policy.EventBraceStyle, braceHelper, true);
NewLine();
EndNode(customEventDeclaration);
}
示例12: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
var resolveResult = _resolver.Resolve(eventDeclaration);
if (!(resolveResult is MemberResolveResult)) {
_errorReporter.Region = eventDeclaration.GetRegion();
_errorReporter.InternalError("Event declaration " + eventDeclaration.Name + " does not resolve to a member.");
return;
}
var evt = ((MemberResolveResult)resolveResult).Member as IEvent;
if (evt == null) {
_errorReporter.Region = eventDeclaration.GetRegion();
_errorReporter.InternalError("Event declaration " + eventDeclaration.Name + " does not resolve to an event (resolves to " + resolveResult.ToString() + ")");
return;
}
var jsClass = GetJsClass(evt.DeclaringTypeDefinition);
if (jsClass == null)
return;
var impl = _metadataImporter.GetEventSemantics(evt);
switch (impl.Type) {
case EventScriptSemantics.ImplType.AddAndRemoveMethods: {
if (!eventDeclaration.AddAccessor.IsNull) {
MaybeCompileAndAddMethodToType(jsClass, eventDeclaration.AddAccessor, eventDeclaration.AddAccessor.Body, evt.AddAccessor, impl.AddMethod);
}
if (!eventDeclaration.RemoveAccessor.IsNull) {
MaybeCompileAndAddMethodToType(jsClass, eventDeclaration.RemoveAccessor, eventDeclaration.RemoveAccessor.Body, evt.RemoveAccessor, impl.RemoveMethod);
}
break;
}
case EventScriptSemantics.ImplType.NotUsableFromScript: {
break;
}
default: {
throw new InvalidOperationException("Invalid event implementation type");
}
}
}
示例13: VisitCustomEventDeclaration
public virtual void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(customEventDeclaration);
}
}
示例14: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
VisitNewDeclarationSpace(eventDeclaration);
}
示例15: VisitCustomEventDeclaration
public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
{
FormatAttributedNode(eventDeclaration);
EnforceBraceStyle(policy.EventBraceStyle, eventDeclaration.LBraceToken, eventDeclaration.RBraceToken);
if (policy.IndentEventBody) {
curIndent.Push(IndentType.Block);
}
if (!eventDeclaration.AddAccessor.IsNull) {
FixIndentation(eventDeclaration.AddAccessor.StartLocation);
if (!eventDeclaration.AddAccessor.Body.IsNull) {
if (!policy.AllowEventAddBlockInline || eventDeclaration.AddAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.AddAccessor.Body.RBraceToken.StartLocation.Line) {
EnforceBraceStyle(policy.EventAddBraceStyle, eventDeclaration.AddAccessor.Body.LBraceToken, eventDeclaration.AddAccessor.Body.RBraceToken);
} else {
nextStatementIndent = " ";
}
VisitBlockWithoutFixingBraces(eventDeclaration.AddAccessor.Body, policy.IndentBlocks);
}
}
if (!eventDeclaration.RemoveAccessor.IsNull) {
FixIndentation(eventDeclaration.RemoveAccessor.StartLocation);
if (!eventDeclaration.RemoveAccessor.Body.IsNull) {
if (!policy.AllowEventRemoveBlockInline || eventDeclaration.RemoveAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.RemoveAccessor.Body.RBraceToken.StartLocation.Line) {
EnforceBraceStyle(policy.EventRemoveBraceStyle, eventDeclaration.RemoveAccessor.Body.LBraceToken, eventDeclaration.RemoveAccessor.Body.RBraceToken);
} else {
nextStatementIndent = " ";
}
VisitBlockWithoutFixingBraces(eventDeclaration.RemoveAccessor.Body, policy.IndentBlocks);
}
}
if (policy.IndentEventBody) {
curIndent.Pop ();
}
if (eventDeclaration.NextSibling is EventDeclaration && IsSimpleEvent(eventDeclaration) && IsSimpleEvent(eventDeclaration.NextSibling)) {
EnsureBlankLinesAfter(eventDeclaration, policy.BlankLinesBetweenEventFields);
} else if (IsMember(eventDeclaration.NextSibling)) {
EnsureBlankLinesAfter(eventDeclaration, policy.BlankLinesBetweenMembers);
}
}