예제 #1
0
        static void Main(string[] args)
        {
            // Step 1, define site field
            var customerField = new FieldDefinition
            {
                Id = new Guid("26470917-fbbf-413b-9eb3-537f74797e4e"),
                Title = "Customer Name",
                InternalName = "cstm_CustomerName",
                Description = "Name of the target customer.",
                Group = "Hello SPMeta2",
                FieldType = BuiltInFieldTypes.Text
            };

            // Step 2, define site model and artifact relationships - add field to the site 
            var siteModel = SPMeta2Model
                             .NewSiteModel(site =>
                             {
                                 site.AddField(customerField);
                             });

            // Step 3, deploy model via CSOM
            using (var clientContext = new ClientContext(SampleConsts.CSOM_SiteUrl))
            {
                var csomProvisionService = new CSOMProvisionService();
                csomProvisionService.DeployModel(SPMeta2.CSOM.ModelHosts.SiteModelHost.FromClientContext(clientContext), siteModel);
            }

            // Step 4, deploy model via SSOM
            using (var site = new SPSite(SampleConsts.SSOM_SiteUrl))
            {
                var csomProvisionService = new SSOMProvisionService();
                csomProvisionService.DeployModel(SPMeta2.SSOM.ModelHosts.SiteModelHost.FromSite(site), siteModel);
            }
        }
 protected void DeploySiteModelAsSSOM(ModelNode model)
 {
     using (var site = new SPSite(SampleConsts.SSOM_SiteUrl))
     {
         var ssomProvisionService = new SSOMProvisionService();
         ssomProvisionService.DeployModel(SPMeta2.SSOM.ModelHosts.SiteModelHost.FromSite(site), model);
     }
 }
예제 #3
0
        public static void DeployListModel(this SSOMProvisionService modelHost, SPList list, ModelNode model)
        {
            var listHost = ModelHostBase.Inherit <ListModelHost>(WebModelHost.FromWeb(list.ParentWeb), h =>
            {
                h.HostList = list;
            });

            modelHost.DeployModel(listHost, model);
        }
 protected void DeployWebModelAsSSOM(ModelNode model)
 {
     using (var site = new SPSite(SampleConsts.SSOM_SiteUrl))
     {
         using (var web = site.OpenWeb())
         {
             var ssomProvisionService = new SSOMProvisionService();
             ssomProvisionService.DeployModel(SPMeta2.SSOM.ModelHosts.WebModelHost.FromWeb(web), model);
         }
     }
 }
예제 #5
0
 public static void DeployWebModel(this SSOMProvisionService modelHost, SPWeb web, ModelNode model)
 {
     modelHost.DeployModel(WebModelHost.FromWeb(web), model);
 }
예제 #6
0
 public static void DeploySiteModel(this SSOMProvisionService modelHost, SPSite site, ModelNode model)
 {
     modelHost.DeployModel(SiteModelHost.FromSite(site), model);
 }
예제 #7
0
 public static void DeployWebApplicationModel(this SSOMProvisionService modelHost, SPWebApplication webApplication, ModelNode model)
 {
     modelHost.DeployModel(WebApplicationModelHost.FromWebApplication(webApplication), model);
 }
예제 #8
0
 public static void DeployFarmModel(this SSOMProvisionService modelHost, SPFarm farm, ModelNode model)
 {
     modelHost.DeployModel(FarmModelHost.FromFarm(farm), model);
 }