English 中文(简体)
要求履行职务
原标题:Serialize a call to a function

I need to implement the concept of task in my application. In my project, the task is an operation that must be performed and is identified by a name: each task also has input parameters (types and values) and produces one or more outputs.

Having to implement the Task class, how can I express the concept of "operation that has some kind of result"? I could store the name of the operation in a string attribute, but how do I express the type returned by this operation? Similarly, how can I implement a list of input parameters of the operation, when these parameters may also be of different types?

目标是将工作队的目标编成序号,并将其发送至另一节点。 接收人分析所收到的任务对象,读写行动的名称并履行相应的职能。

例如,假设A和Node B“拥有”以下方法......

a. 拨号A:

- double getAreaOfRectangle(double length, double width);
- double getAreaOfTriangle(double base, double height);
- double getAreaOfParallelogram(double base, double height).

B号:

- double getAreaOfCircle(double radius);
- double getAreaOfTrapezoid(double base1, double base2, double height).

If the node C needs to calculate the area of ​​a rectangle, it knows it must contact the node A and send a message to node A by specifying the operation (double areaOfRectangle) and the inputs (double width and double height). Similarly, if the node C needs to calculate the area of ​​a circle, it must send a message to node B, specifying the operation and the length of the radius. In order to send the inputs, since they could be different types (or even new user-defined types), I could use an array of object...

有些任务可能取决于其他任务,即投入参数可能至少具有另一项任务的一项产出,因此,我还需要执行任务产出与另一项任务的投入之间的联系。

我应如何界定这一类别?

问题回答

您应考虑使用4.NET中的表达树。 参见本条关于更轻松的内容。

C#中的陈代谢树





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签