/// <inheritdoc /> protected sealed override void ProcessRegistrationDetailsPriorToRegistration( RegistrationDetails registrationDetails, RegistrationTime registrationTime) { if (registrationDetails == null) { throw new ArgumentNullException(nameof(registrationDetails)); } if (registrationDetails.TypeToRegister is TypeToRegisterForJson typeToRegisterForJson) { this.ProcessTypeToRegisterForJson(typeToRegisterForJson); // During initialization, we wait until FinalizeInitialization() so that we have ALL // of the registered types on hand, to determine which ones participate in a hierarchy. // This is required because ParticipatesInHierarchy() requires the whole set of registered // types (and specifically to look for a non-abstract class that has inheritors, which // is rare/a design smell). Post-initialization, we are looking at a closed generic type // and should determine if it participates in a hierarchy. There is potentially the case // where a non-abstract closed generic class shows up first, we determine it does not // participate in a hierarchy because it has no inheritors, and subsequently another // closed generic class shows up that inherits from the first type. Should be rare; // cross that bridge when we get there. if (registrationTime == RegistrationTime.PostInitialization) { this.AddHierarchyParticipatingTypes(new[] { registrationDetails.TypeToRegister.Type }); } } else { throw new NotSupportedException(Invariant($"{nameof(registrationDetails)}.{nameof(RegistrationDetails.TypeToRegister)} is expected to be of type {nameof(TypeToRegisterForJson)}, but found this type: {registrationDetails.TypeToRegister.GetType().ToStringReadable()}.")); } }
/// <inheritdoc /> protected sealed override void ProcessRegistrationDetailsPriorToRegistration( RegistrationDetails registrationDetails, RegistrationTime registrationTime) { if (registrationDetails == null) { throw new ArgumentNullException(nameof(registrationDetails)); } if (registrationTime == RegistrationTime.Unknown) { throw new ArgumentOutOfRangeException(Invariant($"'{nameof(registrationTime)}' == '{RegistrationTime.Unknown}'"), (Exception)null); } if (registrationDetails.TypeToRegister is TypeToRegisterForBson typeToRegisterForBson) { // There's nothing to do if it's a generic type definition. // The closed generic types will be registered post-initialization. // Upon serializing, the serializer will call this.SerializationConfiguration.ThrowOnUnregisteredTypeIfAppropriate, // which recurses through the runtime types of the object being serialized // and registers any unregistered closed generic types it encounters. // Upon deserialization this is handled by ObcBsonDiscriminatorConvention. if (typeToRegisterForBson.Type.IsGenericTypeDefinition) { return; } this.ProcessTypeToRegisterForBson(typeToRegisterForBson, registrationDetails.SerializationConfigurationType); } else { throw new NotSupportedException(Invariant($"{nameof(registrationDetails)}.{nameof(RegistrationDetails.TypeToRegister)} is expected to be of type {nameof(TypeToRegisterForBson)}, but found this type: {registrationDetails.TypeToRegister.GetType().ToStringReadable()}.")); } }
public void RegistrationTimeConstructor_ShouldReturnValidTime() { // Arrange string expectedResult = "11:12 05/04/2000"; // Act var registrationTime = new RegistrationTime("11:12 05/04/2000"); string actualResult = registrationTime.ToString(); // Assert Assert.AreEqual(expectedResult, actualResult); }
public string RegisterOrderEmergency() { var description = this.args[0]; var level = (EmergencyLevel)Enum.Parse(typeof(EmergencyLevel), this.args[1]); var registrationTime = new RegistrationTime(this.args[2]); var status = this.args[3]; var data = new object[] { description, level, registrationTime, status }; var emergency = this.emergencyFactory.CreateEmergency("PublicOrderEmergency", data); this.register.EnqueueEmergency(emergency); return(string.Format(OutputMessages.RegisterOrderEmergency, level, registrationTime)); }
private RegistrationDetails RegisterType( TypeToRegister typeToRegister, RegistrationTime registrationTime) { if (typeToRegister == null) { throw new ArgumentNullException(nameof(typeToRegister)); } var result = new RegistrationDetails(typeToRegister, this.SerializationConfigurationType); this.RegisterType(result, registrationTime); return(result); }
/// <inheritdoc /> protected sealed override void ProcessRegistrationDetailsPriorToRegistration( RegistrationDetails registrationDetails, RegistrationTime registrationTime) { if (registrationDetails == null) { throw new ArgumentNullException(nameof(registrationDetails)); } if (registrationDetails.TypeToRegister is TypeToRegisterForPropertyBag typeToRegisterForPropertyBag) { // TypeToRegisterForPropertyBag throws NotSupportedException on generic type definitions // if (registrationDetails.TypeToRegister.Type.IsGenericTypeDefinition) // { // throw new NotSupportedException(Invariant($"Registering generic type definitions is not supported in {nameof(PropertyBagSerializationConfigurationBase)}.")); // } this.ProcessTypeToRegisterForPropertyBag(typeToRegisterForPropertyBag); } else { throw new NotSupportedException(Invariant($"{nameof(registrationDetails)}.{nameof(RegistrationDetails.TypeToRegister)} is expected to be of type {nameof(TypeToRegisterForPropertyBag)}, but found this type: {registrationDetails.TypeToRegister.GetType().ToStringReadable()}.")); } }
private void RegisterType( RegistrationDetails registrationDetails, RegistrationTime registrationTime) { var typeToRegister = registrationDetails.TypeToRegister; var type = typeToRegister.Type; if (!IsTypeThatCanBeRegistered(typeToRegister)) { throw new InvalidOperationException(Invariant($"Serialization configuration {this.SerializationConfigurationType.ConcreteSerializationConfigurationDerivativeType.ToStringReadable()} is attempting to register the following type which cannot be registered: {type.ToStringReadable()}.")); } if (this.registeredTypeToRegistrationDetailsMap.ContainsKey(type)) { var existingSerializationConfigurationType = this.registeredTypeToRegistrationDetailsMap[type].SerializationConfigurationType; throw new InvalidOperationException(Invariant($"Serialization configuration type {registrationDetails.SerializationConfigurationType.ConcreteSerializationConfigurationDerivativeType.ToStringReadable()} is attempting to register type '{type.ToStringReadable()}' but it was already registered by {existingSerializationConfigurationType.ConcreteSerializationConfigurationDerivativeType.ToStringReadable()}.")); } this.ProcessRegistrationDetailsPriorToRegistration(registrationDetails, registrationTime); this.registeredTypeToRegistrationDetailsMap.TryAdd(type, registrationDetails); }
public override string ToString() { return(String.Format("ID:{0}, Firstname: {1}, Lastname: {2}, Phone number: " + "{3}, Email: {4}, Data of Registration: {5}", PersonId, PersonFirstname, PersonLastname, PhoneNumber, Email, RegistrationTime.ToString())); }
public PublicPropertyEmergency(string description, EmergencyLevel emergencyLevel, RegistrationTime registrationTime, int propertyDamage) : base(description, emergencyLevel, registrationTime) { this.PropertyDamage = propertyDamage; }
public PublicOrderEmergency(string description, EmergencyLevel emergencyLevel, RegistrationTime registrationTime, string status) : base(description, emergencyLevel, registrationTime) { this.Status = status; }
protected BaseEmergency(string description, EmergencyLevel emergencyLevel, RegistrationTime registrationTime) { this.Description = description; this.emergencyLevel = emergencyLevel; this.registrationTime = registrationTime; }
public PublicHealthEmergency(string description, EmergencyLevel emergencyLevel, RegistrationTime registrationTime, int casualties) : base(description, emergencyLevel, registrationTime) { this.Casualties = casualties; }
public override string ToString() { return(string.Format("PCC = {0}, Deposit = {1}, Name = {2}, Type = {3}, Phone = {4}, Registration = {5}, VA = {6}", Pcc, Deposit.Format(decimalPoint: 2), Name, Type, Phone, RegistrationTime.Format(), Va)); }
/// <summary> /// Processes a <see cref="RegistrationDetails"/> prior to registration. /// </summary> /// <param name="registrationDetails">Details related to the registration.</param> /// <param name="registrationTime">The time of registration.</param> protected virtual void ProcessRegistrationDetailsPriorToRegistration( RegistrationDetails registrationDetails, RegistrationTime registrationTime) { /* no-op - inheritors can use this to examine the registration details prior to registration and perform inheritor-specific setup/logic (e.g. using a custom serializer for a type) */ }