Beispiel #1
0
        /// <summary>
        /// Returns <c>true</c> if error matches <paramref name="domain"/> and
        /// <paramref name="code"/>, <c>false</c> otherwise.
        /// </summary>
        /// <returns>The matches.</returns>
        /// <param name="domain">An error domain.</param>
        /// <param name="code">An error code.</param>
        /// <remarks>
        /// If domain contains a <c>Failed</c> (or otherwise generic) error code,
        /// you should generally not check for it explicitly, but should instead
        /// treat any not-explicitly-recognized error code as being equivalent to
        /// the <c>Failed</c> code. This way, if the domain is extended in the
        /// future to provide a more specific error code for a certain case, your
        /// code will still work.
        /// </remarks>
        public bool Matches(Quark domain, int code)
        {
            AssertNotDisposed();
            var ret = g_error_matches(handle, domain, code);

            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// Returns <c>true</c> if error matches <paramref name="domain"/> and
        /// <paramref name="code"/>, <c>false</c> otherwise.
        /// </summary>
        /// <returns>The matches.</returns>
        /// <param name="domain">An error domain.</param>
        /// <param name="code">An error code.</param>
        /// <remarks>
        /// If domain contains a <c>Failed</c> (or otherwise generic) error code,
        /// you should generally not check for it explicitly, but should instead
        /// treat any not-explicitly-recognized error code as being equivalent to
        /// the <c>Failed</c> code. This way, if the domain is extended in the
        /// future to provide a more specific error code for a certain case, your
        /// code will still work.
        /// </remarks>
        public bool Matches(Quark domain, System.Enum code)
        {
            AssertNotDisposed();
            var ret = g_error_matches(handle, domain, (int)(object)code);

            return(ret);
        }
Beispiel #3
0
        static IntPtr NewLiteral(Quark domain, int code, string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            var messagePtr = GMarshal.StringToUtf8Ptr(message);
            var ret        = g_error_new_literal(domain, code, messagePtr);

            GMarshal.Free(messagePtr);
            return(ret);
        }
Beispiel #4
0
 /* <type name="utf8" type="const gchar*" managed-name="Utf8" /> */
 /* transfer-ownership:none */
 static extern IntPtr g_quark_to_string(
     /* <type name="Quark" type="GQuark" managed-name="Quark" /> */
     /* transfer-ownership:none */
     Quark quark);
Beispiel #5
0
 static extern IntPtr g_error_new_literal(
     Quark domain,
     int code,
     IntPtr message);
Beispiel #6
0
 static extern bool g_error_matches(
     IntPtr err,
     Quark domain,
     int code);
Beispiel #7
0
 /// <summary>
 /// Creates a new <see cref="Error"/> with the given <paramref name="domain"/>,
 /// <paramref name="code"/> and message.
 /// </summary>
 /// <param name="domain">Error domain.</param>
 /// <param name="code">Error code.</param>
 /// <param name="format">Message format string.</param>
 /// <param name="args">Objects to format.</param>
 public Error(Quark domain, System.Enum code, string format, params object[] args)
     : this(domain, (int)(object)code, string.Format(format, args))
 {
 }
Beispiel #8
0
 /// <summary>
 /// Creates a new <see cref="Error"/> with the given <paramref name="domain"/>,
 /// <paramref name="code"/> and message.
 /// </summary>
 /// <param name="domain">Error domain.</param>
 /// <param name="code">Error code.</param>
 /// <param name="format">Message format string.</param>
 /// <param name="args">Objects to format.</param>
 public Error(Quark domain, int code, string format, params object[] args)
     : this(domain, code, string.Format(format, args))
 {
 }
Beispiel #9
0
 /// <summary>
 /// Creates a new <see cref="Error"/> with the given <paramref name="domain"/>,
 /// <paramref name="code"/> and <paramref name="message"/>.
 /// </summary>
 /// <param name="domain">Error domain.</param>
 /// <param name="code">Error code.</param>
 /// <param name="message">Error message.</param>
 public Error(Quark domain, System.Enum code, string message)
     : this(NewLiteral(domain, (int)(object) code, message), Transfer.Full)
 {
 }
Beispiel #10
0
 /// <summary>
 /// Creates a new <see cref="Error"/> with the given <paramref name="domain"/>,
 /// <paramref name="code"/> and <paramref name="message"/>.
 /// </summary>
 /// <param name="domain">Error domain.</param>
 /// <param name="code">Error code.</param>
 /// <param name="message">Error message.</param>
 public Error(Quark domain, int code, string message)
     : this(NewLiteral(domain, code, message), Transfer.Full)
 {
 }