Class ResourceIdentifier
This class contains all the required code for maintaining resource identifiers. It has implicit conversions to and from a string, which makes it much easier to use. It has both static methods that operate on strings, as well as a class that can be manipulated.
Inheritance
Inherited Members
Namespace: OSGeo.MapGuide.ObjectModels
Assembly: OSGeo.MapGuide.ObjectModels.dll
Syntax
public class ResourceIdentifier
Constructors
| Improve this Doc View SourceResourceIdentifier(ResourceIdentifier)
Constructs a new ResourceIdentifier, based on an existing one.
Declaration
public ResourceIdentifier(ResourceIdentifier id)
Parameters
Type | Name | Description |
---|---|---|
ResourceIdentifier | id | The resource identifier to copy |
ResourceIdentifier(String)
Constructs a new ResourceIdentifier with the given full path
Declaration
public ResourceIdentifier(string resourceId)
Parameters
Type | Name | Description |
---|---|---|
System.String | resourceId | The path of the resource to refence |
ResourceIdentifier(String, ResourceTypes)
Constructs a new library based resource identifier
Declaration
public ResourceIdentifier(string name, ResourceTypes type)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the resource, may include path information with the "/" character |
ResourceTypes | type | The type of resource the identifier names |
ResourceIdentifier(String, ResourceTypes, String)
Constructs a new session based resource identifier
Declaration
public ResourceIdentifier(string name, ResourceTypes type, string sessionId)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the resource, may include path information with the "/" character |
ResourceTypes | type | The type of resource the identifier names |
System.String | sessionId | The session id to use |
Properties
| Improve this Doc View SourceExtension
Gets or sets the extension of the resourceId
Declaration
public string Extension { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Fullname
Gets or sets the name and extension of the resource
Declaration
public string Fullname { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Fullpath
Gets the full path of the resource, that is the path without repository information
Declaration
public string Fullpath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
IsEmpty
Gets a value indicating if the resource is blank
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsFolder
Gets a value indicating if the resource identifier points to a folder
Declaration
public bool IsFolder { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsInLibrary
Gets a value indicating if the resource is in the library repository
Declaration
public bool IsInLibrary { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsInSessionRepository
Gets a value indicating if the resource is in the session repository
Declaration
public bool IsInSessionRepository { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsValid
Gets a value indicating if the resource identifier is valid
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Length
Gets the length of the resource identifier as a string
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Name
Gets or sets the name of the resource
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ParentFolder
Gets the containing folder path for the resource, including the repository
Declaration
public string ParentFolder { get; }
Property Value
Type | Description |
---|---|
System.String |
Path
Gets the path of the resource, that is the path without repository information and no extension
Declaration
public string Path { get; set; }
Property Value
Type | Description |
---|---|
System.String |
RepositoryPath
Gets or sets the path to the resource, including the repository
Declaration
public string RepositoryPath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ResourceId
Gets or sets the full resource identifier
Declaration
public string ResourceId { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ResourceType
Gets the resource type
Declaration
public string ResourceType { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceConvertToLibrary()
Converts this instance to be in the library repository
Declaration
public void ConvertToLibrary()
ConvertToLibrary(String)
Converts a resource id to be placed in the library
Declaration
public static string ConvertToLibrary(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to convert |
Returns
Type | Description |
---|---|
System.String | The converted identifier |
ConvertToSession(String)
Converts this instance to be in the session repository
Declaration
public void ConvertToSession(string sessionId)
Parameters
Type | Name | Description |
---|---|---|
System.String | sessionId | The sessionid |
ConvertToSession(String, String)
Converts a resource id to be placed in the library
Declaration
public static string ConvertToSession(string identifier, string sessionId)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to convert |
System.String | sessionId | The session id of the repository it should be placed in |
Returns
Type | Description |
---|---|
System.String | The converted identifier |
GetFullname(String)
Gets the name and extension of the identifier
Declaration
public static string GetFullname(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to extract the information from |
Returns
Type | Description |
---|---|
System.String | The full name of the identifier |
GetFullpath(String)
Returns the full path of the resource, that is the resourceId without the repository information
Declaration
public static string GetFullpath(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to get the path from |
Returns
Type | Description |
---|---|
System.String | The path of the identifier |
GetName(String)
Gets the name of a resource, given its identifier
Declaration
public static string GetName(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to look for |
Returns
Type | Description |
---|---|
System.String | The name of the resource |
GetParentFolder(String)
Gets the parent folder.
Declaration
public static string GetParentFolder(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier. |
Returns
Type | Description |
---|---|
System.String |
GetPath(String)
Returns the path of the resource, that is the resourceId without the repository information and extension
Declaration
public static string GetPath(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to get the path from |
Returns
Type | Description |
---|---|
System.String | The path of the identifier |
GetRepository(String)
Gets the repository part of a resource identifier, eg.: "Library://" or "Session:xxxx//"
Declaration
public static string GetRepository(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier |
Returns
Type | Description |
---|---|
System.String |
GetRepositoryPath(String)
Returns the path that contains the resource, including the repository
Declaration
public static string GetRepositoryPath(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The resource identifier to use |
Returns
Type | Description |
---|---|
System.String | The folder for the identifier |
GetResourceTypeAsString(String)
Gets the type of this resource.
Declaration
public static string GetResourceTypeAsString(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier |
Returns
Type | Description |
---|---|
System.String |
Remarks
Use this method over OSGeo.MapGuide.MaestroAPI.Resource.ResourceIdentifier.GetResourceType if the Maestro API may not be aware of the new resource type
GetSessionID(String)
Gets the session id from a resource identifier. Must be a valid session-based id, otherwise null is returned
Declaration
public static string GetSessionID(string resourceId)
Parameters
Type | Name | Description |
---|---|---|
System.String | resourceId |
Returns
Type | Description |
---|---|
System.String |
IsFolderResource(String)
Returns a value indicating if the resource points to a folder
Declaration
public static bool IsFolderResource(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to evaluate |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating if the resource points to a folder |
IsSessionBased(String)
Determines whether this resource id is session-based
Declaration
public static bool IsSessionBased(string resourceID)
Parameters
Type | Name | Description |
---|---|---|
System.String | resourceID | The resource ID. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Normalize()
Normalizes the identifier, that is prepends a slash if the identifier points to a folder
Declaration
public void Normalize()
Normalize(String)
Normalizes a identifier, that is prepends a slash if it is a folder resource
Declaration
public static string Normalize(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to normalize |
Returns
Type | Description |
---|---|
System.String | The normalized identifier |
SetExtension(String, String)
Changes the extension of the given resource
Declaration
public static string SetExtension(string identifier, string newextension)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to change the extension for |
System.String | newextension | The new extension to use |
Returns
Type | Description |
---|---|
System.String | The renmaed identifier |
SetName(String, String)
Sets the name of the resource, with or without the extension
Declaration
public static string SetName(string identifier, string newname)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to give a new name |
System.String | newname | The new name to assign |
Returns
Type | Description |
---|---|
System.String | The renamed identifier |
SetPath(String, String)
Sets the path of the identifier, with or without the extension
Declaration
public static string SetPath(string identifier, string newpath)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to update |
System.String | newpath | The new path to user, with or without the extension |
Returns
Type | Description |
---|---|
System.String | The new identifier |
SetRepositoryPath(String, String)
Sets the path including the repository to the given value
Declaration
public static string SetRepositoryPath(string identifier, string folder)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to change the folder for |
System.String | folder | The new folder |
Returns
Type | Description |
---|---|
System.String | An identifier in the new folder |
ToString()
Returns the full resource id as a string
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | The full resource id as a string |
Overrides
Validate(String, ResourceTypes)
Determines if a resource identifier is valid and of the desired type
Declaration
public static bool Validate(string identifier, ResourceTypes type)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to validate |
ResourceTypes | type | The type the resource identifer must be |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating if the identifier is valid |
Validate(String, Boolean)
Determines if a resource identifier is valid
Declaration
public static bool Validate(string identifier, bool strict = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to validate |
System.Boolean | strict | If true, will check if the type of the resource id is one that is supported by Maestro |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating if the identifier is valid |
Operators
| Improve this Doc View SourceImplicit(ResourceIdentifier to String)
Helper operator that makes using the resource identifiers easier
Declaration
public static implicit operator string (ResourceIdentifier id)
Parameters
Type | Name | Description |
---|---|---|
ResourceIdentifier | id | The id to convert to a string |
Returns
Type | Description |
---|---|
System.String | The converted string |
Implicit(String to ResourceIdentifier)
Helper operator that makes using the resource identifiers easier
Declaration
public static implicit operator ResourceIdentifier(string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | The id to convert into a resource indetifier class |
Returns
Type | Description |
---|---|
ResourceIdentifier | The resource identifier |