-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from BoBoBaSs84/39-refac-implement-the-members…
…-of-inotifypropertychanged-interface Done.
- Loading branch information
Showing
9 changed files
with
180 additions
and
144 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Los.Santos.Dope.Wars.Classes.BaseTypes; | ||
|
||
/// <summary> | ||
/// The <see cref="NotifyBase"/> class. | ||
/// <remarks> | ||
/// The <see cref="NotifyBase"/> class implements the following interfaces: | ||
/// <list type="bullet"> | ||
/// <item>The members of the <see cref="INotifyPropertyChanged"/> interface.</item> | ||
/// <item>The members of the <see cref="INotifyPropertyChanging"/> interface.</item> | ||
/// </list> | ||
/// </remarks> | ||
/// </summary> | ||
public abstract class NotifyBase : INotifyPropertyChanged, INotifyPropertyChanging | ||
{ | ||
/// <summary> | ||
/// Sets a new value for a property and notifies about the change. | ||
/// </summary> | ||
/// <remarks> | ||
/// Will throw an exception of type <see cref="ArgumentNullException"/> if <paramref name="propertyName"/> is <see langword="null"/>. | ||
/// </remarks> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="field">The referenced field.</param> | ||
/// <param name="newValue">The new value for the property.</param> | ||
/// <param name="propertyName">The property name.</param> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
protected void SetProperty<T>(ref T field, T newValue, [CallerMemberName] string? propertyName = null) | ||
{ | ||
if (propertyName is null) | ||
throw new ArgumentNullException(nameof(propertyName)); | ||
|
||
if (!Equals(field, newValue)) | ||
{ | ||
RaisePropertyChanging(propertyName); | ||
field = newValue; | ||
RaisePropertyChanged(propertyName); | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public event PropertyChangedEventHandler? PropertyChanged; | ||
/// <inheritdoc/> | ||
public event PropertyChangingEventHandler? PropertyChanging; | ||
|
||
/// <summary> | ||
/// The method is used to raise the 'property changed' event. | ||
/// </summary> | ||
/// <remarks> | ||
/// The calling member's name will be used as the parameter. | ||
/// </remarks> | ||
/// <param name="propertyName">The name of the property, can be <see langword="null"/>.</param> | ||
protected virtual void RaisePropertyChanged([CallerMemberName] string? propertyName = null) => | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
|
||
/// <summary> | ||
/// The method is used to raise the 'property changing' event. | ||
/// </summary> | ||
/// <remarks> | ||
/// The calling member's name will be used as the parameter. | ||
/// </remarks> | ||
/// <param name="propertyName">The name of the property, can be <see langword="null"/>.</param> | ||
protected virtual void RaisePropertyChanging([CallerMemberName] string? propertyName = null) => | ||
PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName)); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
namespace Los.Santos.Dope.Wars.Interfaces; | ||
|
||
/// <summary> | ||
/// The <see cref="IPlayerStash"/> interface, provides methods specifically for the player | ||
/// The <see cref="IPlayerStash"/> interface, provides th epublic methods for the player stash. | ||
/// </summary> | ||
public interface IPlayerStash | ||
{ | ||
/// <summary> | ||
/// The <see cref="BuyDrug(string, int, int)"/> method is used to manipulate the player stash | ||
/// The method is used to manipulate the player stash by adding drugs through a buy transaction. | ||
/// </summary> | ||
/// <param name="drugName"></param> | ||
/// <param name="drugQuantity"></param> | ||
/// <param name="drugPrice"></param> | ||
/// <param name="drugName">The name of the drug.</param> | ||
/// <param name="drugQuantity">The quantity / amount of the drug.</param> | ||
/// <param name="drugPrice">The current price of the drug.</param> | ||
void BuyDrug(string drugName, int drugQuantity, int drugPrice); | ||
|
||
/// <summary> | ||
/// The <see cref="SellDrug(string, int, int)"/> method is used to manipulate the player stash | ||
/// The method is used to manipulate the player stash by adding drugs through a sell transaction. | ||
/// </summary> | ||
/// <param name="drugName"></param> | ||
/// <param name="drugQuantity"></param> | ||
/// <param name="drugPrice"></param> | ||
/// <param name="drugName">The name of the drug.</param> | ||
/// <param name="drugQuantity">The quantity / amount of the drug.</param> | ||
/// <param name="drugPrice">The current price of the drug.</param> | ||
void SellDrug(string drugName, int drugQuantity, int drugPrice); | ||
|
||
/// <summary> | ||
/// The <see cref="MoveIntoInventory(string, int, int)"/> method is used to make transfers into player inventories | ||
/// The method is used to make transfers into player inventories by adding drug into a inventory. | ||
/// </summary> | ||
/// <param name="drugName"></param> | ||
/// <param name="drugQuantity"></param> | ||
/// <param name="drugPrice"></param> | ||
/// <param name="drugName">The name of the drug.</param> | ||
/// <param name="drugQuantity">The quantity / amount of the drug.</param> | ||
/// <param name="drugPrice">The current price of the drug.</param> | ||
void MoveIntoInventory(string drugName, int drugQuantity, int drugPrice); | ||
|
||
/// <summary> | ||
/// The <see cref="TakeFromInventory(string, int)"/> method is used to make transfers from player inventories | ||
/// The method is used to make transfers into player inventories by removing drug from a inventory. | ||
/// </summary> | ||
/// <param name="drugName"></param> | ||
/// <param name="drugQuantity"></param> | ||
/// <param name="drugName">The name of the drug.</param> | ||
/// <param name="drugQuantity">The quantity / amount of the drug.</param> | ||
void TakeFromInventory(string drugName, int drugQuantity); | ||
} |
Oops, something went wrong.