예제 #1
0
        /// <summary>
        /// Applies the system property attribute to the property by renaming the property to the
        /// system property name.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="member">The <see cref="MemberInfo"/> that corresponds to the property.</param>
        /// <param name="isIntegerIdType">Indicates if the type that the property is on, has an integer id type or not.</param>
        private static void ApplySystemPropertyAttributes(JsonProperty property, MemberInfo member, bool isIntegerIdType)
        {
            // Check for system property attributes
            MobileServiceSystemProperties systemProperties = MobileServiceSystemProperties.None;

            foreach (object attribute in member.GetCustomAttributes(true))
            {
                ISystemPropertyAttribute systemProperty = attribute as ISystemPropertyAttribute;
                if (systemProperty != null)
                {
                    if (isIntegerIdType)
                    {
                        throw new InvalidOperationException(
                                  string.Format(CultureInfo.InvariantCulture,
                                                Resources.MobileServiceContractResolver_IntegerIdTypeWithSystemPropertyAttributes,
                                                member.DeclaringType.FullName,
                                                systemProperty.SystemProperty));
                    }

                    if (systemProperties != MobileServiceSystemProperties.None)
                    {
                        throw new InvalidOperationException(
                                  string.Format(CultureInfo.InvariantCulture,
                                                Resources.MobileServiceContractResolver_MultipleSystemPropertyAttributes,
                                                member.Name,
                                                member.DeclaringType.FullName,
                                                systemProperty.SystemProperty,
                                                systemProperties));
                    }

                    property.PropertyName = GetSystemPropertyString(systemProperty.SystemProperty);
                    systemProperties      = systemProperty.SystemProperty;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Applies the system property attribute to the property by renaming the property to the
        /// system property name.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="member">The <see cref="MemberInfo"/> that corresponds to the property.</param>
        private static void ApplySystemPropertyAttributes(JsonProperty property, MemberInfo member)
        {
            // Check for system property attributes
            MobileServiceSystemProperties systemProperties = MobileServiceSystemProperties.None;

            foreach (object attribute in member.GetCustomAttributes(true))
            {
                ISystemPropertyAttribute systemProperty = attribute as ISystemPropertyAttribute;
                if (systemProperty != null)
                {
                    if (systemProperties != MobileServiceSystemProperties.None)
                    {
                        throw new InvalidOperationException(
                                  string.Format(CultureInfo.InvariantCulture,
                                                "A member can only have one system property attribute. The member '{0}' on type '{1}' has system property attributes '{2}' and '{3}'.",
                                                member.Name,
                                                member.DeclaringType.FullName,
                                                systemProperty.SystemProperty,
                                                systemProperties));
                    }

                    property.PropertyName = GetSystemPropertyString(systemProperty.SystemProperty);
                    systemProperties      = systemProperty.SystemProperty;
                }
            }
        }