// PUBLIC METHODS ///////////////////////////////////////////////////
        #region IApiObjectTypeConvention Implementation
        public void Apply(IApiEnumerationTypeBuilder apiEnumerationTypeBuilder, ApiConventionSettings apiConventionSettings)
        {
            Contract.Requires(apiEnumerationTypeBuilder != null);

            var clrEnumerationType = apiEnumerationTypeBuilder.ClrType;
            var clrEnumerationFieldInfoCollection = ClrEnumerationValueDiscoveryRules.GetClrEnumerationValues(clrEnumerationType);

            var apiEnumerationTypeConfiguration = (ApiEnumerationTypeConfiguration)apiEnumerationTypeBuilder;
            var apiPrecedenceStack = apiEnumerationTypeConfiguration.ApiPrecedenceStack;

            foreach (var clrEnumerationFieldInfo in clrEnumerationFieldInfoCollection)
            {
                HandleApiEnumerationValueAttribute(apiEnumerationTypeBuilder, apiPrecedenceStack, clrEnumerationFieldInfo);
            }
        }
Exemple #2
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region IApiObjectTypeConvention Implementation
        public void Apply(IApiEnumerationTypeBuilder apiEnumerationTypeBuilder, ApiConventionSettings apiConventionSettings)
        {
            Contract.Requires(apiEnumerationTypeBuilder != null);

            // Call ApiEnumerationValue method on all the discoverable CLR enum values for the given CLR enum type.
            var clrEnumerationType = apiEnumerationTypeBuilder.ClrType;
            var clrEnumerationFieldInfoCollection = ClrEnumerationValueDiscoveryRules.GetClrEnumerationValues(clrEnumerationType);

            foreach (var clrFieldInfo in clrEnumerationFieldInfoCollection)
            {
                var clrName    = clrFieldInfo.Name;
                var clrOrdinal = (int)Enum.Parse(clrEnumerationType, clrName);

                apiEnumerationTypeBuilder.ApiEnumerationValue(clrName, clrOrdinal);
            }
        }