Exemplo n.º 1
0
        public static string GetDocFromMTPS(string shortId)
        {
            try
            {
                if (proxy == null)
                {
                    proxy = new ContentServicePortTypeClient();
                }

                var request = new getContentRequest
                {
                    contentIdentifier  = shortId,
                    locale             = "en-us",
                    version            = "VS.85",
                    requestedDocuments = new[] { new requestedDocument()
                                                 {
                                                     type = documentTypes.primary, selector = "Mtps.Xhtml"
                                                 } }
                };
                var response = proxy.GetContent(new appId()
                {
                    value = "Sandcastle"
                }, request);
                if (response.primaryDocuments[0].Any != null)
                {
                    return(response.primaryDocuments[0].Any.OuterXml);
                }
            } catch (Exception ex)
            {
                Logger.Warning("MTPS error for id {0} : {1}", shortId, ex.Message);
            }
            return(string.Empty);
        }
Exemplo n.º 2
0
        private async Task <string> GetDocFromMTPS(string shortId)
        {
            try
            {
                if (proxy == null)
                {
                    proxy = new ContentServicePortTypeClient(ContentServicePortTypeClient.EndpointConfiguration.ContentService);
                }


                var request = new getContentRequest
                {
                    contentIdentifier  = shortId,
                    locale             = "en-us",
                    version            = "VS.85",
                    requestedDocuments = new[] { new requestedDocument {
                                                     type = documentTypes.primary, selector = "Mtps.Xhtml"
                                                 } }
                };
                var response = await Task.Run(() => proxy.GetContent(new appId {
                    value = "Sandcastle"
                }, request));

                if (response.primaryDocuments[0].Any != null)
                {
                    return(response.primaryDocuments[0].Any.OuterXml);
                }
            }
            catch (Exception)
            {
                return(string.Empty);
            }
            return(string.Empty);
        }
Exemplo n.º 3
0
        public Uri ResolveAssetId(string assetId, Version version)
        {
            string ret;
            if (this._cachedMsdnUrls.TryGetValue(assetId, out ret))
            {
                if (ret != null)
                    return new Uri(string.Format(UrlFormat, this._locale, ret));

                return null;
            }

            // filter out non-MS namespaces
            string name = assetId.Substring(2);
            if (!name.StartsWith("System", StringComparison.OrdinalIgnoreCase) &&
                !name.StartsWith("Microsoft", StringComparison.OrdinalIgnoreCase) &&
                !name.StartsWith("Accessibility", StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            getContentRequest msdnRequest = new getContentRequest();
            msdnRequest.contentIdentifier = "AssetId:" + assetId;
            msdnRequest.locale = this._locale;

            string endpoint = null;

            ContentServicePortTypeClient client = new ContentServicePortTypeClient(_msdnBinding, _msdnEndpoint);
            try
            {
                getContentResponse msdnResponse = client.GetContent(new appId {value = "LostDoc"}, msdnRequest);
                endpoint = msdnResponse.contentId;
            }
            catch (FaultException<mtpsFaultDetailType>)
            {
            }
            finally
            {
                try
                {
                    client.Close();
                }
                catch
                {
                    client.Abort();
                }
                
                ((IDisposable)client).Dispose();
            }

            this._cachedMsdnUrls.TryAdd(assetId, endpoint);

            if (string.IsNullOrEmpty(endpoint))
                return null;
            
            return new Uri(string.Format(UrlFormat, this._locale, endpoint));
        }
Exemplo n.º 4
0
        public Uri ResolveAssetId(string assetId, Version version)
        {
            if (this._cachedMsdnUrls.ContainsKey(assetId) && this._cachedMsdnUrls[assetId] != null)
                return new Uri(string.Format(UrlFormat, this._locale, this._cachedMsdnUrls[assetId]));

            getContentRequest msdnRequest = new getContentRequest();
            msdnRequest.contentIdentifier = "AssetId:" + assetId;
            msdnRequest.locale = this._locale;

            string endpoint = null;

            Binding msdnBinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            EndpointAddress msdnEndpoint =
                new EndpointAddress("http://services.msdn.microsoft.com/ContentServices/ContentService.asmx");
            ContentServicePortTypeClient client =
                new ContentServicePortTypeClient(msdnBinding, msdnEndpoint);
            try
            {
                getContentResponse msdnResponse =
                    client.GetContent(new appId {value = "LostDoc"}, msdnRequest);
                endpoint = msdnResponse.contentId;
            }
            catch (FaultException<mtpsFaultDetailType>)
            {
            }
            finally
            {
                try
                {
                    client.Close();
                }
                catch
                {
                    client.Abort();
                }

                if (client is IDisposable)
                    ((IDisposable)client).Dispose();
            }

            this._cachedMsdnUrls[assetId] = endpoint;

            if (string.IsNullOrEmpty(endpoint))
            {
                return null;
            }
            else
            {
                return new Uri(string.Format(UrlFormat, this._locale, endpoint));
            }
        }
Exemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            // Use the ContentService (web service)
            // Set up a request object
            getContentRequest request = new getContentRequest();
            request.contentIdentifier = "abhtw0f1";

            // Create the client
            ContentServicePortTypeClient client = new ContentServicePortTypeClient();

            this.DataContext = client.GetContent(new appId(), request);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MsdnRegistry"/> class.
        /// </summary>
        public MsdnRegistry()
        {
            // Use caching file per application using it
            AppId = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location);
            string directory = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SharpDX"), AppId);
            if (!Directory.Exists(directory))
                Directory.CreateDirectory(directory);
            MsdnRegistryCachingFile = Path.Combine(directory, MsdnRegistryCachingFilePostfix);

            Locale = DefaultLocale;
            var endpointAddress = new EndpointAddress(MtpsService);
            var binding = new BasicHttpBinding();
            msdnClient = new ContentServicePortTypeClient(binding, endpointAddress);
            LoadCacheFromDisk();
        }
Exemplo n.º 7
0
        // Returns the navigation node that corresponds to this content. If
        // we give it a navigation node already, it'll return that node, so
        // no harm done.
        public string GetNavigationNode()
        {
            // Load the contentItem. If we get a Toc entry, then we know it is
            // a navigation node rather than a content node. The reason is that
            // getNavigationPaths only returns the root node if the target node is
            // a navigation node already. We could check to see if we get one path
            // consisting of one node, but the user could give a target node that is
            // the same as the root node. Perf isn't an issue because this should
            // only be called once with the rootNode.

            Load(false); // Don't load images in case we are a content node.

            if (Toc != null)
            {
                return(ContentId);
            }

            var root = new navigationKey {
                contentId = RootContentItem.ContentId, locale = _locale, version = RootContentItem.Version
            };

            var target = new navigationKey {
                contentId = ContentId, locale = _locale, version = _collection + "." + _version
            };
            //            target.contentId = "AssetId:" + assetId;

            var client  = new ContentServicePortTypeClient("ContentService");
            var request = new GetNavigationPathsRequest1
            {
                getNavigationPathsRequest = { target = target, root = root }
            };

            var response = client.GetNavigationPaths(request);

            // We need to deal with the case where the content appears in many
            // places in the TOC. For now, just use the first path.
            if (response.getNavigationPathsResponse.navigationPaths.Length == 0)
            {
                return(null);
            }

            // This is the last node in the first path.
            return(response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes[response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes.Length - 1].navigationNodeKey.contentId);
        }
Exemplo n.º 8
0
        // Use the standard root node to get a list of locales available.
        public static SortedDictionary <string, string> GetLocales()
        {
            var locales = new SortedDictionary <string, string>();

            var client = new ContentServicePortTypeClient(WcfService.SERVICE_NAME);


            GetContentResponse1 response;

            var request = new GetContentRequest1(new appId(), new getContentRequest())
            {
                getContentRequest =
                {
                    contentIdentifier = RootContentItem.ContentId,
                    locale            = Defaults.LANGUAGE
                }
            };


            try
            {
                response = client.GetContent(request);
            }
            catch
            {
                locales.Add(Defaults.LOCALE, Defaults.LANGUAGE);
                return(locales);
            }

            foreach (var versionAndLocale in response.getContentResponse.availableVersionsAndLocales)
            {
                // Use the DisplayName as the key instead of the locale because
                // that's how we want the collection sorted.
                string displayName = new CultureInfo(versionAndLocale.locale).DisplayName;

                if (locales.ContainsKey(displayName) == false)
                {
                    locales.Add(displayName, versionAndLocale.locale.ToLower());
                }
            }

            return(locales);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MsdnRegistry"/> class.
        /// </summary>
        public MsdnRegistry()
        {
            // Use caching file per application using it
            AppId = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location);
            string directory = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SharpDX"), AppId);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            MsdnRegistryCachingFile = Path.Combine(directory, MsdnRegistryCachingFilePostfix);

            Locale = DefaultLocale;
            var endpointAddress = new EndpointAddress(MtpsService);
            var binding         = new BasicHttpBinding();

            msdnClient = new ContentServicePortTypeClient(binding, endpointAddress);
            LoadCacheFromDisk();
        }
Exemplo n.º 10
0
        // Use the standard root node to get a list of locales available.
        public static SortedDictionary<string, string> GetLocales()
        {
            var locales = new SortedDictionary<string, string>();

            var client = new ContentServicePortTypeClient(WcfService.SERVICE_NAME);

            GetContentResponse1 response;

            var request = new GetContentRequest1(new appId(), new getContentRequest())
            {
                getContentRequest =
                {
                    contentIdentifier = RootContentItem.ContentId,
                    locale = Defaults.LANGUAGE
                }
            };

            try
            {
                response = client.GetContent(request);
            }
            catch
            {
                locales.Add(Defaults.LOCALE, Defaults.LANGUAGE);
                return locales;
            }

            foreach (var versionAndLocale in response.getContentResponse.availableVersionsAndLocales)
            {
                // Use the DisplayName as the key instead of the locale because
                // that's how we want the collection sorted.
                string displayName = new CultureInfo(versionAndLocale.locale).DisplayName;

                if (locales.ContainsKey(displayName) == false)
                    locales.Add(displayName, versionAndLocale.locale.ToLower());
            }

            return locales;
        }
Exemplo n.º 11
0
        public Uri ResolveAssetId(string assetId, Version version)
        {
            Uri ret;
            if (this._cachedMsdnUrls.TryGetValue(assetId, out ret))
                return ret;

            // filter out non-MS namespaces

            string name = assetId.Substring(assetId.IndexOf(':') + 1);
            if (!name.StartsWith("System", StringComparison.OrdinalIgnoreCase) &&
                !name.StartsWith("Microsoft", StringComparison.OrdinalIgnoreCase) &&
                !name.StartsWith("Accessibility", StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            getContentRequest msdnRequest = new getContentRequest();
            msdnRequest.contentIdentifier = "AssetId:" + assetId;
            msdnRequest.locale = this._locale;

            int retries = 3;
            do
            {
                ContentServicePortTypeClient client = new ContentServicePortTypeClient(_msdnBinding, _msdnEndpoint);
                try
                {
                    getContentResponse msdnResponse = client.GetContent(new appId { value = "LostDoc" }, msdnRequest);
                    if (msdnResponse.contentId != null)
                        ret = new Uri(string.Format(UrlFormat, this._locale, msdnResponse.contentId));

                    break;
                }
                catch (TimeoutException)
                {
                    // retry
                }
                catch (FaultException<mtpsFaultDetailType> fe)
                {
                    // this is a fallback because MSDN doesn't have links for enumeration fields
                    // so we assume that any unresolved field will be represented on it's parent type page
                    if (assetId.StartsWith("F:"))
                    {
                        // TODO add logging for this
                        string parentEnum = "T:" + assetId.Substring("F:".Length);
                        parentEnum = parentEnum.Substring(0, parentEnum.LastIndexOf('.'));
                        ret = this.ResolveAssetId(parentEnum, version);
                    }

                    break;
                }
                finally
                {
                    try
                    {
                        client.Close();
                    }
                    catch
                    {
                        client.Abort();
                    }

                    ((IDisposable)client).Dispose();
                }
            } while (--retries > 0);

            this._cachedMsdnUrls.TryAdd(assetId, ret);

            return ret;
        }
Exemplo n.º 12
0
        // Returns the navigation node that corresponds to this content. If
        // we give it a navigation node already, it'll return that node, so
        // no harm done.
        public string GetNavigationNode()
        {
            // Load the contentItem. If we get a Toc entry, then we know it is
            // a navigation node rather than a content node. The reason is that
            // getNavigationPaths only returns the root node if the target node is
            // a navigation node already. We could check to see if we get one path
            // consisting of one node, but the user could give a target node that is
            // the same as the root node. Perf isn't an issue because this should
            // only be called once with the rootNode.

            Load(false); // Don't load images in case we are a content node.

            if (Toc != null)
                return ContentId;

            var root = new navigationKey { contentId = RootContentItem.ContentId, locale = _locale, version = RootContentItem.Version };

            var target = new navigationKey { contentId = ContentId, locale = _locale, version = _collection + "." + _version };
            //            target.contentId = "AssetId:" + assetId;

            var client = new ContentServicePortTypeClient("ContentService");
            var request = new GetNavigationPathsRequest1
                              {
                                  getNavigationPathsRequest = {target = target, root = root}
                              };

            var response = client.GetNavigationPaths(request);

            // We need to deal with the case where the content appears in many
            // places in the TOC. For now, just use the first path.
            if (response.getNavigationPathsResponse.navigationPaths.Length == 0)
                return null;

            // This is the last node in the first path.
            return response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes[response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes.Length - 1].navigationNodeKey.contentId;
        }
Exemplo n.º 13
0
        public Uri ResolveAssetId(string assetId, Version version)
        {
            string ret;

            if (this._cachedMsdnUrls.TryGetValue(assetId, out ret))
            {
                if (ret != null)
                {
                    return(new Uri(string.Format(UrlFormat, this._locale, ret)));
                }

                return(null);
            }

            // filter out non-MS namespaces
            string name = assetId.Substring(2);

            if (!name.StartsWith("System", StringComparison.OrdinalIgnoreCase) &&
                !name.StartsWith("Microsoft", StringComparison.OrdinalIgnoreCase) &&
                !name.StartsWith("Accessibility", StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            getContentRequest msdnRequest = new getContentRequest();

            msdnRequest.contentIdentifier = "AssetId:" + assetId;
            msdnRequest.locale            = this._locale;

            string endpoint = null;

            ContentServicePortTypeClient client = new ContentServicePortTypeClient(_msdnBinding, _msdnEndpoint);

            try
            {
                getContentResponse msdnResponse = client.GetContent(new appId {
                    value = "LostDoc"
                }, msdnRequest);
                endpoint = msdnResponse.contentId;
            }
            catch (FaultException <mtpsFaultDetailType> )
            {
            }
            finally
            {
                try
                {
                    client.Close();
                }
                catch
                {
                    client.Abort();
                }

                ((IDisposable)client).Dispose();
            }

            this._cachedMsdnUrls.TryAdd(assetId, endpoint);

            if (string.IsNullOrEmpty(endpoint))
            {
                return(null);
            }

            return(new Uri(string.Format(UrlFormat, this._locale, endpoint)));
        }
Exemplo n.º 14
0
        // Added the loadFailSafe optimization
        public void Load(bool loadImages, bool loadFailSafe = true)
        {
            var request = new GetContentRequest1(new appId(), new getContentRequest())
            {
                getContentRequest =
                {
                    contentIdentifier = ContentIdentifier,
                    locale =_locale,
                    version =_collection + "." + _version
                }
            };

            var documents = new List<requestedDocument>
                                {
                                    new requestedDocument {type = documentTypes.common, selector = Selectors.Mtps.LINKS},
                                    new requestedDocument {type = documentTypes.primary,  selector = Selectors.Mtps.TOC},
                                    new requestedDocument {type = documentTypes.common, selector = Selectors.Mtps.SEARCH},
                                    new requestedDocument {type = documentTypes.feature,  selector = Selectors.Mtps.ANNOTATIONS}
                                };

            if (loadFailSafe)
                documents.Add(new requestedDocument { type = documentTypes.primary, selector = Selectors.Mtps.FAILSAFE });

            request.getContentRequest.requestedDocuments = documents.ToArray();

            var client = new ContentServicePortTypeClient(WcfService.SERVICE_NAME);
            //client.GetContent()  appIdValue = new appId { value = Application };

            GetContentResponse1 response;
            try
            {
                response = client.GetContent(request);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debugger.Break();
                return;
            }

            if (validateAsFilename.Match(response.getContentResponse.contentId).Success)
            {
                ContentId = response.getContentResponse.contentId;
            }
            else
            {
                throw (new BadContentIdException("ContentId contains illegal characters: [" + ContentId + "]"));
            }

            NumImages = response.getContentResponse.imageDocuments.Length;

            foreach (var commonDoc in response.getContentResponse.commonDocuments)
            {
                if (commonDoc.Any == null) continue;

                if (commonDoc.commonFormat.ToLowerInvariant() == Selectors.Mtps.SEARCH.ToLowerInvariant())
                {
                    Metadata = commonDoc.Any[0].OuterXml;
                }
                else if (commonDoc.commonFormat.ToLowerInvariant() == Selectors.Mtps.LINKS.ToLowerInvariant())
                {
                    Links = commonDoc.Any[0].OuterXml;
                }
            }

            foreach (primary primaryDoc in response.getContentResponse.primaryDocuments)
            {
                if (primaryDoc.Any == null) continue;

                if (primaryDoc.primaryFormat.ToLowerInvariant() == Selectors.Mtps.FAILSAFE.ToLowerInvariant())
                {
                    Xml = primaryDoc.Any.OuterXml;
                }
                else if (primaryDoc.primaryFormat.ToLowerInvariant() == Selectors.Mtps.TOC.ToLowerInvariant())
                {
                    Toc = primaryDoc.Any.OuterXml;
                }
            }

            foreach (feature featureDoc in response.getContentResponse.featureDocuments)
            {
                if (featureDoc.Any == null) continue;

                if (featureDoc.featureFormat.ToLowerInvariant() == Selectors.Mtps.ANNOTATIONS.ToLowerInvariant())
                {
                    Annotations = featureDoc.Any[0].OuterXml;
                }

            }

            // If we get no meta/search or wiki data, plug in NOP data because
            // we can't LoadXml an empty string nor pass null navigators to
            // the transform.
            if (string.IsNullOrEmpty(Metadata))
                Metadata = "<se:search xmlns:se=\"urn:mtpg-com:mtps/2004/1/search\" />";

            if (string.IsNullOrEmpty(Annotations))
                Annotations = "<an:annotations xmlns:an=\"urn:mtpg-com:mtps/2007/1/annotations\" />";

            if (loadImages)
            {
                var imageDocs = new requestedDocument[response.getContentResponse.imageDocuments.Length];

                // Now that we know their names, we run a request with each image.
                for (int i = 0; i < response.getContentResponse.imageDocuments.Length; i++)
                {
                    imageDocs[i] = new requestedDocument
                                       {
                                           type = documentTypes.image,
                                           selector = response.getContentResponse.imageDocuments[i].name + "." + response.getContentResponse.imageDocuments[i].imageFormat
                                       };
                }

                request.getContentRequest.requestedDocuments = imageDocs;

                response = client.GetContent(request);

                foreach (image imageDoc in response.getContentResponse.imageDocuments)
                {
                    var imageFilename = imageDoc.name + "." + imageDoc.imageFormat;

                    if (validateAsFilename.Match(imageFilename).Success)
                    {
                        Images.Add(new Image(imageDoc.name, imageDoc.imageFormat, imageDoc.Value));
                    }
                    else
                    {
                        throw (new BadImageNameExeception("Image filename contains illegal characters: [" + imageFilename + "]"));
                    }
                }
            }
        }
Exemplo n.º 15
0
        public static string GetDocFromMTPS(string shortId)
        {
            try
            {
                if (proxy == null) 
                    proxy = new ContentServicePortTypeClient();

                var request = new getContentRequest
                    {
                        contentIdentifier = shortId,
                        locale = "en-us",
                        version = "VS.85",
                        requestedDocuments = new[] { new requestedDocument() { type = documentTypes.primary, selector = "Mtps.Xhtml" } }
                    };
                var response = proxy.GetContent(new appId() { value = "Sandcastle" }, request);
                if (response.primaryDocuments[0].Any != null)
                    return response.primaryDocuments[0].Any.OuterXml;
            } catch (Exception ex)
            {
                Logger.Warning("MTPS error for id {0} : {1}", shortId, ex.Message);
            }
            return string.Empty;
        }
Exemplo n.º 16
0
        // Added the loadFailSafe optimization
        public void Load(bool loadImages, bool loadFailSafe = true)
        {
            var request = new GetContentRequest1(new appId(), new getContentRequest())
            {
                getContentRequest =
                {
                    contentIdentifier = ContentIdentifier,
                    locale            = _locale,
                    version           = _collection + "." + _version
                }
            };


            var documents = new List <requestedDocument>
            {
                new requestedDocument {
                    type = documentTypes.common, selector = Selectors.Mtps.LINKS
                },
                new requestedDocument {
                    type = documentTypes.primary, selector = Selectors.Mtps.TOC
                },
                new requestedDocument {
                    type = documentTypes.common, selector = Selectors.Mtps.SEARCH
                },
                new requestedDocument {
                    type = documentTypes.feature, selector = Selectors.Mtps.ANNOTATIONS
                }
            };


            if (loadFailSafe)
            {
                documents.Add(new requestedDocument {
                    type = documentTypes.primary, selector = Selectors.Mtps.FAILSAFE
                });
            }

            request.getContentRequest.requestedDocuments = documents.ToArray();

            var client = new ContentServicePortTypeClient(WcfService.SERVICE_NAME);
            //client.GetContent()  appIdValue = new appId { value = Application };

            GetContentResponse1 response;

            try
            {
                response = client.GetContent(request);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debugger.Break();
                return;
            }

            if (validateAsFilename.Match(response.getContentResponse.contentId).Success)
            {
                ContentId = response.getContentResponse.contentId;
            }
            else
            {
                throw (new BadContentIdException("ContentId contains illegal characters: [" + ContentId + "]"));
            }

            NumImages = response.getContentResponse.imageDocuments.Length;


            foreach (var commonDoc in response.getContentResponse.commonDocuments)
            {
                if (commonDoc.Any == null)
                {
                    continue;
                }

                if (commonDoc.commonFormat.ToLowerInvariant() == Selectors.Mtps.SEARCH.ToLowerInvariant())
                {
                    Metadata = commonDoc.Any[0].OuterXml;
                }
                else if (commonDoc.commonFormat.ToLowerInvariant() == Selectors.Mtps.LINKS.ToLowerInvariant())
                {
                    Links = commonDoc.Any[0].OuterXml;
                }
            }

            foreach (primary primaryDoc in response.getContentResponse.primaryDocuments)
            {
                if (primaryDoc.Any == null)
                {
                    continue;
                }

                if (primaryDoc.primaryFormat.ToLowerInvariant() == Selectors.Mtps.FAILSAFE.ToLowerInvariant())
                {
                    Xml = primaryDoc.Any.OuterXml;
                }
                else if (primaryDoc.primaryFormat.ToLowerInvariant() == Selectors.Mtps.TOC.ToLowerInvariant())
                {
                    Toc = primaryDoc.Any.OuterXml;
                }
            }


            foreach (feature featureDoc in response.getContentResponse.featureDocuments)
            {
                if (featureDoc.Any == null)
                {
                    continue;
                }

                if (featureDoc.featureFormat.ToLowerInvariant() == Selectors.Mtps.ANNOTATIONS.ToLowerInvariant())
                {
                    Annotations = featureDoc.Any[0].OuterXml;
                }
            }

            // If we get no meta/search or wiki data, plug in NOP data because
            // we can't LoadXml an empty string nor pass null navigators to
            // the transform.
            if (string.IsNullOrEmpty(Metadata))
            {
                Metadata = "<se:search xmlns:se=\"urn:mtpg-com:mtps/2004/1/search\" />";
            }

            if (string.IsNullOrEmpty(Annotations))
            {
                Annotations = "<an:annotations xmlns:an=\"urn:mtpg-com:mtps/2007/1/annotations\" />";
            }


            if (loadImages)
            {
                var imageDocs = new requestedDocument[response.getContentResponse.imageDocuments.Length];

                // Now that we know their names, we run a request with each image.
                for (int i = 0; i < response.getContentResponse.imageDocuments.Length; i++)
                {
                    imageDocs[i] = new requestedDocument
                    {
                        type     = documentTypes.image,
                        selector = response.getContentResponse.imageDocuments[i].name + "." + response.getContentResponse.imageDocuments[i].imageFormat
                    };
                }

                request.getContentRequest.requestedDocuments = imageDocs;


                response = client.GetContent(request);

                foreach (image imageDoc in response.getContentResponse.imageDocuments)
                {
                    var imageFilename = imageDoc.name + "." + imageDoc.imageFormat;

                    if (validateAsFilename.Match(imageFilename).Success)
                    {
                        Images.Add(new Image(imageDoc.name, imageDoc.imageFormat, imageDoc.Value));
                    }
                    else
                    {
                        throw (new BadImageNameExeception("Image filename contains illegal characters: [" + imageFilename + "]"));
                    }
                }
            }
        }
Exemplo n.º 17
0
 public ContentServicePortTypeClient(EndpointConfiguration endpointConfiguration) :
     base(ContentServicePortTypeClient.GetBindingForEndpoint(endpointConfiguration), ContentServicePortTypeClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 18
0
 public ContentServicePortTypeClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(ContentServicePortTypeClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }