Skip to content

Commit

Permalink
#444 Rename WinRT and WinRT81 to WINDOWS_UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
nigel-sampson committed May 30, 2017
1 parent a09739c commit 3d9bea1
Show file tree
Hide file tree
Showing 28 changed files with 105 additions and 117 deletions.
4 changes: 2 additions & 2 deletions src/Caliburn.Micro.Platform/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Caliburn.Micro.Xamarin.Forms
namespace Caliburn.Micro
#endif
{
#if WinRT
#if WINDOWS_UWP
using System.Linq;
using Windows.UI.Xaml;
using System.Reflection;
Expand Down Expand Up @@ -122,7 +122,7 @@ public static void Invoke(object target, string methodName, DependencyObject vie

var context = new ActionExecutionContext {
Target = target,
#if WinRT
#if WINDOWS_UWP
Method = target.GetType().GetRuntimeMethods().Single(m => m.Name == methodName),
#else
Method = target.GetType().GetMethod(methodName),
Expand Down
2 changes: 1 addition & 1 deletion src/Caliburn.Micro.Platform/ActionExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Caliburn.Micro
using System;
using System.Collections.Generic;
using System.Reflection;
#if WinRT
#if WINDOWS_UWP
using Windows.UI.Xaml;
#elif XFORMS
using global::Xamarin.Forms;
Expand Down
20 changes: 10 additions & 10 deletions src/Caliburn.Micro.Platform/ActionMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.ComponentModel;
using System.Linq;
using System.Reflection;
#if WinRT81
#if WINDOWS_UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Markup;
Expand All @@ -27,7 +27,7 @@
/// <summary>
/// Used to send a message from the UI to a presentation model class, indicating that a particular Action should be invoked.
/// </summary>
#if WinRT
#if WINDOWS_UWP
[ContentProperty(Name = "Parameters")]
#else
[ContentProperty("Parameters")]
Expand Down Expand Up @@ -91,7 +91,7 @@ public ActionMessage() {
/// Gets or sets the name of the method to be invoked on the presentation model class.
/// </summary>
/// <value>The name of the method.</value>
#if !WinRT
#if !WINDOWS_UWP
[Category("Common Properties")]
#endif
public string MethodName {
Expand All @@ -103,7 +103,7 @@ public string MethodName {
/// Gets the parameters to pass as part of the method invocation.
/// </summary>
/// <value>The parameters.</value>
#if !WinRT
#if !WINDOWS_UWP
[Category("Common Properties")]
#endif
public AttachedCollection<Parameter> Parameters {
Expand All @@ -118,7 +118,7 @@ public AttachedCollection<Parameter> Parameters {
/// <summary>
/// Called after the action is attached to an AssociatedObject.
/// </summary>
#if WinRT81
#if WINDOWS_UWP
protected override void OnAttached() {
if (!View.InDesignMode) {
Parameters.Attach(AssociatedObject);
Expand Down Expand Up @@ -198,7 +198,7 @@ void ElementLoaded(object sender, RoutedEventArgs e) {
Path = new PropertyPath(Message.HandlerProperty),
Source = currentElement
};
#elif WinRT
#elif WINDOWS_UWP
var binding = new Binding {
Source = currentElement
};
Expand Down Expand Up @@ -338,7 +338,7 @@ public override string ToString() {
/// <remarks>Returns a value indicating whether or not the action is available.</remarks>
public static Func<ActionExecutionContext, bool> ApplyAvailabilityEffect = context => {
#if WinRT
#if WINDOWS_UWP
var source = context.Source as Control;
#else
var source = context.Source;
Expand All @@ -347,7 +347,7 @@ public override string ToString() {
return true;
}
#if WinRT
#if WINDOWS_UWP
var hasBinding = ConventionManager.HasBinding(source, Control.IsEnabledProperty);
#else
var hasBinding = ConventionManager.HasBinding(source, UIElement.IsEnabledProperty);
Expand All @@ -366,7 +366,7 @@ public override string ToString() {
/// <param name="message">The message.</param>
/// <returns>The matching method, if available.</returns>
public static Func<ActionMessage, object, MethodInfo> GetTargetMethod = (message, target) => {
#if WinRT
#if WINDOWS_UWP
return (from method in target.GetType().GetRuntimeMethods()
where method.Name == message.MethodName
let methodParameters = method.GetParameters()
Expand Down Expand Up @@ -543,7 +543,7 @@ static MethodInfo TryFindGuardMethod(ActionExecutionContext context, IEnumerable

static MethodInfo GetMethodInfo(Type t, string methodName)
{
#if WinRT
#if WINDOWS_UWP
return t.GetRuntimeMethods().SingleOrDefault(m => m.Name == methodName);
#else
return t.GetMethod(methodName);
Expand Down
2 changes: 1 addition & 1 deletion src/Caliburn.Micro.Platform/AssemblySource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.ComponentModel;
using System.Linq;
using System.Reflection;
#if !WinRT
#if !WINDOWS_UWP
using System.Windows;
#else
using Windows.UI.Xaml;
Expand Down
2 changes: 1 addition & 1 deletion src/Caliburn.Micro.Platform/Bind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Caliburn.Micro
#endif
{
using System;
#if WinRT
#if WINDOWS_UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
#elif XFORMS
Expand Down
18 changes: 8 additions & 10 deletions src/Caliburn.Micro.Platform/BindingScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if WinRT
#if WINDOWS_UWP
using System.ServiceModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand All @@ -26,15 +26,15 @@ static BindingScope()
{
AddChildResolver<ContentControl>(e => new[] { e.Content as DependencyObject });
AddChildResolver<ItemsControl>(e => e.Items.OfType<DependencyObject>().ToArray() );
#if !WinRT
#if !WINDOWS_UWP
AddChildResolver<HeaderedContentControl>(e => new[] { e.Header as DependencyObject });
AddChildResolver<HeaderedItemsControl>(e => new[] { e.Header as DependencyObject });
#endif
#if WinRT
#if WINDOWS_UWP
AddChildResolver<SemanticZoom>(e => new[] { e.ZoomedInView as DependencyObject, e.ZoomedOutView as DependencyObject });
AddChildResolver<ListViewBase>(e => new[] { e.Header as DependencyObject });
#endif
#if WinRT81
#if WINDOWS_UWP
AddChildResolver<ListViewBase>(e => new[] { e.Footer as DependencyObject });
AddChildResolver<Hub>(ResolveHub);
AddChildResolver<HubSection>(e => new[] { e.Header as DependencyObject });
Expand All @@ -54,7 +54,7 @@ static BindingScope()
/// <param name="name">The name to search for.</param>
/// <returns>The named element or null if not found.</returns>
public static FrameworkElement FindName(this IEnumerable<FrameworkElement> elementsToSearch, string name) {
#if WinRT
#if WINDOWS_UWP
return elementsToSearch.FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
#else
return elementsToSearch.FirstOrDefault(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
Expand Down Expand Up @@ -183,7 +183,7 @@ public static bool RemoveChildResolver(ChildResolver resolver) {
queue.Enqueue(childDo);
}
#if WinRT
#if WINDOWS_UWP
var page = current as Page;
if (page != null) {
Expand Down Expand Up @@ -217,7 +217,7 @@ public static bool RemoveChildResolver(ChildResolver resolver) {
return descendants;
};

#if WinRT81
#if WINDOWS_UWP
private static IEnumerable<DependencyObject> ResolveFlyoutBase(FlyoutBase flyoutBase) {
if (flyoutBase == null)
yield break;
Expand All @@ -240,15 +240,13 @@ private static IEnumerable<DependencyObject> ResolveFlyoutBase(FlyoutBase flyout

private static IEnumerable<DependencyObject> ResolveMenuFlyoutItems(MenuFlyoutItemBase item) {
yield return item;
#if WINDOWS_UWP
var subItem = item as MenuFlyoutSubItem;

if (subItem != null && subItem.Items != null) {
foreach (var subSubItem in subItem.Items) {
yield return subSubItem;
}
}
#endif
}

private static IEnumerable<DependencyObject> ResolveCommandBar(CommandBar commandBar) {
Expand Down Expand Up @@ -300,7 +298,7 @@ private static IEnumerable<DependencyObject> ResolveHub(Hub hub) {
if ((bool) root.GetValue(View.IsScopeRootProperty))
break;
#if WinRT
#if WINDOWS_UWP
if (root is AppBar) {
var frame = Window.Current.Content as Frame;
var page = (frame != null) ? frame.Content as Page : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if WinRT
#if WINDOWS_UWP
namespace Caliburn.Micro
{
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/Caliburn.Micro.Platform/ChildResolver.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
#if WinRT
#if WINDOWS_UWP
using Windows.UI.Xaml;
#else
using System.Windows;
Expand Down
42 changes: 17 additions & 25 deletions src/Caliburn.Micro.Platform/ConventionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
#if WinRT81
#if WINDOWS_UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
Expand All @@ -21,7 +21,7 @@
using System.Windows.Shapes;
using EventTrigger = System.Windows.Interactivity.EventTrigger;
#endif
#if !WinRT
#if !WINDOWS_UWP
using System.Windows.Documents;
#endif

Expand Down Expand Up @@ -52,12 +52,12 @@ public static class ConventionManager {
/// The default DataTemplate used for ItemsControls when required.
/// </summary>
public static DataTemplate DefaultItemTemplate = (DataTemplate)
#if WinRT
#if WINDOWS_UWP
XamlReader.Load(
#else
XamlReader.Parse(
#endif
#if WinRT
#if WINDOWS_UWP
"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:cal='using:Caliburn.Micro'>" +
"<ContentControl cal:View.Model=\"{Binding}\" VerticalContentAlignment=\"Stretch\" HorizontalContentAlignment=\"Stretch\" IsTabStop=\"False\" />" +
"</DataTemplate>"
Expand All @@ -73,7 +73,7 @@ public static class ConventionManager {
/// The default DataTemplate used for Headered controls when required.
/// </summary>
public static DataTemplate DefaultHeaderTemplate = (DataTemplate)
#if WinRT
#if WINDOWS_UWP
XamlReader.Load(
#else
XamlReader.Parse(
Expand Down Expand Up @@ -115,7 +115,7 @@ public static class ConventionManager {
/// <param name="bindableProperty"></param>
public static Action<Type, string, PropertyInfo, FrameworkElement, ElementConvention, DependencyProperty> SetBinding =
(viewModelType, path, property, element, convention, bindableProperty) => {
#if WinRT
#if WINDOWS_UWP
var binding = new Binding { Path = new PropertyPath(path) };
#else
var binding = new Binding(path);
Expand All @@ -134,7 +134,7 @@ public static class ConventionManager {
/// Applies the appropriate binding mode to the binding.
/// </summary>
public static Action<Binding, PropertyInfo> ApplyBindingMode = (binding, property) => {
#if WinRT
#if WINDOWS_UWP
var setMethod = property.SetMethod;
binding.Mode = (property.CanWrite && setMethod != null && setMethod.IsPublic) ? BindingMode.TwoWay : BindingMode.OneWay;
#else
Expand All @@ -153,7 +153,7 @@ public static class ConventionManager {
binding.ValidatesOnExceptions = true;
}
#endif
#if !WinRT
#if !WINDOWS_UWP
if (typeof(IDataErrorInfo).IsAssignableFrom(viewModelType)) {
binding.ValidatesOnDataErrors = true;
binding.ValidatesOnExceptions = true;
Expand All @@ -173,8 +173,8 @@ public static class ConventionManager {
/// Determines whether a custom string format is needed and applies it to the binding.
/// </summary>
public static Action<Binding, ElementConvention, PropertyInfo> ApplyStringFormat = (binding, convention, property) => {
#if !WinRT
if(typeof(DateTime).IsAssignableFrom(property.PropertyType))
#if !WINDOWS_UWP
if (typeof(DateTime).IsAssignableFrom(property.PropertyType))
binding.StringFormat = "{0:d}";
#endif
};
Expand All @@ -183,7 +183,7 @@ public static class ConventionManager {
/// Determines whether a custom update source trigger should be applied to the binding.
/// </summary>
public static Action<DependencyProperty, DependencyObject, Binding, PropertyInfo> ApplyUpdateSourceTrigger = (bindableProperty, element, binding, info) => {
#if WinRT81 || NET
#if WINDOWS_UWP || NET
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
#endif
};
Expand All @@ -202,27 +202,21 @@ static ConventionManager() {
return View.ModelProperty;
};
#endif
#if !WinRT
#if !WINDOWS_UWP
AddElementConvention<DatePicker>(DatePicker.SelectedDateProperty, "SelectedDate", "SelectedDateChanged");
#endif
#if WinRT81
#if WINDOWS_UWP
AddElementConvention<DatePicker>(DatePicker.DateProperty, "Date", "DateChanged");
AddElementConvention<TimePicker>(TimePicker.TimeProperty, "Time", "TimeChanged");
AddElementConvention<Hub>(Hub.HeaderProperty, "Header", "Loaded");
AddElementConvention<HubSection>(HubSection.HeaderProperty, "Header", "SectionsInViewChanged");
AddElementConvention<MenuFlyoutItem>(MenuFlyoutItem.TextProperty, "Text", "Click");
AddElementConvention<ToggleMenuFlyoutItem>(ToggleMenuFlyoutItem.IsCheckedProperty, "IsChecked", "Click");
#endif
#if WinRT81
AddElementConvention<SearchBox>(SearchBox.QueryTextProperty, "QueryText", "QuerySubmitted");
#endif
#if WinRT
AddElementConvention<ToggleSwitch>(ToggleSwitch.IsOnProperty, "IsOn", "Toggled");
AddElementConvention<ProgressRing>(ProgressRing.IsActiveProperty, "IsActive", "Loaded");
AddElementConvention<Slider>(Slider.ValueProperty, "Value", "ValueChanged");
AddElementConvention<RichEditBox>(RichEditBox.DataContextProperty, "DataContext", "TextChanged");
#endif
#if WINDOWS_UWP
AddElementConvention<Pivot>(Pivot.ItemsSourceProperty, "SelectedItem", "SelectionChanged")
.ApplyBinding = (viewModelType, path, property, element, convention) =>
{
Expand All @@ -236,8 +230,6 @@ static ConventionManager() {
return true;
};
#endif
#if WinRT
AddElementConvention<HyperlinkButton>(HyperlinkButton.ContentProperty, "DataContext", "Click");
AddElementConvention<PasswordBox>(PasswordBox.PasswordProperty, "Password", "PasswordChanged");
#else
Expand Down Expand Up @@ -366,7 +358,7 @@ public static ElementConvention GetElementConvention(Type elementType) {

ElementConvention propertyConvention;
ElementConventions.TryGetValue(elementType, out propertyConvention);
#if WinRT
#if WINDOWS_UWP
return propertyConvention ?? GetElementConvention(elementType.GetTypeInfo().BaseType);
#else
return propertyConvention ?? GetElementConvention(elementType.BaseType);
Expand Down Expand Up @@ -436,7 +428,7 @@ public static void ApplyItemTemplate(ItemsControl itemsControl, PropertyInfo pro
return;
}

#if !WinRT
#if !WINDOWS_UWP
if (property.PropertyType.IsGenericType) {
var itemType = property.PropertyType.GetGenericArguments().First();
if (itemType.IsValueType || typeof(string).IsAssignableFrom(itemType)) {
Expand Down Expand Up @@ -478,7 +470,7 @@ public static void ApplyItemTemplate(ItemsControl itemsControl, PropertyInfo pro
foreach (var potentialName in DerivePotentialSelectionNames(baseName)) {
if (viewModelType.GetPropertyCaseInsensitive(potentialName) != null) {
var selectionPath = path.Replace(baseName, potentialName);
#if WinRT
#if WINDOWS_UWP
var binding = new Binding { Mode = BindingMode.TwoWay, Path = new PropertyPath(selectionPath) };
#else
var binding = new Binding(selectionPath) { Mode = BindingMode.TwoWay };
Expand Down Expand Up @@ -537,7 +529,7 @@ public static void ApplyHeaderTemplate(FrameworkElement element, DependencyPrope
/// <param name="propertyName">The property to search for.</param>
/// <returns>The property or null if not found.</returns>
public static PropertyInfo GetPropertyCaseInsensitive(this Type type, string propertyName) {
#if WinRT
#if WINDOWS_UWP
var typeInfo = type.GetTypeInfo();
var typeList = new List<Type> { type };

Expand Down
Loading

0 comments on commit 3d9bea1

Please sign in to comment.