Search Results for

    Show / Hide Table of Contents

    Class Utility

    Various helper functions

    Inheritance
    System.Object
    Utility
    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: OSGeo.MapGuide.MaestroAPI
    Assembly: OSGeo.MapGuide.MaestroAPI.dll
    Syntax
    public static class Utility

    Fields

    | Improve this Doc View Source

    XML_EXCEPTION_KEY

    The exception data key that hints that an System.Exception thrown is related to XML content errors

    Declaration
    public const string XML_EXCEPTION_KEY = "XmlError"
    Field Value
    Type Description
    System.String

    Methods

    | Improve this Doc View Source

    ChangeColorBrightness(Color, Single)

    Creates color with corrected brightness.

    Declaration
    public static Color ChangeColorBrightness(Color color, float correctionFactor)
    Parameters
    Type Name Description
    System.Drawing.Color color

    Color to correct.

    System.Single correctionFactor

    The brightness correction factor. Must be between -1 and 1. Negative values produce darker colors.

    Returns
    Type Description
    System.Drawing.Color

    Corrected System.Drawing.Color structure.

    | Improve this Doc View Source

    CleanUpFeatureSet(String)

    Removes the outer <FeatureInformation> tag, and returns a blank string for empty sets. This eases the use of SelectionXml, because different parts of MapGuide represents it differently.

    Declaration
    public static string CleanUpFeatureSet(string input)
    Parameters
    Type Name Description
    System.String input

    The string to clean

    Returns
    Type Description
    System.String

    The cleaned string

    | Improve this Doc View Source

    CopyStream(Stream, Stream)

    Copies the content of a stream into another stream. Automatically attempts to rewind the source stream.

    Declaration
    public static void CopyStream(Stream source, Stream target)
    Parameters
    Type Name Description
    System.IO.Stream source

    The source stream

    System.IO.Stream target

    The target stream

    | Improve this Doc View Source

    CopyStream(Stream, Stream, Utility.StreamCopyProgressDelegate, Int64)

    Copies the content of a stream into another stream, with callbacks.

    Declaration
    public static void CopyStream(Stream source, Stream target, Utility.StreamCopyProgressDelegate callback, long updateFrequence)
    Parameters
    Type Name Description
    System.IO.Stream source

    The source stream

    System.IO.Stream target

    The target stream

    Utility.StreamCopyProgressDelegate callback

    An optional callback delegate, may be null.

    System.Int64 updateFrequence

    The number of bytes to copy before calling the callback delegate, set to 0 to get every update

    | Improve this Doc View Source

    CopyStream(Stream, Stream, Boolean)

    Copies the content of a stream into another stream.

    Declaration
    public static void CopyStream(Stream source, Stream target, bool rewind)
    Parameters
    Type Name Description
    System.IO.Stream source

    The source stream

    System.IO.Stream target

    The target stream

    System.Boolean rewind

    True if the source stream should be rewound before being copied

    | Improve this Doc View Source

    CreateDefaultLayer(IServerConnection, LayerType)

    Creates a layer definition at the highest supported resource version

    Declaration
    public static ILayerDefinition CreateDefaultLayer(IServerConnection conn, LayerType layerType)
    Parameters
    Type Name Description
    IServerConnection conn
    LayerType layerType
    Returns
    Type Description
    ILayerDefinition
    | Improve this Doc View Source

    CreateDefaultLayer(IServerConnection, String, ClassDefinition, String)

    Creates a default Layer Definition from the given Class Definition

    Declaration
    public static string CreateDefaultLayer(IServerConnection conn, string fsId, ClassDefinition clsDef, string targetFolder)
    Parameters
    Type Name Description
    IServerConnection conn
    System.String fsId
    ClassDefinition clsDef
    System.String targetFolder
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    CreateFlexibleLayout(IServerConnection, String, Boolean)

    Creates a flexible layout

    Declaration
    public static IApplicationDefinition CreateFlexibleLayout(IServerConnection conn, string templateName, bool statelessMode = false)
    Parameters
    Type Name Description
    IServerConnection conn
    System.String templateName
    System.Boolean statelessMode

    If true, the widget set will only be populated with widgets that can work without a running MapGuide Server

    Returns
    Type Description
    IApplicationDefinition
    | Improve this Doc View Source

    CreateMapDefinition(IServerConnection, String)

    Creates a map definition at the highest supported resource version

    Declaration
    public static IMapDefinition CreateMapDefinition(IServerConnection conn, string name)
    Parameters
    Type Name Description
    IServerConnection conn
    System.String name
    Returns
    Type Description
    IMapDefinition
    | Improve this Doc View Source

    CreateMapDefinition(IServerConnection, String, String, IEnvelope)

    Creates a map definition at the highest supported resource version

    Declaration
    public static IMapDefinition CreateMapDefinition(IServerConnection conn, string name, string csWkt, IEnvelope extent)
    Parameters
    Type Name Description
    IServerConnection conn
    System.String name
    System.String csWkt
    IEnvelope extent
    Returns
    Type Description
    IMapDefinition
    | Improve this Doc View Source

    CreateSimpleSymbol(IServerConnection, String, String)

    Creates a simple symbol definition at the highest supported resource version

    Declaration
    public static ISimpleSymbolDefinition CreateSimpleSymbol(IServerConnection conn, string name, string description)
    Parameters
    Type Name Description
    IServerConnection conn
    System.String name
    System.String description
    Returns
    Type Description
    ISimpleSymbolDefinition
    | Improve this Doc View Source

    CreateWatermarkPreviewMapDefinition(IWatermarkDefinition)

    Creates a preview map definition for the given watermark

    Declaration
    public static IMapDefinition2 CreateWatermarkPreviewMapDefinition(IWatermarkDefinition wmd)
    Parameters
    Type Name Description
    IWatermarkDefinition wmd
    Returns
    Type Description
    IMapDefinition2
    | Improve this Doc View Source

    DecodeFDOName(String)

    Converts FDO encoded characters into their original character.

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

    The FDO encoded string

    Returns
    Type Description
    System.String

    The unencoded version of the string

    Remarks

    FDO names must always be encoded when writing back to attributes in XML configuration documents as it may contain reserved characters that would render the final XML attribute content invalid.

    Consequently, such names must always be decoded when reading from XML configuration documents otherwise these escape characters may still be present after reading

    | Improve this Doc View Source

    EncodeFDOName(String)

    FDO encodes a string

    Declaration
    public static string EncodeFDOName(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.String
    Remarks

    FDO names must always be encoded when writing back to attributes in XML configuration documents as it may contain reserved characters that would render the final XML attribute content invalid.

    Consequently, such names must always be decoded when reading from XML configuration documents otherwise these escape characters may still be present after reading

    | Improve this Doc View Source

    ExplodeThemeIntoFilteredLayers(IServerConnection, ExplodeThemeOptions, LengthyOperationProgressCallBack)

    Explodes a themed layer into filtered sub-layers where each sub-layer is filtered on the individual theme rule's filter

    Declaration
    public static void ExplodeThemeIntoFilteredLayers(IServerConnection conn, ExplodeThemeOptions options, LengthyOperationProgressCallBack progress)
    Parameters
    Type Name Description
    IServerConnection conn
    ExplodeThemeOptions options
    LengthyOperationProgressCallBack progress
    | Improve this Doc View Source

    FdoStringifiyLiteral(String)

    Surrounds the given string with single-quotes. Mainly used for FDO expressions where string literals are required as un-quoted strings will trigger the FDO expression engine.

    Declaration
    public static string FdoStringifiyLiteral(string str)
    Parameters
    Type Name Description
    System.String str
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    FormatSizeString(Int64)

    Formats a number of bytes to a human readable format, ea.: 2.56 Kb

    Declaration
    public static string FormatSizeString(long size)
    Parameters
    Type Name Description
    System.Int64 size

    The size in bytes

    Returns
    Type Description
    System.String

    The human readable string

    | Improve this Doc View Source

    GenerateLayerName(String, String, String, Int32, IVectorRule)

    Generates a unique layer name for a given vector rule

    Declaration
    public static string GenerateLayerName(string layerFormat, string layerName, string scaleRange, int i, IVectorRule rule)
    Parameters
    Type Name Description
    System.String layerFormat
    System.String layerName
    System.String scaleRange
    System.Int32 i
    IVectorRule rule
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetResourceIdPointers(XmlNode)

    Enumerates all xml nodes in the document, and looks for tags or attributes named ResourceId

    Declaration
    public static List<KeyValuePair<XmlNode, string>> GetResourceIdPointers(XmlNode item)
    Parameters
    Type Name Description
    System.Xml.XmlNode item

    The xml item to examine

    Returns
    Type Description
    System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.Xml.XmlNode, System.String>>

    A list with all found elements

    | Improve this Doc View Source

    GetScaleRangeStr(IVectorScaleRange)

    String-ifies a scale range

    Declaration
    public static string GetScaleRangeStr(IVectorScaleRange parentRange)
    Parameters
    Type Name Description
    IVectorScaleRange parentRange
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetStylizationFunctions()

    Returns the list of known FDO stylization expression functions

    Declaration
    public static IEnumerable<IFdoFunctionDefintion> GetStylizationFunctions()
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<IFdoFunctionDefintion>
    | Improve this Doc View Source

    HasOriginalXml(Exception)

    Gets whether the given exception has original xml content attached

    Declaration
    public static bool HasOriginalXml(Exception ex)
    Parameters
    Type Name Description
    System.Exception ex
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    InRange<T>(T, T, T, Boolean)

    Returns true if the given value is in range

    Declaration
    public static bool InRange<T>(T val, T min, T max, bool bInclusive = true)
        where T : IComparable
    Parameters
    Type Name Description
    T val
    T min
    T max
    System.Boolean bInclusive
    Returns
    Type Description
    System.Boolean
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    IsDbXmlError(Exception)

    Gets whether the thrown exception is related to DBXML

    Declaration
    public static bool IsDbXmlError(Exception ex)
    Parameters
    Type Name Description
    System.Exception ex
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsSessionExpiredException(Exception)

    Helper to determine if the given exception is related to session expiry

    Declaration
    public static bool IsSessionExpiredException(Exception ex)
    Parameters
    Type Name Description
    System.Exception ex
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsSuccessfulConnectionTestResult(String)

    Checks if the given result is a successful test connection result

    Declaration
    public static bool IsSuccessfulConnectionTestResult(string sResult)
    Parameters
    Type Name Description
    System.String sResult
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsZero(Double)

    Returns true if this value is zero for all intents and purposes

    Declaration
    public static bool IsZero(this double val)
    Parameters
    Type Name Description
    System.Double val
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsZero(Single)

    Returns true if this value is zero for all intents and purposes

    Declaration
    public static bool IsZero(this float val)
    Parameters
    Type Name Description
    System.Single val
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MakeWktCircle(Double, Double, Double)

    Creates the WKT for the given circle

    Declaration
    public static string MakeWktCircle(double x, double y, double r)
    Parameters
    Type Name Description
    System.Double x
    System.Double y
    System.Double r
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    MakeWktPolygon(Double, Double, Double, Double)

    Creates the polygon WKT for the given bounding box

    Declaration
    public static string MakeWktPolygon(double x1, double y1, double x2, double y2)
    Parameters
    Type Name Description
    System.Double x1
    System.Double y1
    System.Double x2
    System.Double y2
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    ParseHTMLColor(String)

    Parses a color in HTML notation (ea. #ffaabbff)

    Declaration
    public static Color ParseHTMLColor(string color)
    Parameters
    Type Name Description
    System.String color

    The HTML representation of the color

    Returns
    Type Description
    System.Drawing.Color

    The .Net color structure that matches the color

    | Improve this Doc View Source

    ParseHTMLColorARGB(String)

    Parses a color in HTML notation (ea. #ffaabbff)

    Declaration
    public static Color ParseHTMLColorARGB(string color)
    Parameters
    Type Name Description
    System.String color

    The HTML representation of the color

    Returns
    Type Description
    System.Drawing.Color

    The .Net color structure that matches the color

    | Improve this Doc View Source

    ParseHTMLColorRGBA(String)

    Parses a color in HTML notation (ea. #ffaabbff)

    Declaration
    public static Color ParseHTMLColorRGBA(string color)
    Parameters
    Type Name Description
    System.String color

    The HTML representation of the color

    Returns
    Type Description
    System.Drawing.Color

    The .Net color structure that matches the color

    | Improve this Doc View Source

    ParseQueryString(String)

    Parses the given query string to a dictionary

    Declaration
    public static IDictionary<string, string> ParseQueryString(string queryString)
    Parameters
    Type Name Description
    System.String queryString
    Returns
    Type Description
    System.Collections.Generic.IDictionary<System.String, System.String>
    | Improve this Doc View Source

    RemoveUTF8BOM(MemoryStream)

    Creates a copy of the stream, with removed Utf8 BOM, if any

    Declaration
    public static MemoryStream RemoveUTF8BOM(MemoryStream ms)
    Parameters
    Type Name Description
    System.IO.MemoryStream ms

    The stream to fix

    Returns
    Type Description
    System.IO.MemoryStream

    A stream with no Utf8 BOM

    | Improve this Doc View Source

    ReplaceResourceIds(XmlDocument, String, String)

    Replaces all references of the given resource id.

    Declaration
    public static bool ReplaceResourceIds(XmlDocument doc, string srcId, string dstId)
    Parameters
    Type Name Description
    System.Xml.XmlDocument doc

    A resource document. Any replacements will modify the XmlDocument that is passed in

    System.String srcId

    The resource id to replace

    System.String dstId

    The resource id to replace with

    Returns
    Type Description
    System.Boolean

    true if a replacement was made. false if no replacements were made

    | Improve this Doc View Source

    SerializeDigit(Double)

    Turns a decimal value into a string representation in EN-US format

    Declaration
    public static string SerializeDigit(double digit)
    Parameters
    Type Name Description
    System.Double digit

    The value to encode

    Returns
    Type Description
    System.String

    The encoded value

    | Improve this Doc View Source

    SerializeDigit(Single)

    Turns a decimal value into a string representation in EN-US format

    Declaration
    public static string SerializeDigit(float digit)
    Parameters
    Type Name Description
    System.Single digit

    The value to encode

    Returns
    Type Description
    System.String

    The encoded value

    | Improve this Doc View Source

    SerializeHTMLColor(Color, Boolean)

    Returns the HTML ARGB representation of an .Net color structure

    Declaration
    public static string SerializeHTMLColor(Color color, bool includeAlpha)
    Parameters
    Type Name Description
    System.Drawing.Color color

    The color to encode

    System.Boolean includeAlpha

    A flag indicating if the color structures alpha value should be included

    Returns
    Type Description
    System.String

    The HTML representation of the color structure

    | Improve this Doc View Source

    SerializeHTMLColorARGB(Color, Boolean)

    Returns the HTML ARGB representation of an .Net color structure

    Declaration
    public static string SerializeHTMLColorARGB(Color color, bool includeAlpha)
    Parameters
    Type Name Description
    System.Drawing.Color color

    The color to encode

    System.Boolean includeAlpha

    A flag indicating if the color structures alpha value should be included

    Returns
    Type Description
    System.String

    The HTML representation of the color structure

    | Improve this Doc View Source

    SerializeHTMLColorRGBA(Color, Boolean)

    Returns the HTML RGBA representation of an .Net color structure

    Declaration
    public static string SerializeHTMLColorRGBA(Color color, bool includeAlpha)
    Parameters
    Type Name Description
    System.Drawing.Color color

    The color to encode

    System.Boolean includeAlpha

    A flag indicating if the color structures alpha value should be included

    Returns
    Type Description
    System.String

    The HTML representation of the color structure

    | Improve this Doc View Source

    StreamAsArray(Stream)

    Reads all data from a stream, and returns it as a single array. Note that this is very inefficient if the stream is several megabytes long.

    Declaration
    public static byte[] StreamAsArray(Stream s)
    Parameters
    Type Name Description
    System.IO.Stream s

    The stream to exhaust

    Returns
    Type Description
    System.Byte[]

    The streams content as an array

    | Improve this Doc View Source

    StripVersionFromProviderName(String)

    Strips the version component from provider name

    Declaration
    public static string StripVersionFromProviderName(string providername)
    Parameters
    Type Name Description
    System.String providername

    The provider name.

    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    StripWmsMetadata(ResourceDocumentHeaderType)

    Strips known WMS metadata from the given resource document header

    Declaration
    public static void StripWmsMetadata(ResourceDocumentHeaderType header)
    Parameters
    Type Name Description
    ResourceDocumentHeaderType header
    | Improve this Doc View Source

    ThrowAsWebException(Exception)

    This method tries to extract the html content of a WebException. If succesfull, it will return an exception with an error message corresponding to the html text. If not, it will return the original exception object.

    Declaration
    public static Exception ThrowAsWebException(Exception ex)
    Parameters
    Type Name Description
    System.Exception ex

    The exception object to extract from

    Returns
    Type Description
    System.Exception

    A potentially better exeception

    | Improve this Doc View Source

    ToConnectionString(NameValueCollection)

    Converts the specified name value collection into a connection string

    Declaration
    public static string ToConnectionString(NameValueCollection values)
    Parameters
    Type Name Description
    System.Collections.Specialized.NameValueCollection values
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    TransformEnvelope(ICoordinateSystemCatalog, IEnvelope, String, String)

    Transforms the envelope from the given source coordinate system to the given target coordinate system

    Declaration
    public static IEnvelope TransformEnvelope(ICoordinateSystemCatalog csCatalog, IEnvelope env, string srcCsWkt, string dstCsWkt)
    Parameters
    Type Name Description
    ICoordinateSystemCatalog csCatalog

    The connection's associated coordinate system catalog

    IEnvelope env

    The envelope.

    System.String srcCsWkt

    The source coordinate system WKT.

    System.String dstCsWkt

    The destination coordinate system WKT.

    Returns
    Type Description
    IEnvelope
    | Improve this Doc View Source

    XmlDeepCopy(Object)

    Builds a copy of the object by serializing it to xml, and then deserializing it. Please note that this function is has a large overhead.

    Declaration
    public static object XmlDeepCopy(object source)
    Parameters
    Type Name Description
    System.Object source

    The object to copy

    Returns
    Type Description
    System.Object

    A copy of the object

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2009 - 2022 Jackie Ng