public static void AddContentType(this SPList list, SPContentTypeId contentTypeId) { SPContentType contentType = list.ParentWeb.AvailableContentTypes[contentTypeId]; if (contentType != null) { list.AddContentType(contentType); } }
private void ContentTypesAction(SPList list, IEnumerable <SPContentType> contentTypes) { foreach (SPContentType contentType in contentTypes) { if (!list.ContainsContentTypeWithId(contentType.Id) && list.IsContentTypeAllowed(contentType)) { list.AddContentType(contentType); } } }