Exemplo n.º 1
0
        public void TestMethod1()
        {
            using (SPCtx ctx = new SPCtx(_siteUrl))
            {
                ctx.Web.ContentTypes.EnsureContentType(SPContentTypeMetadata.Get(typeof(FormSubmissionItem)), ctx.Web);
                ctx.Web.Fields.EnsureFields(SPFieldMetadata.GetMetadata(typeof(FormSubmissionItem)));
                ctx.Web.ContentTypes.EnsureFieldLinks(SPFieldMetadata.GetMetadata(typeof(FormSubmissionItem)), ctx.Web.Fields);
                //FormSubmissionList list = ctx.Web.GetList<FormSubmissionList>(true);
                FormSubmissionList list = new FormSubmissionList(true);
                list.LoadList(ctx.Web, true);
                list.EnsureList();

                /* var item = list.AddItem();
                 * Console.WriteLine(item.ContentType);
                 *
                 *
                 * item.SubmitValue = "whatever";
                 * item.Update();
                 * Console.WriteLine(item.ContentType); */
            }
        }
Exemplo n.º 2
0
 public static void EnsureContentType(this SPContentTypeCollection contentTypeCollection, SPContentTypeMetadata contentTypeMetadata, SPWeb parentWeb = null)
 {
     if (contentTypeCollection.GetContentType(contentTypeMetadata) == null)
     {
         contentTypeCollection.Add(contentTypeMetadata, parentWeb);
     }
 }
Exemplo n.º 3
0
 public static void EnsureContentType <T>(this SPWeb web) where T : SPTypedListItem, new()
 {
     web.ContentTypes.EnsureContentType(SPContentTypeMetadata.Get(typeof(T)), web);
     web.Fields.EnsureFields(SPFieldMetadata.GetMetadata(typeof(T)));
     web.ContentTypes.EnsureFieldLinks(SPFieldMetadata.GetMetadata(typeof(T)), web.Fields);
 }
Exemplo n.º 4
0
 public static void Add(this SPContentTypeCollection contentTypeCollection, SPContentTypeMetadata contentTypeMetadata, SPWeb parentWeb = null)
 {
     contentTypeMetadata.AddContentTypeTo(contentTypeCollection, parentWeb);
 }
Exemplo n.º 5
0
 public static SPContentType GetContentType(this SPContentTypeCollection contentTypeCollection, SPContentTypeMetadata contentTypeMetadata)
 {
     return(contentTypeMetadata.GetContentType(contentTypeCollection));
 }