Beispiel #1
0
        public void SetBlogInfo(BlogInfo blogInfo)
        {
            if (blogInfo.Id != _hostBlogId)
            {
                _blogName    = blogInfo.Name;
                _hostBlogId  = blogInfo.Id;
                _homePageUrl = blogInfo.HomepageUrl;
                if (!UrlHelper.IsUrl(_homePageUrl))
                {
                    Trace.Assert(!string.IsNullOrEmpty(_homePageUrl), "Homepage URL was null or empty");
                    string baseUrl = UrlHelper.GetBaseUrl(_postApiUrl);
                    _homePageUrl = UrlHelper.UrlCombineIfRelative(baseUrl, _homePageUrl);
                }

                // reset categories, authors, and pages
                Categories = new BlogPostCategory[] {};
                Keywords   = new BlogPostKeyword[] {};
                Authors    = new AuthorInfo[] {};
                Pages      = new PageInfo[] {};

                // reset option overrides
                if (OptionOverrides != null)
                {
                    OptionOverrides.Clear();
                }

                if (UserOptionOverrides != null)
                {
                    UserOptionOverrides.Clear();
                }

                if (HomePageOverrides != null)
                {
                    HomePageOverrides.Clear();
                }

                // reset provider buttons
                if (ButtonDescriptions != null)
                {
                    ButtonDescriptions = new IBlogProviderButtonDescription[0];
                }

                // reset template
                TemplateFiles = new BlogEditingTemplateFile[0];
            }
        }
Beispiel #2
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);
        }