Пример #1
0
        public NrdoQuery GetQuery(string name)
        {
            if (!queriesByLookup.ContainsKey(lookup))
            {
                queriesByLookup[lookup] = new Dictionary <string, NrdoQuery>();
            }
            Dictionary <string, NrdoQuery> queries = queriesByLookup[lookup];

            if (!queries.ContainsKey(name))
            {
                NrdoQuery query = null;
                foreach (AssemblyName asmName in lookup.GetPossibleAssemblies(name))
                {
                    Assembly assembly = Assembly.Load(asmName);
                    if (assembly == null)
                    {
                        throw new ArgumentException("Failed to load assembly " + asmName.FullName + "; Codebase=" + asmName.CodeBase);
                    }
                    query = getQueryInternal(assembly, name);
                    if (query != null)
                    {
                        break;
                    }
                }
                queries[name] = query;
            }
            return(queries[name]);
        }
Пример #2
0
        public static NrdoQuery GetQuery(Type type)
        {
            Assembly assembly = type.Assembly;
            string   name     = NrdoCodeBase.getQueryNameFromType(type);
            var      mangled  = name == null ? null : NrdoReflection.MangleName(assembly, name);

            if (name == null || mangled != type.FullName)
            {
                throw new ArgumentException(type.FullName + " is not a valid nrdo database query class (name = " + (name ?? "null") + ", mangled = " + (mangled ?? "null") + ")");
            }
            NrdoQuery result = NrdoCodeBase.getQueryInternal(assembly, name, type);

            if (result == null)
            {
                throw new ArgumentException(type.FullName + " is not a valid nrdo database query class");
            }
            return(result);
        }
Пример #3
0
 private static IEnumerable <NrdoQuery> getAllQueriesInternal(Assembly assembly)
 {
     return(from attr in assembly.GetAttributes <NrdoQueriesAttribute>() select NrdoQuery.GetQuery(attr.Type));
 }