[Monodevelop-patches-list] r2503 - in trunk/MonoDevelop/Core/src/Tools: . mdhost mdhost/src
Lluis Sanchez <lluis@ximian.com>
lluis at mono-cvs.ximian.com
Mon May 2 20:28:50 EDT 2005
Author: lluis
Date: 2005-05-02 20:28:50 -0400 (Mon, 02 May 2005)
New Revision: 2503
Added:
trunk/MonoDevelop/Core/src/Tools/mdhost/
trunk/MonoDevelop/Core/src/Tools/mdhost/Makefile.am
trunk/MonoDevelop/Core/src/Tools/mdhost/src/
trunk/MonoDevelop/Core/src/Tools/mdhost/src/AssemblyInfo.cs
trunk/MonoDevelop/Core/src/Tools/mdhost/src/mdhost.cs
Log:
New application that hosts out-of-process objects.
Added: trunk/MonoDevelop/Core/src/Tools/mdhost/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/Tools/mdhost/Makefile.am 2005-05-03 00:26:49 UTC (rev 2502)
+++ trunk/MonoDevelop/Core/src/Tools/mdhost/Makefile.am 2005-05-03 00:28:50 UTC (rev 2503)
@@ -0,0 +1,22 @@
+
+ASSEMBLY = mdhost.exe
+
+FILES = src/AssemblyInfo.cs \
+src/mdhost.cs
+
+build_sources = $(addprefix $(srcdir)/, $(FILES))
+
+all: $(ASSEMBLY)
+
+REFS = /r:$(top_builddir)/build/bin/MonoDevelop.Base.dll /r:System.Runtime.Remoting
+
+$(ASSEMBLY): $(build_sources)
+ $(CSC) $(build_sources) $(REFS) /out:$(ASSEMBLY) \
+ && cp $(ASSEMBLY) $(top_builddir)/build/bin/.
+
+assemblydir = $(libdir)/monodevelop/bin
+assembly_DATA = $(ASSEMBLY)
+
+CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
+EXTRA_DIST = $(FILES)
+
Added: trunk/MonoDevelop/Core/src/Tools/mdhost/src/AssemblyInfo.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Tools/mdhost/src/AssemblyInfo.cs 2005-05-03 00:26:49 UTC (rev 2502)
+++ trunk/MonoDevelop/Core/src/Tools/mdhost/src/AssemblyInfo.cs 2005-05-03 00:28:50 UTC (rev 2503)
@@ -0,0 +1,33 @@
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes specify the key for the sign of your assembly. See the
+// .NET Framework documentation for more information about signing.
+// This is not required, if you don't want signing let these attributes like they're.
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
Added: trunk/MonoDevelop/Core/src/Tools/mdhost/src/mdhost.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Tools/mdhost/src/mdhost.cs 2005-05-03 00:26:49 UTC (rev 2502)
+++ trunk/MonoDevelop/Core/src/Tools/mdhost/src/mdhost.cs 2005-05-03 00:28:50 UTC (rev 2503)
@@ -0,0 +1,116 @@
+//
+// mdhost.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using MonoDevelop.Services;
+using System.IO;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Runtime.Remoting.Lifetime;
+using System.Reflection;
+
+public class MonoDevelopProcessHost
+{
+ public static int Main (string[] args)
+ {
+ if (args.Length == 0) {
+ Console.WriteLine ("This application is for MonoDevelop internal use only.");
+ return 0;
+ }
+ try {
+ ChannelServices.RegisterChannel (new TcpChannel (0));
+
+ byte[] data = Convert.FromBase64String (args [0]);
+ MemoryStream ms = new MemoryStream (data);
+ BinaryFormatter bf = new BinaryFormatter ();
+ IProcessHostController pc = (IProcessHostController) bf.Deserialize (ms);
+
+ ProcessHost rp = new ProcessHost (pc);
+ pc.RegisterHost (rp);
+ try {
+ pc.WaitForExit ();
+ } catch {
+ }
+ rp.Dispose ();
+
+ } catch (Exception ex) {
+ }
+
+ return 0;
+ }
+}
+
+public class ProcessHost: MarshalByRefObject, IProcessHost, ISponsor
+{
+ IProcessHostController controller;
+
+ public ProcessHost (IProcessHostController controller)
+ {
+ this.controller = controller;
+ MarshalByRefObject mbr = (MarshalByRefObject) controller;
+ ILease lease = mbr.GetLifetimeService () as ILease;
+ lease.Register (this);
+ }
+
+ public RemoteProcessObject CreateInstance (Type type)
+ {
+ RemoteProcessObject proc = (RemoteProcessObject) Activator.CreateInstance (type);
+ proc.Attach (controller);
+ return proc;
+ }
+
+ public RemoteProcessObject CreateInstance (string fullTypeName)
+ {
+ Type t = Type.GetType (fullTypeName);
+ if (t == null) throw new InvalidOperationException ("Type not found: " + fullTypeName);
+ return CreateInstance (t);
+ }
+
+ public RemoteProcessObject CreateInstance (string assemblyPath, string typeName)
+ {
+ Assembly asm = Assembly.LoadFrom (assemblyPath);
+ Type t = asm.GetType (typeName);
+ if (t == null) throw new InvalidOperationException ("Type not found: " + typeName);
+ return CreateInstance (t);
+ }
+
+ TimeSpan ISponsor.Renewal (ILease lease)
+ {
+ return TimeSpan.FromSeconds (7);
+ }
+
+ public void Dispose ()
+ {
+ MarshalByRefObject mbr = (MarshalByRefObject) controller;
+ ILease lease = mbr.GetLifetimeService () as ILease;
+ lease.Unregister (this);
+ }
+}
More information about the Monodevelop-patches-list
mailing list