Class CommerceHelper
Implements helper methods for the CommerceLib project.
Inheritance
Inherited Members
Namespace: Mediachase.Commerce.Shared
Assembly: Mediachase.Commerce.dll
Version: 12.17.2Syntax
public static class CommerceHelper
Fields
CodeValidCharacters
Defines the characters that are valid for a product code.
Declaration
public const string CodeValidCharacters = "\\w\\s-_(),."
Field Value
Type | Description |
---|---|
System.String |
Remarks
This is intended to be used as a subset of a Regex - the definition allows regular alphanumerics as well as the symbols -, _, (, ), comma and dot.
Methods
ByteSizeToStr(Int64)
Translates size to string. For instance 1.2 KB instead of 1200, or 200 bytes instead of 200.
Declaration
public static string ByteSizeToStr(long size)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | size | The size in bytes. |
Returns
Type | Description |
---|---|
System.String | String representation of the size converted to bytes, KB or MB. |
CleanUrlField(String)
Cleans the URL field.
Declaration
public static string CleanUrlField(string input)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The input. |
Returns
Type | Description |
---|---|
System.String |
CleanUrlField(String, IUrlSegmentGenerator)
Cleans the URL field.
Declaration
public static string CleanUrlField(string input, IUrlSegmentGenerator urlSegmentGenerator)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The input. |
EPiServer.Web.IUrlSegmentGenerator | urlSegmentGenerator | The URL segment generator. |
Returns
Type | Description |
---|---|
System.String |
ConvertToString(StringCollection, String)
Converts to string.
Declaration
public static string ConvertToString(StringCollection collection, string separator)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.StringCollection | collection | The collection. |
System.String | separator | The separator. |
Returns
Type | Description |
---|---|
System.String |
GetAbsolutePath(String)
Returns absolute path for the specified relative url.
Declaration
public static string GetAbsolutePath(string xsPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | xsPath | The xs path. |
Returns
Type | Description |
---|---|
System.String |
GetAbsoluteThemedPath(String, String)
Gets the absolute themed path.
Declaration
public static string GetAbsoluteThemedPath(string virtualPath, string themeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | virtualPath | The virtual path. |
System.String | themeName | Name of the theme. |
Returns
Type | Description |
---|---|
System.String | Absolute path. |
GetContextParameter(String)
Returns an object with the given name from the current HttpContext.
Declaration
public static object GetContextParameter(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
Returns
Type | Description |
---|---|
System.Object |
GetContextParameter(String, Object)
Returns an object with the given name from the current HttpContext.
Declaration
public static object GetContextParameter(string name, object defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
System.Object | defaultValue | The default value. |
Returns
Type | Description |
---|---|
System.Object |
GetContextParameter<T>(String, T)
Returns an object with the given name from the current HttpContext.
Declaration
public static T GetContextParameter<T>(string name, T defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
T | defaultValue | The default value. |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
HasWriteAccess(DirectoryInfo)
Determines whether [has write access] [the specified index dir].
Declaration
public static bool HasWriteAccess(DirectoryInfo indexDir)
Parameters
Type | Name | Description |
---|---|---|
System.IO.DirectoryInfo | indexDir | The index dir. |
Returns
Type | Description |
---|---|
System.Boolean |
|
RemoveContextParameter(String)
Removes the context parameter.
Declaration
public static void RemoveContextParameter(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
SetContextParameter(String, Object)
Adds specified object to the current HttpContext.
Declaration
public static void SetContextParameter(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
System.Object | value | The value. |
TryParse<T>(Enum, String, out T)
Tries the parse.
Declaration
public static bool TryParse<T>(this Enum theEnum, string valueToParse, out T returnValue)
Parameters
Type | Name | Description |
---|---|---|
System.Enum | theEnum | The enum. |
System.String | valueToParse | The value to parse. |
T | returnValue | The return value. |
Returns
Type | Description |
---|---|
System.Boolean |
Type Parameters
Name | Description |
---|---|
T |