/*
* Copyright (c) 2016 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Tizen.Applications
{
///
/// The class containing common properties of the Badge.
///
public class Badge
{
private int count = 0;
///
/// Initializes a new instance of the Badge class.
///
/// 3
/// Application ID
/// Count value
/// True if it should be displayed
/// Thrown when failed because of invalid argument
public Badge(string appId, int count = 1, bool visible = true)
{
if (IsNegativeNumber(count))
{
throw BadgeErrorFactory.GetException(BadgeError.InvalidParameter, "The count must be positive number");
}
AppId = appId;
this.count = count;
Visible = visible;
}
///
/// Property for the count value of the badge.
///
/// 3
/// Thrown when set negative number
public int Count
{
get
{
return count;
}
set
{
if (IsNegativeNumber(value))
{
throw BadgeErrorFactory.GetException(BadgeError.InvalidParameter, "The count must be positive number");
}
count = value;
}
}
///
/// Property for the application ID of the badge.
///
/// 3
public string AppId { get; set; }
///
/// Property for display visibility. True if the badge display visible, otherwise false..
///
/// 3
public bool Visible{ get; set; }
private bool IsNegativeNumber(int number)
{
return number < 0;
}
}
}