[NUI] Fixing the emtpy finalizers(CA1821)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / VisualFactory.cs
1 /*
2  * Copyright(c) 2018 Samsung Electronics Co., Ltd.
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
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23
24     /// <summary>
25     /// The VisualFactory is a singleton object that provides and shares visuals between views.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     public class VisualFactory : BaseHandle
29     {
30
31         /// <summary>
32         /// Instance of the VisualFactory singleton.
33         /// </summary>
34         private static VisualFactory instance;
35
36         internal VisualFactory(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.VisualFactory.Upcast(cPtr), cMemoryOwn)
37         {
38         }
39
40         internal VisualFactory() : this(Interop.VisualFactory.NewVisualFactory(), true)
41         {
42             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
43         }
44
45         /// <summary>
46         /// Retrieves the VisualFactory singleton.
47         /// </summary>
48         /// <since_tizen> 3 </since_tizen>
49         public static VisualFactory Instance
50         {
51             get
52             {
53                 if (!instance)
54                 {
55                     instance = new VisualFactory(Interop.VisualFactory.Get(), true);
56                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
57                 }
58
59                 return instance;
60             }
61         }
62
63         /// <summary>
64         /// Please do not use! this will be deprecated, please use VisualFactory.Instance instead.
65         /// </summary>
66         /// <since_tizen> 3 </since_tizen>
67         [Obsolete("Please do not use! This will be deprecated! Please use VisualFactory.Instance instead! " +
68             "Like: " +
69             "VisualFactory visualFactory = VisualFactory.Instance; " +
70             "visualFactory.CreateVisual(visualMap);")]
71         [EditorBrowsable(EditorBrowsableState.Never)]
72         public static VisualFactory Get()
73         {
74             return VisualFactory.Instance;
75         }
76
77         /// <summary>
78         /// Request the visual.
79         /// </summary>
80         /// <param name="propertyMap">The map contains the properties required by the visual. The content of the map determines the type of visual that will be returned.</param>
81         /// <returns>The handle to the created visual.</returns>
82         /// <since_tizen> 3 </since_tizen>
83         public VisualBase CreateVisual(PropertyMap propertyMap)
84         {
85             VisualBase ret = new VisualBase(Interop.VisualFactory.CreateVisual(SwigCPtr, PropertyMap.getCPtr(propertyMap)), true);
86             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
87             return ret;
88         }
89
90     }
91
92 }