コード例 #1
0
 /// <summary>
 /// <para>
 /// Returns the original ID represented by the given public ID.
 /// </para>
 /// <para>
 /// This method returns null if the input value was not created by the same converter using the same configuration.
 /// </para>
 /// </summary>
 public static decimal?GetDecimalOrDefault(this IPublicIdentityConverter converter, Guid publicId)
 {
     if (converter is null)
     {
         throw new ArgumentNullException(nameof(converter));
     }
     return(converter.TryGetDecimal(publicId, out var id) ? id : (decimal?)null);
 }
コード例 #2
0
 /// <summary>
 /// <para>
 /// Returns the original ID represented by the given public ID.
 /// </para>
 /// <para>
 /// This method returns null if the input value was not created by the same converter using the same configuration.
 /// </para>
 /// </summary>
 public static ulong?GetUlongOrDefault(this IPublicIdentityConverter converter, Guid publicId)
 {
     if (converter is null)
     {
         throw new ArgumentNullException(nameof(converter));
     }
     return(converter.TryGetUlong(publicId, out var id) ? id : (ulong?)null);
 }
コード例 #3
0
        /// <summary>
        /// Sets the ubiquitous default scope, overwriting and disposing the previous one if necessary.
        /// </summary>
        /// <param name="newConverter">The public identity converter to register. May be null to unregister.</param>
        internal static void SetDefaultValue(IPublicIdentityConverter newConverter)
        {
            var newDefaultScope = newConverter is null
                                ? null
                                : new PublicIdentityScope(newConverter, AmbientScopeOption.NoNesting);

            SetDefaultScope(newDefaultScope);
        }
コード例 #4
0
 /// <summary>
 /// Private constructor.
 /// Does not activate this instance.
 /// </summary>
 private PublicIdentityScope(IPublicIdentityConverter converter, AmbientScopeOption ambientScopeOption)
     : base(ambientScopeOption)
 {
     this.Converter = converter ?? throw new ArgumentNullException(nameof(converter));
 }
コード例 #5
0
 /// <summary>
 /// Establishes the given public identity converter as the ambient one until the scope is disposed.
 /// </summary>
 public PublicIdentityScope(IPublicIdentityConverter converter)
     : this(converter, AmbientScopeOption.ForceCreateNew)
 {
     this.Activate();
 }