Do something if the parameter name is someParam

  • Thread starter Thread starter roundcrisis
  • Start date Start date
R

roundcrisis

Hi there:

I m trying to do something (check values) if one of the parameter in a
procedure is used, for example

let say I have the following procedures:

index(int a, string specialParam, ..)
save (string specialParam)
delete(string specialParam, string lloooo)
upstream()

basically i want to run another prooc anytime a procedure that has
specialParam as a parameter is run, and actually if this proc returns
false, then the original procedure shouldn't run
I know this is not terribly clear so please feel free to ask for
clarification
any ideas?

Thanks
 
roundcrisis said:
Hi there:

I m trying to do something (check values) if one of the parameter in a
procedure is used, for example

let say I have the following procedures:

index(int a, string specialParam, ..)
save (string specialParam)
delete(string specialParam, string lloooo)
upstream()

basically i want to run another prooc anytime a procedure that has
specialParam as a parameter is run, and actually if this proc returns
false, then the original procedure shouldn't run
I know this is not terribly clear so please feel free to ask for
clarification
any ideas?

Just make another method and run it inside each method here.

ie:

private bool handleSpecial(string specialParam)
{ /* do stuff here */ }

then in other methods;

private void index(int a, string specialParam,..)
{
if (!handleSpecial(specialParam))
return;
}

What part are you confused about?

Chris.
 
Just make another method and run it inside each method here.

ie:

private bool handleSpecial(string specialParam)
{ /* do stuff here */ }

then in other methods;

private void index(int a, string specialParam,..)
{
if (!handleSpecial(specialParam))
return;

}

What part are you confused about?

Chris.- Hide quoted text -

- Show quoted text -

this is a bit bigger than that
many classes involved, etc
 
What you want is something like Aspect Oriented Programming, where you
could cross-cut all the methods that have a certain parameter.

Nothing like that exists for .NET right now, at least out of the box. I
believe there are some people out there working on something like this, but
I don't know how much progress was made. You could google AOP (or aspect
oriented programming) and .NET and see what comes up.

You could achieve this with creating a sink for a ContextBoundObject,
but it would require you to derive all your classes from ContextBoundObject,
as well as write the sink code. Also, all of your parameters would have to
be serializable or derive from MarshalByRefObject, and there would be a
performance hit in calling your objects as well.
 
What you want is something like Aspect Oriented Programming, where you
could cross-cut all the methods that have a certain parameter.

Nothing like that exists for .NET right now, at least out of the box. I
believe there are some people out there working on something like this, but
I don't know how much progress was made. You could google AOP (or aspect
oriented programming) and .NET and see what comes up.

You could achieve this with creating a sink for a ContextBoundObject,
but it would require you to derive all your classes from ContextBoundObject,
as well as write the sink code. Also, all of your parameters would have to
be serializable or derive from MarshalByRefObject, and there would be a
performance hit in calling your objects as well.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




this is a bit bigger than that
many classes involved, etc- Hide quoted text -

- Show quoted text -

thanks I m actually using monorail and I ended up using filters to
achieve this
very simple, short code and no need to repeat calls all over
It s a solution that doesnt suit everyone but works for me
Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top