예제 #1
0
        public object Clone()
        {
            TemporaryBlogSettings newSettings = new TemporaryBlogSettings();

            newSettings.CopyFrom(this);
            return(newSettings);
        }
        public static bool EditSettings(IWin32Window owner, TemporaryBlogSettings blogSettings, bool showAccountSettings, Type selectedPanel)
        {
            // make a copy of the blog settings for editing
            TemporaryBlogSettings editableBlogSettings = blogSettings.Clone() as TemporaryBlogSettings;

            // show form
            using (PreferencesForm preferencesForm = new PreferencesForm())
            {
                using (BlogClientUIContextScope uiContextScope = new BlogClientUIContextScope(preferencesForm))
                {
                    // customize form title and behavior
                    preferencesForm.Text = String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.WeblogSettings), blogSettings.BlogName);
                    preferencesForm.HideApplyButton();

                    // panels
                    int iPanel = 0;
                    if (showAccountSettings)
                        preferencesForm.SetEntry(iPanel++, new AccountPanel(blogSettings, editableBlogSettings));

                    preferencesForm.SetEntry(iPanel++, new ImagesPanel(blogSettings, editableBlogSettings));
                    preferencesForm.SetEntry(iPanel++, new EditingPanel(blogSettings, editableBlogSettings));
                    preferencesForm.SetEntry(iPanel++, new BlogPluginsPanel(blogSettings, editableBlogSettings));
                    preferencesForm.SetEntry(iPanel++, new AdvancedPanel(blogSettings, editableBlogSettings));
                    preferencesForm.SelectEntry(selectedPanel);

                    // show the dialog
                    return (preferencesForm.ShowDialog(owner) == DialogResult.OK);
                }
            }
        }
        public static TemporaryBlogSettings ForBlogId(string blogId)
        {
            using (BlogSettings blogSettings = BlogSettings.ForBlogId(blogId))
            {
                TemporaryBlogSettings tempSettings = new TemporaryBlogSettings(blogId);
                tempSettings.IsNewWeblog          = false;
                tempSettings.IsSpacesBlog         = blogSettings.IsSpacesBlog;
                tempSettings.IsSharePointBlog     = blogSettings.IsSharePointBlog;
                tempSettings.IsGoogleBloggerBlog  = blogSettings.IsGoogleBloggerBlog;
                tempSettings.IsStaticSiteBlog     = blogSettings.IsStaticSiteBlog;
                tempSettings.HostBlogId           = blogSettings.HostBlogId;
                tempSettings.BlogName             = blogSettings.BlogName;
                tempSettings.HomepageUrl          = blogSettings.HomepageUrl;
                tempSettings.ForceManualConfig    = blogSettings.ForceManualConfig;
                tempSettings.ManifestDownloadInfo = blogSettings.ManifestDownloadInfo;
                tempSettings.SetProvider(blogSettings.ProviderId, blogSettings.ServiceName, blogSettings.PostApiUrl, blogSettings.ClientType);
                tempSettings.Credentials         = blogSettings.Credentials;
                tempSettings.LastPublishFailed   = blogSettings.LastPublishFailed;
                tempSettings.Categories          = blogSettings.Categories;
                tempSettings.Keywords            = blogSettings.Keywords;
                tempSettings.Authors             = blogSettings.Authors;
                tempSettings.Pages               = blogSettings.Pages;
                tempSettings.FavIcon             = blogSettings.FavIcon;
                tempSettings.Image               = blogSettings.Image;
                tempSettings.WatermarkImage      = blogSettings.WatermarkImage;
                tempSettings.OptionOverrides     = blogSettings.OptionOverrides;
                tempSettings.UserOptionOverrides = blogSettings.UserOptionOverrides;
                tempSettings.ButtonDescriptions  = blogSettings.ButtonDescriptions;
                tempSettings.HomePageOverrides   = blogSettings.HomePageOverrides;

                //set the save password flag
                tempSettings.SavePassword = blogSettings.Credentials.Password != null &&
                                            blogSettings.Credentials.Password != String.Empty;

                // file upload support
                tempSettings.FileUploadSupport = blogSettings.FileUploadSupport;

                // get ftp settings if necessary
                if (blogSettings.FileUploadSupport == FileUploadSupport.FTP)
                {
                    FtpUploaderSettings.Copy(blogSettings.FileUploadSettings, tempSettings.FileUploadSettings);
                }

                blogSettings.PublishingPluginSettings.CopyTo(tempSettings.PublishingPluginSettings);

                using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(blogId))
                {
                    tempSettings.TemplateFiles = editSettings.EditorTemplateHtmlFiles;
                }
                return(tempSettings);
            }
        }
        public static TemporaryBlogSettings ForBlogId(string blogId)
        {
            using (BlogSettings blogSettings = BlogSettings.ForBlogId(blogId))
            {
                TemporaryBlogSettings tempSettings = new TemporaryBlogSettings(blogId);
                tempSettings.IsNewWeblog = false;
                tempSettings.IsSpacesBlog = blogSettings.IsSpacesBlog;
                tempSettings.IsSharePointBlog = blogSettings.IsSharePointBlog;
                tempSettings.IsGoogleBloggerBlog = blogSettings.IsGoogleBloggerBlog;
                tempSettings.HostBlogId = blogSettings.HostBlogId;
                tempSettings.BlogName = blogSettings.BlogName;
                tempSettings.HomepageUrl = blogSettings.HomepageUrl;
                tempSettings.ForceManualConfig = blogSettings.ForceManualConfig;
                tempSettings.ManifestDownloadInfo = blogSettings.ManifestDownloadInfo;
                tempSettings.SetProvider(blogSettings.ProviderId, blogSettings.ServiceName, blogSettings.PostApiUrl, blogSettings.ClientType);
                tempSettings.Credentials = blogSettings.Credentials;
                tempSettings.LastPublishFailed = blogSettings.LastPublishFailed;
                tempSettings.Categories = blogSettings.Categories;
                tempSettings.Keywords = blogSettings.Keywords;
                tempSettings.Authors = blogSettings.Authors;
                tempSettings.Pages = blogSettings.Pages;
                tempSettings.FavIcon = blogSettings.FavIcon;
                tempSettings.Image = blogSettings.Image;
                tempSettings.WatermarkImage = blogSettings.WatermarkImage;
                tempSettings.OptionOverrides = blogSettings.OptionOverrides;
                tempSettings.UserOptionOverrides = blogSettings.UserOptionOverrides;
                tempSettings.ButtonDescriptions = blogSettings.ButtonDescriptions;
                tempSettings.HomePageOverrides = blogSettings.HomePageOverrides;

                //set the save password flag
                tempSettings.SavePassword = blogSettings.Credentials.Password != null &&
                    blogSettings.Credentials.Password != String.Empty;

                // file upload support
                tempSettings.FileUploadSupport = blogSettings.FileUploadSupport;

                // get ftp settings if necessary
                if (blogSettings.FileUploadSupport == FileUploadSupport.FTP)
                {
                    FtpUploaderSettings.Copy(blogSettings.FileUploadSettings, tempSettings.FileUploadSettings);
                }

                blogSettings.PublishingPluginSettings.CopyTo(tempSettings.PublishingPluginSettings);

                using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(blogId))
                {
                    tempSettings.TemplateFiles = editSettings.EditorTemplateHtmlFiles;
                }
                return tempSettings;
            }
        }
예제 #5
0
        public void CopyFrom(TemporaryBlogSettings sourceSettings)
        {
            // simple members
            _id = sourceSettings._id;
            _switchToWeblog = sourceSettings._switchToWeblog;
            _isNewWeblog = sourceSettings._isNewWeblog;
            _savePassword = sourceSettings._savePassword;
            _isSpacesBlog = sourceSettings._isSpacesBlog;
            _isSharePointBlog = sourceSettings._isSharePointBlog;
            _hostBlogId = sourceSettings._hostBlogId;
            _blogName = sourceSettings._blogName;
            _homePageUrl = sourceSettings._homePageUrl;
            _manifestDownloadInfo = sourceSettings._manifestDownloadInfo;
            _providerId = sourceSettings._providerId;
            _serviceName = sourceSettings._serviceName;
            _clientType = sourceSettings._clientType;
            _postApiUrl = sourceSettings._postApiUrl;
            _lastPublishFailed = sourceSettings._lastPublishFailed;
            _fileUploadSupport = sourceSettings._fileUploadSupport;
            _instrumentationOptIn = sourceSettings._instrumentationOptIn;

            if (sourceSettings._availableImageEndpoints == null)
            {
                _availableImageEndpoints = null;
            }
            else
            {
                // Good thing BlogInfo is immutable!
                _availableImageEndpoints = (BlogInfo[])sourceSettings._availableImageEndpoints.Clone();
            }

            // credentials
            BlogCredentialsHelper.Copy(sourceSettings._credentials, _credentials);

            // template files
            _templateFiles = new BlogEditingTemplateFile[sourceSettings._templateFiles.Length];
            for (int i = 0; i < sourceSettings._templateFiles.Length; i++)
            {
                BlogEditingTemplateFile sourceFile = sourceSettings._templateFiles[i];
                _templateFiles[i] = new BlogEditingTemplateFile(sourceFile.TemplateType, sourceFile.TemplateFile);
            }

            // option overrides
            if (sourceSettings._optionOverrides != null)
            {
                _optionOverrides.Clear();
                foreach (DictionaryEntry entry in sourceSettings._optionOverrides)
                    _optionOverrides.Add(entry.Key, entry.Value);
            }

            // user option overrides
            if (sourceSettings._userOptionOverrides != null)
            {
                _userOptionOverrides.Clear();
                foreach (DictionaryEntry entry in sourceSettings._userOptionOverrides)
                    _userOptionOverrides.Add(entry.Key, entry.Value);
            }

            // homepage overrides
            if (sourceSettings._homepageOptionOverrides != null)
            {
                _homepageOptionOverrides.Clear();
                foreach (DictionaryEntry entry in sourceSettings._homepageOptionOverrides)
                    _homepageOptionOverrides.Add(entry.Key, entry.Value);
            }

            // categories
            if (sourceSettings._categories != null)
            {
                _categories = new BlogPostCategory[sourceSettings._categories.Length];
                for (int i = 0; i < sourceSettings._categories.Length; i++)
                {
                    BlogPostCategory sourceCategory = sourceSettings._categories[i];
                    _categories[i] = sourceCategory.Clone() as BlogPostCategory;
                }
            }
            else
            {
                _categories = null;
            }

            if (sourceSettings._keywords != null)
            {
                _keywords = new BlogPostKeyword[sourceSettings._keywords.Length];
                for (int i = 0; i < sourceSettings._keywords.Length; i++)
                {
                    BlogPostKeyword sourceKeyword = sourceSettings._keywords[i];
                    _keywords[i] = sourceKeyword.Clone() as BlogPostKeyword;
                }
            }
            else
            {
                _keywords = null;
            }

            // authors and pages
            _authors = sourceSettings._authors.Clone() as AuthorInfo[];
            _pages = sourceSettings._pages.Clone() as PageInfo[];

            // buttons
            if (sourceSettings._buttonDescriptions != null)
            {
                _buttonDescriptions = new BlogProviderButtonDescription[sourceSettings._buttonDescriptions.Length];
                for (int i = 0; i < sourceSettings._buttonDescriptions.Length; i++)
                    _buttonDescriptions[i] = sourceSettings._buttonDescriptions[i].Clone() as BlogProviderButtonDescription;
            }
            else
            {
                _buttonDescriptions = null;
            }

            // favicon
            _favIcon = sourceSettings._favIcon;

            // images
            _image = sourceSettings._image;
            _watermarkImage = sourceSettings._watermarkImage;

            // host blogs
            _hostBlogs = new BlogInfo[sourceSettings._hostBlogs.Length];
            for (int i = 0; i < sourceSettings._hostBlogs.Length; i++)
            {
                BlogInfo sourceBlog = sourceSettings._hostBlogs[i];
                _hostBlogs[i] = new BlogInfo(sourceBlog.Id, sourceBlog.Name, sourceBlog.HomepageUrl);
            }

            // file upload settings
            _fileUploadSettings = sourceSettings._fileUploadSettings.Clone() as TemporaryFileUploadSettings;

            _pluginSettings = new SettingsPersisterHelper(new MemorySettingsPersister());
            _pluginSettings.CopyFrom(sourceSettings._pluginSettings, true, true);
        }
예제 #6
0
 public object Clone()
 {
     TemporaryBlogSettings newSettings = new TemporaryBlogSettings();
     newSettings.CopyFrom(this);
     return newSettings;
 }
예제 #7
0
        public void CopyFrom(TemporaryBlogSettings sourceSettings)
        {
            // simple members
            _id                   = sourceSettings._id;
            _switchToWeblog       = sourceSettings._switchToWeblog;
            _isNewWeblog          = sourceSettings._isNewWeblog;
            _savePassword         = sourceSettings._savePassword;
            _isSpacesBlog         = sourceSettings._isSpacesBlog;
            _isSharePointBlog     = sourceSettings._isSharePointBlog;
            _hostBlogId           = sourceSettings._hostBlogId;
            _blogName             = sourceSettings._blogName;
            _homePageUrl          = sourceSettings._homePageUrl;
            _manifestDownloadInfo = sourceSettings._manifestDownloadInfo;
            _providerId           = sourceSettings._providerId;
            _serviceName          = sourceSettings._serviceName;
            _clientType           = sourceSettings._clientType;
            _postApiUrl           = sourceSettings._postApiUrl;
            _lastPublishFailed    = sourceSettings._lastPublishFailed;
            _fileUploadSupport    = sourceSettings._fileUploadSupport;
            _instrumentationOptIn = sourceSettings._instrumentationOptIn;

            if (sourceSettings._availableImageEndpoints == null)
            {
                _availableImageEndpoints = null;
            }
            else
            {
                // Good thing BlogInfo is immutable!
                _availableImageEndpoints = (BlogInfo[])sourceSettings._availableImageEndpoints.Clone();
            }

            // credentials
            BlogCredentialsHelper.Copy(sourceSettings._credentials, _credentials);

            // template files
            _templateFiles = new BlogEditingTemplateFile[sourceSettings._templateFiles.Length];
            for (int i = 0; i < sourceSettings._templateFiles.Length; i++)
            {
                BlogEditingTemplateFile sourceFile = sourceSettings._templateFiles[i];
                _templateFiles[i] = new BlogEditingTemplateFile(sourceFile.TemplateType, sourceFile.TemplateFile);
            }

            // option overrides
            if (sourceSettings._optionOverrides != null)
            {
                _optionOverrides.Clear();
                foreach (DictionaryEntry entry in sourceSettings._optionOverrides)
                {
                    _optionOverrides.Add(entry.Key, entry.Value);
                }
            }

            // user option overrides
            if (sourceSettings._userOptionOverrides != null)
            {
                _userOptionOverrides.Clear();
                foreach (DictionaryEntry entry in sourceSettings._userOptionOverrides)
                {
                    _userOptionOverrides.Add(entry.Key, entry.Value);
                }
            }

            // homepage overrides
            if (sourceSettings._homepageOptionOverrides != null)
            {
                _homepageOptionOverrides.Clear();
                foreach (DictionaryEntry entry in sourceSettings._homepageOptionOverrides)
                {
                    _homepageOptionOverrides.Add(entry.Key, entry.Value);
                }
            }

            // categories
            if (sourceSettings._categories != null)
            {
                _categories = new BlogPostCategory[sourceSettings._categories.Length];
                for (int i = 0; i < sourceSettings._categories.Length; i++)
                {
                    BlogPostCategory sourceCategory = sourceSettings._categories[i];
                    _categories[i] = sourceCategory.Clone() as BlogPostCategory;
                }
            }
            else
            {
                _categories = null;
            }

            if (sourceSettings._keywords != null)
            {
                _keywords = new BlogPostKeyword[sourceSettings._keywords.Length];
                for (int i = 0; i < sourceSettings._keywords.Length; i++)
                {
                    BlogPostKeyword sourceKeyword = sourceSettings._keywords[i];
                    _keywords[i] = sourceKeyword.Clone() as BlogPostKeyword;
                }
            }
            else
            {
                _keywords = null;
            }

            // authors and pages
            _authors = sourceSettings._authors.Clone() as AuthorInfo[];
            _pages   = sourceSettings._pages.Clone() as PageInfo[];

            // buttons
            if (sourceSettings._buttonDescriptions != null)
            {
                _buttonDescriptions = new BlogProviderButtonDescription[sourceSettings._buttonDescriptions.Length];
                for (int i = 0; i < sourceSettings._buttonDescriptions.Length; i++)
                {
                    _buttonDescriptions[i] = sourceSettings._buttonDescriptions[i].Clone() as BlogProviderButtonDescription;
                }
            }
            else
            {
                _buttonDescriptions = null;
            }


            // favicon
            _favIcon = sourceSettings._favIcon;

            // images
            _image          = sourceSettings._image;
            _watermarkImage = sourceSettings._watermarkImage;

            // host blogs
            _hostBlogs = new BlogInfo[sourceSettings._hostBlogs.Length];
            for (int i = 0; i < sourceSettings._hostBlogs.Length; i++)
            {
                BlogInfo sourceBlog = sourceSettings._hostBlogs[i];
                _hostBlogs[i] = new BlogInfo(sourceBlog.Id, sourceBlog.Name, sourceBlog.HomepageUrl);
            }

            // file upload settings
            _fileUploadSettings = sourceSettings._fileUploadSettings.Clone() as TemporaryFileUploadSettings;

            _pluginSettings = new SettingsPersisterHelper(new MemorySettingsPersister());
            _pluginSettings.CopyFrom(sourceSettings._pluginSettings, true, true);
        }