Skip to content

Commit fa0132c

Browse files
weitzhandlerglennawatson
authored andcommitted
Feature: add constructors to Uno ReactiveUserControl for Android/iOS (#2119)
1 parent 2637a5d commit fa0132c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6+
using System;
67
using System.Diagnostics.CodeAnalysis;
78
#if NETFX_CORE || HAS_UNO
89
using Windows.UI.Xaml;
@@ -81,6 +82,9 @@ namespace ReactiveUI
8182
/// <typeparam name="TViewModel">
8283
/// The type of the view model backing the view.
8384
/// </typeparam>
85+
#if HAS_UNO && IOS
86+
[global::Foundation.Register]
87+
#endif
8488
[SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")]
8589
public abstract
8690
#if HAS_UNO
@@ -100,6 +104,48 @@ class ReactiveUserControl<TViewModel> :
100104
typeof(ReactiveUserControl<TViewModel>),
101105
new PropertyMetadata(null));
102106

107+
#if HAS_UNO
108+
/// <summary>
109+
/// Initializes a new instance of the <see cref="ReactiveUserControl{TViewModel}"/> class.
110+
/// </summary>
111+
protected ReactiveUserControl()
112+
{
113+
// needed so the others are optional.
114+
}
115+
116+
#if ANDROID
117+
/// <summary>
118+
/// Initializes a new instance of the <see cref="ReactiveUserControl{TViewModel}"/> class.
119+
/// Native constructor, do not use explicitly.
120+
/// </summary>
121+
/// <remarks>
122+
/// Used by the Xamarin Runtime to materialize native
123+
/// objects that may have been collected in the managed world.
124+
/// </remarks>
125+
/// <param name="javaReference">A <see cref="IntPtr"/> containing a Java Native Interface (JNI) object reference.</param>
126+
/// <param name="transfer">A <see cref="JniHandleOwnership"/> indicating how to handle handle.</param>
127+
protected ReactiveUserControl(IntPtr javaReference, global::Android.Runtime.JniHandleOwnership transfer)
128+
: base(javaReference, transfer)
129+
{
130+
}
131+
#endif
132+
#if IOS
133+
/// <summary>
134+
/// Initializes a new instance of the <see cref="ReactiveUserControl{TViewModel}"/> class.
135+
/// Native constructor, do not use explicitly.
136+
/// </summary>
137+
/// <param name="handle">Handle to the native control.</param>
138+
/// <remarks>
139+
/// Used by the Xamarin Runtime to materialize native.
140+
/// objects that may have been collected in the managed world.
141+
/// </remarks>
142+
protected ReactiveUserControl(IntPtr handle)
143+
: base(handle)
144+
{
145+
}
146+
#endif
147+
#endif
148+
103149
/// <summary>
104150
/// Gets the binding root view model.
105151
/// </summary>

0 commit comments

Comments
 (0)