public string ToString(string format, IFormatProvider formatProvider)
{
if (format == null)
{
StringBuilder path = new StringBuilder();
// write the reference type component.
switch (m_elementType)
{
case ElementType.AnyHierarchical:
{
path.Append('/');
break;
}
case ElementType.AnyComponent:
{
path.Append('.');
break;
}
case ElementType.ForwardReference:
case ElementType.InverseReference:
{
if (m_referenceTypeName != null && !String.IsNullOrEmpty(m_referenceTypeName.Name))
{
path.Append('<');
if (!m_includeSubtypes)
{
path.Append('#');
}
if (m_elementType == ElementType.InverseReference)
{
path.Append('!');
}
if (m_referenceTypeName.NamespaceIndex != 0)
{
path.AppendFormat("{0}:", m_referenceTypeName.NamespaceIndex);
}
EncodeName(path, m_referenceTypeName.Name);
path.Append('>');
}
break;
}
}
// write the target browse name component.
if (m_targetName != null && !String.IsNullOrEmpty(m_targetName.Name))
{
if (m_targetName.NamespaceIndex != 0)
{
path.AppendFormat("{0}:", m_targetName.NamespaceIndex);
}
EncodeName(path, m_targetName.Name);
}
return path.ToString();
}
throw new FormatException(Utils.Format("Invalid format string: '{0}'.", format));
}
#endregion