本文整理汇总了C#中StringTable.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# StringTable.GetString方法的具体用法?C# StringTable.GetString怎么用?C# StringTable.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTable
的用法示例。
在下文中一共展示了StringTable.GetString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportServerIndex
/// <summary>
/// Exports a server index.
/// </summary>
private uint ExportServerIndex(uint serverIndex, StringTable serverUris)
{
// nothing special required for indexes 0.
if (serverIndex <= 0)
{
return serverIndex;
}
// return a bad value if parameters are bad.
if (serverUris == null || serverUris.Count < serverIndex)
{
return UInt16.MaxValue;
}
// find an existing index.
int count = 1;
string targetUri = serverUris.GetString(serverIndex);
if (this.ServerUris != null)
{
for (int ii = 0; ii < this.ServerUris.Length; ii++)
{
if (this.ServerUris[ii] == targetUri)
{
return (ushort)(ii + 1); // add 1 to adjust for the well-known URIs which are not stored.
}
}
count += this.ServerUris.Length;
}
// add a new entry.
string[] uris = new string[count];
if (this.ServerUris != null)
{
Array.Copy(this.ServerUris, uris, count - 1);
}
uris[count-1] = targetUri;
this.ServerUris = uris;
// return the new index.
return (ushort)count;
}
示例2: InitializeRemoteToLocalMapping
/// <summary>
/// Initializes the remote to local mapping for a pair of string tables.
/// </summary>
/// <param name="localTable">The local table.</param>
/// <param name="remoteTable">The remote table.</param>
/// <returns>The mapping.</returns>
private int[] InitializeRemoteToLocalMapping(List<string> localTable, StringTable remoteTable)
{
List<int> indexes = new List<int>();
indexes.Add(0);
if (remoteTable is NamespaceTable)
{
indexes.Add(1);
}
int start = indexes.Count;
for (int ii = start; ii < remoteTable.Count; ii++)
{
string uri = remoteTable.GetString((uint)ii);
// look for the matching local index.
bool found = false;
for (int jj = 0; jj < localTable.Count; jj++)
{
if (localTable[jj] == uri)
{
found = true;
indexes.Add(jj+start);
break;
}
}
// not found.
if (!found)
{
localTable.Add(uri);
indexes.Add(localTable.Count-1+start);
}
}
// return the indexes.
return indexes.ToArray();
}