コード例 #1
0
ファイル: Bundle.cs プロジェクト: yunmiha/TizenFX
        /// <summary>
        /// The bundle constructor.
        /// </summary>
        /// <param name="handle">The SafeBundleHandle instance.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the handle is null or invalid.</exception>
        /// <since_tizen> 3 </since_tizen>
        public Bundle(SafeBundleHandle handle)
        {
            if (handle == null)
            {
                throw new ArgumentNullException("handle");
            }

            if (handle.IsInvalid)
            {
                throw new ArgumentNullException("handle", "handle is invalid");
            }

            _handle = Interop.Bundle.DangerousClone(handle.DangerousGetHandle());
            _keys   = new HashSet <string>();
            Interop.Bundle.Iterator iterator = (string key, int type, IntPtr keyval, IntPtr userData) =>
            {
                _keys.Add(key);
            };

            Interop.Bundle.Foreach(_handle, iterator, IntPtr.Zero);
            if ((BundleErrorFactory.BundleError)ErrorFacts.GetLastResult() == BundleErrorFactory.BundleError.InvalidParameter)
            {
                throw new ArgumentException("Invalid parameter - cannot create bundle instance");
            }
        }
コード例 #2
0
ファイル: Bundle.cs プロジェクト: yunmiha/TizenFX
 static internal void CheckAndThrowException(int error, SafeBundleHandle handle)
 {
     if ((BundleError)error == BundleError.None)
     {
         return;
     }
     else if ((BundleError)error == BundleError.OutOfMemory)
     {
         throw new InvalidOperationException("Out of memory");
     }
     else if ((BundleError)error == BundleError.InvalidParameter)
     {
         if (handle.IsInvalid)
         {
             throw new InvalidOperationException("Invalid bundle instance (object may have been disposed or released)");
         }
         throw new ArgumentException("Invalid parameter");
     }
     else if ((BundleError)error == BundleError.KeyNotAvailable)
     {
         throw new ArgumentException("Key does not exist in the bundle");
     }
     else if ((BundleError)error == BundleError.KeyExists)
     {
         throw new ArgumentException("Key already exists");
     }
 }
コード例 #3
0
ファイル: Bundle.cs プロジェクト: yunmiha/TizenFX
 /// <summary>
 /// The bundle constructor.
 /// </summary>
 /// <exception cref="System.InvalidOperationException">Thrown when out of memory.</exception>
 /// <example>
 /// <code>
 /// Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
 /// </code>
 /// </example>
 /// <since_tizen> 3 </since_tizen>
 public Bundle()
 {
     _handle = Interop.Bundle.Create();
     BundleErrorFactory.CheckAndThrowException(ErrorFacts.GetLastResult(), _handle);
     _keys = new HashSet <string>();
 }