Click here to Skip to main content
15,892,643 members
Articles / Programming Languages / C#

Remoting Probe

Rate me:
Please Sign up or sign in to vote.
4.96/5 (29 votes)
10 Sep 200216 min read 195.8K   2.2K   98  
Using the remoting probe to publish details of the "talking" between the remoting object and its consumer. Here is its design, implementation and usage in the Remoting Analyzer Studio.
//=============================================================================
//	The Remoting Probe State class (internal class)
//	and IRemotingProbe.
//	(C) Copyright 2002, Roman Kiss (rkiss@pathcom.com)
//	All rights reserved.
//	The code and information is provided "as-is" without waranty of any kind,
//	either expresed or implied.
//-----------------------------------------------------------------------------
//	History:
//		08/26/2002	Roman Kiss				Initial Revision
//=============================================================================
//
using System;
using System.Text;

namespace RKiss.MessageProbe
{
	#region classes
	public class ProbeState 
	{
		//status (sharable read/write fields) 
		private volatile bool m_EnableCall = false;
		private volatile bool m_EnableReturn = false;
		private volatile bool m_EnableError = false;
		private volatile bool m_EnableBinary = true;
		//signature of the probe (readonly)
		string  m_name = "";
		string	m_Id = Guid.NewGuid().ToString();
		string  m_TimeStamp = DateTime.Now.ToString();
		
		//
		public string Name			 {get { return m_name; }}
		public string Id				 {get { return m_Id; }}
		public string TimeStamp  {get { return m_TimeStamp; }}
		public bool EnableCall   {get { return m_EnableCall; }}
		public bool EnableReturn {get { return m_EnableReturn; }}
		public bool EnableError  {get { return m_EnableError; }}
		public bool EnableBinary {get { return m_EnableBinary; }}
		
		public ProbeState() {}
		public ProbeState(string name, bool call, bool ret, bool err, bool binary) 
		{
			m_name = name; 
			m_EnableCall = call; m_EnableReturn = ret; m_EnableError = err; m_EnableBinary = binary; 
		}
		public string GetStatus() 
		{
			StringBuilder sb = new StringBuilder();
			sb.AppendFormat("call = {0}, return = {1}, error = {2}, binary = {3}", 
											m_EnableCall, m_EnableReturn, m_EnableError, m_EnableBinary);
			return sb.ToString();
		}
		public void SetStatus(string status) 
		{
			if(status != null) 
			{
				string[] ctrls = status.Split(',');
				if(ctrls != null) 
				{
					foreach(string ctrl in ctrls) 
					{
						string[] prop = ctrl.Trim().Split('=');
						string name = prop[0].Trim();
						string val = prop[1].Trim();
						if(name == "call")
							m_EnableCall = Convert.ToBoolean(val);
						else
						if(name == "return")
							m_EnableReturn = Convert.ToBoolean(val);
						else
						if(name == "error")
							m_EnableError = Convert.ToBoolean(val);
						else
						if(name == "binary")
							m_EnableBinary = Convert.ToBoolean(val);
						else
						if(name == "All")
						{
							m_EnableCall = Convert.ToBoolean(val);
							m_EnableReturn = Convert.ToBoolean(val);
							m_EnableError = Convert.ToBoolean(val);
						}
					}
				}
			}
		}

	}
	#endregion
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions