2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 namespace Tizen.Applications
22 /// Class that represents a Tizen application.
24 public abstract class Application : IDisposable
26 internal const string LogTag = "Tizen.Applications";
28 private static Application s_CurrentApplication = null;
30 private object _lock = new object();
32 private DirectoryInfo _directoryInfo;
33 private ApplicationInfo _applicationInfo;
36 /// Gets the instance of current application.
38 public static Application Current { get { return s_CurrentApplication; } }
41 /// Gets the class representing directory information of current application.
43 public DirectoryInfo DirectoryInfo
49 if (_directoryInfo == null)
51 _directoryInfo = new DirectoryInfo();
54 return _directoryInfo;
59 /// Gets the class representing information of current application.
61 public ApplicationInfo ApplicationInfo
67 if (_applicationInfo == null)
69 string appId = string.Empty;
70 Interop.AppCommon.AppGetId(out appId);
71 if (!string.IsNullOrEmpty(appId))
73 _applicationInfo = new ApplicationInfo(appId);
77 return _applicationInfo;
82 /// Runs the application's main loop.
84 /// <param name="args">Arguments from commandline.</param>
85 public virtual void Run(string[] args)
89 throw new ArgumentNullException("args");
91 s_CurrentApplication = this;
95 /// Exits the main loop of application.
97 public abstract void Exit();
99 #region IDisposable Support
100 private bool _disposedValue = false; // To detect redundant calls
103 /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
105 /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
106 protected virtual void Dispose(bool disposing)
112 if (_applicationInfo != null)
114 _applicationInfo.Dispose();
118 _disposedValue = true;
123 /// Finalizer of the Application class.
131 /// Releases all resources used by the Application class.
133 public void Dispose()
136 GC.SuppressFinalize(this);