[gme-users] C# interpreters?

Daniel Waddington dwadding at atl.lmco.com
Wed Jan 4 09:42:03 CST 2006


Hi Zoli, I will likely try this out, it may be a few weeks though. I'll 
nag you later ;-)

Thanks,
Daniel.


Zoltan Molnar wrote:

> Hi,
> 
> Yes it did, but only with the help of a proxyinterpreter (a raw com
> interpreter) which currently just invokes this C# interpreter (because
> of the way GME installs/registers a new interpreter is not yet suitable
> for C# interpreters).
> 
> The keyword is CCW (Com Callable Wrapper), which enables .NET objects to
> be callable from/like COM.
> 
> The C# interpreter has to refer the Mga, MgaUtil libraries and has to
> include the System.Runtime.InteropServices; too.
> In project settings 'Register for COM interop' has to be enabled.
> 
> 
> using System;
> using System.Runtime.InteropServices;
> using MGAUTILLib;
> using MGALib;
> using System.Windows.Forms;
> 
> namespace CSInterpreter2
> {
> 	[Guid("EA60E5CC-D141-47d7-98ED-7B8C686BDF52")]
> 	[ClassInterface(ClassInterfaceType.None)]
> 	[ProgId("Mga.Interpreter.CS2IntwMZNumbers")]
> 	public class MyMgaComponent : IMgaComponentEx, IMgaComponent,
> IMgaVersionInfo
> 	{
> 		public MyMgaComponent()
> 		{
> 		}
> 
> 		#region IMgacomponentEx
> 
> 		public void InvokeEx( MgaProject project, MgaFCO
> currentobj, MgaFCOs selectedobjs, int param)
> 		{
> 			System.Text.StringBuilder sb = new
> System.Text.StringBuilder( "My kids are: ");
> 			System.Windows.Forms.MessageBox.Show( "Is it
> really running?");
> 			IMgaTerritory terr;
> 			project.CreateTerritory( null, out terr, null);
> 			transactiontype_enum mod =
> transactiontype_enum.TRANSACTION_GENERAL;
> 			project.BeginTransaction( terr, mod);
> 
> 			MgaFolder rf = project.RootFolder;
> 			MgaFCOs childColl = rf.ChildFCOs;
> 			foreach( MgaFCO child in childColl)
> 			{
> 				sb.AppendFormat( " {0}", child.Name);
> 			}
> 			project.CommitTransaction();
> 			
> 			System.Windows.Forms.MessageBox.Show(
> sb.ToString());
> 			return;
> 		}
> 
> 
> 		public void ObjectsInvokeEx( MgaProject project,
> MgaObject currentobj, MgaObjects selectedobjs, int param)
> 		{
> 			return;
> 		}
> 
> 		private string m_componentProgId =
> "Mga.Interpreter.CS2IntwMZNumbers";
> 		public string ComponentProgID
> 		{ 
> 			get { return m_componentProgId; }
> 		}
> 
> 		public void set_ComponentParameter( string name,
> System.Object variantObj)
> 		{
> 			return;
> 		}
> 		public System.Object get_ComponentParameter( string
> name)
> 		{
> 			return new System.Object();
> 		}
> 		#endregion
> 
> 		#region Imgacomponent
> 
> 		public void Invoke( MgaProject project, MgaFCOs
> selectedobjs, int param)
> 		{
> 			return;
> 		}
> 		public void Initialize( MgaProject project)
> 		{
> 			return;
> 		}
> 		public void Enable( bool newVal)
> 		{
> 			return;
> 		}
> 
> 		private bool m_interactive;
> 		public bool InteractiveMode 
> 		{ 
> 			get { return m_interactive; }
> 			set { m_interactive = value;}
> 		}
> 			
> 		private string m_componentName = "Dummy Csharp
> interpreter";
> 		public string ComponentName 
> 		{ 
> 			get{ return m_componentName; } 
> 		}
> 			
> 		private componenttype_enum m_componentType =
> componenttype_enum.COMPONENTTYPE_INTERPRETER;
> 		public componenttype_enum ComponentType 
> 		{ 
> 			get { return m_componentType; }
> 		}
> 			
> 		private string m_paradigm = "SF";
> 		public string Paradigm 
> 		{ 
> 			get { return m_paradigm;} 
> 		}
> 		#endregion
> 
> 		#region Imgaversioninfo
> 		public MGAUTILLib.MgaInterfaceVersion_enum version
> 		{ 
> 			get { return 0;} 
> 		}
> 		#endregion
> 
> 	}
> }
> 
> 
> Finally, the proxyinterpreter's source:
> 
> STDMETHODIMP RawComponent::InvokeEx( IMgaProject *project,  IMgaFCO
> *currentobj,  
> 	
> IMgaFCOs *selectedobjs,  long param) {
> 	COMTRY {
>      CComBSTR bstrCompName( L"Mga.Interpreter.CS2IntwMZNumbers" );
>  
>      CComPtr<IMgaComponentEx> grComponent;
>      COMTHROW( grComponent.CoCreateInstance( bstrCompName ) ) ;
>      COMTHROW( grComponent->put_InteractiveMode( VARIANT_TRUE ) );
>      COMTHROW( grComponent->Enable( VARIANT_TRUE ) );
>      COMTHROW( grComponent->Initialize( project ) );
>      HRESULT ret = grComponent->InvokeEx( project, currentobj,
> selectedobjs, param ) ;
>      if(ret != S_OK)
>       return ret;
> 	} COMCATCH(;);
> }
> 
> Br, Zoli
> 
> 
> 
>>-----Original Message-----
>>From: gme-users-bounces at list.isis.vanderbilt.edu 
>>[mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf 
>>Of Daniel Waddington
>>Sent: Tuesday, December 20, 2005 5:06 PM
>>To: gme-users
>>Subject: [gme-users] C# interpreters?
>>
>>
>>Hi,
>>
>>Has anyone implemented an GME interpreter in C#?
>>
>>Thanks,
>>Daniel.
>>
>>_______________________________________________
>>gme-users mailing list
>>gme-users at list.isis.vanderbilt.edu
>>http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
>>
> 
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users

-- 
===============================
  Dr. Daniel G. Waddington
  Lockheed Martin ATL
  3 Executive Campus, 6th Floor
  Cherry Hill, NJ 08002
  Tel:856 792 9740
===============================


More information about the gme-users mailing list