コード例 #1
0
ファイル: Discoverator.cs プロジェクト: tenengroup/swaggeratr
        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);
                }
            }
        }
コード例 #2
0
ファイル: Discoverator.cs プロジェクト: fraxedas/Swaggeratr
        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;
                }
            }
        }