/// <summary> /// Registers a generic, class independent type. /// </summary> /// <param name="encodingType">The encoding type.</param> /// <param name="tag">The tag number.</param> /// <param name="typeConstructor">The type constructor.</param> /// <param name="replace">True to allow replacing an existing registration, otherwise false</param> /// <returns>The <see cref="DefaultDerAsnDecoder"/> instance.</returns> public DefaultDerAsnDecoder RegisterGenericType(DerAsnEncodingType encodingType, long tag, TypeConstructor typeConstructor, bool replace = false) { if (typeConstructor == null) { throw new ArgumentNullException(nameof(typeConstructor)); } var typeKey = new TypeKey { EncodingType = encodingType, Tag = tag }; if (!replace && _registeredTypes.ContainsKey(typeKey)) { throw new InvalidOperationException($"Type with encoding type {encodingType} and tag number {tag} already registered"); } _registeredTypes[typeKey] = typeConstructor; return(this); }
public DerAsnIdentifier(DerAsnTagClass tagClass, DerAsnEncodingType encodingType, long tag) { TagClass = tagClass; EncodingType = encodingType; Tag = tag; }