/// <summary>
        /// Sets type mapper for the specified <paramref name="contentType"/>
        /// </summary>
        /// <typeparam name="TSPItem">Exact SP list item type, i.e. SPListItem for SSOM, or ListItem for CSOM.</typeparam>
        /// <param name="contentType">Current content type.</param>
        /// <param name="mapper">Instance of <see cref="TypeMapper{TSPItem}"/> that should be associated with specified <see cref="MetaContentType"/></param>
        /// <exception cref="ArgumentNullException"><paramref name="contentType"/> or <paramref name="mapper"/> is null.</exception>
        public static void SetMapper <TSPItem>([NotNull] this MetaContentType contentType,
                                               [NotNull] TypeMapper <TSPItem> mapper)
        {
            Guard.CheckNotNull(nameof(contentType), contentType);
            Guard.CheckNotNull(nameof(mapper), mapper);

            contentType.SetAdditionalProperty(MapperProperty, mapper);
        }
        public static MetaField GetKeyField([NotNull] this MetaContentType contentType)
        {
            Guard.CheckNotNull(nameof(contentType), contentType);

            return(contentType.List.IsExternal
                ? contentType.Fields.FirstOrDefault <MetaField>(n => n.InternalName == Fields.BdcIdentity)
                : contentType.Fields.FirstOrDefault <MetaField>(n => n.InternalName == Fields.Id));
        }
Example #3
0
        /// <summary>
        /// Initializes new instance of <see cref="MetaField"/>.
        /// </summary>
        /// <param name="contentType">Parent <see cref="MetaContentType"/>.</param>
        /// <param name="member">Field or property <see cref="MemberInfo"/>.</param>
        /// <param name="internalName">InternalName of the associated SP Field.</param>
        /// <exception cref="ArgumentNullException">if any argument is null.</exception>
        public MetaField([NotNull] MetaContentType contentType, [NotNull] MemberInfo member,
                         [NotNull] string internalName)
        {
            Guard.CheckNotNull(nameof(contentType), contentType);
            Guard.CheckNotNull(nameof(member), member);
            Guard.CheckNotNullOrEmpty(nameof(internalName), internalName);

            ContentType = contentType;

            Member     = member;
            MemberName = member.Name;
            MemberType = member.GetMemberType();

            InternalName = internalName;
        }
        /// <summary>
        /// Gets type mapper for the specified <paramref name="contentType"/>
        /// </summary>
        /// <typeparam name="TSPItem">Exact SP list item type, i.e. SPListItem for SSOM, or ListItem for CSOM.</typeparam>
        /// <param name="contentType">Current content type.</param>
        /// <returns>Instance of <see cref="TypeMapper{TSPItem}"/> of the current <see cref="MetaContentType"/></returns>
        /// <exception cref="ArgumentNullException"><paramref name="contentType"/> is null.</exception>
        public static TypeMapper <TSPItem> GetMapper <TSPItem>([NotNull] this MetaContentType contentType)
        {
            Guard.CheckNotNull(nameof(contentType), contentType);

            return(contentType.GetAdditionalProperty <TypeMapper <TSPItem> >(MapperProperty));
        }