Beispiel #1
0
        private Type findClosedTypeByFullName(string typeFullName, Assembly defaultAssembly, Action <string> log)
        {
            var type = defaultAssembly.GetExportedTypes().FirstOrDefault(x => x.FullName == typeFullName);

            if (type != null)
            {
                return(type);
            }

            var types     = _types.TypesWithFullName(typeFullName);
            var typeCount = types.Count();

            if (typeCount == 1)
            {
                return(types.First());
            }

            log("Unable to set view model type : {0}".ToFormat(typeFullName));

            if (typeCount > 1)
            {
                var candidates = types.Select(x => x.AssemblyQualifiedName).Join(", ");
                log("Type ambiguity on: {0}".ToFormat(candidates));
            }

            return(null);
        }
Beispiel #2
0
        public void should_return_all_types_with_full_name()
        {
            var pool = new TypePool();

            pool.AddType(generateType("namespace FubuMVC.Core{public class Endpoint{}}", "FubuMVC.Core.Endpoint"));
            pool.AddType(typeof(Core.Endpoint));

            pool.TypesWithFullName(typeof(Core.Endpoint).FullName).ShouldHaveCount(2);
        }