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

View File

@@ -0,0 +1,62 @@
using System;
using System.Drawing;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using RxMouseService;
namespace RxMouseServer
{
public class MouseService : MarshalByRefObject, IMouseService, IObserver<Point>
{
private ReplaySubject<Point> _points;
public MouseService()
{
_points = new ReplaySubject<Point>();
}
public IObservable<Point> GetPoints()
{
var src = _points.ObserveOn(NewThreadScheduler.Default);
return Log(src).Remotable();
}
public IObservable<T> Log<T>(IObservable<T> source)
{
return Observable.Create<T>(observer =>
{
Console.WriteLine("Client connected!");
var d = source.Subscribe(observer);
return Disposable.Create(() =>
{
Console.WriteLine("Client disconnected!");
d.Dispose();
});
});
}
public void OnNext(Point value)
{
_points.OnNext(value);
}
public void OnError(Exception error)
{
throw new NotImplementedException();
}
public void OnCompleted()
{
throw new NotImplementedException();
}
public override object InitializeLifetimeService()
{
return null;
}
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Messaging;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
namespace RxMouseServer
{
partial class Program
{
static IObserver<Point> Msmq()
{
var q = "BARTDE-M6500\\Private$\\MouseService";
var queue = default(MessageQueue);
if (MessageQueue.Exists(q))
{
queue = new MessageQueue(q);
}
else
{
queue = MessageQueue.Create(q);
}
var format = new System.Messaging.BinaryMessageFormatter();
queue.Formatter = format;
var incoming = Observable.Create<string>(observer =>
{
return NewThreadScheduler.Default.ScheduleLongRunning(cancel =>
{
while (!cancel.IsDisposed)
{
var msg = queue.Receive();
observer.OnNext((string)msg.Body);
}
});
});
var sub = new ReplaySubject<Point>();
var map = new Dictionary<string, IDisposable>();
incoming.Subscribe(clientQueue =>
{
var command = clientQueue[0];
var target = clientQueue.Substring(2);
switch (command)
{
case 'S':
{
var cq = new MessageQueue(target);
var crm = new System.Messaging.BinaryMessageFormatter();
cq.Formatter = crm;
map[target] = sub.Subscribe(pt =>
{
cq.Send(pt);
});
}
break;
case 'D':
{
var d = default(IDisposable);
if (map.TryGetValue(target, out d))
d.Dispose();
}
break;
default:
throw new Exception("Don't know what you're talking about!");
}
});
return sub;
}
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections;
using System.Drawing;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Serialization.Formatters;
using RxMouseService;
namespace RxMouseServer
{
partial class Program
{
const string SERVICENAME = "MouseService";
static IObserver<Point> Remoting(int port)
{
ConfigureRemoting(port);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MouseService), SERVICENAME, WellKnownObjectMode.Singleton);
var ms = (IMouseService)Activator.GetObject(typeof(IMouseService), string.Format("tcp://{0}:{1}/{2}", "localhost", port, SERVICENAME));
return (IObserver<Point>)ms;
}
private static void ConfigureRemoting(int port)
{
var serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
var clientProvider = new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = port;
props["name"] = SERVICENAME;
props["typeFilterLevel"] = TypeFilterLevel.Full;
ChannelServices.RegisterChannel(new TcpChannel(props, clientProvider, serverProvider), false);
}
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Drawing;
using System.Reactive.Linq;
using System.Windows.Forms;
namespace RxMouseServer
{
partial class Program
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Server");
int port;
ParseArgs(args, out port);
var observer = Remoting(port);
var frm = new Form();
frm.Load += (o, e) =>
{
var g = frm.CreateGraphics();
var mme = (from mm in Observable.FromEventPattern<MouseEventArgs>(frm, "MouseMove")
select mm.EventArgs.Location)
.DistinctUntilChanged()
.Do(pt =>
{
g.DrawEllipse(Pens.Red, pt.X, pt.Y, 1, 1);
});
mme.Subscribe(observer);
};
Application.Run(frm);
}
static void ParseArgs(string[] args, out int port)
{
port = 9090;
if (args.Length == 1)
{
port = int.Parse(args[0]);
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RxMouseServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MSIT")]
[assembly: AssemblyProduct("RxMouseServer")]
[assembly: AssemblyCopyright("Copyright © MSIT 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1befbebc-d301-4b64-bb2e-522608dc8927")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{52568D5F-7C8A-49FE-A28D-119C7CBCC71D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RxMouseServer</RootNamespace>
<AssemblyName>RxMouseServer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Messaging" />
<Reference Include="System.Reactive.Core, Version=2.0.20527.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\System.Reactive.Core.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=2.0.0.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Linq, Version=2.0.20527.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\System.Reactive.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.PlatformServices, Version=2.0.20527.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\System.Reactive.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Runtime.Remoting, Version=2.0.20527.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\System.Reactive.Runtime.Remoting.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Windows.Forms, Version=1.0.10621.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\System.Reactive.Windows.Forms.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.Msmq.cs" />
<Compile Include="Program.Remoting.cs" />
<Compile Include="MouseService.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RxMouseService\RxMouseService.csproj">
<Project>{E1C1D499-15ED-454A-AE34-35F62E53250C}</Project>
<Name>RxMouseService</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>