Skip to content

Commit

Permalink
housekeeping: remove unused ifdefs for UIKit
Browse files Browse the repository at this point in the history
  • Loading branch information
olevett committed Dec 18, 2017
1 parent 838d196 commit 26122a1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 61 deletions.
44 changes: 1 addition & 43 deletions src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MS-PL license.
// See the LICENSE file in the project root for more information.

Expand All @@ -9,9 +9,6 @@
using System.Reactive.Linq;
using System.Reflection;
using System.Windows.Input;
#if UIKIT
using UIKit;
#endif

namespace ReactiveUI
{
Expand Down Expand Up @@ -117,45 +114,6 @@ protected static IDisposable ForEvent(ICommand command, object target, IObservab

return compDisp;
}

#if UIKIT
/// <summary>
/// Creates a commands binding from event and a property
/// </summary>
protected static IDisposable ForTargetAction(ICommand command, object target, IObservable<object> commandParameter, PropertyInfo enabledProperty)
{
commandParameter = commandParameter ?? Observable.Return(target);

object latestParam = null;

IDisposable actionDisp = null;

var ctl = target as UIControl;
if (ctl != null) {
var eh = new EventHandler((o, e) => {
if (command.CanExecute(latestParam)) command.Execute(latestParam);
});

ctl.AddTarget(eh, UIControlEvent.TouchUpInside);
actionDisp = Disposable.Create(() => ctl.RemoveTarget(eh, UIControlEvent.TouchUpInside));
}

var enabledSetter = Reflection.GetValueSetterForProperty(enabledProperty);
if (enabledSetter == null) return actionDisp;

// Initial enabled state
enabledSetter(target, command.CanExecute(latestParam), null);

var compDisp = new CompositeDisposable(
actionDisp,
commandParameter.Subscribe(x => latestParam = x),
Observable.FromEventPattern<EventHandler, EventArgs>(x => command.CanExecuteChanged += x, x => command.CanExecuteChanged -= x)
.Select(_ => command.CanExecute(latestParam))
.Subscribe(x => enabledSetter(target, x, null)));

return compDisp;
}
#endif
}
}

9 changes: 1 addition & 8 deletions src/ReactiveUI/Platforms/ios/FlexibleCommandBinder.cs
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MS-PL license.
// See the LICENSE file in the project root for more information.

Expand All @@ -9,10 +9,7 @@
using System.Reactive.Linq;
using System.Reflection;
using System.Windows.Input;

#if UIKIT
using UIKit;
#endif

namespace ReactiveUI
{
Expand Down Expand Up @@ -52,9 +49,7 @@ public IDisposable BindCommandToObject(ICommand command, object target, IObserva
}

public IDisposable BindCommandToObject<TEventArgs>(ICommand command, object target, IObservable<object> commandParameter, string eventName)
#if MONO
where TEventArgs : EventArgs
#endif
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -119,7 +114,6 @@ protected static IDisposable ForEvent(ICommand command, object target, IObservab
return compDisp;
}

#if UIKIT
/// <summary>
/// Creates a commands binding from event and a property
/// </summary>
Expand Down Expand Up @@ -156,6 +150,5 @@ protected static IDisposable ForTargetAction(ICommand command, object target, IO

return compDisp;
}
#endif
}
}
6 changes: 2 additions & 4 deletions src/ReactiveUI/Platforms/ios/LinkerOverrides.cs
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MS-PL license.
// See the LICENSE file in the project root for more information.

Expand All @@ -7,7 +7,6 @@

namespace ReactiveUI.Cocoa
{
#if UIKIT
/// <summary>
/// This class exists to force the MT linker to include properties called by RxUI via reflection
/// </summary>
Expand Down Expand Up @@ -65,5 +64,4 @@ public void KeepMe()
eh.Invoke(null, null);
}
}
#endif
}
}
7 changes: 1 addition & 6 deletions src/ReactiveUI/Platforms/ios/RoutedViewHost.cs
@@ -1,19 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MS-PL license.
// See the LICENSE file in the project root for more information.

using System;
using System.Reactive.Linq;
using System.Collections.Specialized;
using System.Reactive.Disposables;

#if UIKIT
using UIKit;
using NSView = UIKit.UIView;
using NSViewController = UIKit.UIViewController;
#else
using AppKit;
#endif

namespace ReactiveUI
{
Expand Down

0 comments on commit 26122a1

Please sign in to comment.