Do something if the parameter name is someParam

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • roundcrisis

    #1

    Do something if the parameter name is someParam

    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

  • Chris Shepherd

    #2
    Re: Do something if the parameter name is someParam

    roundcrisis wrote:
    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(s tring 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.

    Comment

    • roundcrisis

      #3
      Re: Do something if the parameter name is someParam

      On Nov 16, 3:18 pm, Chris Shepherd <c...@nospam.ch sh.cawrote:
      roundcrisis wrote:
      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(s tring 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

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Do something if the parameter name is someParam

        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 ContextBoundObj ect,
        but it would require you to derive all your classes from ContextBoundObj ect,
        as well as write the sink code. Also, all of your parameters would have to
        be serializable or derive from MarshalByRefObj ect, and there would be a
        performance hit in calling your objects as well.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "roundcrisi s" <roundcrisis@gm ail.comwrote in message
        news:4867e928-16ce-4f5b-be86-f41ad07cd8ac@e1 g2000hsh.google groups.com...
        On Nov 16, 3:18 pm, Chris Shepherd <c...@nospam.ch sh.cawrote:
        >roundcrisis wrote:
        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(s tring 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
        >

        Comment

        • roundcrisis

          #5
          Re: Do something if the parameter name is someParam

          On Nov 16, 4:41 pm, "Nicholas Paldino [.NET/C# MVP]"
          <m...@spam.guar d.caspershouse. comwrote:
          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 ContextBoundObj ect,
          but it would require you to derive all your classes from ContextBoundObj ect,
          as well as write the sink code. Also, all of your parameters would have to
          be serializable or derive from MarshalByRefObj ect, and there would be a
          performance hit in calling your objects as well.
          >
          --
          - Nicholas Paldino [.NET/C# MVP]
          - m...@spam.guard .caspershouse.c om
          >
          "roundcrisi s" <roundcri...@gm ail.comwrote in message
          >
          news:4867e928-16ce-4f5b-be86-f41ad07cd8ac@e1 g2000hsh.google groups.com...
          >
          >
          >
          On Nov 16, 3:18 pm, Chris Shepherd <c...@nospam.ch sh.cawrote:
          roundcrisis wrote:
          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(s tring 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- 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

          Comment

          Working...