/**
     * Returns a TransformerItemInput or TransformerItemOutput for the ITransformerItem passed in.
     */

    protected ITransformerItem GetITransformerItemForType(TransformationStringType type, string itemName, int itemCount, double itemProb)
    {
        switch (type)
        {
        case (TransformationStringType.INPUT):
            return(new TransformerItemInput(ItemClass.GetItem(itemName), itemCount));

        case (TransformationStringType.OUTPUT):
            return(new TransformerItemOutput(ItemClass.GetItem(itemName), itemCount, itemProb));

        default:
            throw new Exception("Item property name " + itemName + " is not an input or output string.");
        }
    }
    /**
     *  Converts the property value string into a TransformerItemInput or TransformerItemOutput.
     */

    protected ITransformerItem GetITransformerItemFor(string itemPropName)
    {
        string itemPropData = this.transformationPropClass.Values[itemPropName];

        TransformationStringType type = this.GetType(itemPropName);

        if (type != TransformationStringType.INPUT && type != TransformationStringType.OUTPUT)
        {
            throw new Exception("Item property name " + itemPropName + " is not an input or output string.");
        }

        string itemName  = "";
        int    itemCount = defaultItemCount;
        double itemProb  = defaultItemProb;

        if (!itemPropData.Contains(","))
        {
            itemName  = itemPropData.Trim();
            itemCount = this.defaultItemCount;
        }
        else
        {
            string[] propData = itemPropData.Split(',');
            itemName = propData[0].Trim();
            if (!int.TryParse(propData[1].Trim(), out itemCount))
            {
                Log.Warning("Could not parse " + propData[1] + " as int value. Using default " + this.defaultItemCount + ".");
                itemCount = this.defaultItemCount;
            }

            if (type == TransformationStringType.OUTPUT)
            {
                itemProb = this.defaultItemProb;
                if (propData.GetLength(0) > 2)
                {
                    if (!double.TryParse(propData[2].Trim(), out itemProb))
                    {
                        Log.Warning("Could not parse " + propData[2] + " as a probability double.");
                        itemProb = this.defaultItemProb;
                    }
                }
            }
        }

        return(this.GetITransformerItemForType(type, itemName, itemCount, itemProb));
    }
    /**
     * Adds an element to transformation data.
     */

    protected void AddToTData(Dictionary <int, TransformationData> tData, int transformationIndex, int maxIOIndex, TransformationStringType type)
    {
        string ioString;

        switch (type)
        {
        case (TransformationStringType.INPUT):
            ioString = this.inputString;
            break;

        case (TransformationStringType.OUTPUT):
            ioString = this.outputString;
            break;

        default:
            Log.Warning("Property is not an input or output string. Skipping.");
            return;
        }

        for (int i = 1; i <= maxIOIndex; i += 1)
        {
            string ioProp = this.propValueTransformation + transformationIndex.ToString() + ioString + i.ToString();
            if (!this.transformationPropClass.Values.ContainsKey(ioProp))
            {
                Log.Warning("The following property is not defined: " + ioProp + ". Skipping.");
                continue;
            }

            tData[transformationIndex].Add(this.GetITransformerItemFor(ioProp));
        }
    }