A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System;
5using osu.Framework.Graphics.UserInterface;
6using osu.Framework.Utils;
7
8namespace osu.Framework.Bindables
9{
10 public interface IBindableWithCurrent<T> : IBindable<T>, IHasCurrentValue<T>
11 {
12 /// <summary>
13 /// Creates a new <see cref="IBindableWithCurrent{T}"/> according to the specified value type.
14 /// If the value type is one supported by the <see cref="BindableNumber{T}"/>, an instance of <see cref="BindableNumberWithCurrent{T}"/> will be returned.
15 /// Otherwise an instance of <see cref="BindableWithCurrent{T}"/> will be returned instead.
16 /// </summary>
17 public static IBindableWithCurrent<T> Create()
18 {
19 if (Validation.IsSupportedBindableNumberType<T>())
20 return (IBindableWithCurrent<T>)Activator.CreateInstance(typeof(BindableNumberWithCurrent<>).MakeGenericType(typeof(T)), default(T));
21
22 return new BindableWithCurrent<T>();
23 }
24 }
25}