Show / Hide Table of Contents

    Class Bundle

    A bundle object represents a bundle. A bundle holds items (key-value pairs) and can be used with other Tizen APIs. Keys can be used to access values. This class is accessed by using a constructor to create a new instance of this object. A bundle instance is not guaranteed to be thread safe if the instance is modified by multiple threads.

    Inheritance
    Object
    Bundle
    Implements
    IDisposable
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Tizen.Applications
    Assembly: Tizen.Applications.Common.dll
    Syntax
    public class Bundle : IDisposable

    Constructors

    Bundle()

    The bundle constructor.

    Declaration
    public Bundle()
    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when out of memory.

    Bundle(SafeBundleHandle)

    The bundle constructor.

    Declaration
    public Bundle(SafeBundleHandle handle)
    Parameters
    Type Name Description
    SafeBundleHandle handle

    The SafeBundleHandle instance.

    API Version
    3
    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when the handle is null or invalid.

    Properties

    Count

    The number of items in a bundle object.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32
    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    bundle.AddItem("string", "a_string");
    Console.WriteLine("There are {0} items in the bundle", bundle.Count);

    Keys

    The keys in a bundle object.

    Declaration
    public IEnumerable<string> Keys { get; }
    Property Value
    Type Description
    IEnumerable<String>
    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    bundle.AddItem("string1", "a_string1");
    bundle.AddItem("string2", "a_string2");
    bundle.AddItem("string3", "a_string3");
    Console.WriteLine("The bundle contains the following keys:");
    foreach(string key in bundle.Keys)
    {
        Console.WriteLine(key);
    }

    SafeBundleHandle

    Gets the SafeBundleHandle instance.

    Declaration
    public SafeBundleHandle SafeBundleHandle { get; }
    Property Value
    Type Description
    SafeBundleHandle
    API Version
    3

    Methods

    AddItem(String, Byte[])

    Adds an item into the bundle.

    Declaration
    public void AddItem(string key, byte[] value)
    Parameters
    Type Name Description
    String key

    The key to identify the item with. If an item with the key already exists in the bundle, this method will not succeed.

    Byte[] value

    The value of the item.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    byte[] byteArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    bundle.AddItem("byte_array", byteArray);
    Exceptions
    Type Condition
    ArgumentException

    Thrown when the key already exists or when there is an invalid parameter.

    ArgumentNullException

    Thrown when a value is null.

    InvalidOperationException

    Thrown when out of memory or when the bundle instance has been disposed.

    AddItem(String, Byte[], Int32, Int32)

    Adds an item into the bundle.

    Declaration
    public void AddItem(string key, byte[] value, int offset, int count)
    Parameters
    Type Name Description
    String key

    The key to identify the item with. If an item with the key already exists in the bundle, this method will not succeed.

    Byte[] value

    The value of the item.

    Int32 offset

    The zero-based byte offset in value from which to add to the bundle.

    Int32 count

    The maximum number of bytes to add to the bundle starting with offset.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    byte[] byteArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    bundle.AddItem("byte_array", byteArray, 2, 3);
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown when the offset or count is out of range.

    ArgumentException

    Thrown when the key already exists or when there is an invalid parameter.

    ArgumentNullException

    Thrown when a value is null.

    InvalidOperationException

    Thrown when out of memory or when the bundle instance has been disposed.

    AddItem(String, IEnumerable<String>)

    Adds an item into the bundle.

    Declaration
    public void AddItem(string key, IEnumerable<string> value)
    Parameters
    Type Name Description
    String key

    The key to identify the item with. If an item with the key already exists in the bundle, this method will not succeed.

    IEnumerable<String> value

    The value of the item.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    string[] stringArray = { "a", "b", "c" };
    bundle.AddItem("string_array", stringArray);
    Exceptions
    Type Condition
    ArgumentException

    Thrown when the key already exists or when there is an invalid parameter.

    InvalidOperationException

    Thrown when out of memory or when the bundle instance has been disposed.

    AddItem(String, String)

    Adds an item into the bundle.

    Declaration
    public void AddItem(string key, string value)
    Parameters
    Type Name Description
    String key

    The key to identify the item with. If an item with the key already exists in the bundle, this method will not succeed.

    String value

    The value of the item.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    bundle.AddItem("string", "a_string");
    Exceptions
    Type Condition
    ArgumentException

    Thrown when the key already exists or when there is an invalid parameter.

    InvalidOperationException

    Thrown when out of memory or when the bundle instance has been disposed.

    Contains(String)

    Checks whether the bundle contains an item with a specified key.

    Declaration
    public bool Contains(string key)
    Parameters
    Type Name Description
    String key

    The key to check for.

    Returns
    Type Description
    Boolean

    true if the bundle contains the key, false otherwise.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    bundle.AddItem("string", "a_string");
    if (bundle.Contains("string"))
    {
        string aValue = bundle.GetItem<string>("string");
        Console.WriteLine(aValue);
    }

    Decode(String)

    Decodes an encoded bundle data.

    Declaration
    public static Bundle Decode(string bundleRaw)
    Parameters
    Type Name Description
    String bundleRaw

    The encoded bundle data. bundleRaw should be the returned value of Tizen.Applications.Bundle.Encode, otherwise this method will not succeed.

    Returns
    Type Description
    Bundle

    Decoded Bundle object.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    string bundleRaw = bundle.Encode();
    Bundle data = bundle.Decode(bundleRaw);
    Exceptions
    Type Condition
    ArgumentException

    Thrown when there is an invalid parameter.

    Dispose()

    Releases any unmanaged resources used by this object.

    Declaration
    public void Dispose()
    API Version
    3

    Dispose(Boolean)

    Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    If true, disposes any disposable objects. If false, does not dispose disposable objects.

    API Version
    3

    Encode()

    Encodes bundle to string.

    Declaration
    public string Encode()
    Returns
    Type Description
    String

    Encoded bundle data in string.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    string bundleRaw = bundle.Encode();
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when out of memory or when the bundle instance has been disposed.

    Finalize()

    Destructor of the bundle class.

    Declaration
    protected void Finalize()

    GetItem(String)

    Gets the value of a bundle item with a specified key.

    Declaration
    public object GetItem(string key)
    Parameters
    Type Name Description
    String key

    The key of the bundle item whose value is desired.

    Returns
    Type Description
    Object

    The value of the bundle item.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    bundle.AddItem("string", "a_string");
    if (bundle.Contains("string"))
    {
        object aValue = bundle.GetItem("string");
        if (bundle.Is<string>("string");)
        {
            string aString = (string)aValue;
            Console.WriteLine(aString);
        }
    }
    Exceptions
    Type Condition
    ArgumentException

    Thrown when the key does not exist or when there is an invalid parameter.

    InvalidOperationException

    Thrown when the bundle instance has been disposed.

    GetItem<T>(String)

    Gets the value of a bundle item with a specified key. Note that this is a generic method.

    Declaration
    public T GetItem<T>(string key)
    Parameters
    Type Name Description
    String key

    The key of the bundle item whose value is desired.

    Returns
    Type Description
    T

    The value of the bundle item if it is of the specified generic type.

    Type Parameters
    Name Description
    T

    The generic type to return.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    string[] stringArray = { "a", "b", "c" };
    bundle.AddItem("string_array", stringArray);
    if (bundle.Is<string>("string_array"))
    {
        Console.WriteLine("It is a string");
        Console.WriteLine(bundle.GetItem<string>("string_array"));
    }
    else if (bundle.Is<string[]>("string_array"))
    {
        Console.WriteLine("It is a string[]");
        string[] anArray = bundle.GetItem<string[]>("string_array");
        foreach (string value in anArray)
        {
            Console.WriteLine(value);
        }
    }
    Exceptions
    Type Condition
    ArgumentException

    Thrown when the key does not exist or when there is an invalid parameter.

    InvalidCastException

    Thrown when the value of the bundle item cannot be converted to the specified generic type.

    InvalidOperationException

    Thrown when the bundle instance has been disposed.

    Is<T>(String)

    Checks whether an item is of a specific type.

    Declaration
    public bool Is<T>(string key)
    Parameters
    Type Name Description
    String key

    The key whose type wants to be checked.

    Returns
    Type Description
    Boolean

    true if the item is of the specified type, false otherwise.

    Type Parameters
    Name Description
    T

    The generic type to check for.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    string[] stringArray = { "a", "b", "c" };
    bundle.AddItem("string_array", stringArray);
    if (bundle.Is<string[]>("string_array"))
    {
        Console.WriteLine("It is a string[]");
        string[] anArray = bundle.GetItem<string[]>("string_array");
        foreach (string value in anArray)
        {
            Console.WriteLine(value);
        }
    }
    Exceptions
    Type Condition
    ArgumentException

    Thrown when the key does not exist or when there is an invalid parameter.

    InvalidOperationException

    Thrown when the bundle instance has been disposed.

    RemoveItem(String)

    Removes a bundle item with a specific key from a Bundle.

    Declaration
    public bool RemoveItem(string key)
    Parameters
    Type Name Description
    String key

    The key of the item to delete.

    Returns
    Type Description
    Boolean

    true if the item is successfully found and removed, false otherwise (even if the item is not found).

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    bundle.AddItem("string", "a_string");
    if (bundle.Contains("string"))
    {
        if (bundle.RemoveItem("string"))
        {
            Console.WriteLine("Removed");
        }
    }
    Exceptions
    Type Condition
    ArgumentException

    Thrown when there is an invalid parameter.

    InvalidOperationException

    Thrown when the bundle instance has been disposed.

    TryGetItem(String, out Byte[])

    Gets the value of a bundle item with a specified key.

    Declaration
    public bool TryGetItem(string key, out byte[] value)
    Parameters
    Type Name Description
    String key

    The key of the bundle item whose value is desired.

    Byte[] value

    The value of the bundle item. If the key does not exist or the type of this parameter is incorrect, it is the default value for the value parameter type.

    Returns
    Type Description
    Boolean

    true if an item with the key exists and if the value is the same type as the output value parameter, false otherwise.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    byte[] byteArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    bundle.AddItem("byte_array", byteArray);
    byte[] aByteArray;
    if (bundle.TryGetItem("byte_array", out aByteArray))
    {
        Console.WriteLine("First item in the byte array: {0}", aByteArray[0]);
    }
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when the bundle instance has been disposed.

    TryGetItem(String, out IEnumerable<String>)

    Gets the value of a bundle item with a specified key.

    Declaration
    public bool TryGetItem(string key, out IEnumerable<string> value)
    Parameters
    Type Name Description
    String key

    The key of the bundle item whose value is desired.

    IEnumerable<String> value

    The value of the bundle item. If the key does not exist or the type of this parameter is incorrect, it is the default value for the value parameter type.

    Returns
    Type Description
    Boolean

    true if an item with the key exists and if the value is the same type as the output value parameter, false otherwise.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    string[] stringArray = { "a", "b", "c" };
    bundle.AddItem("string_array", stringArray);
    System.Collections.Generic.IEnumerable<string> aStringEnumerable;
    if (bundle.TryGetItem("string", out aStringEnumerable))
    {
        foreach (string value in aStringEnumerable)
        {
            Console.WriteLine(value);
        }
    }
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when the bundle instance has been disposed.

    TryGetItem(String, out String)

    Gets the value of a bundle item with a specified key.

    Declaration
    public bool TryGetItem(string key, out string value)
    Parameters
    Type Name Description
    String key

    The key of the bundle item whose value is desired.

    String value

    The value of the bundle item. If the key does not exist or the type of this parameter is incorrect, it is the default value for the value parameter type.

    Returns
    Type Description
    Boolean

    true if an item with the key exists and if the value is the same type as the output value parameter, false otherwise.

    API Version
    3
    Examples
    Tizen.Applications.Bundle bundle = new Tizen.Applications.Bundle();
    bundle.AddItem("string", "a_string");
    string aString;
    if (bundle.TryGetItem("string", out aString))
    {
        Console.WriteLine(aString);
    }
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when the bundle instance has been disposed.

    Implements

    System.IDisposable
    Back to top Copyright © 2016-2018 Samsung
    Generated by DocFX