Skip to content

Commit

Permalink
Simplify member access
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 committed Jun 5, 2024
1 parent 8f0c159 commit b72d868
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 129 deletions.
40 changes: 20 additions & 20 deletions QRCoder/PayloadGenerator/BezahlCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
throw new BezahlCodeException("When using 'periodicsinglepaymentsepa' as authority type, the parameters 'periodicTimeunit' and 'periodicTimeunitRotation' must be set.");
}

this._authority = authority;
_authority = authority;

if (name.Length > 70)
throw new BezahlCodeException("(Payee-)Name must be shorter than 71 chars.");
this._name = name;
_name = name;

if (reason.Length > 27)
throw new BezahlCodeException("Reasons texts have to be shorter than 28 chars.");
this._reason = reason;
_reason = reason;

var oldWayFilled = (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(bnc));
var newWayFilled = (!string.IsNullOrEmpty(iban) && !string.IsNullOrEmpty(bic));
Expand All @@ -161,16 +161,16 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
#pragma warning restore CS0612
if (!Regex.IsMatch(account.Replace(" ", ""), @"^[0-9]{1,9}$"))
throw new BezahlCodeException("The account entered isn't valid.");
this._account = account.Replace(" ", "").ToUpper();
_account = account.Replace(" ", "").ToUpper();
if (!Regex.IsMatch(bnc.Replace(" ", ""), @"^[0-9]{1,9}$"))
throw new BezahlCodeException("The bnc entered isn't valid.");
this._bnc = bnc.Replace(" ", "").ToUpper();
_bnc = bnc.Replace(" ", "").ToUpper();

if (authority != AuthorityType.contact && authority != AuthorityType.contact_v2)
{
if (postingKey < 0 || postingKey >= 100)
throw new BezahlCodeException("PostingKey must be within 0 and 99.");
this._postingKey = postingKey;
_postingKey = postingKey;
}
}

Expand All @@ -179,25 +179,25 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
{
if (!IsValidIban(iban))
throw new BezahlCodeException("The IBAN entered isn't valid.");
this._iban = iban.Replace(" ", "").ToUpper();
_iban = iban.Replace(" ", "").ToUpper();
if (!IsValidBic(bic))
throw new BezahlCodeException("The BIC entered isn't valid.");
this._bic = bic.Replace(" ", "").ToUpper();
_bic = bic.Replace(" ", "").ToUpper();

if (authority != AuthorityType.contact_v2)
{
if (sepaReference.Length > 35)
throw new BezahlCodeException("SEPA reference texts have to be shorter than 36 chars.");
this._sepaReference = sepaReference;
_sepaReference = sepaReference;

if (!string.IsNullOrEmpty(creditorId) && !Regex.IsMatch(creditorId.Replace(" ", ""), @"^[a-zA-Z]{2,2}[0-9]{2,2}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){3,3}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,28}$"))
throw new BezahlCodeException("The creditorId entered isn't valid.");
this._creditorId = creditorId;
_creditorId = creditorId;
if (!string.IsNullOrEmpty(mandateId) && !Regex.IsMatch(mandateId.Replace(" ", ""), @"^([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,35}$"))
throw new BezahlCodeException("The mandateId entered isn't valid.");
this._mandateId = mandateId;
_mandateId = mandateId;
if (dateOfSignature != null)
this._dateOfSignature = (DateTime)dateOfSignature;
_dateOfSignature = (DateTime)dateOfSignature;
}
}

Expand All @@ -208,32 +208,32 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
throw new BezahlCodeException("Amount must have less than 3 digits after decimal point.");
if (amount < 0.01m || amount > 999999999.99m)
throw new BezahlCodeException("Amount has to at least 0.01 and must be smaller or equal to 999999999.99.");
this._amount = amount;
_amount = amount;

this._currency = currency;
_currency = currency;

if (executionDate == null)
this._executionDate = DateTime.Now;
_executionDate = DateTime.Now;
else
{
if (DateTime.Today.Ticks > executionDate.Value.Ticks)
throw new BezahlCodeException("Execution date must be today or in future.");
this._executionDate = (DateTime)executionDate;
_executionDate = (DateTime)executionDate;
}
#pragma warning disable CS0612
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.periodicsinglepaymentsepa)
#pragma warning restore CS0612
{
if (periodicTimeunit.ToUpper() != "M" && periodicTimeunit.ToUpper() != "W")
throw new BezahlCodeException("The periodicTimeunit must be either 'M' (monthly) or 'W' (weekly).");
this._periodicTimeunit = periodicTimeunit;
_periodicTimeunit = periodicTimeunit;
if (periodicTimeunitRotation < 1 || periodicTimeunitRotation > 52)
throw new BezahlCodeException("The periodicTimeunitRotation must be 1 or greater. (It means repeat the payment every 'periodicTimeunitRotation' weeks/months.");
this._periodicTimeunitRotation = periodicTimeunitRotation;
_periodicTimeunitRotation = periodicTimeunitRotation;
if (periodicFirstExecutionDate != null)
this._periodicFirstExecutionDate = (DateTime)periodicFirstExecutionDate;
_periodicFirstExecutionDate = (DateTime)periodicFirstExecutionDate;
if (periodicLastExecutionDate != null)
this._periodicLastExecutionDate = (DateTime)periodicLastExecutionDate;
_periodicLastExecutionDate = (DateTime)periodicLastExecutionDate;
}

}
Expand Down
10 changes: 5 additions & 5 deletions QRCoder/PayloadGenerator/BitcoinLikeCryptoCurrencyAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ public class BitcoinLikeCryptoCurrencyAddress : Payload
/// <param name="message">A reference text or message.</param>
public BitcoinLikeCryptoCurrencyAddress(BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string? label = null, string? message = null)
{
this._currencyType = currencyType;
this._address = address;
_currencyType = currencyType;
_address = address;

if (!string.IsNullOrEmpty(label))
{
this._label = Uri.EscapeDataString(label);
_label = Uri.EscapeDataString(label);
}

if (!string.IsNullOrEmpty(message))
{
this._message = Uri.EscapeDataString(message);
_message = Uri.EscapeDataString(message);
}

this._amount = amount;
_amount = amount;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions QRCoder/PayloadGenerator/Bookmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class Bookmark : Payload
/// <param name="title">The title of the bookmark.</param>
public Bookmark(string url, string title)
{
this._url = EscapeInput(url);
this._title = EscapeInput(title);
_url = EscapeInput(url);
_title = EscapeInput(title);
}

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions QRCoder/PayloadGenerator/CalendarEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public CalendarEvent(string subject, string? description, string? location, Date
/// <param name="encoding">Type of encoding (universal or iCal).</param>
public CalendarEvent(string subject, string? description, string? location, DateTime start, DateTime end, bool allDayEvent, EventEncoding encoding = EventEncoding.Universal)
{
this._subject = subject;
this._description = description;
this._location = location;
this._encoding = encoding;
_subject = subject;
_description = description;
_location = location;
_encoding = encoding;
string dtFormatStart = "yyyyMMdd", dtFormatEnd = "yyyyMMdd";
if (!allDayEvent)
{
Expand All @@ -52,8 +52,8 @@ public CalendarEvent(string subject, string? description, string? location, Date
if (end.Kind == DateTimeKind.Utc)
dtFormatEnd = "yyyyMMddTHHmmssZ";
}
this._start = start.ToString(dtFormatStart);
this._end = end.ToString(dtFormatEnd);
_start = start.ToString(dtFormatStart);
_end = end.ToString(dtFormatEnd);
}

/// <summary>
Expand Down
40 changes: 20 additions & 20 deletions QRCoder/PayloadGenerator/ContactData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,26 @@ public class ContactData : Payload
/// <param name="orgTitle">Organization/Company Title.</param>
public ContactData(ContactOutputType outputType, string firstname, string lastname, string? nickname = null, string? phone = null, string? mobilePhone = null, string? workPhone = null, string? email = null, DateTime? birthday = null, string? website = null, string? street = null, string? houseNumber = null, string? city = null, string? zipCode = null, string? country = null, string? note = null, string? stateRegion = null, AddressOrder addressOrder = AddressOrder.Default, string? org = null, string? orgTitle = null)
{
this._firstname = firstname;
this._lastname = lastname;
this._nickname = nickname;
this._org = org;
this._orgTitle = orgTitle;
this._phone = phone;
this._mobilePhone = mobilePhone;
this._workPhone = workPhone;
this._email = email;
this._birthday = birthday;
this._website = website;
this._street = street;
this._houseNumber = houseNumber;
this._city = city;
this._stateRegion = stateRegion;
this._zipCode = zipCode;
this._country = country;
this._addressOrder = addressOrder;
this._note = note;
this._outputType = outputType;
_firstname = firstname;
_lastname = lastname;
_nickname = nickname;
_org = org;
_orgTitle = orgTitle;
_phone = phone;
_mobilePhone = mobilePhone;
_workPhone = workPhone;
_email = email;
_birthday = birthday;
_website = website;
_street = street;
_houseNumber = houseNumber;
_city = city;
_stateRegion = stateRegion;
_zipCode = zipCode;
_country = country;
_addressOrder = addressOrder;
_note = note;
_outputType = outputType;
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions QRCoder/PayloadGenerator/Geolocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public class Geolocation : Payload
/// <param name="encoding">Encoding type - GEO or GoogleMaps.</param>
public Geolocation(string latitude, string longitude, GeolocationEncoding encoding = GeolocationEncoding.GEO)
{
this._latitude = latitude.Replace(",", ".");
this._longitude = longitude.Replace(",", ".");
this._encoding = encoding;
_latitude = latitude.Replace(",", ".");
_longitude = longitude.Replace(",", ".");
_encoding = encoding;
}

/// <summary>
Expand Down
20 changes: 10 additions & 10 deletions QRCoder/PayloadGenerator/Girocode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,34 @@ public class Girocode : Payload
/// <exception cref="GirocodeException">Thrown when the input values are not valid according to the Girocode specification.</exception>
public Girocode(string iban, string bic, string name, decimal amount, string remittanceInformation = "", TypeOfRemittance typeOfRemittance = TypeOfRemittance.Unstructured, string purposeOfCreditTransfer = "", string messageToGirocodeUser = "", GirocodeVersion version = GirocodeVersion.Version1, GirocodeEncoding encoding = GirocodeEncoding.ISO_8859_1)
{
this._version = version;
this._encoding = encoding;
_version = version;
_encoding = encoding;
if (!IsValidIban(iban))
throw new GirocodeException("The IBAN entered isn't valid.");
this._iban = iban.Replace(" ", "").ToUpper();
_iban = iban.Replace(" ", "").ToUpper();
if (!IsValidBic(bic))
throw new GirocodeException("The BIC entered isn't valid.");
this._bic = bic.Replace(" ", "").ToUpper();
_bic = bic.Replace(" ", "").ToUpper();
if (name.Length > 70)
throw new GirocodeException("(Payee-)Name must be shorter than 71 chars.");
this._name = name;
_name = name;
if (amount.ToString().Replace(",", ".").Contains(".") && amount.ToString().Replace(",", ".").Split('.')[1].TrimEnd('0').Length > 2)
throw new GirocodeException("Amount must have less than 3 digits after decimal point.");
if (amount < 0.01m || amount > 999999999.99m)
throw new GirocodeException("Amount has to be at least 0.01 and must be smaller or equal to 999999999.99.");
this._amount = amount;
_amount = amount;
if (purposeOfCreditTransfer.Length > 4)
throw new GirocodeException("Purpose of credit transfer can only have 4 chars at maximum.");
this._purposeOfCreditTransfer = purposeOfCreditTransfer;
_purposeOfCreditTransfer = purposeOfCreditTransfer;
if (typeOfRemittance == TypeOfRemittance.Unstructured && remittanceInformation.Length > 140)
throw new GirocodeException("Unstructured reference texts have to be shorter than 141 chars.");
if (typeOfRemittance == TypeOfRemittance.Structured && remittanceInformation.Length > 35)
throw new GirocodeException("Structured reference texts have to be shorter than 36 chars.");
this._typeOfRemittance = typeOfRemittance;
this._remittanceInformation = remittanceInformation;
_typeOfRemittance = typeOfRemittance;
_remittanceInformation = remittanceInformation;
if (messageToGirocodeUser.Length > 70)
throw new GirocodeException("Message to the Girocode-User reader texts have to be shorter than 71 chars.");
this._messageToGirocodeUser = messageToGirocodeUser;
_messageToGirocodeUser = messageToGirocodeUser;
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions QRCoder/PayloadGenerator/MMS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public class MMS : Payload
/// <param name="encoding">Encoding type.</param>
public MMS(string number, MMSEncoding encoding = MMSEncoding.MMS)
{
this._number = number;
_number = number;
_subject = string.Empty;
this._encoding = encoding;
_encoding = encoding;
}

/// <summary>
Expand All @@ -32,9 +32,9 @@ public MMS(string number, MMSEncoding encoding = MMSEncoding.MMS)
/// <param name="encoding">Encoding type.</param>
public MMS(string number, string subject, MMSEncoding encoding = MMSEncoding.MMS)
{
this._number = number;
this._subject = subject;
this._encoding = encoding;
_number = number;
_subject = subject;
_encoding = encoding;
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions QRCoder/PayloadGenerator/Mail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public class Mail : Payload
/// <param name="encoding">Payload encoding type. Choose dependent on your QR Code scanner app.</param>
public Mail(string? mailReceiver = null, string? subject = null, string? message = null, MailEncoding encoding = MailEncoding.MAILTO)
{
this._mailReceiver = mailReceiver;
this._subject = subject;
this._message = message;
this._encoding = encoding;
_mailReceiver = mailReceiver;
_subject = subject;
_message = message;
_encoding = encoding;
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions QRCoder/PayloadGenerator/MoneroTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public MoneroTransaction(string address, float? txAmount = null, string? txPayme
{
if (string.IsNullOrEmpty(address))
throw new MoneroTransactionException("The address is mandatory and has to be set.");
this._address = address;
_address = address;
if (txAmount != null && txAmount <= 0)
throw new MoneroTransactionException("Value of 'txAmount' must be greater than 0.");
this._txAmount = txAmount;
this._txPaymentId = txPaymentId;
this._recipientName = recipientName;
this._txDescription = txDescription;
_txAmount = txAmount;
_txPaymentId = txPaymentId;
_recipientName = recipientName;
_txDescription = txDescription;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion QRCoder/PayloadGenerator/PhoneNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PhoneNumber : Payload
/// <param name="number">Phone number of the receiver.</param>
public PhoneNumber(string number)
{
this._number = number;
_number = number;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion QRCoder/PayloadGenerator/RussiaPaymentOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private RussiaPaymentOrder()
/// <param name="characterSet">Type of encoding (default UTF-8)</param>
public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, OptionalFields? optionalFields = null, CharacterSets characterSet = CharacterSets.utf_8) : this()
{
this._characterSet = characterSet;
_characterSet = characterSet;
_mFields.Name = ValidateInput(name, "Name", @"^.{1,160}$");
_mFields.PersonalAcc = ValidateInput(personalAcc, "PersonalAcc", @"^[1-9]\d{4}[0-9ABCEHKMPTX]\d{14}$");
_mFields.BankName = ValidateInput(bankName, "BankName", @"^.{1,45}$");
Expand Down
10 changes: 5 additions & 5 deletions QRCoder/PayloadGenerator/SMS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public class SMS : Payload
/// <param name="encoding">Encoding type.</param>
public SMS(string number, SMSEncoding encoding = SMSEncoding.SMS)
{
this._number = number;
_number = number;
_subject = string.Empty;
this._encoding = encoding;
_encoding = encoding;
}

/// <summary>
Expand All @@ -32,9 +32,9 @@ public SMS(string number, SMSEncoding encoding = SMSEncoding.SMS)
/// <param name="encoding">Encoding type.</param>
public SMS(string number, string subject, SMSEncoding encoding = SMSEncoding.SMS)
{
this._number = number;
this._subject = subject;
this._encoding = encoding;
_number = number;
_subject = subject;
_encoding = encoding;
}

/// <summary>
Expand Down
Loading

0 comments on commit b72d868

Please sign in to comment.