示例#1
0
        public bool ContainedIn(ISymbol symbol)
        {
            bool result     = false;
            var  attributes = symbol.GetAttributes();

            foreach (var attribute in attributes)
            {
                INamedTypeSymbol attributeClass = attribute.AttributeClass;
                if (Uid != VisitorHelper.GetId(attributeClass))
                {
                    continue;
                }

                // arguments need to be a total match of the config
                IEnumerable <string> arguments = attribute.ConstructorArguments.Select(arg => GetLiteralString(arg));
                if (!ConstructorArguments.SequenceEqual(arguments))
                {
                    continue;
                }

                // namedarguments need to be a superset of the config
                Dictionary <string, string> namedArguments = attribute.NamedArguments.ToDictionary(pair => pair.Key, pair => GetLiteralString(pair.Value));
                if (!ConstructorNamedArguments.Except(namedArguments).Any())
                {
                    result = true;
                    break;
                }
            }

            return(result);
        }
示例#2
0
        public bool ContainedIn(SymbolFilterData symbol)
        {
            bool result     = false;
            var  attributes = symbol.Attributes;

            foreach (var attribute in attributes)
            {
                if (Uid != attribute.Id)
                {
                    continue;
                }

                // arguments need to be a total match of the config
                if (ConstructorArguments != null && !ConstructorArguments.SequenceEqual(attribute.ConstructorArguments))
                {
                    continue;
                }

                // namedarguments need to be a superset of the config
                if (!ConstructorNamedArguments.Except(attribute.ConstructorNamedArguments).Any())
                {
                    result = true;
                    break;
                }
            }

            return(result);
        }