C# Класс Project290.Storage.GameSaver

Used for saving ordered or unordered game data for up to 256 classes of game saves for any number of users, uniquely identified by a Gamertag.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GameSaver ( string gameTitle, bool columnSortOrder ) : System

Initializes a new instance of the GameSaver class.

GetScore ( string gamertag, int columnIndex ) : int

Gets the score value at the specified column index for the specified gamertag. Returns int.MinValue if there is a problem.

GetScoreBoard ( int columnIndexToSort ) : Scoreboard

Gets the Scoreboard corresponding to this game save data.

MergeBuffer ( byte bufferToMerge ) : void

Merges the specified buffer with this buffer.

Read ( ) : bool

Reads the file and stores it to the buffer. WARNING: This process will overwrite the buffer.

Reset ( ) : void

Resets this instance. This must be called before saving can be done, but unless the storage device is removed, this need only be called once.

SetScore ( string gamertag, int scoreToSet, int columnIndex ) : void

Sets the game data for the specified gamertag with the specified score (value) at the specified score column (index). No change will be made if the ordering constraint for that column index is not satisfied. Note that the changes made by calling this method will not be made until calling the Write() method.

SetScore ( string gamertag, int scoreToSet, int columnIndex, bool overwriteOrdering ) : void

Sets the game data for the specified gamertag with the specified score (value) at the specified score column (index). If overwriteOrdering is true, then the value of that player for this index will be overwritten, and if this value is set to false, then no change will be made if the ordering constraint for that column index is not satisfied. Note that the changes made by calling this method will not be made until calling the Write() method.

Update ( ) : void

Updates this instance.

Write ( ) : bool

Writes the data in the buffer to the file.

Приватные методы

Метод Описание
CheckBuffer ( ) : void

Checks the buffer to make sure it is not brand new. If so, then it sets the size of the columns of the buffer.

GetAllColumnSortOrders ( ) : void

From the buffer data, this writes the column sort orders to the global variable this.columnSortOrder.

GetBlockSize ( ) : int

Gets the number of bytes needed to store a gamertag and the data in the associated columns.

GetColumnSortOrder ( int column ) : bool

Gets the column sort order for the specified column index.

GetDevice ( IAsyncResult result ) : void

Gets the device.

GetGamertag ( byte buffer, int startIndex, int length ) : string

Gets the gamertag from the buffer between the startIndex (inclusive) and startIndex + length (exclusive).

GetGamertag ( int startIndex, int length ) : string

Gets the gamertag from the buffer between the startIndex (inclusive) and startIndex + length (exclusive).

GetGamertagIndex ( int nthGamertag ) : int

Gets the starting index in the buffer of the nth gamertag.

GetValueFromBuffer ( byte buffer, int startingIndex ) : int

Gets the value from buffer.

NumberOfBufferEntries ( ) : int

Gets the number of actual buffer entries.

ReadInBuffer ( IAsyncResult result ) : void

Reads the in buffer.

ReadOverwriteBuffer ( Microsoft.Xna.Framework.Storage.StorageContainer container ) : void

Reads the buffer, and overwrites the content of it.

SetColumnSortOrder ( bool ascending, int column ) : void

Sets the column sort order for the corresponding column, depending on the specified order (ascending or not).

UpdateGamertagLookup ( ) : void

Updates the gamertag lookup table based on the buffer.

WriteData ( IAsyncResult result ) : void

Writes the data.

WriteGamerTag ( byte buffer, string gamertag, int index ) : void

Writes the gamer tag to the buffer at the specified index.

WriteGamerTag ( string gamertag, int index ) : void

Writes the gamer tag to the buffer at the specified index.

WriteInfoToBuffer ( string gamertag, int value, int columnIndex ) : bool

Writes the specified info to the buffer.

Описание методов

GameSaver() публичный Метод

Initializes a new instance of the GameSaver class.
public GameSaver ( string gameTitle, bool columnSortOrder ) : System
gameTitle string The game title. This must be unique for the game, /// as if not, two scoreboards saved on the same console may merge together when /// they should not.
columnSortOrder bool The sort orders. This should be the same length as /// the orderedColumnsToSort array, and true at an index means the scores will /// be sorted from high to low.
Результат System

GetScore() публичный Метод

Gets the score value at the specified column index for the specified gamertag. Returns int.MinValue if there is a problem.
public GetScore ( string gamertag, int columnIndex ) : int
gamertag string The gamertag.
columnIndex int The zero-based column index.
Результат int

GetScoreBoard() публичный Метод

Gets the Scoreboard corresponding to this game save data.
public GetScoreBoard ( int columnIndexToSort ) : Scoreboard
columnIndexToSort int The column index to sort on.
Результат Scoreboard

MergeBuffer() публичный Метод

Merges the specified buffer with this buffer.
public MergeBuffer ( byte bufferToMerge ) : void
bufferToMerge byte The buffer to merge.
Результат void

Read() публичный Метод

Reads the file and stores it to the buffer. WARNING: This process will overwrite the buffer.
public Read ( ) : bool
Результат bool

Reset() публичный Метод

Resets this instance. This must be called before saving can be done, but unless the storage device is removed, this need only be called once.
public Reset ( ) : void
Результат void

SetScore() публичный Метод

Sets the game data for the specified gamertag with the specified score (value) at the specified score column (index). No change will be made if the ordering constraint for that column index is not satisfied. Note that the changes made by calling this method will not be made until calling the Write() method.
public SetScore ( string gamertag, int scoreToSet, int columnIndex ) : void
gamertag string The gamertag.
scoreToSet int The score to write.
columnIndex int Index of the column.
Результат void

SetScore() публичный Метод

Sets the game data for the specified gamertag with the specified score (value) at the specified score column (index). If overwriteOrdering is true, then the value of that player for this index will be overwritten, and if this value is set to false, then no change will be made if the ordering constraint for that column index is not satisfied. Note that the changes made by calling this method will not be made until calling the Write() method.
public SetScore ( string gamertag, int scoreToSet, int columnIndex, bool overwriteOrdering ) : void
gamertag string The gamertag.
scoreToSet int The score to write.
columnIndex int The column index.
overwriteOrdering bool If overwriteOrdering /// is true, then the value of that player for this index will be overwritten, /// and if this value is set to false, then no change will be made if the /// ordering constraint for that column index is not satisfied.
Результат void

Update() публичный Метод

Updates this instance.
public Update ( ) : void
Результат void

Write() публичный Метод

Writes the data in the buffer to the file.
public Write ( ) : bool
Результат bool