C# Class ESRI.ArcGIS.Client.Toolkit.DataSources.Kml.Zip.SharedUtilities

Collects general purpose utility methods.
ファイルを表示 Open project: Esri/arcgis-toolkit-sl-wpf

Public Methods

Method Description
GetTempFilename ( ) : string

Return a random filename, suitable for use as a temporary file.

The System.IO.Path.GetRandomFileName() method is not available on the Compact Framework, so this library provides its own substitute.

RoundToEvenSecond ( System.DateTime source ) : System.DateTime

Round the given DateTime value to an even second value.

Round up in the case of an odd second value. The rounding does not consider fractional seconds.

This is useful because the Zip spec allows storage of time only to the nearest even second. So if you want to compare the time of an entry in the archive with it's actual time in the filesystem, you need to round the actual filesystem time, or use a 2-second threshold for the comparison.

This is most nautrally an extension method for the DateTime class but this library is built for .NET 2.0, not for .NET 3.5; This means extension methods are a no-no.

StringToMemoryStream ( string s ) : System.IO.MemoryStream

Creates a MemoryStream for the given string. This is used internally by Library, specifically by the ZipFile.AddStringAsFile() method. But it may be useful in other scenarios.

TrimVolumeAndSwapSlashes ( string pathName ) : string

Utility routine for transforming path names.

Protected Methods

Method Description
FindSignature ( System stream, int SignatureToFind ) : long

Finds a signature in the zip stream. This is useful for finding the end of a zip entry, for example.

Private Methods

Method Description
DateTimeToPacked ( System.DateTime time ) : Int32
GenerateRandomStringImpl ( int length, int delta ) : string
GetOneRandomChar ( int delta ) : char
PackedToDateTime ( Int32 packedDateTime ) : System.DateTime
ReadInt ( System s ) : int
ReadSignature ( System s ) : int
SharedUtilities ( ) : System
StringFromBuffer ( byte buf, int maxlength ) : string
StringFromBuffer ( byte buf, int maxlength, System encoding ) : string
StringToByteArray ( string value ) : byte[]
StringToByteArray ( string value, System encoding ) : byte[]
Utf8StringFromBuffer ( byte buf, int maxlength ) : string
Utf8StringToByteArray ( string value ) : byte[]
_ReadFourBytes ( System s, string message ) : int

Method Details

FindSignature() protected static method

Finds a signature in the zip stream. This is useful for finding the end of a zip entry, for example.
protected static FindSignature ( System stream, int SignatureToFind ) : long
stream System
SignatureToFind int
return long

GetTempFilename() public static method

Return a random filename, suitable for use as a temporary file.
The System.IO.Path.GetRandomFileName() method is not available on the Compact Framework, so this library provides its own substitute.
public static GetTempFilename ( ) : string
return string

RoundToEvenSecond() public static method

Round the given DateTime value to an even second value.

Round up in the case of an odd second value. The rounding does not consider fractional seconds.

This is useful because the Zip spec allows storage of time only to the nearest even second. So if you want to compare the time of an entry in the archive with it's actual time in the filesystem, you need to round the actual filesystem time, or use a 2-second threshold for the comparison.

This is most nautrally an extension method for the DateTime class but this library is built for .NET 2.0, not for .NET 3.5; This means extension methods are a no-no.

public static RoundToEvenSecond ( System.DateTime source ) : System.DateTime
source System.DateTime The DateTime value to round
return System.DateTime

StringToMemoryStream() public static method

Creates a MemoryStream for the given string. This is used internally by Library, specifically by the ZipFile.AddStringAsFile() method. But it may be useful in other scenarios.
public static StringToMemoryStream ( string s ) : System.IO.MemoryStream
s string The string to use as input for the MemoryStream
return System.IO.MemoryStream

TrimVolumeAndSwapSlashes() public static method

Utility routine for transforming path names.
public static TrimVolumeAndSwapSlashes ( string pathName ) : string
pathName string source path.
return string