Show / Hide Table of Contents

Class SyndicationEncodingUtility

Provides methods for encoding and decoding information exposed by syndicated content. This class cannot be inherited.

Inheritance
System.Object
SyndicationEncodingUtility
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Argotic.Common
Assembly: Argotic.Common.dll
Syntax
public static class SyndicationEncodingUtility

Methods

| Improve this Doc View Source

CreateSafeNavigator(Stream)

Creates a System.Xml.XPath.XPathNavigator against the supplied System.IO.Stream.

Declaration
public static XPathNavigator CreateSafeNavigator(Stream stream)
Parameters
Type Name Description
System.IO.Stream stream

The System.IO.Stream object that contains the XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied stream. The supplied stream XML data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Remarks

The character encoding of the supplied stream is automatically determined based on the encoding attribute of the XML document declaration. If the character encoding cannot be determined, a default encoding of System.Text.Encoding.UTF8 is used.

Exceptions
Type Condition
System.ArgumentNullException

The stream is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateSafeNavigator(Stream, Encoding)

Creates a System.Xml.XPath.XPathNavigator against the supplied System.IO.Stream using the specified System.Text.Encoding.

Declaration
public static XPathNavigator CreateSafeNavigator(Stream stream, Encoding encoding)
Parameters
Type Name Description
System.IO.Stream stream

The System.IO.Stream object that contains the XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

System.Text.Encoding encoding

A System.Text.Encoding object that indicates the character encoding to use when reading the supplied stream.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied stream. The supplied stream XML data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Exceptions
Type Condition
System.ArgumentNullException

The stream is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The encoding is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateSafeNavigator(TextReader)

Creates a System.Xml.XPath.XPathNavigator against the supplied System.IO.TextReader.

Declaration
public static XPathNavigator CreateSafeNavigator(TextReader reader)
Parameters
Type Name Description
System.IO.TextReader reader

The System.IO.TextReader object that contains the XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied reader. The supplied reader XML data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Exceptions
Type Condition
System.ArgumentNullException

The reader is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateSafeNavigator(String)

Creates a System.Xml.XPath.XPathNavigator against the supplied XML data.

Declaration
public static XPathNavigator CreateSafeNavigator(string xml)
Parameters
Type Name Description
System.String xml

The XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied XML data. The supplied xml data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Exceptions
Type Condition
System.ArgumentNullException

The xml data is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The xml data is an empty string.

| Improve this Doc View Source

CreateSafeNavigator(Uri, WebRequestOptions)

Creates a System.Xml.XPath.XPathNavigator against the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static XPathNavigator CreateSafeNavigator(Uri source, WebRequestOptions options)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

WebRequestOptions options

A WebRequestOptions that holds options that should be applied to web requests.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied source. The supplied source XML data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateSafeNavigator(Uri, WebRequestOptions, Encoding)

Creates a System.Xml.XPath.XPathNavigator against the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static XPathNavigator CreateSafeNavigator(Uri source, WebRequestOptions options, Encoding encoding)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

WebRequestOptions options

A WebRequestOptions that holds options that should be applied to web requests.

System.Text.Encoding encoding

A System.Text.Encoding object that indicates the expected character encoding of the supplied source. This value can be null.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied source. The supplied source XML data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Remarks

If the encoding is null, the character encoding of the supplied source is determined automatically. Otherwise the specified encoding is used when reading the XML data represented by the supplied source.

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateSafeNavigator(Uri, ICredentials, IWebProxy)

Creates a System.Xml.XPath.XPathNavigator against the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static XPathNavigator CreateSafeNavigator(Uri source, ICredentials credentials, IWebProxy proxy)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

System.Net.ICredentials credentials

A System.Net.ICredentials that provides the proper set of credentials to the source resource when required. If credentials is null, request is made using the default application credentials.

System.Net.IWebProxy proxy

A System.Net.IWebProxy that provides proxy access to the source resource when required. If proxy is null, request is made using the System.Net.WebRequest default proxy settings.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied source. The supplied source XML data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateSafeNavigator(Uri, ICredentials, IWebProxy, Encoding)

Creates a System.Xml.XPath.XPathNavigator against the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static XPathNavigator CreateSafeNavigator(Uri source, ICredentials credentials, IWebProxy proxy, Encoding encoding)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the XML data to be navigated by the created System.Xml.XPath.XPathNavigator.

System.Net.ICredentials credentials

A System.Net.ICredentials that provides the proper set of credentials to the source resource when required. If credentials is null, request is made using the default application credentials.

System.Net.IWebProxy proxy

A System.Net.IWebProxy that provides proxy access to the source resource when required. If proxy is null, request is made using the System.Net.WebRequest default proxy settings.

System.Text.Encoding encoding

A System.Text.Encoding object that indicates the expected character encoding of the supplied source. This value can be null.

Returns
Type Description
System.Xml.XPath.XPathNavigator

An System.Xml.XPath.XPathNavigator that provides a cursor model for navigating the supplied source. The supplied source XML data is parsed to remove invalid XML characters that would normally prevent a navigator from being created.

Remarks

If the encoding is null, the character encoding of the supplied source is determined automatically. Otherwise the specified encoding is used when reading the XML data represented by the supplied source.

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateWebRequest(Uri, WebRequestOptions)

Returns a System.Net.WebRequest that makes a request for a resource located at the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static WebRequest CreateWebRequest(Uri source, WebRequestOptions options)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the resource to be retrieved.

WebRequestOptions options

A WebRequestOptions that holds options that should be applied to web requests.

Returns
Type Description
System.Net.WebRequest

An System.Net.WebRequest that makes a request to the source. If unable to create a System.Net.WebRequest for the specified source, returns a null reference (Nothing in Visual Basic).

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateWebRequest(Uri, ICredentials, IWebProxy)

Returns a System.Net.WebRequest that makes a request for a resource located at the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static WebRequest CreateWebRequest(Uri source, ICredentials credentials, IWebProxy proxy)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the resource to be retrieved.

System.Net.ICredentials credentials

A System.Net.ICredentials that provides the proper set of credentials to the source resource when required. If credentials is null, request is made using the default application credentials if supported by the underlying protocol.

System.Net.IWebProxy proxy

A System.Net.IWebProxy that provides proxy access to the source resource when required. If proxy is null, request is made using the System.Net.WebRequest default proxy settings if supported by the underlying protocol.

Returns
Type Description
System.Net.WebRequest

An System.Net.WebRequest that makes a request to the source. If unable to create a System.Net.WebRequest for the specified source, returns a null reference (Nothing in Visual Basic).

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateWebResponse(Uri, WebRequestOptions)

Returns the System.Net.WebResponse to a request for a resource located at the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static WebResponse CreateWebResponse(Uri source, WebRequestOptions options)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the resource to be retrieved.

WebRequestOptions options

A WebRequestOptions that holds options that should be applied to web requests.

Returns
Type Description
System.Net.WebResponse

An System.Net.WebResponse that contains the response from the requested resource. If unable to create a System.Net.WebResponse for the requested source, returns a null reference (Nothing in Visual Basic).

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

CreateWebResponse(Uri, ICredentials, IWebProxy)

Returns the System.Net.WebResponse to a request for a resource located at the supplied System.Uri using the specified System.Net.ICredentials and System.Net.IWebProxy.

Declaration
public static WebResponse CreateWebResponse(Uri source, ICredentials credentials, IWebProxy proxy)
Parameters
Type Name Description
System.Uri source

A System.Uri that points to the location of the resource to be retrieved.

System.Net.ICredentials credentials

A System.Net.ICredentials that provides the proper set of credentials to the source resource when required. If credentials is null, request is made using the default application credentials if supported by the underlying protocol.

System.Net.IWebProxy proxy

A System.Net.IWebProxy that provides proxy access to the source resource when required. If proxy is null, request is made using the System.Net.WebRequest default proxy settings if supported by the underlying protocol.

Returns
Type Description
System.Net.WebResponse

An System.Net.WebResponse that contains the response from the requested resource. If unable to create a System.Net.WebResponse for the requested source, returns a null reference (Nothing in Visual Basic).

Exceptions
Type Condition
System.ArgumentNullException

The source is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

DecodeBase64String(String)

Decodes a base64 encoded string.

Declaration
public static Stream DecodeBase64String(string encodedValue)
Parameters
Type Name Description
System.String encodedValue

The base64 encoded string to decode.

Returns
Type Description
System.IO.Stream

A System.IO.Stream the represents the decoded result of the base64 encoded value.

Exceptions
Type Condition
System.ArgumentNullException

The encodedValue is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The encodedValue is an empty string.

| Improve this Doc View Source

DecodeHtmlEscapedString(String)

Decodes an HTML escaped string.

Declaration
public static string DecodeHtmlEscapedString(string escapedValue)
Parameters
Type Name Description
System.String escapedValue

The HTML escaped string to decode.

Returns
Type Description
System.String

A string the represents the unescaped result of the HTML escaped value.

Exceptions
Type Condition
System.ArgumentNullException

The escapedValue is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The escapedValue is an empty string.

| Improve this Doc View Source

EncodeInvalidXmlHexadecimalCharacters(String)

Encodes the supplied string so that it can be safely represented in XML.

Declaration
public static string EncodeInvalidXmlHexadecimalCharacters(string content)
Parameters
Type Name Description
System.String content

A string that represents the XML data to parse for invalid XML hexadecimal characters.

Returns
Type Description
System.String

A string that has been encoded to be safe for XML.

Remarks

The encoding process replaces invalid XML hexadecimal characters with their equivalent decimal representation.

Hexadecimal characters that are valid include: #x9, #xA, #xD, [#x20-#xD7FF], [#xE000-#xFFFD], [#x10000-#x10FFFF], and any Unicode character; excluding the surrogate blocks FFFE and FFFF.

Exceptions
Type Condition
System.ArgumentNullException

The content is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The content is an empty string.

| Improve this Doc View Source

EncodeSafeDirectoryName(String)

Converts a string into a value that can be safely used as a System.IO.Directory name.

Declaration
public static string EncodeSafeDirectoryName(string name)
Parameters
Type Name Description
System.String name

The directory name to encode.

Returns
Type Description
System.String

A string that can be safely used as an argument when System.IO.Directory.CreateDirectory(System.String).

Exceptions
Type Condition
System.ArgumentNullException

The name is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The name is an empty string.

| Improve this Doc View Source

GetXmlEncoding(Byte[])

Returns an System.Text.Encoding that represents the XML character encoding for the supplied array of bytes.

Declaration
public static Encoding GetXmlEncoding(byte[] data)
Parameters
Type Name Description
System.Byte[] data

An array of bytes that represents an XML data source to determine the character encoding for.

Returns
Type Description
System.Text.Encoding

A System.Text.Encoding that represents the character encoding specified by the XML data source. If the character encoding is not specified or unable to be determined, returns System.Text.Encoding.UTF8.

Exceptions
Type Condition
System.ArgumentNullException

The data is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

GetXmlEncoding(Stream)

Returns an System.Text.Encoding that represents the XML character encoding for the supplied System.IO.Stream.

Declaration
public static Encoding GetXmlEncoding(Stream stream)
Parameters
Type Name Description
System.IO.Stream stream

A System.IO.Stream that represents an XML data source to determine the character encoding for.

Returns
Type Description
System.Text.Encoding

A System.Text.Encoding that represents the character encoding specified by the XML data source. If the character encoding is not specified or unable to be determined, returns System.Text.Encoding.UTF8.

Exceptions
Type Condition
System.ArgumentNullException

The stream is a null reference (Nothing in Visual Basic).

| Improve this Doc View Source

GetXmlEncoding(String)

Returns an System.Text.Encoding that represents the XML character encoding for the supplied content.

Declaration
public static Encoding GetXmlEncoding(string content)
Parameters
Type Name Description
System.String content

A string that represents the XML data to determine the character encoding for.

Returns
Type Description
System.Text.Encoding

A System.Text.Encoding that represents the character encoding specified by the XML data. If the character encoding is not specified or unable to be determined, returns System.Text.Encoding.UTF8.

Exceptions
Type Condition
System.ArgumentNullException

The content is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The content is an empty string.

| Improve this Doc View Source

RemoveInvalidXmlHexadecimalCharacters(String)

Sanitizes the supplied string so that it can be safely represented in XML.

Declaration
public static string RemoveInvalidXmlHexadecimalCharacters(string content)
Parameters
Type Name Description
System.String content

A string that represents the XML data to parse for invalid XML hexadecimal characters.

Returns
Type Description
System.String

A string that has been sanitized to be safe for XML.

Remarks

The sanitation process removes characters that are invalid for XML encoding.

Hexadecimal characters that are valid include: #x9, #xA, #xD, [#x20-#xD7FF], [#xE000-#xFFFD], [#x10000-#x10FFFF], and any Unicode character; excluding the surrogate blocks FFFE and FFFF.

Exceptions
Type Condition
System.ArgumentNullException

The content is a null reference (Nothing in Visual Basic).

System.ArgumentNullException

The content is an empty string.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX