2 * Copyright (c) 2017 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.
18 using System.Runtime.InteropServices;
20 namespace Tizen.WebView
23 /// Argument from the SmartCallback.
25 public class SmartCallbackArgs : EventArgs
29 internal SmartCallbackArgs(IntPtr arg)
35 /// Gets argument as integer type.
37 /// <returns>Argument as integer type</returns>
38 public int GetAsInteger()
40 if (_arg == IntPtr.Zero)
44 return Marshal.ReadInt32(_arg, 0);
48 /// Gets argument as double type.
50 /// <returns>Argument as double type</returns>
51 public double GetAsDouble()
53 if (_arg == IntPtr.Zero)
57 double[] ret = new double[1];
58 Marshal.Copy(_arg, ret, 0, 1);
63 /// Gets argument as boolean type.
65 /// <returns>Argument as boolean type</returns>
66 public bool GetAsBoolean()
68 if (_arg == IntPtr.Zero)
72 return Marshal.ReadByte(_arg) != (byte)0;
76 /// Gets argument as string type.
78 /// <returns>Argument as string type</returns>
79 public string GetAsString()
81 if (_arg == IntPtr.Zero)
85 return Marshal.PtrToStringAnsi(_arg);
88 internal static SmartCallbackArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
90 return new SmartCallbackArgs(info);