다음을 통해 공유


GetDefinition Method

Creates a CatalogDefinition object for the definition specified by the definition.

Namespace:  Microsoft.CommerceServer.Catalog
Assembly:  Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)

Syntax

'Declaration
Public Function GetDefinition ( _
    definitionName As String _
) As CatalogDefinition
'Usage
Dim instance As CatalogContext
Dim definitionName As String
Dim returnValue As CatalogDefinition

returnValue = instance.GetDefinition(definitionName)
public CatalogDefinition GetDefinition(
    string definitionName
)
public:
CatalogDefinition^ GetDefinition(
    String^ definitionName
)
public function GetDefinition(
    definitionName : String
) : CatalogDefinition

Parameters

  • definitionName
    Type: System..::.String
    The name of the definition. Should not be nullNothingnullptra null reference (Nothing in Visual Basic).

Return Value

Type: Microsoft.CommerceServer.Catalog..::.CatalogDefinition
A CatalogDefinition object containing the catalog definition.

Exceptions

Exception Condition
ArgumentNullException

The definitionName is nullNothingnullptra null reference (Nothing in Visual Basic)

ValidationException

The definitionName is an empty string or exceeds 128 characters.

EntityDoesNotExistException

The definition specified by definitionName does not exist in the catalog system.

Remarks

This method creates and returns a CatalogDefinition object for the specified definitionName. You can then call properties on this object to get and set the definition information, add or remove properties from the definition and change the order of properties in the definition. If you make any changes to the CatalogDefinition object you should call the Save method to save the changes to the catalog system.

Examples

This example describes how to get a catalog definition, add a property to it and access the properties in the definition.

private void GetCatalogDefinition(CatalogContext catalogContext, string definitionName)
{
  CatalogDefinition catalogDefinition = catalogContext.GetDefinition(definitionName);
  catalogDefinition.AddProperty("PropertyToAdd", DefinitionPropertyType.NormalProperty);
  catalogDefinition.Save();
  foreach(CatalogDefinitionPropertiesDataSet.CatalogDefinitionProperty catalogDefinitionProperty in catalogDefinition.DefinitionProperties.CatalogDefinitionProperties)
  {
    string propertyName = catalogDefinitionProperty.PropertyName;
    int propertyOrder   = catalogDefinitionProperty.PropertyOrder;
    DefinitionPropertyType propertyType = (DefinitionPropertyType)catalogDefinitionProperty.PropertyType;
  }
}

Permissions

See Also

Reference

CatalogContext Class

CatalogContext Members

Microsoft.CommerceServer.Catalog Namespace