protected virtual void DeployPage(object modelHost, SPList list, SPFolder folder, MasterPageDefinitionBase definition)
        {
            var web = list.ParentWeb;
            var targetPage = GetCurrentObject(folder, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = targetPage == null ? null : targetPage.File,
                ObjectType = typeof(SPFile),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            if (targetPage == null)
                targetPage = CreateObject(modelHost, folder, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = targetPage.File,
                ObjectType = typeof(SPFile),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            ModuleFileModelHandler.WithSafeFileOperation(list, folder,
                targetPage.Url,
                GetSafePageFileName(definition),
                definition.Content,
                definition.NeedOverride,
                null,
                afterFile =>
                {
                    var pageItem = afterFile.Properties;

                    //pageItem[BuiltInInternalFieldNames.Title] = definition.Title;
                    pageItem["vti_title"] = definition.Title;
                    pageItem["MasterPageDescription"] = definition.Description;
                    pageItem[BuiltInInternalFieldNames.ContentTypeId] = PageContentTypeId;

                    if (definition.UIVersion.Count > 0)
                    {
                        var value = new SPFieldMultiChoiceValue();

                        foreach (var v in definition.UIVersion)
                            value.Add(v);

                        pageItem["UIVersion"] = value.ToString();
                    }

                    pageItem["DefaultCssFile"] = definition.DefaultCSSFile;

                    //pageItem.Update();

                    //pageItem.SystemUpdate();
                });
        }
 protected File FindPageFile(List list, Folder folder, MasterPageDefinitionBase definition)
 {
     var pageName = GetSafePageFileName(definition);
     return GetCurrentPage(list, folder, pageName);
 }
        private SPListItem CreateObject(object modelHost, SPFolder folder, MasterPageDefinitionBase definition)
        {
            var pageName = GetSafePageFileName(definition);
            var fileContent = definition.Content;

            ModuleFileModelHandler.DeployModuleFile(folder,
                  SPUrlUtility.CombineUrl(folder.ServerRelativeUrl, pageName),
                  pageName,
                  fileContent,
                  true,
                  null,
                  null);

            return GetCurrentObject(folder, definition);
        }
        protected ListItem FindPage(List list, Folder folder, MasterPageDefinitionBase definition)
        {
            var pageName = GetSafePageFileName(definition);

            return FindPageByName(list, folder, pageName);
        }