Beispiel #1
0
        static void Main(string[] args)
        {
            ExclusiveLocking.RunTest();
            NonExclusiveLocking.RunTest();
            Signaling.RunTest();
            SignalingWithReset.RunTest();
            AbortCondition.RunTest();

            Console.ReadLine();
        }
Beispiel #2
0
        /// <summary>
        /// The ToString implementation.
        /// </summary>
        /// <param name="format">The format specifier to use, e.g. <b>Console.WriteLine(depot.ToString("c"));</b></param>
        /// <param name="provider">Allow clients to format output for their own types using [ICustomFormatter](https://msdn.microsoft.com/en-us/library/system.icustomformatter.aspx).</param>
        /// <returns>The formatted string.</returns>
        /// <exception cref="FormatException">thrown if an invalid format string is specified.</exception>
        /// \par Format specifiers:
        /// \arg \c G Depot name. Default when not using a format specifier.
        /// \arg \c LV Long version (verbose).
        /// \arg \c I Depot ID number.
        /// \arg \c S Depot's slice number.
        /// \arg \c E Exclusive locking status: \e true or \e false.
        /// \arg \c C [Case sensitivity](@ref AcUtils#CaseSensitivity): \e Sensitive or \e Insensitive.
        public string ToString(string format, IFormatProvider provider)
        {
            if (provider != null)
            {
                ICustomFormatter fmt = provider.GetFormat(this.GetType()) as ICustomFormatter;
                if (fmt != null)
                {
                    return(fmt.Format(format, this, provider));
                }
            }

            if (String.IsNullOrEmpty(format))
            {
                format = "G";
            }

            switch (format.ToUpperInvariant())
            {
            case "G":         // Depot name (default when not using a format specifier).
                return(Name); // general format should be short since it can be called by anything

            case "LV":        // long version (verbose)
                return($"{Name} ({ID}), slice {Slice}, {Case}{(ExclusiveLocking ? ", exclusive locking" : String.Empty)}");

            case "I":     // depot ID number
                return(ID.ToString());

            case "S":     // depot's slice number
                return(Slice.ToString());

            case "E":     // exclusive locking status
                return(ExclusiveLocking.ToString());

            case "C":     // whether the depot is case sensitive or insensitive
                return(Case.ToString());

            default:
                throw new FormatException($"The {format} format string is not supported.");
            }
        }