如何使用类重构c#代码阶段?

问题描述 投票:0回答:1

所以我在BP的代码阶段中有一些代码,它可以工作。 问题是它很笨重,冗长而脆弱。我想知道怎么可能在BP中使用class / es将这些代码重构为更简洁和可扩展的东西,而不必编写外部类库然后引用它(这不是那么容易做到的)我的环境)。 我知道可以使用Global Code选项卡编写方法,但是我可以在那里编写一个抽象类吗?子类去哪儿了?接口怎么样?如果这是太基本的道歉,我以前找不到任何指导我的东西。任何帮助或指示表示赞赏,谢谢。

代码是一个基本决策阶段,它使用来自数据项“Main_Segment”的输入,并使用本地(私有)变量“parcel_label”和“found”将一些静态值输出到BP数据项“Parcel_Label”和“Found”中。

(BP数据项)找到=(局部变量)

(BP数据项)Parcel_Label =(局部变量)parcel_label

(BP数据项)Main_Segment =(局部变量)segdescript

string segdescript = Main_Segment;
found = false;
parcel_label = "";


    if (segdescript.Contains("Segment 001") || segdescript.Contains("Segment 101"))
            {
                found = true;       //if first condition is met, assign value of true to "found".
                if (found = true)   //as "found" is now true, the assignment below is carried out.
                {
                    parcel_label = "Parcel0000";
                }
            }
//and again...

    if (segdescript.Contains("Segment 002") || segdescript.Contains("Segment 202"))
            {
                found = true;
                if (found = true)
                {
                    parcel_label = "Parcel1111";
                }
            }
//and again another 97 times...zzz

c# .net blueprism rpa
1个回答
1
投票

好吧我明白了:所以可以编写抽象类和任意数量的子类和接口,但它们都必须在初始化页面的“全局代码”选项卡中相互编写。然后,可以从整个项目中的各个代码阶段实例化这些子类中的任何一个。

© www.soinside.com 2019 - 2024. All rights reserved.