Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

35
external/rx/xpkg/Details.md vendored Normal file
View File

@@ -0,0 +1,35 @@
The Reactive Extensions (Rx) is a library for composing asynchronous
and event-based programs using observable sequences and LINQ-style
query operators. Using Rx, developers represent asynchronous data
streams with Observables , query asynchronous data streams using LINQ
operators , and parameterize the concurrency in the asynchronous data
streams using Schedulers . Simply put, Rx = Observables + LINQ +
Schedulers.
Whether you are authoring a traditional desktop or web-based
application, you have to deal with asynchronous and event-based
programming from time to time. Desktop applications have I/O
operations and computationally expensive tasks that might take a long
time to complete and potentially block other active
threads. Furthermore, handling exceptions, cancellation, and
synchronization is difficult and error-prone.
Using Rx, you can represent multiple asynchronous data streams (that
come from diverse sources, e.g., stock quote, tweets, computer events,
web service requests, etc., and subscribe to the event stream using
the IObserver<T> interface. The IObservable<T> interface notifies the
subscribed IObserver<T> interface whenever an event occurs.
Because observable sequences are data streams, you can query them
using standard LINQ query operators implemented by the Observable
extension methods. Thus you can filter, project, aggregate, compose
and perform time-based operations on multiple events easily by using
these standard LINQ operators. In addition, there are a number of
other reactive stream specific operators that allow powerful queries
to be written. Cancellation, exceptions, and synchronization are also
handled gracefully by using the extension methods provided by Rx.
To learn more about the Reactive Extensions, see Microsoft's
RX open source site:
http://rx.codeplex.com

108
external/rx/xpkg/GettingStarted.md vendored Normal file
View File

@@ -0,0 +1,108 @@
This Reactive Extensions (Rx) component is to package Reactive Extensions (version 2.x) from Microsoft.
Rx is published as an open source project and you can pick up sources from CodePlex (http://rx.codeplex.com). There is a dedicated web page section for Rx on MSDN website too: http://msdn.microsoft.com/en-us/data/gg577609.aspx
This component contains Rx libraries that are suited for Xamarin.Android and Xamarin.iOS.
We are not going to explain what is Rx and how the library works. To begin with basics of Rx, their website has lots of introductory materials on those websites. On this document, we explain how to use Rx in Xamarin products.
# Adjusting Library References
After adding this component to your project, you would notice that there are several dlls in this package. You would however most likely need to use the following four assemblies:
* System.Reactive.Interfaces.dll
* System.Reactive.Core.dll
* System.Reactive.Linq.dll
* System.Reactive.PlatformServices.dll
All other assemblies are optional and you would like to use them only in certain scenarios. On the other hand, those four assemblies are essential. So far let's remove other assemblies in this package.
![typical Rx assembly references](https://raw.github.com/mono/rx/rx-oss-v2.1/xpkg/ProjectReferences.png)
(Note that Rx version 2.x is very different from Rx v1.0 in terms of assemblies; Rx 1.0 consists only of System.Reactive.dll, which does not exist in Rx v2.x.)
# Sample: Transforming touch events into another event
Here I show an example use of Observable.FromEventPattern() and Observable.ToEventPattern() methods to turn View.Touch event into "notify only when three fingers are moving" event (here I named it as "TripleTouch").
Let's begin with a simple application project. After you created one, you will need some using statements for Rx:
using System.Reactive;
using System.Reactive.Linq;
The "TripleTouch" event is defined and implemented as follows:
IEventPatternSource<View.TouchEventArgs> triple_touch_source;
public event EventHandler<View.TouchEventArgs> TripleTouch {
add { triple_touch_source.OnNext += value; }
remove { triple_touch_source.OnNext -= value; }
}
This event is populated when the View is set up. In the simple application sample, I wrote this in the Activity's OnCreate():
...
// this "surface" is the target View here.
// It can be "this" when you implement a custom component.
var surface = FindViewById<View> (Resource.Id.theToucheable);
triple_touch_source = Observable.FromEventPattern<View.TouchEventArgs> (surface, "Touch")
.Where (ev => ev.EventArgs.Event.Action == MotionEventActions.Move)
.Where (ev => ev.EventArgs.Event.PointerCount == 3)
.ToEventPattern ();
...
Then it could be consumed by the View users (in the sample, the first line of code is in OnCreate() method):
...
TripleTouch += (sender, ev) => this.RunOnUiThread (() => text.Text = GetEventDescription (ev.Event));
...
static string GetEventDescription (MotionEvent e)
{
return string.Format ("({0}, {1})", e.RawX, e.RawY);
}
In the sample app project, we defined very simple UI in Main.axml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<View
android:id="@+id/theToucheable"
android:layout_width="fill_parent"
android:layout_height="440.7dp"
android:layout_marginBottom="0.0dp" />
<TextView
android:id="@+id/theText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="(touch corrdinates shown here)" />
</LinearLayout>
The sample is all done. Build and run the app on device. Then touch one finger. Nothing happens. Touch with one more finger. Still nothing happens. Add another finger. Then it starts showing the coordinate (of the first finger; this is just a sample so it doesn't give complicated action).
What implements such behavior? Let's see the Observable part:
triple_touch_source = Observable.FromEventPattern<View.TouchEventArgs> (surface, "Touch")
This converts View.Touch event into an IObservable.
.Where (ev => ev.EventArgs.Event.Action == MotionEventActions.Move)
This filters out events that are not move events.
.Where (ev => ev.EventArgs.Event.PointerCount == 3)
This filters out events that don't detect three fingers. Now that we have only three-fingered events, we want to convert this observables into another event source:
.ToEventPattern ();
Once it's done, we use it to process the actual event. Note that since we are going to control UI, we need to invoke RunOnUiThread():
TripleTouch += (sender, ev) => this.RunOnUiThread (() => text.Text = GetEventDescription (ev.Event));
Actually, if you don't convert the filtered observables into another event, you might want to use SynchronizationContext instead (we didn't do that in this example because having event processing all within the UI thread is not good):
(...) .SubscribeOn (Android.App.Application.SynchronizationContext) (...)

54
external/rx/xpkg/Makefile vendored Normal file
View File

@@ -0,0 +1,54 @@
all: package
clean: android_clean iOS_clean
.PHONY: android android_build android_copy android_sign
android: Rx_Xamarin android_build android_copy #android_sign
android_build:
xbuild Rx_Xamarin/Rx_Xamarin_android.sln /p:DelaySign=false /p:AssemblyOriginatorKeyFile=$(KEYFILE_SNK) /p:SignAssembly=$(SIGN_ASSEMBLY) /p:SignAssemblySpec=$(SIGN_ASSEMBLY_SPEC)
android_copy:
for proj in Interfaces Core Linq PlatformServices Debugger Providers Runtime.Remoting Experimental ; \
do \
cp Rx_Xamarin/android/rx/System.Reactive.$$proj/bin/Debug/System.Reactive.$$proj.dll Rx_Xamarin/android/libs ; \
done
android_sign:
for proj in Interfaces Core Linq PlatformServices Debugger Providers Runtime.Remoting Experimental ; \
do \
sn -R Rx_Xamarin/android/libs/System.Reactive.$$proj.dll $(KEYFILE_SNK) ; \
done
.PHONY: iOS iOS_build iOS_copy iOS_sign
iOS: Rx_Xamarin iOS_build iOS_sign #iOS_sign
iOS_build:
xbuild Rx_Xamarin/Rx_Xamarin_iOS.sln
iOS_copy:
for $$proj in Interfaces Core Linq PlatformServices Debugger Experimental \
do \
cp Rx_Xamarin/iOS/rx/System.Reactive.$(proj)/bin/Debug/System.Reactive.$(proj).dll Rx_Xamarin/iOS/libs \
done
iOS_sign:
for $$proj in Interfaces Core Linq PlatformServices Debugger Experimental \
do \
sn -R Rx_Xamarin/iOS/libs/System.Reactive.$(proj).dll $(KEYFILE_SNNK) \
done
package: android iOS
./build-package.sh
Rx_Xamarin:
ln -s ../Rx/NET/Source/Rx_Xamarin Rx_Xamarin
android_clean: Rx_Xamarin
xbuild Rx_Xamarin/Rx_Xamarin_android.sln /t:Clean
iOS_clean: Rx_Xamarin
xbuild Rx_Xamarin/Rx_Xamarin_iOS.sln /t:Clean

BIN
external/rx/xpkg/ProjectReferences.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

12
external/rx/xpkg/README vendored Normal file
View File

@@ -0,0 +1,12 @@
You need to prepare signing key file (sln) to sign those assemblies. Xamarin packages should be signed with its own key.
To build *signed* assemblies, you need to run:
make KEYFILE_SNK=/path/to/yourkey.snk SIGN_ASSEMBLY=true SIGN_ASSEMBLY_SPEC=SIGNED
Xamarin will publish "signed" version of those assemblies on the component
store, so that Starter users can make use of Rx assemblies.
If you don't need any signing, simply build Rx_Xamarin/android/Rx_Xamarin_android.sln.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

27
external/rx/xpkg/build-package.sh vendored Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
mono xpkg.exe create RxForXamarin-2.1.xam \
--name="Reactive Extensions (Rx) for Xamarin" \
--publisher="Xamarin, Inc." \
--website="http://www.xamarin.com" \
--summary="a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators." \
--license="../Rx/NET/Source/license.txt" \
--library=android:Rx_Xamarin/android/libs/System.Reactive.Interfaces.dll \
--library=android:Rx_Xamarin/android/libs/System.Reactive.Core.dll \
--library=android:Rx_Xamarin/android/libs/System.Reactive.Linq.dll \
--library=android:Rx_Xamarin/android/libs/System.Reactive.PlatformServices.dll \
--library=android:Rx_Xamarin/android/libs/System.Reactive.Experimental.dll \
--library=android:Rx_Xamarin/android/libs/System.Reactive.Debugger.dll \
--library=android:Rx_Xamarin/android/libs/System.Reactive.Providers.dll \
--library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Interfaces.dll \
--library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Core.dll \
--library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Linq.dll \
--library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.PlatformServices.dll \
--library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Experimental.dll \
--library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Debugger.dll \
--details=Details.md \
--getting-started=GettingStarted.md \
--details=Details.md \
--icon=RxForXamarin_128x128.png \
--sample="Touch Event Observable Sample. Observable event pattern conversion sample using View.Touch event:Rx_Xamarin/android/samples/ReactiveAndroidSample/ReactiveAndroidSample.sln" \
--sample="GitHub API Client Sample. GitHub API client sample demonstrates use of Rx API with GitHub:Rx_Xamarin/android/samples/GithubApiClientSample/GithubApiClientSample.sln"