示例#1
0
        /// <summary>
        /// <see cref="CodeResolvingUtils.GetEventHandlerInfo"/> helper allows not only graph events but also helper methods with appropriate signature.
        /// However, for graph events semantic model we are interested only in graph events, so we need to rule out helper methods by checking their signature.
        /// </summary>
        /// <param name="eventCandidate">The event candidate.</param>
        /// <param name="signatureType">Type of the signature.</param>
        /// <param name="eventCategory">Category the event belongs to.</param>
        /// <returns/>
        private bool IsValidGraphEvent(IMethodSymbol eventCandidate, EventHandlerSignatureType signatureType, GraphEventCategory eventCategory)
        {
            if (eventCandidate.IsStatic || eventCandidate.Parameters.Length > 2 || eventCategory == GraphEventCategory.None)
            {
                return(false);
            }
            else if (signatureType != EventHandlerSignatureType.Default)
            {
                return(true);
            }

            const char underscore = '_';

            if (eventCandidate.Name[0] == underscore || eventCandidate.Name[eventCandidate.Name.Length - 1] == underscore)
            {
                return(false);
            }

            int underscoresCount = eventCandidate.Name.Count(c => c == underscore);

            switch (eventCategory)
            {
            case GraphEventCategory.Row:
                return(underscoresCount == 1);

            case GraphEventCategory.Field:
                return(underscoresCount == 2);

            default:
                return(false);
            }
        }
示例#2
0
 public GraphFieldEventInfo(MethodDeclarationSyntax node, IMethodSymbol symbol, int declarationOrder,
                            EventHandlerSignatureType signatureType, EventType eventType, GraphFieldEventInfo baseInfo)
     : base(node, symbol, declarationOrder, signatureType, eventType, baseInfo)
 {
     ValidateEventType(eventType);
     DacFieldName = GetDacFieldName();
 }
 protected GraphEventInfoBase(MethodDeclarationSyntax node, IMethodSymbol symbol, int declarationOrder,
                              EventHandlerSignatureType signatureType, EventType eventType) :
     base(node, symbol, declarationOrder)
 {
     SignatureType = signatureType;
     EventType     = eventType;
     DacName       = GetDacName();
 }
示例#4
0
            public void AddFieldEvent(EventHandlerSignatureType signatureType, EventType eventType, IMethodSymbol methodSymbol,
                                      int declarationOrder, CancellationToken cancellationToken)
            {
                var methodNode = GetMethodNode(methodSymbol, cancellationToken);

                if (methodNode == null || !_fieldEvents.TryGetValue(eventType, out OverridableItemsCollection <GraphFieldEventInfo> collectionToAdd))
                {
                    return;
                }

                GraphFieldEventInfo eventToAdd = new GraphFieldEventInfo(methodNode, methodSymbol, declarationOrder, signatureType, eventType);

                if (!eventToAdd.DacName.IsNullOrEmpty() && !eventToAdd.DacFieldName.IsNullOrEmpty())
                {
                    collectionToAdd.Add(eventToAdd);
                }
            }
示例#5
0
 public EventInfo(EventType type, EventHandlerSignatureType signatureType)
 {
     Type          = type;
     SignatureType = signatureType;
 }
示例#6
0
 public GraphRowEventInfo(MethodDeclarationSyntax node, IMethodSymbol symbol, int declarationOrder,
                          EventHandlerSignatureType signatureType, EventType eventType, GraphRowEventInfo baseInfo)
     : base(node, symbol, declarationOrder, signatureType, eventType, baseInfo)
 {
 }