Svace issues of dereferenced nullable variables have been fixed.
}
// Apply ItemSpacing.
- if ((alertDialogStyle.ItemSpacing != null) && Layout is LinearLayout)
+ if ((alertDialogStyle.ItemSpacing != null) && (Layout is LinearLayout linearLayout))
{
- (Layout as LinearLayout).CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height);
+ linearLayout.CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height);
}
// Apply Title style.
VerticalAlignment = VerticalAlignment.Center,
};
- if (styleApplied && (alertDialogStyle != null) && (alertDialogStyle.ItemSpacing != null) && (Layout is LinearLayout))
+ if (styleApplied && (alertDialogStyle != null) && (alertDialogStyle.ItemSpacing != null) && (Layout is LinearLayout linearLayout))
{
- (Layout as LinearLayout).CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height);
+ linearLayout.CellPadding = new Size2D(alertDialogStyle.ItemSpacing.Width, alertDialogStyle.ItemSpacing.Height);
}
this.Relayout += OnRelayout;
public static readonly new BindableProperty PaddingProperty = BindableProperty.Create(nameof(Padding), typeof(Extents), typeof(FlexibleView), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (FlexibleView)bindable;
- if (newValue != null)
+ if (newValue is Extents extents)
{
- instance.InternalPadding = newValue as Extents;
+ instance.InternalPadding = extents;
}
},
defaultValueCreator: (bindable) =>
return;
}
- if (container != null && container.Layout is LinearLayout)
+ if (container != null && (container.Layout is LinearLayout linearLayout))
{
- (container.Layout as LinearLayout).CellPadding = new Size2D(indicatorSpacing, 0);
+ linearLayout.CellPadding = new Size2D(indicatorSpacing, 0);
}
for (int i = 0; i < indicatorList.Count; i++)
{
for (int i = 0; i < Children.Count; i++)
{
- RecycleItem item = Children[i] as RecycleItem;
- if (item.DataIndex == prevFocusedDataIndex)
+ if ((Children[i] is RecycleItem item) && (item.DataIndex == prevFocusedDataIndex))
{
nextFocusedView = item;
break;
}
focusedView = nextFocusedView;
- if ((nextFocusedView as RecycleItem) != null)
+ if (nextFocusedView is RecycleItem item)
{
- prevFocusedDataIndex = (nextFocusedView as RecycleItem).DataIndex;
+ prevFocusedDataIndex = item.DataIndex;
}
ScrollTo(targetPosition, true);
if (null != fieldName)
{
- obj = type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public).GetValue(null);
+ obj = type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
}
else
{
- obj = type.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public).GetValue(null);
+ obj = type.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
}
}
private void TransitionSetFinished(object sender, EventArgs e)
{
- (sender as TransitionSet).Finished -= TransitionSetFinished;
+ if (sender is TransitionSet transitionSet)
+ {
+ transitionSet.Finished -= TransitionSetFinished;
+ }
providerImage.Unparent();
providerImage.Dispose();
providerImage = null;
view.themeData?.selectorData?.BorderlineColor?.Reset(view);
- Selector<Color> selector = newValue as Selector<Color>;
- if (selector.HasAll()) view.SetBorderlineColor(selector.All);
- else view.EnsureSelectorData().BorderlineColor = new TriggerableSelector<Color>(view, selector, view.SetBorderlineColor, true);
+ if (newValue is Selector<Color> selector)
+ {
+ if (selector.HasAll()) view.SetBorderlineColor(selector.All);
+ else view.EnsureSelectorData().BorderlineColor = new TriggerableSelector<Color>(view, selector, view.SetBorderlineColor, true);
+ }
+ else
+ {
+ view.SetBorderlineColor((Color)newValue);
+ }
},
defaultValueCreator: (bindable) =>
{
if (null != parent)
{
- if (null != xNameToElements)
+ if ((null != xNameToElements) && (xNameToElements[pair.Key] is View holdedXElements))
{
- var holdedXElements = xNameToElements[pair.Key] as View;
holdedXElements.CopyBindingRelationShip(view);
holdedXElements.CopyFrom(view);