Example #1
0
 private static string AnonymousPropertyInitializerRetriever(IAttributeInstance attr)
 {
     return(attr.PositionParameters()
            .Select(value => value.ConstantValue)
            .Where(value => value.IsString()).SelectNotNull(value => value.Value as string)
            .FirstOrDefault());
 }
Example #2
0
        public IEnumerable <string> GetParameters()
        {
            var parameters = attribute.PositionParameters()
                             .Where(x => !x.IsBadValue)
                             .ToArray();

            var constantItems = parameters.Where(x => x.IsConstant);

            var typeItems = parameters
                            .Where(x => x.IsType)
                            .Select(x => x.TypeValue)
                            .OfType <IDeclaredType>()
                            .Where(x => x.IsValid())
                            .Select(x => x.GetClrName().ShortName);

            var arrayItems = parameters
                             .Where(x => x.IsArray)
                             .SelectMany(x => x.ArrayValue);

            var stringItems = constantItems
                              .Concat(arrayItems)
                              .Select(x => x.ConstantValue.Value)
                              .Where(x => x != null)
                              .Select(x => x !.ToString());

            return(typeItems.Concat(stringItems));
        }
Example #3
0
        public CommonAttribute GetCommonAttribute(IAttributeInstance attributeInstance)
        {
            var type = GetCommonType(attributeInstance.GetAttributeType());
            var positionalArguments = attributeInstance.PositionParameters().Select(GetPositionalArgument).WhereNotNull();
            var namedArguments      = attributeInstance.NamedParameters().Select(GetNamedArguments).WhereNotNull();

            return(new CommonAttribute(type, positionalArguments, namedArguments));
        }
Example #4
0
        public CommonAttribute GetCommonAttribute(IAttributeInstance attributeInstance)
        {
            var type = GetCommonType(attributeInstance.GetAttributeType());
              var positionalArguments = attributeInstance.PositionParameters().Select(GetPositionalArgument).WhereNotNull();
              var namedArguments = attributeInstance.NamedParameters().Select(GetNamedArguments).WhereNotNull();

              return new CommonAttribute(type, positionalArguments, namedArguments);
        }