private static AnchorableShowStrategy GetContentAnchorableStrategy(LayoutAnchorable anchorable) { var anchorableStrategy = AnchorableStrategy.Most; if (anchorable != null) { if (anchorable.IsAnchorable()) { anchorableStrategy = anchorable.GetAnchorableStrategy(); } else if (anchorable.Content.IsAnchorable()) { anchorableStrategy = anchorable.Content.GetAnchorableStrategy(); } else { throw new InvalidOperationException(); } } AnchorableShowStrategy flag = 0; foreach (AnchorableStrategy strategyFlag in SplitAnchorableStrategies(anchorableStrategy)) { var strategy = AnchorableShowStrategy.Most; strategyFlag.ValueSwitchOn() .Case(AnchorableStrategy.Most, x => strategy = AnchorableShowStrategy.Most) .Case(AnchorableStrategy.Left, x => strategy = AnchorableShowStrategy.Left) .Case(AnchorableStrategy.Right, x => strategy = AnchorableShowStrategy.Right) .Case(AnchorableStrategy.Top, x => strategy = AnchorableShowStrategy.Top) .Case(AnchorableStrategy.Bottom, x => strategy = AnchorableShowStrategy.Bottom) .Default(x => { throw new InvalidEnumArgumentException("Unknown AnchorableStrategy value"); }); flag |= strategy; } if (flag == 0) { flag = AnchorableShowStrategy.Most; } return(flag); }
private static bool GetContentAnchorableIsHidden(LayoutAnchorable anchorable) { if (anchorable == null) { return(false); } if (anchorable.IsAnchorable()) { return(anchorable.GetAnchorableIsHidden()); } else if (anchorable.Content.IsAnchorable()) { return(anchorable.Content.GetAnchorableIsHidden()); } else { throw new InvalidOperationException(); } }
private static AnchorableShowStrategy GetContentAnchorableStrategy(LayoutAnchorable anchorable) { var anchorableStrategy = AnchorableStrategies.Most; if (anchorable != null) { if (anchorable.IsAnchorable()) { anchorableStrategy = anchorable.GetAnchorableStrategy(); } else if (anchorable.Content.IsAnchorable()) { anchorableStrategy = anchorable.Content.GetAnchorableStrategy(); } else { throw new InvalidOperationException(); } } AnchorableShowStrategy flag = 0; foreach (AnchorableStrategies strategyFlag in SplitAnchorableStrategies(anchorableStrategy)) { var strategy = AnchorableShowStrategy.Most; strategy = strategyFlag switch { AnchorableStrategies.Most => AnchorableShowStrategy.Most, AnchorableStrategies.Left => AnchorableShowStrategy.Left, AnchorableStrategies.Right => AnchorableShowStrategy.Right, AnchorableStrategies.Top => AnchorableShowStrategy.Top, AnchorableStrategies.Bottom => AnchorableShowStrategy.Bottom, _ => throw new InvalidOperationException($@"Unknown AnchorableStrategy value {strategyFlag}"), }; flag |= strategy; } if (flag == 0) { flag = AnchorableShowStrategy.Most; } return(flag); }