/* * Copyright (c) Contributors, http://opensimulator.org/ See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the OpenSim Project nor the names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Funktion Die Datei definiert das C#-Interface IMoneyManager. Sie legt die Methoden fest, die eine Klasse zur Verwaltung von Geldtransaktionen, Guthaben und Benutzerinformationen implementieren muss. Typische Aufgaben des Interfaces: Abfragen und Ändern von Benutzer-Guthaben (getBalance, withdrawMoney, giveMoney) Hinzufügen und Abfragen von Transaktionen (addTransaction, FetchTransaction) Verwaltung von Benutzern (addUser, addUserInfo, fetchUserInfo, updateUserInfo) Validierung und Ablauf von Transaktionen (ValidateTransfer, SetTransExpired) NullPointer-Checks & Fehlerquellen Interface selbst: Das Interface enthält keine Implementierung. Es ist lediglich eine Methodendefinition. Das bedeutet: Es gibt keine Logik, also auch keine Möglichkeit für NullPointer-Fehler innerhalb dieser Datei. Fehlerquellen oder NullPointer-Probleme hängen ausschließlich von den konkreten Implementierungen dieser Methoden ab. Parameter: Die Methoden nehmen meist Strings, UUIDs, Ints und komplexe Typen wie TransactionData oder UserInfo als Parameter. In einer späteren Implementierung sollte geprüft werden, ob übergebene Objekte (z.B. user, transaction) null sind, bevor darauf zugegriffen wird. Rückgabewerte wie TransactionData oder UserInfo könnten null sein, wenn nichts gefunden wird – auch das ist Sache der Implementierung. Rückgabewerte: Methoden, die Objekte zurückgeben (FetchTransaction, fetchUserInfo), haben keine Angaben, ob sie null zurückgeben dürfen. Das sollte dokumentiert oder in der Implementierung behandelt werden. Zusammenfassung NullPointer-Gefahr: Im Interface selbst nicht möglich, da keine Ausführung erfolgt. Fehlerquellen: Keine im Interface; alle Fehlerquellen und NullPointer-Risiken entstehen erst in den Klassen, die dieses Interface implementieren. Funktion: Definition aller nötigen Methoden zur Verwaltung von Geldtransaktionen und Benutzerinformationen im OpenSim-Kontext. Fazit: Die Datei IMoneyManager.cs ist ein reines Methoden-Interface und enthält keine Logik, die zu NullPointer-Fehlern führen kann. Typische Fehlerquellen und NullPointer sollten in den konkreten Implementierungen der Methoden sorgfältig behandelt werden (z.B. Nullprüfungen auf Parameter, Rückgabewerte). */ #pragma warning disable IDE1006 using OpenMetaverse; namespace OpenSim.Data.MySQL.MySQLMoneyDataWrapper { public interface IMoneyManager { /// Gets the balance. /// The user identifier. int getBalance(string userID); /// Withdraws the money. /// The transaction identifier. /// The sender identifier. /// The amount. bool withdrawMoney(UUID transactionID, string senderID, int amount); /// Gives the money. /// The transaction identifier. /// The receiver identifier. /// The amount. bool giveMoney(UUID transactionID, string receiverID, int amount); /// Adds the transaction. /// The transaction. bool addTransaction(TransactionData transaction); /// Updates the transaction status. /// The transaction identifier. /// The status. /// The description. bool updateTransactionStatus(UUID transactionID, int status, string description); /// Fetches the transaction. /// The transaction identifier. TransactionData FetchTransaction(UUID transactionID); /// Fetches the transaction. /// The user identifier. /// The start time. /// The end time. /// The index. /// The ret number. TransactionData[] FetchTransaction(string userID, int startTime, int endTime, uint index, uint retNum); /// Gets the transaction number. /// The user identifier. /// The start time. /// The end time. int getTransactionNum(string userID, int startTime, int endTime); /// Adds the user. /// The user identifier. /// The balance. /// The status. /// The type. bool addUser(string userID, int balance, int status, int type); /// Sets the trans expired. /// The dead time. bool SetTransExpired(int deadTime); /// Validates the transfer. /// The secure code. /// The transaction identifier. bool ValidateTransfer(string secureCode, UUID transactionID); /// Adds the user information. /// The user. bool addUserInfo(UserInfo user); /// Fetches the user information. /// The user identifier. UserInfo fetchUserInfo(string userID); /// Updates the user information. /// The user. bool updateUserInfo(UserInfo user); } }