Ejemplo n.º 1
0
        private static IEnumerable <Models.Service> GetDiscoveratedServices(Assembly assembly)
        {
            IEnumerable <TypeInfo> types;

            try
            {
                types = assembly.DefinedTypes;
            }
            catch (ReflectionTypeLoadException)
            {
                //couldn't load this assembly - probably a non-issue
                yield break;
            }

            foreach (TypeInfo ti in types)
            {
                SwaggeratedAttribute da = ti.GetCustomAttribute <SwaggeratedAttribute>();
                if (da != null)
                {
                    DescriptionAttribute descAttr = ti.GetCustomAttribute <DescriptionAttribute>();
                    Models.Service       service  = new Models.Service
                    {
                        path        = da.LocalPath,
                        description = (descAttr == null) ? da.Description : descAttr.Description
                    };
                    yield return(service);
                }
            }
        }
Ejemplo n.º 2
0
 private static Type FindServiceTypeByPath(string servicePath)
 {
     Assembly[] allAssm = AppDomain.CurrentDomain.GetAssemblies();
     foreach (Assembly assembly in allAssm)
     {
         foreach (TypeInfo ti in assembly.DefinedTypes)
         {
             SwaggeratedAttribute da = ti.GetCustomAttribute <SwaggeratedAttribute>();
             if (da != null && da.LocalPath == servicePath)
             {
                 return(ti.AsType());
             }
         }
     }
     return(null);
 }