コード例 #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); */
            }
        }
コード例 #2
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);
 }