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 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;
                }
            }
        }