[MediaController] Fix CustomCommand crash issue (#5652)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Badge / Tizen.Applications / Badge.cs
1 /*
2  * Copyright (c) 2016 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18
19 namespace Tizen.Applications
20 {
21     /// <summary>
22     /// The class containing common properties of the Badge.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class Badge
26     {
27         private int count = 0;
28
29         /// <summary>
30         /// Initializes a new instance of the Badge class.
31         /// </summary>
32         /// <since_tizen> 3 </since_tizen>
33         /// <param name="appId">Application ID</param>
34         /// <param name="count">Count value</param>
35         /// <param name="visible">True if it should be displayed</param>
36         /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
37         public Badge(string appId, int count = 1, bool visible = true)
38         {
39             if (IsNegativeNumber(count))
40             {
41                 throw BadgeErrorFactory.GetException(BadgeError.InvalidParameter, "The count must be positive number");
42             }
43             AppId = appId;
44             this.count = count;
45             Visible = visible;
46         }
47
48         /// <summary>
49         /// Property for the count value of the badge.
50         /// </summary>
51         /// <since_tizen> 3 </since_tizen>
52         /// <exception cref="ArgumentException">Thrown when set negative number</exception>
53         public int Count
54         {
55             get
56             {
57                 return count;
58             }
59             set
60             {
61                 if (IsNegativeNumber(value))
62                 {
63                     throw BadgeErrorFactory.GetException(BadgeError.InvalidParameter, "The count must be positive number");
64                 }
65
66                 count = value;
67             }
68         }
69
70         /// <summary>
71         /// Property for the application ID of the badge.
72         /// </summary>
73         /// <since_tizen> 3 </since_tizen>
74         public string AppId { get; set; }
75
76         /// <summary>
77         /// Property for display visibility. True if the badge display visible, otherwise false..
78         /// </summary>
79         /// <since_tizen> 4 </since_tizen>
80         public bool Visible{ get; set; }
81
82         private bool IsNegativeNumber(int number)
83         {
84             return number < 0;
85         }
86     }
87 }