public void Qualified()
        {
            var expected = new TypeParts("SomeType", "ns1");
            var identity = TypePartsParser.Default.Get(QualifiedType);

            Assert.Equal(expected, identity, TypePartsEqualityComparer.Default);
        }
 public MarkupExtensionParts(TypeParts type, ImmutableArray <IExpression> arguments,
                             ImmutableArray <KeyValuePair <string, IExpression> > properties)
 {
     Type       = type;
     Arguments  = arguments;
     Properties = properties;
 }
        public string Get(TypeParts parameter)
        {
            var parts      = parameter.GetArguments();
            var arguments  = parts.HasValue ? $"[{string.Join(",", parts.Value.Select(_selector))}]" : null;
            var dimensions = parameter.Dimensions.HasValue ? $"^{string.Join(",", parameter.Dimensions.Value.ToArray())}" : null;
            var result     = $"{_formatter.Get(parameter)}{arguments}{dimensions}";

            return(result);
        }
Exemplo n.º 4
0
        static TypeParts Copy(TypeParts parameter)
        {
            var array = parameter.GetArguments()
                        ?.ToArray();
            var result = new TypeParts(string.Concat(parameter.Name, Extension), parameter.Identifier,
                                       array != null ? array.ToImmutableArray : (Func <ImmutableArray <TypeParts> >)null,
                                       parameter.Dimensions);

            return(result);
        }
Exemplo n.º 5
0
        TypeParts Get(TypeParts parameter)
        {
            var arguments = parameter.GetArguments();
            var result    = new TypeParts(parameter.Name, Prefix(parameter.Identifier),
                                          arguments.HasValue
                                        ? arguments.Value.Select(_selector)
                                          .ToImmutableArray
                                        : (Func <ImmutableArray <TypeParts> >)null, parameter.Dimensions);

            return(result);
        }
Exemplo n.º 6
0
 TypeInfo TryParse(TypeParts parameter)
 {
     try
     {
         return(Parse(parameter));
     }
     catch (ParseException)
     {
         return(Parse(Copy(parameter)));
     }
 }
        public void Generic()
        {
            var expected = new TypeParts("GenericType", "ns123", new[]
            {
                new TypeParts("string", "sys"),
                new TypeParts("int"),
                new TypeParts("SomeOtherType", "ns4")
            }.ToImmutableArray);

            var actual = TypePartsParser.Default.Get(GenericType);

            Assert.Equal(expected, actual, TypePartsEqualityComparer.Default);
            Assert.Equal(GenericType.Replace(" ", ""), TypePartsFormatter.Default.Get(actual));
        }
Exemplo n.º 8
0
    TypeParts  Contains(string type)
    {
        foreach (var t in typeParts)
        {
            if (t.type == type)
            {
                return(t);
            }
        }

        var tp = new TypeParts();

        tp.type = type;
        typeParts.Add(tp);

        return(tp);
    }
        public void CompoundGeneric()
        {
            var expected = new TypeParts("CompoundGenericType", "ns100", new[]
            {
                new TypeParts("string", "sys"),
                new TypeParts("AnotherGenericType", "exs",
                              new[]
                {
                    new TypeParts("AnotherType", "ns5"),
                    new TypeParts("OneMoreType", "ns6")
                }.ToImmutableArray),
                new TypeParts("SomeOtherType", "ns40")
            }.ToImmutableArray);

            var actual = TypePartsParser.Default.Get(CompoundGenericType);

            Assert.Equal(CompoundGenericType.Replace(" ", ""), TypePartsFormatter.Default.Get(actual));
            Assert.Equal(expected, actual, TypePartsEqualityComparer.Default);
        }
Exemplo n.º 10
0
 public MemberParts(TypeParts type, string memberName)
 {
     Type       = type;
     MemberName = memberName;
 }
Exemplo n.º 11
0
 static TypeParts Get(TypeParts parameter) => default(TypeParts);
Exemplo n.º 12
0
        TypeInfo Parse(TypeParts parameter)
        {
            var s = _formatter.Get(parameter);

            return((TypeInfo)_parser.Get(s));
        }