[MediaVision] Refactoring
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia / Common / Size.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 namespace Tizen.Multimedia
18 {
19     public struct Size
20     {
21         /// <summary>
22         /// Initializes a new instance of the Size with the specified values.
23         /// </summary>
24         /// <param name="width">Width of the size.</param>
25         /// <param name="height">Height of the size.</param>
26         public Size(int width, int height)
27         {
28             Width = width;
29             Height = height;
30         }
31
32         /// <summary>
33         /// Gets or sets the width of the Size.
34         /// </summary>
35         public int Width
36         {
37             get;
38             set;
39         }
40
41         /// <summary>
42         /// Gets or sets the height of the Size.
43         /// </summary>
44         public int Height
45         {
46             get;
47             set;
48         }
49
50         public override string ToString() => $"Width={ Width.ToString() }, Height={ Height.ToString() }";
51
52         public override int GetHashCode()
53         {
54             return new { Width, Height }.GetHashCode();
55         }
56
57         public override bool Equals(object obj)
58         {
59             return obj is Size && this == (Size)obj;
60         }
61
62         public static bool operator ==(Size lhs, Size rhs)
63         {
64             return lhs.Width == rhs.Width && lhs.Height == rhs.Height;
65         }
66
67         public static bool operator !=(Size lhs, Size rhs)
68         {
69             return !(lhs == rhs);
70         }
71     }
72 }