Esempio n. 1
0
        /// <summary>
        /// Create a <see cref="SymbolAndDeclaration{IEventSymbol, EventDeclarationSyntax}"/> is symbol exists.
        /// </summary>
        /// <param name="symbol">The <see cref="IEventSymbol"/>.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that cancels the operation.</param>
        /// <param name="result">The <see cref="SymbolAndDeclaration{IEventSymbol, EventDeclarationSyntax}"/>.</param>
        /// <returns>True if the symbol exists.</returns>
        public static bool TryCreate(IEventSymbol symbol, CancellationToken cancellationToken, out SymbolAndDeclaration <IEventSymbol, EventDeclarationSyntax> result)
        {
            if (symbol is null)
            {
                throw new System.ArgumentNullException(nameof(symbol));
            }

            if (symbol.TrySingleEventDeclaration(cancellationToken, out var declaration))
            {
                result = new SymbolAndDeclaration <IEventSymbol, EventDeclarationSyntax>(symbol, declaration);
                return(true);
            }

            result = default;
            return(false);
        }