98c6ffc58ccb48cd09464319da7c60830800a864
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / EffectiveFlowDirectionExtensions.cs
1 using System;
2 using System.ComponentModel;
3 using Tizen.NUI.Binding;
4
5 namespace Tizen.NUI.Binding
6 {
7         [EditorBrowsable(EditorBrowsableState.Never)]
8         internal static class EffectiveFlowDirectionExtensions
9         {
10                 internal static EffectiveFlowDirection ToEffectiveFlowDirection(this FlowDirection self, bool isExplicit = false)
11                 {
12                         switch (self)
13                         {
14                                 case FlowDirection.MatchParent:
15                                         return default(EffectiveFlowDirection);
16
17
18                                 case FlowDirection.LeftToRight:
19                                         if (isExplicit)
20                                         {
21                                                 return EffectiveFlowDirection.Explicit;
22                                         }
23                                         else
24                                         {
25                                                 return default(EffectiveFlowDirection);
26                                         }
27
28                                 case FlowDirection.RightToLeft:
29                                         if (isExplicit)
30                                         {
31                                                 return EffectiveFlowDirection.RightToLeft | EffectiveFlowDirection.Explicit;
32                                         }
33                                         else
34                                         {
35                                                 return EffectiveFlowDirection.RightToLeft;
36                                         }
37
38                                 default:
39                                         throw new InvalidOperationException($"Cannot convert {self} to {nameof(EffectiveFlowDirection)}.");
40                         }
41                 }
42
43                 internal static FlowDirection ToFlowDirection(this EffectiveFlowDirection self)
44                 {
45                         if (self.IsLeftToRight())
46                                 return FlowDirection.LeftToRight;
47                         else
48                                 return FlowDirection.RightToLeft;
49
50                         throw new InvalidOperationException($"Cannot convert {self} to {nameof(FlowDirection)}.");
51                 }
52
53                 public static bool IsRightToLeft(this EffectiveFlowDirection self)
54                 {
55                         return (self & EffectiveFlowDirection.RightToLeft) == EffectiveFlowDirection.RightToLeft;
56                 }
57
58                 public static bool IsLeftToRight(this EffectiveFlowDirection self)
59                 {
60                         return (self & EffectiveFlowDirection.RightToLeft) != EffectiveFlowDirection.RightToLeft;
61                 }
62
63                 public static bool IsImplicit(this EffectiveFlowDirection self)
64                 {
65                         return (self & EffectiveFlowDirection.Explicit) != EffectiveFlowDirection.Explicit;
66                 }
67
68                 public static bool IsExplicit(this EffectiveFlowDirection self)
69                 {
70                         return (self & EffectiveFlowDirection.Explicit) == EffectiveFlowDirection.Explicit;
71                 }
72         }
73 }