Skip to content

Commit

Permalink
Change IndexOf to string indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakov-h committed Jul 2, 2024
1 parent e0b92f4 commit e48345d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ValveKeyValue/ValveKeyValue.Test/Test Data/apisurface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ public sealed class ValveKeyValue.StringTable
public bool Equals(object obj);
protected void Finalize();
public string get_Item(int index);
public int get_Item(string value);
public int GetHashCode();
public Type GetType();
public int IndexOf(string value);
protected object MemberwiseClone();
public void PrepareForSerialization();
public string ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void WriteKeyForNextValue(string name)
{
if (stringTable is not null)
{
writer.Write(stringTable.IndexOf(name));
writer.Write(stringTable[name]);
}
else
{
Expand Down
13 changes: 8 additions & 5 deletions ValveKeyValue/ValveKeyValue/StringTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public string this[int index]
}
}

public int IndexOf(string value)
public int this[string value]
{
if (reverse is null)
get
{
throw new InvalidOperationException("String table has not been prepared for serialization.");
}
if (reverse is null)
{
throw new InvalidOperationException("String table has not been prepared for serialization.");
}

return reverse[value];
return reverse[value];
}
}

public void PrepareForSerialization()
Expand Down

0 comments on commit e48345d

Please sign in to comment.