Click here to Skip to main content
15,891,136 members
Articles / Programming Languages / C#

LiveCode.NET

Rate me:
Please Sign up or sign in to vote.
4.86/5 (55 votes)
6 May 2002Public Domain3 min read 231.7K   2.5K   170  
Compile C# code on-the-fly. Usage in a plug-in / plug-out component model.
//
//						PlugOne
//
//	sample splugin containing two classes implementing 'IPlugInterface'
//
using System;
using MultiPlug.PlugInterface;

namespace MultiPlug.PlugOne
{

public class FirstClass : MarshalByRefObject, IPlugInterface
{
	public FirstClass( string initString )
	{
		baseText = "FirstClass: " + initString;
	}

	public void Dispose()
		{}

	public string ModifyString( string inpString )
	{
		return baseText + " @ " + inpString;
	}

	public string CurrentText
	{
		get { return baseText;  }
		set { baseText = value; }
	}

	public bool StartThread( IPlugEvent eventCallback )
		{ throw new NotSupportedException( "MultiPlug.PlugOne.FirstClass doesn't support events!" ); }
		
	public void StopThread()
		{ throw new NotSupportedException( "MultiPlug.PlugOne.FirstClass doesn't support events!" ); }

	private string baseText;
}











// -------------------------------------------------------------------------------------
// ICustomInterface is a custom interface strictly for internal use only in this plugin

internal interface ICustomInterface
	{
	void CustomMethod( string anyString );
	}



	/// <summary> SecondClass is a plugin also implementing a custom interface besides IPlugInterface. </summary>
public class SecondClass : MarshalByRefObject, IPlugInterface, ICustomInterface
{
	public SecondClass( string initString )
	{
		baseText = "SecondClass: " + initString;
	}

	public void Dispose()
		{}

	public string ModifyString( string inpString )
	{
		return baseText + " @ " + inpString;
	}

	public string CurrentText
	{
		get { return baseText;  }
		set { baseText = value; }
	}

	public bool StartThread( IPlugEvent eventCallback )
		{ throw new NotSupportedException( "MultiPlug.PlugOne.SecondClass doesn't support events!" ); }
		
	public void StopThread()
		{ throw new NotSupportedException( "MultiPlug.PlugOne.SecondClass doesn't support events!" ); }


	void ICustomInterface.CustomMethod( string anyString )
	{
		baseText = anyString;
	}

	private string baseText;
}


}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Web Developer
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions