wawawawa
unread,Nov 30, 2007, 11:19:52 AM11/30/07Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi, I am trying to make a attribibute that decorate a method. The
attribute will spawn a process on execute that method then exit that
process after the method execution is done. But I got stuck.
The idea is do this:
[ProcessRepeat(10)]
public void something(){
}
Then it will have 10 process to run somthing(). Then each of those
processes kill themselves when something() returns. How something
deals with sychroniszation issues on their shared resource is
something() problem.
Can anyone help? Thanks
Here is all I can come up with:
using System;
using System.Diagnostics;
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
public class ProcessRepeatAttribute : TestAttributeBase //TSee end
of file for code:If insterested.
{
int count;
Process[] processList;
public int Count
{ get { return count; } //??? any locking req? }
public ProcessRepeatAttribute(int count) {
if (threadCount > 0) {
lock (threadCount) {
this.threadCount = threadCount;
}
}
}
internal class ProcessRepeatAttributeTestDecorator : TestDecorator //
TestDecorator is just holder of 2 empty func before and after test
run. + gettestdecorator; all empty body
{
Process[] processList = new
Process[ProcessRepeatAttribute.Count];
ProcessRepeatAttribute processRepeatAttribute;
public override void BeforeTestRun() {
base.BeforeTestRun(); //the base before
test run is empty
//processList[i].Process.Start() <---
}
public override void AfterTestRun() {
base.AfterTestRun (); //nase call is empty
//processList[i].Kill;
}
}
public override TestDecorator GetTestDecorator()
{
return new ProcessRepeatAttributeTestDecorator();
}
}
}
-------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
[AttributeUsage(AttributeTargets.Method, AllowMultiple=true)]
public abstract class TestAttributeBase : Attribute
{
public abstract TestDecorator GetTestDecorator();
private MethodInfo _method;
protected MethodInfo MethodInfo
{
get { return _method; }
}
object testClassInstance;
internal protected object TestClassInstance
{
get { return testClassInstance; }
set { testClassInstance = value; }
}
internal void SetMethodInfo(MethodInfo method)
{
_method = method;
}
}