/// <summary> /// Parse the given string as a charging station identification. /// </summary> /// <param name="Text">A text representation of a charging station identification.</param> public static ChargingStation_Id Parse(String Text) { #region Initial checks if (Text.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Text), "The given text representation of a charging station identification must not be null or empty!"); } #endregion var MatchCollection = ChargingStationId_RegEx.Matches(Text); if (MatchCollection.Count != 1) { throw new ArgumentException("Illegal text representation of a charging station identification: '" + Text + "'!", nameof(Text)); } ChargingStationOperator_Id _OperatorId; if (ChargingStationOperator_Id.TryParse(MatchCollection[0].Groups[1].Value, out _OperatorId)) { return(new ChargingStation_Id(_OperatorId, MatchCollection[0].Groups[2].Value)); } throw new ArgumentException("Illegal charging station identification '" + Text + "'!", nameof(Text)); }
/// <summary> /// Create a valid charging pool identification based on the given parameters. /// </summary> /// <param name="OperatorId">The identification of an Charging Station Operator.</param> /// <param name="Address">The address of the charging pool.</param> /// <param name="GeoLocation">The geo location of the charging pool.</param> /// <param name="Length">The maximum size of the generated charging pool identification suffix [12 < n < 50].</param> /// <param name="Mapper">A delegate to modify a generated charging pool identification suffix.</param> public static ChargingPool_Id Generate(ChargingStationOperator_Id OperatorId, Address Address, GeoCoordinate?GeoLocation = null, //String HelperId = "", Byte Length = 15, Func <String, String> Mapper = null) { if (Length < 12) { Length = 12; } if (Length > 50) { Length = 50; } var Suffíx = new SHA1CryptoServiceProvider(). ComputeHash(Encoding.UTF8.GetBytes( String.Concat( OperatorId.ToString(), Address.ToString(), GeoLocation?.ToString() ?? "" //HelperId ?? "" ) )). ToHexString(). SubstringMax(Length). ToUpper(); return(Parse(OperatorId, Mapper != null ? Mapper(Suffíx) : Suffíx)); }
/// <summary> /// Parse the given string as an EVSE identification. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Suffix">The suffix of the EVSE identification.</param> public static EVSE_Id Parse(ChargingStationOperator_Id OperatorId, String Suffix) { switch (OperatorId.Format) { case OperatorIdFormats.ISO: case OperatorIdFormats.ISO_STAR: if (!IdSuffixISO_RegEx.IsMatch(Suffix)) { throw new ArgumentException("Illegal EVSE identification suffix '" + Suffix + "'!", nameof(Suffix)); } return(new EVSE_Id(OperatorId, Suffix)); case OperatorIdFormats.DIN: if (!IdSuffixDIN_RegEx.IsMatch(Suffix)) { throw new ArgumentException("Illegal EVSE identification suffix '" + Suffix + "'!", nameof(Suffix)); } return(new EVSE_Id(OperatorId, Suffix)); } throw new ArgumentException("Illegal EVSE identification suffix '" + Suffix + "'!", nameof(Suffix)); }
/// <summary> /// Create a new status diff. /// </summary> /// <param name="Timestamp">The timestamp of the status diff.</param> /// <param name="EVSEOperatorId">The unique identification of the Charging Station Operator.</param> /// <param name="EVSEOperatorName">The optional internationalized name of the Charging Station Operator.</param> public ChargingPoolAdminStatusDiff(DateTime Timestamp, ChargingStationOperator_Id EVSEOperatorId, I18NString EVSEOperatorName = null) : base(Timestamp, EVSEOperatorId, EVSEOperatorName) { }
/// <summary> /// An exception thrown whenever a charging station operator already exists within the given roaming network. /// </summary> /// <param name="RoamingNetwork">The roaming network.</param> /// <param name="ChargingStationOperatorId">The charging station operator identification.</param> /// <param name="Name">The multi-language name of the charging station operator.</param> public ChargingStationOperatorAlreadyExists(RoamingNetwork RoamingNetwork, ChargingStationOperator_Id ChargingStationOperatorId, I18NString Name) : base(RoamingNetwork, "The given charging station operator identification '" + ChargingStationOperatorId + "' with name '" + Name?.FirstText() + "' already exists within the given '" + RoamingNetwork.Id + "' roaming network!") { }
/// <summary> /// Create a new charging station operator status update. /// </summary> /// <param name="Id">The unique identification of the charging station operator.</param> /// <param name="OldStatus">The old timestamped status of the charging station operator.</param> /// <param name="NewStatus">The new timestamped status of the charging station operator.</param> public ChargingStationOperatorStatusUpdate(ChargingStationOperator_Id Id, ChargingStationOperatorStatus OldStatus, ChargingStationOperatorStatus NewStatus) { this.Id = Id; this.OldStatus = OldStatus.Combined; this.NewStatus = NewStatus.Combined; }
/// <summary> /// Create a new charging station operator status update. /// </summary> /// <param name="Id">The unique identification of the charging station operator.</param> /// <param name="OldStatus">The old timestamped status of the charging station operator.</param> /// <param name="NewStatus">The new timestamped status of the charging station operator.</param> public ChargingStationOperatorStatusUpdate(ChargingStationOperator_Id Id, Timestamped <ChargingStationOperatorStatusTypes> OldStatus, Timestamped <ChargingStationOperatorStatusTypes> NewStatus) { this.Id = Id; this.OldStatus = OldStatus; this.NewStatus = NewStatus; }
/// <summary> /// Create a new charging station operator status. /// </summary> /// <param name="Id">The unique identification of the charging station operator.</param> /// <param name="Status">The current status of the charging station operator.</param> /// <param name="Timestamp">The timestamp of the current status of the charging station operator.</param> public ChargingStationOperatorStatus(ChargingStationOperator_Id Id, ChargingStationOperatorStatusTypes Status, DateTime Timestamp) { this.Id = Id; this.Status = Status; this.Timestamp = Timestamp; }
/// <summary> /// An invalid charging pool operator identification was given. /// </summary> /// <param name="ChargingStationOperator">The charging station operator in which the exception occured.</param> /// <param name="InvalidChargingStationOperatorId">The invalid operator identification.</param> /// <param name="ValidChargingStationOperatorIds">All expected operator identifications.</param> public InvalidChargingPoolOperatorId(ChargingStationOperator ChargingStationOperator, ChargingStationOperator_Id InvalidChargingStationOperatorId, IEnumerable <ChargingStationOperator_Id> ValidChargingStationOperatorIds) : base(ChargingStationOperator, "Invalid charging station operator identification '" + InvalidChargingStationOperatorId + "' where only '" + ValidChargingStationOperatorIds.AggregateWith(", ") + "' are expected!") { }
/// <summary> /// Create a new status diff. /// </summary> /// <param name="Timestamp">The timestamp of the status diff.</param> /// <param name="EVSEOperatorId">The unique identification of the Charging Station Operator.</param> /// <param name="NewStatus">All new status.</param> /// <param name="ChangedStatus">All changed status.</param> /// <param name="RemovedIds">All removed status.</param> /// <param name="EVSEOperatorName">The optional internationalized name of the Charging Station Operator.</param> public ChargingPoolAdminStatusDiff(DateTime Timestamp, ChargingStationOperator_Id EVSEOperatorId, IEnumerable <KeyValuePair <ChargingPool_Id, ChargingPoolAdminStatusTypes> > NewStatus, IEnumerable <KeyValuePair <ChargingPool_Id, ChargingPoolAdminStatusTypes> > ChangedStatus, IEnumerable <ChargingPool_Id> RemovedIds, I18NString EVSEOperatorName = null) : base(Timestamp, EVSEOperatorId, NewStatus, ChangedStatus, RemovedIds, EVSEOperatorName) { }
/// <summary> /// Parse the given string as a charging reservation identification. /// </summary> public static Boolean TryParse(String Text, out ChargingReservation_Id ReservationId) { #region Initial checks if (Text.IsNullOrEmpty()) { ReservationId = default(ChargingReservation_Id); return(false); } #endregion try { ReservationId = default(ChargingReservation_Id); var _MatchCollection = ReservationId_RegEx.Matches(Text); if (_MatchCollection.Count != 1) { return(false); } ChargingStationOperator_Id _OperatorId; // New format... if (ChargingStationOperator_Id.TryParse(_MatchCollection[0].Groups[1].Value, out _OperatorId)) { ReservationId = new ChargingReservation_Id(_OperatorId, _MatchCollection[0].Groups[2].Value); return(true); } if (ChargingStationOperator_Id.TryParse(_MatchCollection[0].Groups[3].Value, out _OperatorId)) { ReservationId = new ChargingReservation_Id(_OperatorId, _MatchCollection[0].Groups[4].Value); return(true); } } #pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception. #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch (Exception e) #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body #pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. { } ReservationId = default(ChargingReservation_Id); return(false); }
/// <summary> /// Create a new status diff. /// </summary> /// <param name="Timestamp">The timestamp of the status diff.</param> /// <param name="EVSEOperatorId">The unique identification of the Charging Station Operator.</param> /// <param name="EVSEOperatorName">The optional internationalized name of the Charging Station Operator.</param> public StatusDiff(DateTime Timestamp, ChargingStationOperator_Id EVSEOperatorId, I18NString EVSEOperatorName = null) { this._Timestamp = Timestamp; this._EVSEOperatorId = EVSEOperatorId; this._NewStatus = NewStatus != null ? new List <KeyValuePair <TId, TStatusType> >(NewStatus) : new List <KeyValuePair <TId, TStatusType> >(); this._ChangedStatus = ChangedStatus != null ? new List <KeyValuePair <TId, TStatusType> >(ChangedStatus) : new List <KeyValuePair <TId, TStatusType> >(); this._RemovedIds = RemovedIds != null ? new List <TId>(RemovedIds) : new List <TId>(); this._EVSEOperatorName = EVSEOperatorName != null ? EVSEOperatorName : new I18NString(); }
/// <summary> /// Parse the given string as a charging station identification. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Suffix">The suffix of the charging station identification.</param> public static ChargingStation_Id Parse(ChargingStationOperator_Id OperatorId, String Suffix) { switch (OperatorId.Format) { case OperatorIdFormats.ISO_STAR: return(Parse(OperatorId.ToString() + "*S" + Suffix)); case OperatorIdFormats.ISO: return(Parse(OperatorId.ToString() + "S" + Suffix)); default: return(Parse(OperatorId.ToString(OperatorIdFormats.ISO_STAR) + "*S" + Suffix)); } }
/// <summary> /// Generate a new charging station identification /// based on the given charging station operator and identification suffix. /// </summary> private ChargingStation_Id(ChargingStationOperator_Id OperatorId, String Suffix) { #region Initial checks if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The charging station identification suffix must not be null or empty!"); } #endregion this.OperatorId = OperatorId; this.Suffix = Suffix; }
/// <summary> /// Generate a new unique identification of a charging station identification. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Length">The desired length of the identification suffix.</param> /// <param name="Mapper">A delegate to modify the newly generated charging station identification.</param> public static ChargingStation_Id Random(ChargingStationOperator_Id OperatorId, Byte Length = 50, Func <String, String> Mapper = null) { if (Length < 12 || Length > 50) { Length = 50; } return(new ChargingStation_Id(OperatorId, Mapper != null ? Mapper(_Random.RandomString(Length)) : _Random.RandomString(Length))); }
/// <summary> /// Generate a new unique identification of an EVSE. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Mapper">A delegate to modify the newly generated EVSE identification.</param> public static EVSE_Id Random(ChargingStationOperator_Id OperatorId, Func <String, String> Mapper = null) => new EVSE_Id(OperatorId, Mapper != null ? Mapper(_Random.RandomString(12)) : _Random.RandomString(12));
public static ChargingReservation_Id Random(ChargingStationOperator_Id OperatorId, Byte Length = 20) => new ChargingReservation_Id(OperatorId, _Random.RandomString(Length));
/// <summary> /// Generate a new unique identification of a charging tariff. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Mapper">A delegate to modify the newly generated charging tariff identification.</param> public static ChargingTariff_Id Random(ChargingStationOperator_Id OperatorId, Func <String, String> Mapper = null) => new ChargingTariff_Id(OperatorId, Mapper != null ? Mapper(_Random.RandomString(30)) : _Random.RandomString(30));
/// <summary> /// Parse the given string as a charging tariff identification. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Suffix">The suffix of the charging tariff identification.</param> public static ChargingTariff_Id Parse(ChargingStationOperator_Id OperatorId, ChargingTariffGroup_Id TariffGroupId, String Suffix) => Parse(OperatorId.ToString(OperatorIdFormats.ISO_STAR) + "*T" + TariffGroupId + "_" + Suffix);
public static ChargingLocation FromChargingStationOperatorId(ChargingStationOperator_Id ChargingStationOperatorId) => new ChargingLocation(ChargingStationOperatorId: ChargingStationOperatorId);
public ChargingLocation SetChargingStationOperator(ChargingStationOperator_Id ChargingStationOperatorId) { this.ChargingStationOperatorId = ChargingStationOperatorId; return(this); }
/// <summary> /// Parse the given string as a charging reservation identification. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Suffix">The suffix of the charging reservation identification.</param> public static ChargingReservation_Id Parse(ChargingStationOperator_Id OperatorId, String Suffix) => Parse(OperatorId.ToString() + "*R" + Suffix);
/// <summary> /// Parse the given string as a charging reservation identification. /// </summary> public static Boolean TryParse(ChargingStationOperator_Id OperatorId, String Suffix, out ChargingReservation_Id ReservationId) => TryParse(OperatorId.ToString() + "*R" + Suffix, out ReservationId);
/// <summary> /// Parse the given string as a charging station group identification. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Suffix">The suffix of the charging station group identification.</param> public static ChargingStationGroup_Id Parse(ChargingStationOperator_Id OperatorId, String Suffix) => Parse(OperatorId.ToString(OperatorIdFormats.ISO_STAR) + "*GS" + Suffix);