private void AppendManifestDownloadInfo(WriterEditingManifestDownloadInfo manifestDownloadInfo, StringBuilder settingsContents) { if (manifestDownloadInfo != null) { settingsContents.AppendFormat(CultureInfo.InvariantCulture, "ManifestUrl:{0}ManifestExpires:{1}ManifestLastModified:{2}ManifestEtag:{3}", manifestDownloadInfo.SourceUrl, manifestDownloadInfo.Expires, manifestDownloadInfo.LastModified, manifestDownloadInfo.ETag); } }
/// <summary> /// SetContext using a weblog account /// </summary> public void SetContext(BlogAccount blogAccount, IBlogCredentialsAccessor credentials, string blogHomepageUrl, string blogTemplateDir, WriterEditingManifestDownloadInfo manifestDownloadInfo, bool probeForManifest, string providerId, IDictionary optionOverrides, IDictionary userOptionOverrides, IDictionary homepageOptionOverrides) { // note context set _contextSet = true; // create a blog client _blogAccount = blogAccount; _credentials = credentials; _blogClient = BlogClientManager.CreateClient(blogAccount.ClientType, blogAccount.PostApiUrl, credentials, providerId, optionOverrides, userOptionOverrides, homepageOptionOverrides); // set other context that we've got _blogHomepageUrl = blogHomepageUrl; _blogTemplateDir = blogTemplateDir; _manifestDownloadInfo = manifestDownloadInfo; _probeForManifest = probeForManifest; }
protected override object DetectBlogService(IProgressHost progressHost) { using (BlogClientUIContextSilentMode uiContextScope = new BlogClientUIContextSilentMode()) //supress prompting for credentials { try { // get the weblog homepage and rsd service description if available IHTMLDocument2 weblogDOM = GetWeblogHomepageDOM(progressHost); // while we have the DOM available, scan for a writer manifest url if (_manifestDownloadInfo == null) { string manifestUrl = WriterEditingManifest.DiscoverUrl(_homepageUrl, weblogDOM); if (manifestUrl != String.Empty) _manifestDownloadInfo = new WriterEditingManifestDownloadInfo(manifestUrl); } string html = weblogDOM != null ? HTMLDocumentHelper.HTMLDocToString(weblogDOM) : null; bool detectionSucceeded = false; if (!detectionSucceeded) detectionSucceeded = AttemptGenericAtomLinkDetection(_homepageUrl, html, !ApplicationDiagnostics.PreferAtom); if (!detectionSucceeded && _blogSettings.IsGoogleBloggerBlog) detectionSucceeded = AttemptBloggerDetection(_homepageUrl, html); if (!detectionSucceeded) { RsdServiceDescription rsdServiceDescription = GetRsdServiceDescription(progressHost, weblogDOM); // if there was no rsd service description or we fail to auto-configure from the // rsd description then move on to other auto-detection techniques if (!(detectionSucceeded = AttemptRsdBasedDetection(progressHost, rsdServiceDescription))) { // try detection by analyzing the homepage url and contents UpdateProgress(progressHost, 75, Res.Get(StringId.ProgressAnalyzingHomepage)); if (weblogDOM != null) detectionSucceeded = AttemptHomepageBasedDetection(_homepageUrl, html); else detectionSucceeded = AttemptUrlBasedDetection(_homepageUrl); // if we successfully detected then see if we can narrow down // to a specific weblog if (detectionSucceeded) { if (!BlogProviderParameters.UrlContainsParameters(_postApiUrl)) { // we detected the provider, now see if we can detect the weblog id // (or at lease the list of the user's weblogs) UpdateProgress(progressHost, 80, Res.Get(StringId.ProgressAnalyzingWeblogList)); AttemptUserBlogDetection(); } } } } if (!detectionSucceeded && html != null) AttemptGenericAtomLinkDetection(_homepageUrl, html, false); // finished UpdateProgress(progressHost, 100, String.Empty); } catch (OperationCancelledException) { // WasCancelled == true } catch (BlogClientOperationCancelledException) { Cancel(); // WasCancelled == true } catch (BlogAccountDetectorException ex) { if (ApplicationDiagnostics.AutomationMode) Trace.WriteLine(ex.ToString()); else Trace.Fail(ex.ToString()); // ErrorOccurred == true } catch (Exception ex) { // ErrorOccurred == true Trace.Fail(ex.Message, ex.ToString()); ReportError(MessageId.WeblogDetectionUnexpectedError, ex.Message); } return this; } }
protected override object DetectBlogService(IProgressHost progressHost) { using (BlogClientUIContextSilentMode uiContextScope = new BlogClientUIContextSilentMode()) //suppress prompting for credentials { try { // get the weblog homepage and rsd service description if available IHTMLDocument2 weblogDOM = GetWeblogHomepageDOM(progressHost); // while we have the DOM available, scan for a writer manifest url if (_manifestDownloadInfo == null) { string manifestUrl = WriterEditingManifest.DiscoverUrl(_homepageUrl, weblogDOM); if (manifestUrl != String.Empty) { _manifestDownloadInfo = new WriterEditingManifestDownloadInfo(manifestUrl); } } string html = weblogDOM != null?HTMLDocumentHelper.HTMLDocToString(weblogDOM) : null; bool detectionSucceeded = false; if (!detectionSucceeded) { detectionSucceeded = AttemptGenericAtomLinkDetection(_homepageUrl, html, !ApplicationDiagnostics.PreferAtom); } if (!detectionSucceeded && _blogSettings.IsGoogleBloggerBlog) { detectionSucceeded = AttemptBloggerDetection(_homepageUrl, html); } if (!detectionSucceeded) { RsdServiceDescription rsdServiceDescription = GetRsdServiceDescription(progressHost, weblogDOM); // if there was no rsd service description or we fail to auto-configure from the // rsd description then move on to other auto-detection techniques if (!(detectionSucceeded = AttemptRsdBasedDetection(progressHost, rsdServiceDescription))) { // try detection by analyzing the homepage url and contents UpdateProgress(progressHost, 75, Res.Get(StringId.ProgressAnalyzingHomepage)); if (weblogDOM != null) { detectionSucceeded = AttemptHomepageBasedDetection(_homepageUrl, html); } else { detectionSucceeded = AttemptUrlBasedDetection(_homepageUrl); } // if we successfully detected then see if we can narrow down // to a specific weblog if (detectionSucceeded) { if (!BlogProviderParameters.UrlContainsParameters(_postApiUrl)) { // we detected the provider, now see if we can detect the weblog id // (or at lease the list of the user's weblogs) UpdateProgress(progressHost, 80, Res.Get(StringId.ProgressAnalyzingWeblogList)); AttemptUserBlogDetection(); } } } } if (!detectionSucceeded && html != null) { AttemptGenericAtomLinkDetection(_homepageUrl, html, false); } // finished UpdateProgress(progressHost, 100, String.Empty); } catch (OperationCancelledException) { // WasCancelled == true } catch (BlogClientOperationCancelledException) { Cancel(); // WasCancelled == true } catch (BlogAccountDetectorException ex) { if (ApplicationDiagnostics.AutomationMode) { Trace.WriteLine(ex.ToString()); } else { Trace.Fail(ex.ToString()); } // ErrorOccurred == true } catch (Exception ex) { // ErrorOccurred == true Trace.Fail(ex.Message, ex.ToString()); ReportError(MessageId.WeblogDetectionUnexpectedError, ex.Message); } return(this); } }
private WriterEditingManifest(WriterEditingManifestDownloadInfo downloadInfo, XmlDocument xmlDocument, IBlogClient blogClient, IBlogCredentialsAccessor credentials) { // record blog client and credentials _blogClient = blogClient; _credentials = credentials; // record download info if (UrlHelper.IsUrl(downloadInfo.SourceUrl)) { _downloadInfo = downloadInfo; } // only process an xml document if we got one if (xmlDocument == null) { return; } // create namespace manager XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable); nsmgr.AddNamespace("m", "http://schemas.microsoft.com/wlw/manifest/weblog"); // throw if the root element is not manifest if (xmlDocument.DocumentElement.LocalName.ToUpperInvariant() != "MANIFEST") { throw new ArgumentException("Not a valid writer editing manifest"); } // get button descriptions _buttonDescriptions = new IBlogProviderButtonDescription[] { }; XmlNode buttonsNode = xmlDocument.SelectSingleNode("//m:buttons", nsmgr); if (buttonsNode != null) { ArrayList buttons = new ArrayList(); foreach (XmlNode buttonNode in buttonsNode.SelectNodes("m:button", nsmgr)) { try { // id string id = XmlHelper.NodeText(buttonNode.SelectSingleNode("m:id", nsmgr)); if (id == String.Empty) { throw new ArgumentException("Missing id field"); } // title string description = XmlHelper.NodeText(buttonNode.SelectSingleNode("m:text", nsmgr)); if (description == String.Empty) { throw new ArgumentException("Missing text field"); } // imageUrl string imageUrl = XmlHelper.NodeText(buttonNode.SelectSingleNode("m:imageUrl", nsmgr)); if (imageUrl == String.Empty) { throw new ArgumentException("Missing imageUrl field"); } // download the image Bitmap image = DownloadImage(imageUrl, downloadInfo.SourceUrl); // clickUrl string clickUrl = BlogClientHelper.GetAbsoluteUrl(XmlHelper.NodeText(buttonNode.SelectSingleNode("m:clickUrl", nsmgr)), downloadInfo.SourceUrl); // contentUrl string contentUrl = BlogClientHelper.GetAbsoluteUrl(XmlHelper.NodeText(buttonNode.SelectSingleNode("m:contentUrl", nsmgr)), downloadInfo.SourceUrl); // contentDisplaySize Size contentDisplaySize = XmlHelper.NodeSize(buttonNode.SelectSingleNode("m:contentDisplaySize", nsmgr), Size.Empty); // button must have either clickUrl or hasContent if (clickUrl == String.Empty && contentUrl == String.Empty) { throw new ArgumentException("Must either specify a clickUrl or contentUrl"); } // notificationUrl string notificationUrl = BlogClientHelper.GetAbsoluteUrl(XmlHelper.NodeText(buttonNode.SelectSingleNode("m:notificationUrl", nsmgr)), downloadInfo.SourceUrl); // add the button buttons.Add(new BlogProviderButtonDescription(id, imageUrl, image, description, clickUrl, contentUrl, contentDisplaySize, notificationUrl)); } catch (Exception ex) { // buttons fail silently and are not "all or nothing" Trace.WriteLine("Error occurred reading custom button description: " + ex.Message); } } _buttonDescriptions = buttons.ToArray(typeof(IBlogProviderButtonDescription)) as IBlogProviderButtonDescription[]; } // get options _optionOverrides = new Hashtable(); AddOptionsFromNode(xmlDocument.SelectSingleNode("//m:weblog", nsmgr), _optionOverrides); AddOptionsFromNode(xmlDocument.SelectSingleNode("//m:options", nsmgr), _optionOverrides); AddOptionsFromNode(xmlDocument.SelectSingleNode("//m:apiOptions[@name='" + _blogClient.ProtocolName + "']", nsmgr), _optionOverrides); XmlNode defaultViewNode = xmlDocument.SelectSingleNode("//m:views/m:default", nsmgr); if (defaultViewNode != null) { _optionOverrides["defaultView"] = XmlHelper.NodeText(defaultViewNode); } // separate out client type const string CLIENT_TYPE = "clientType"; if (_optionOverrides.Contains(CLIENT_TYPE)) { string type = _optionOverrides[CLIENT_TYPE].ToString(); if (ValidateClientType(type)) { _clientType = type; } _optionOverrides.Remove(CLIENT_TYPE); } // separate out image const string IMAGE_URL = "imageUrl"; _image = GetImageBytes(IMAGE_URL, _optionOverrides, downloadInfo.SourceUrl, new Size(16, 16)); _optionOverrides.Remove(IMAGE_URL); // separate out watermark image const string WATERMARK_IMAGE_URL = "watermarkImageUrl"; _watermark = GetImageBytes(WATERMARK_IMAGE_URL, _optionOverrides, downloadInfo.SourceUrl, new Size(84, 84)); _optionOverrides.Remove(WATERMARK_IMAGE_URL); // get templates XmlNode webLayoutUrlNode = xmlDocument.SelectSingleNode("//m:views/m:view[@type='WebLayout']/@src", nsmgr); if (webLayoutUrlNode != null) { string webLayoutUrl = XmlHelper.NodeText(webLayoutUrlNode); if (webLayoutUrl != String.Empty) { _webLayoutUrl = BlogClientHelper.GetAbsoluteUrl(webLayoutUrl, downloadInfo.SourceUrl); } } XmlNode webPreviewUrlNode = xmlDocument.SelectSingleNode("//m:views/m:view[@type='WebPreview']/@src", nsmgr); if (webPreviewUrlNode != null) { string webPreviewUrl = XmlHelper.NodeText(webPreviewUrlNode); if (webPreviewUrl != String.Empty) { _webPreviewUrl = BlogClientHelper.GetAbsoluteUrl(webPreviewUrl, downloadInfo.SourceUrl); } } }
public static WriterEditingManifest FromDownloadInfo(WriterEditingManifestDownloadInfo downloadInfo, IBlogClient blogClient, IBlogCredentialsAccessor credentials, bool expectedAvailable) { if (downloadInfo == null) { return(null); } try { // if the manifest is not yet expired then don't try a download at all if (downloadInfo.Expires > DateTimeHelper.UtcNow) { return(new WriterEditingManifest(downloadInfo)); } // execute the download HttpWebResponse response = null; try { if (credentials != null) { response = blogClient.SendAuthenticatedHttpRequest(downloadInfo.SourceUrl, REQUEST_TIMEOUT, new HttpRequestFilter(new EditingManifestFilter(downloadInfo).Filter)); } else { response = HttpRequestHelper.SendRequest(downloadInfo.SourceUrl, new HttpRequestFilter(new EditingManifestFilter(downloadInfo).Filter)); } } catch (WebException ex) { // Not modified -- return ONLY an updated downloadInfo (not a document) HttpWebResponse errorResponse = ex.Response as HttpWebResponse; if (errorResponse != null && errorResponse.StatusCode == HttpStatusCode.NotModified) { return(new WriterEditingManifest( new WriterEditingManifestDownloadInfo( downloadInfo.SourceUrl, HttpRequestHelper.GetExpiresHeader(errorResponse), downloadInfo.LastModified, HttpRequestHelper.GetETagHeader(errorResponse)))); } else { throw; } } // read headers DateTime expires = HttpRequestHelper.GetExpiresHeader(response); DateTime lastModified = response.LastModified; string eTag = HttpRequestHelper.GetETagHeader(response); // read document using (Stream stream = response.GetResponseStream()) { XmlDocument manifestXmlDocument = new XmlDocument(); manifestXmlDocument.Load(stream); // return the manifest return(new WriterEditingManifest( new WriterEditingManifestDownloadInfo(downloadInfo.SourceUrl, expires, lastModified, eTag), manifestXmlDocument, blogClient, credentials)); } } catch (Exception ex) { if (expectedAvailable) { Trace.WriteLine("Error attempting to download manifest from " + downloadInfo.SourceUrl + ": " + ex.ToString()); } return(null); } }
public EditingManifestFilter(WriterEditingManifestDownloadInfo previousDownloadInfo) { _previousDownloadInfo = previousDownloadInfo; }
private WriterEditingManifest(WriterEditingManifestDownloadInfo downloadInfo) : this(downloadInfo, null, null, null) { }
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); }
public static WriterEditingManifest FromDownloadInfo(WriterEditingManifestDownloadInfo downloadInfo, IBlogClient blogClient, IBlogCredentialsAccessor credentials, bool expectedAvailable) { if (downloadInfo == null) return null; try { // if the manifest is not yet expired then don't try a download at all if (downloadInfo.Expires > DateTimeHelper.UtcNow) return new WriterEditingManifest(downloadInfo); // execute the download HttpWebResponse response = null; try { if (credentials != null) response = blogClient.SendAuthenticatedHttpRequest(downloadInfo.SourceUrl, REQUEST_TIMEOUT, new HttpRequestFilter(new EditingManifestFilter(downloadInfo).Filter)); else response = HttpRequestHelper.SendRequest(downloadInfo.SourceUrl, new HttpRequestFilter(new EditingManifestFilter(downloadInfo).Filter)); } catch (WebException ex) { // Not modified -- return ONLY an updated downloadInfo (not a document) HttpWebResponse errorResponse = ex.Response as HttpWebResponse; if (errorResponse != null && errorResponse.StatusCode == HttpStatusCode.NotModified) { return new WriterEditingManifest( new WriterEditingManifestDownloadInfo( downloadInfo.SourceUrl, HttpRequestHelper.GetExpiresHeader(errorResponse), downloadInfo.LastModified, HttpRequestHelper.GetETagHeader(errorResponse))); } else throw; } // read headers DateTime expires = HttpRequestHelper.GetExpiresHeader(response); DateTime lastModified = response.LastModified; string eTag = HttpRequestHelper.GetETagHeader(response); // read document using (Stream stream = response.GetResponseStream()) { XmlDocument manifestXmlDocument = new XmlDocument(); manifestXmlDocument.Load(stream); // return the manifest return new WriterEditingManifest( new WriterEditingManifestDownloadInfo(downloadInfo.SourceUrl, expires, lastModified, eTag), manifestXmlDocument, blogClient, credentials); } } catch (Exception ex) { if (expectedAvailable) { Trace.WriteLine("Error attempting to download manifest from " + downloadInfo.SourceUrl + ": " + ex.ToString()); } return null; } }
private WriterEditingManifest(WriterEditingManifestDownloadInfo downloadInfo, XmlDocument xmlDocument, IBlogClient blogClient, IBlogCredentialsAccessor credentials) { // record blog client and credentials _blogClient = blogClient; _credentials = credentials; // record download info if (UrlHelper.IsUrl(downloadInfo.SourceUrl)) _downloadInfo = downloadInfo; // only process an xml document if we got one if (xmlDocument == null) return; // create namespace manager XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable); nsmgr.AddNamespace("m", "http://schemas.microsoft.com/wlw/manifest/weblog"); // throw if the root element is not manifest if (xmlDocument.DocumentElement.LocalName.ToUpperInvariant() != "MANIFEST") throw new ArgumentException("Not a valid writer editing manifest"); // get button descriptions _buttonDescriptions = new IBlogProviderButtonDescription[] { }; XmlNode buttonsNode = xmlDocument.SelectSingleNode("//m:buttons", nsmgr); if (buttonsNode != null) { ArrayList buttons = new ArrayList(); foreach (XmlNode buttonNode in buttonsNode.SelectNodes("m:button", nsmgr)) { try { // id string id = XmlHelper.NodeText(buttonNode.SelectSingleNode("m:id", nsmgr)); if (id == String.Empty) throw new ArgumentException("Missing id field"); // title string description = XmlHelper.NodeText(buttonNode.SelectSingleNode("m:text", nsmgr)); if (description == String.Empty) throw new ArgumentException("Missing text field"); // imageUrl string imageUrl = XmlHelper.NodeText(buttonNode.SelectSingleNode("m:imageUrl", nsmgr)); if (imageUrl == String.Empty) throw new ArgumentException("Missing imageUrl field"); // download the image Bitmap image = DownloadImage(imageUrl, downloadInfo.SourceUrl); // clickUrl string clickUrl = BlogClientHelper.GetAbsoluteUrl(XmlHelper.NodeText(buttonNode.SelectSingleNode("m:clickUrl", nsmgr)), downloadInfo.SourceUrl); // contentUrl string contentUrl = BlogClientHelper.GetAbsoluteUrl(XmlHelper.NodeText(buttonNode.SelectSingleNode("m:contentUrl", nsmgr)), downloadInfo.SourceUrl); // contentDisplaySize Size contentDisplaySize = XmlHelper.NodeSize(buttonNode.SelectSingleNode("m:contentDisplaySize", nsmgr), Size.Empty); // button must have either clickUrl or hasContent if (clickUrl == String.Empty && contentUrl == String.Empty) throw new ArgumentException("Must either specify a clickUrl or contentUrl"); // notificationUrl string notificationUrl = BlogClientHelper.GetAbsoluteUrl(XmlHelper.NodeText(buttonNode.SelectSingleNode("m:notificationUrl", nsmgr)), downloadInfo.SourceUrl); // add the button buttons.Add(new BlogProviderButtonDescription(id, imageUrl, image, description, clickUrl, contentUrl, contentDisplaySize, notificationUrl)); } catch (Exception ex) { // buttons fail silently and are not "all or nothing" Trace.WriteLine("Error occurred reading custom button description: " + ex.Message); } } _buttonDescriptions = buttons.ToArray(typeof(IBlogProviderButtonDescription)) as IBlogProviderButtonDescription[]; } // get options _optionOverrides = new Hashtable(); AddOptionsFromNode(xmlDocument.SelectSingleNode("//m:weblog", nsmgr), _optionOverrides); AddOptionsFromNode(xmlDocument.SelectSingleNode("//m:options", nsmgr), _optionOverrides); AddOptionsFromNode(xmlDocument.SelectSingleNode("//m:apiOptions[@name='" + _blogClient.ProtocolName + "']", nsmgr), _optionOverrides); XmlNode defaultViewNode = xmlDocument.SelectSingleNode("//m:views/m:default", nsmgr); if (defaultViewNode != null) _optionOverrides["defaultView"] = XmlHelper.NodeText(defaultViewNode); // separate out client type const string CLIENT_TYPE = "clientType"; if (_optionOverrides.Contains(CLIENT_TYPE)) { string type = _optionOverrides[CLIENT_TYPE].ToString(); if (ValidateClientType(type)) _clientType = type; _optionOverrides.Remove(CLIENT_TYPE); } // separate out image const string IMAGE_URL = "imageUrl"; _image = GetImageBytes(IMAGE_URL, _optionOverrides, downloadInfo.SourceUrl, new Size(16, 16)); _optionOverrides.Remove(IMAGE_URL); // separate out watermark image const string WATERMARK_IMAGE_URL = "watermarkImageUrl"; _watermark = GetImageBytes(WATERMARK_IMAGE_URL, _optionOverrides, downloadInfo.SourceUrl, new Size(84, 84)); _optionOverrides.Remove(WATERMARK_IMAGE_URL); // get templates XmlNode webLayoutUrlNode = xmlDocument.SelectSingleNode("//m:views/m:view[@type='WebLayout']/@src", nsmgr); if (webLayoutUrlNode != null) { string webLayoutUrl = XmlHelper.NodeText(webLayoutUrlNode); if (webLayoutUrl != String.Empty) _webLayoutUrl = BlogClientHelper.GetAbsoluteUrl(webLayoutUrl, downloadInfo.SourceUrl); } XmlNode webPreviewUrlNode = xmlDocument.SelectSingleNode("//m:views/m:view[@type='WebPreview']/@src", nsmgr); if (webPreviewUrlNode != null) { string webPreviewUrl = XmlHelper.NodeText(webPreviewUrlNode); if (webPreviewUrl != String.Empty) _webPreviewUrl = BlogClientHelper.GetAbsoluteUrl(webPreviewUrl, downloadInfo.SourceUrl); } }
private WriterEditingManifest(WriterEditingManifestDownloadInfo downloadInfo) : this(downloadInfo, null, null, null) { }
public EditingManifestFilter(WriterEditingManifestDownloadInfo previousDownloadInfo) { _previousDownloadInfo = previousDownloadInfo; }