G
Guest
I am enjoying making generalized methods to serve common needs, such as:
ImageProcessing.MakeQuickResize();
ImageProcessing.Sharpen();
FileOps.CreateYearAndMonthAndDayDirectoryBasedOnDate()
Sender.EmailCommaDelimitedList()
What would be really cool is if I could make a generalized function that
would accept other methods as parameters, and would perform the methods on
another parameterized item that's fed to the function. So we might have the
equivalent of the following
public void ExecuteParameterizedMethodsOnEveryFileInADirectory( string
targetPath, MakeQuickResize(100,100), Sharpen(), ConvertToGray(),
RegisterInDb(), RenameByDBReference() ) ...
Is what I'm speculating about possible? Is this something that maybe
delegates are good for? (Have never used them...) If it is, can someone
suggest the right syntax? What I posit above is clearly wrong syntactically.
Finally, if it is possible to chain up methods in this way, I'm wondering if
there's any way to pass around return types to other members of the chain. A
hypothetical example would be:
Method 1 registers a filename in a database system, and a new filename is
derived from the DateTime stamp of creation
Method 2 uses that filename that was returned as a string to execute
something else.
Thanks for any insight you can offer.
-KF
ImageProcessing.MakeQuickResize();
ImageProcessing.Sharpen();
FileOps.CreateYearAndMonthAndDayDirectoryBasedOnDate()
Sender.EmailCommaDelimitedList()
What would be really cool is if I could make a generalized function that
would accept other methods as parameters, and would perform the methods on
another parameterized item that's fed to the function. So we might have the
equivalent of the following
public void ExecuteParameterizedMethodsOnEveryFileInADirectory( string
targetPath, MakeQuickResize(100,100), Sharpen(), ConvertToGray(),
RegisterInDb(), RenameByDBReference() ) ...
Is what I'm speculating about possible? Is this something that maybe
delegates are good for? (Have never used them...) If it is, can someone
suggest the right syntax? What I posit above is clearly wrong syntactically.
Finally, if it is possible to chain up methods in this way, I'm wondering if
there's any way to pass around return types to other members of the chain. A
hypothetical example would be:
Method 1 registers a filename in a database system, and a new filename is
derived from the DateTime stamp of creation
Method 2 uses that filename that was returned as a string to execute
something else.
Thanks for any insight you can offer.
-KF