示例#1
0
        public void Init()
        {
            var requestAttribute = ParameterType.CustomAttribute <HttpRequestAttribute>(true);

            if (null != requestAttribute)
            {
                UrlPattern = requestAttribute.Api;
                Method     = requestAttribute.Method;
                Host       = requestAttribute.Host;
                ParameterType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).ToList().ForEach(propertyInfo =>
                {
                    var propertyName = propertyInfo.Name;
                    var getter       = ResolveGetter(propertyInfo);
                    Getters.AddOrUpdate(propertyName, getter, (k, v) => getter);
                    var attribute = propertyInfo.CustomAttribute <HttpComponentAttribute>(true);
                    if (null == attribute)
                    {
                        return;
                    }
                    var component = new HttpComponentInfo(propertyName, attribute, NamingRule);
                    Components.AddOrUpdate(propertyName, component, (p, a) => component);
                });
            }
        }