Beispiel #1
0
        public void ParseNameOnly()
        {
            FullTypeNameInfo actual = "string".ParseType();

            actual.Name.Should().Be("string");
            actual.IsNamespaceDefined.Should().BeFalse();
        }
        private ObjectTypeList AddStruct <TType>() where TType : struct
        {
            var type = typeof(TType);
            var id   = _counter++;

            _list.Add(new object[] { id,
                                     type.FullName,
                                     type.Namespace,
                                     "BCL",
                                     true,
                                     GetAlias <TType>(),
                                     0, 0 });
            _ids.Add(type, id);

            type = typeof(Nullable <TType>);
            FullTypeNameInfo ft = FullTypeNameInfo.Parse(type.FullName);

            id = _counter++;
            _list.Add(new object[] { id,
                                     ft.ToString(false, true),
                                     ft.Namespace,
                                     "BCL",
                                     true,
                                     GetAlias <TType?>(),
                                     0, 0 });
            _ids.Add(type, id);
            return(this);
        }
Beispiel #3
0
        public void ParseFullName()
        {
            FullTypeNameInfo actual = "System.String".ParseType();

            actual.Name.Should().Be("String");
            actual.IsNamespaceDefined.Should().BeTrue();
            actual.Namespace.Should().Be("System");
        }
Beispiel #4
0
        public void ParseAssemblyFullName()
        {
            FullTypeNameInfo actual = typeof(string).AssemblyQualifiedName.ParseType();

            actual.Name.Should().Be("String");
            actual.IsNamespaceDefined.Should().BeTrue();
            actual.Namespace.Should().Be("System");
        }
Beispiel #5
0
 public TBuilder BindParameter(string path, string paramName, FullTypeNameInfo paramType)
 {
     _parameterBindings.Add(new BindingParameter()
     {
         Path          = path,
         ParameterName = paramName,
         ParameterType = paramType
     });
     return((TBuilder)this);
 }
Beispiel #6
0
        public void ToStringAsCSharpCodeShort()
        {
            var type = "System.Nullable<System.String>";

            FullTypeNameInfo fullTypeInfo = type;

            string actual = fullTypeInfo.ToString(true, true);

            actual.Should().Be("System.String?");
        }
Beispiel #7
0
        public void ToStringAsCSharpCodeOnlyName()
        {
            var type = "System.Nullable<System.String>";

            FullTypeNameInfo fullTypeInfo = type;

            string actual = fullTypeInfo.ToString(false, false);

            actual.Should().Be("Nullable<string>");
        }
Beispiel #8
0
        public void ParseCSharpName()
        {
            FullTypeNameInfo actual = "System.Nullable<System.String>";

            actual.Name.Should().Be("Nullable");
            actual.IsGeneric.Should().BeTrue();
            actual.IsNullable.Should().BeTrue();
            actual.Namespace.Should().Be("System");
            actual.GenericArguments.First().Name.Should().Be("String");
            actual.GenericArguments.First().Namespace.Should().Be("System");
        }
Beispiel #9
0
        public void ParseGenericsWithManyArgs()
        {
            FullTypeNameInfo actual = FullTypeNameInfo.Parse(typeof(Dictionary <string, int>).FullName);

            actual.Name.Should().Be("Dictionary");
            actual.Namespace.Should().Be("System.Collections.Generic");
            actual.IsGeneric.Should().BeTrue();
            actual.GenericArguments.First().Name.Should().Be("String");
            actual.GenericArguments.First().Namespace.Should().Be("System");
            actual.GenericArguments.Last().Name.Should().Be("Int32");
            actual.GenericArguments.Last().Namespace.Should().Be("System");
        }
Beispiel #10
0
        public void ParseAssemblyGenericFullName()
        {
            FullTypeNameInfo actual = typeof(List <string>).AssemblyQualifiedName.ParseType();

            actual.Name.Should().Be("List");
            actual.IsNamespaceDefined.Should().BeTrue();
            actual.Namespace.Should().Be("System.Collections.Generic");
            var fArg = actual.GenericArguments.First();

            fArg.Name.Should().Be("String");
            fArg.Namespace.Should().Be("System");
        }
Beispiel #11
0
        public void ParseDetectsNestedGenerics()
        {
            FullTypeNameInfo actual = typeof(List <List <string> >).FullName.ParseType();

            actual.Name.Should().Be("List");
            actual.IsNamespaceDefined.Should().BeTrue();
            actual.Namespace.Should().Be("System.Collections.Generic");

            actual = actual.GenericArguments.First();
            actual.IsNamespaceDefined.Should().BeTrue();
            actual.Name.Should().Be("List");
            actual.Namespace.Should().Be("System.Collections.Generic");

            actual = actual.GenericArguments.First();
            actual.IsNamespaceDefined.Should().BeTrue();
            actual.Name.Should().Be("String");
            actual.Namespace.Should().Be("System");
        }
Beispiel #12
0
 public ControllerAction(string name,
                         IEnumerable <Argument> requestArguments,
                         string responseType,
                         HttpVerb verb,
                         bool isResponseCollection,
                         string route,
                         Type handlerGenericInterfaceType,
                         Type handlerRequestType,
                         Type handlerReturnType)
 {
     Name                        = name;
     RequestArguments            = new ArgumentCollection(requestArguments);
     ResponseType                = responseType;
     Verb                        = verb;
     IsResponseCollection        = isResponseCollection;
     Route                       = route;
     HandlerGenericInterfaceType = handlerGenericInterfaceType;
     HandlerRequestType          = handlerRequestType;
     HandlerReturnType           = handlerReturnType;
     _handlerInterfaceInfo       = new Lazy <FullTypeNameInfo>(() => FullTypeNameInfo.Parse(HandlerGenericInterfaceType.FullName));
 }
Beispiel #13
0
        public void ParseDetectsArgsOfGenerics()
        {
            FullTypeNameInfo actual = typeof(Nullable <int>).FullName.ParseType();

            actual.GenericArguments.First().Name.Should().Be("Int32");
        }
Beispiel #14
0
        public void ParseDetectsNameOfGenerics()
        {
            FullTypeNameInfo actual = typeof(Nullable <int>).FullName.ParseType();

            actual.Name.Should().Be("Nullable");
        }
Beispiel #15
0
        public void ParseDetectsGenerics()
        {
            FullTypeNameInfo actual = typeof(Nullable <int>).FullName.ParseType();

            actual.IsGeneric.Should().BeTrue();
        }