public static bool IsAnnotatedPropertyGetter(Method method)
        {
            bool isAnnotatedPropertyGetter = false;

            if (IntrospectionUtility.IsPropertyGetter(method))
            {
                isAnnotatedPropertyGetter = FragmentUtility.ContainsFragment(method.DeclaringMember.Attributes);
            }
            return(isAnnotatedPropertyGetter);
        }
        public static Fragment GetMemberBindingFragmentType(MemberBinding memberBinding)
        {
            var fragmentType = Fragment.CreateEmpty();

            if (memberBinding.BoundMember is Field)
            {
                Field field = (Field)memberBinding.BoundMember;
                fragmentType = FragmentUtility.GetFragmentType(field.Attributes);
            }
            return(fragmentType);
        }
        public static Fragment[] GetAnnotatedParameterFragmentTypes(Method method)
        {
            var buffer = new List <Fragment>();

            if (!IsAnnotatedPropertySetter(method))
            {
                buffer.AddRange(method.Parameters.Select(parameter => FragmentUtility.GetFragmentType(parameter.Attributes)));
            }
            else
            {
                buffer.Add(FragmentUtility.GetFragmentType(method.DeclaringMember.Attributes));
            }
            return(buffer.ToArray());
        }
        public static Fragment InferReturnFragmentType(Method method)
        {
            Fragment fragmentType;
            AttributeNodeCollection definingAttributes = GetDefiningAttributes(method);

            if (definingAttributes != null)
            {
                fragmentType = FragmentUtility.GetFragmentType(definingAttributes);
            }
            else
            {
                fragmentType = Fragment.CreateEmpty();
            }

            return(fragmentType);
        }
        private static AttributeNodeCollection GetDefiningAttributes(Method method)
        {
            AttributeNodeCollection definingAttributes;

            Method[] interfaceDeclarations = IntrospectionUtility.InterfaceDeclarations(method);

            if (interfaceDeclarations.Any())
            {
                definingAttributes = interfaceDeclarations.First().ReturnAttributes;
            }
            else if (FragmentUtility.IsAnnotatedPropertyGetter(method))
            {
                definingAttributes = method.DeclaringMember.Attributes;
            }
            else
            {
                definingAttributes = method.ReturnAttributes;
            }

            return(definingAttributes);
        }