private IEnumerable <Namespace> GetPageNamespacesToSearch(Type originType) { Namespace ns = Namespace.FromType(originType); if (this.IsAccessorType(originType)) { if (ns.AsTypeName().Name == "Accessors") { ns = ns.Up(); } if (this.HasAccessorSuffix(originType, out string prefix)) { yield return(ns.Add("Queries").Add(prefix)); yield return(ns.Add("Commands").Add(prefix)); yield return(ns.Add("Queries.Shared")); yield return(ns.Add("Commands.Shared")); } yield return(ns.Add("Queries")); yield return(ns.Add("Commands")); } else if (this.IsPageType(originType)) { Namespace root = ns.Traverse().FirstOrDefault(ns2 => ns2.AsTypeName().Name == "Queries" || ns2.AsTypeName().Name == "Commands"); yield return(ns); if (root != null) { yield return(root); yield return(root.Add("Shared")); } } }
private PageDescriptor CreateDescriptor(string procName, Type originType) { Type domainType = this.GetDomainType(originType); Namespace forPath = this.GetPathNamespace(procName, originType, domainType); IEnumerable <Namespace> typeNames; if (forPath != null) { typeNames = new[] { forPath.Up().Add(this.SanitizeTypeName(forPath.AsTypeName().Name)) } } ; else { typeNames = this.GetPageNamespacesToSearch(originType).Distinct().Select(ns => ns.Add(Namespace.FromPath(procName))); typeNames = typeNames.Select(ns => ns.Up().Add(this.SanitizeTypeName(ns.AsTypeName().Name))); } foreach (string typeName in typeNames.Select(ns => ns.Definition)) { Type pageType = originType.Assembly.GetType(typeName, throwOnError: false, ignoreCase: true); if (typeof(ISqlPage).IsAssignableFrom(pageType)) { return(new PageDescriptor() { OriginType = originType, PageType = pageType, DomainType = domainType, Locator = this, }); } } throw this.GetPageNotFoundException(procName, typeNames); }