예제 #1
0
        /**
         *
         * SPWeb model assembly example
         *
         */
        public static WebModelNode WebDemoModel()
        {
            return(SPMeta2Model.NewWebModel(Web =>
            {
                Web
                .AddWelcomePage(new WelcomePageDefinition
                {
                    Url = ListsInfo.Contacts().CustomUrl
                })

                .AddWebFeature(FeaturesInfo.DisableMinimalDownloadStrategy)

                .AddField(FieldsInfo.Email())
                .AddField(FieldsInfo.PhoneNumber())
                .AddField(FieldsInfo.EmployeesCount())
                .AddField(FieldsInfo.Owner())
                .AddField(FieldsInfo.Function())

                .AddContentType(ContentTypesInfo.Contact(), contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(new ContentTypeFieldLinkDefinition
                    {
                        FieldId = BuiltInFieldId.Title,
                        DisplayName = "Name",
                        Required = true
                    })
                    .AddContentTypeFieldLink(FieldsInfo.Email())
                    .AddContentTypeFieldLink(FieldsInfo.PhoneNumber())
                    ;
                })
                .AddContentType(ContentTypesInfo.Function(), contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(FieldsInfo.Owner())
                    .AddContentTypeFieldLink(FieldsInfo.EmployeesCount())
                    ;
                })
                .AddContentType(ContentTypesInfo.SubFunction(), contentType =>
                {
                    contentType
                    .AddContentTypeFieldLink(FieldsInfo.Function())
                    .AddContentTypeFieldLink(FieldsInfo.Owner())
                    ;
                })

                .AddList(ListsInfo.Contacts(), List =>
                {
                    List
                    .AddRemoveStandardContentTypes()
                    .AddContentTypeLink(ContentTypesInfo.Contact())
                    .AddListView(ViewsInfo.ContactsView())
                    ;
                })
                .AddList(ListsInfo.Functions(), List =>
                {
                    List
                    .AddRemoveStandardContentTypes()
                    .AddContentTypeLink(ContentTypesInfo.Function())
                    .AddListView(ViewsInfo.FunctionsView())
                    ;
                })
                .AddList(ListsInfo.SubFunctions(), List =>
                {
                    List
                    .AddRemoveStandardContentTypes()
                    .AddContentTypeLink(ContentTypesInfo.SubFunction())
                    .AddListView(ViewsInfo.SubFunctionsView())
                    ;
                })
                ;
            }));
        }