Exemple #1
0
        protected override IEnumerable <Declaration> ObjectionableDeclarations(DeclarationFinder finder)
        {
            if (!finder.TryFindProjectDeclaration("Excel", out var excel))
            {
                // [RequiredHost] attribute puts this in "should not happen" territory.
                yield break;
            }
            var sheetsClass = (ModuleDeclaration)finder.FindClassModule("Sheets", excel, true);

            if (sheetsClass == null)
            {
                // [RequiredHost] attribute puts this in "should not happen" territory.
                yield break;
            }

            if (sheetsClass != null)
            {
                foreach (var property in sheetsClass.Members.OfType <PropertyDeclaration>())
                {
                    if (InterestingProperties.Any(name => name.Equals(property.IdentifierName, System.StringComparison.InvariantCultureIgnoreCase)))
                    {
                        yield return(property);
                    }
                }
            }
        }
Exemple #2
0
        protected override IEnumerable <Declaration> ObjectionableDeclarations(DeclarationFinder finder)
        {
            if (Excel == null)
            {
                if (!finder.TryFindProjectDeclaration("Excel", out var excel))
                {
                    return(Enumerable.Empty <Declaration>());
                }
                Excel = excel;
            }

            if (_relevantClasses == null)
            {
                _relevantClasses = InterestingClasses
                                   .Select(className => finder.FindClassModule(className, Excel, true))
                                   .OfType <ModuleDeclaration>()
                                   .ToList();
            }

            if (_relevantProperties == null)
            {
                _relevantProperties = _relevantClasses
                                      .SelectMany(classDeclaration => classDeclaration.Members)
                                      .OfType <PropertyGetDeclaration>()
                                      .Where(member => InterestingMembers.Contains(member.IdentifierName))
                                      .ToList();
            }

            return(_relevantProperties);
        }