- 概要
- カスタム アクティビティ
- アクティビティを .NET 6 に移行する
- リリース ノート
- ワークフロー アナライザーのルールを構築する
- アクティビティ プロジェクト設定の構成
- カスタム ウィザードの作成
- スコープによるアクティビティの優先度設定
- UiPath.Activities.Api.Base
- UiPath.Studio.Activities.Api
- UiPath.Studio.Activities.Api.Activities
- UiPath.Studio.Activities.Api.BusyService
- UiPath.Studio.Activities.Api.ExpressionEditor
- UiPath.Studio.Activities.Api.Expressions
- UiPath.Studio.Activities.Api.Licensing
- UiPath.Studio.Activities.Api.Mocking
- UiPath.Studio.Activities.Api.ObjectLibrary
- UiPath.Studio.Activities.Api.PackageBindings
- UiPath.Studio.Activities.Api.ProjectProperties
- UiPath.Studio.Activities.Api.ScopedActivities
- UiPath.Studio.Activities.Api.Settings
- UiPath.Studio.Activities.Api.Wizards
- UiPath.Studio.Activities.Api.Workflow
- UiPath.Studio.Api.Controls
- UiPath.Studio.Api.Telemetry
- UiPath.Studio.Api.Theme
- Robot JavaScript SDK
- トリガー SDK
- エージェント SDK

開発者ガイド
カスタム アクティビティのコードを記述する
カスタム アクティビティのコードの書き方をよりよく理解するために、ユーザーに 2 つの数字を求め、合計の四角形を出力する単純なアクティビティを作成してみましょう。
-
Microsoft Visual Studio を起動します。
-
[ ファイル] > [新規>プロジェクト... ] を選択します (ショートカット:
Ctrl + Shift + N)。[新しいプロジェクト] ウィンドウが表示されます。 -
[言語] ドロップダウン メニューから [C#] を選択します。C# を使用するすべての依存関係のリストが表示されます。
-
[クラス ライブラリ (.NET Framework)] を選択します。これは、カスタム アクティビティを
.dllファイルとしてエクスポートするのに役立ちます。[次へ] を選択して [新しいプロジェクトを設定] ウィンドウに移動します。![Microsoft Visual Studio の [Create a new project] ウィンドウ](https://dev-assets.cms.uipath.com/assets/images/sdk/sdk-create-a-new-project-window-in-microsoft-visual-studio-105352-dc74c4c6-73dc0bd7.webp)
-
[ プロジェクト名 ] フィールドに目的のアクティビティ名を入力します。この場合、「MathSquareOfSum」を使用できます。
-
[フレームワーク] ドロップダウン メニューから [.NET Framework 4.6.1] を選択します。これにより、ライブラリと UiPath Studio の相互運用性が確保されます。
重要:Windows - レガシ プロジェクトでは、UiPath Studio は .NET Framework 4.5.2 から 4.6.1 で作成されたアクティビティをサポートします。Windows 対応のプロジェクトで使用するためにアクティビティを .NET に移行する方法については、「 アクティビティを .NET 6 に移行する」をご覧ください。

-
[ 作成 ] を選択してコード デザイナーに移動し、アクティビティ コードの記述を開始します。
-
[ ソリューション エクスプローラー ] パネルで [ 参照 ] ブランチを右クリックし、[ 参照を追加...] を選択します。[参照マネージャー] ウィンドウが表示されます。
-
System.Activitiesを検索し、参照System.ComponentModel.Compositionして追加します。それぞれの前にあるチェックボックスをオンにして、[ OK]をクリックしてください。これにより、前述の参照のクラスを使用できるようになります。![System.Activities アセンブリが選択されている [参照マネージャー] ウィンドウ](https://dev-assets.cms.uipath.com/assets/images/sdk/sdk-reference-manager-window-with-the-system-activities-assembly-selected-105648-7eff6771-fdca4065.webp)
![System.ComponentModel.Composition アセンブリが選択された [参照マネージャー] ウィンドウ](https://dev-assets.cms.uipath.com/assets/images/sdk/sdk-reference-manager-window-with-the-system-componentmodel-composition-assembly-selected-105735-10d923ef-d973f0e2.webp)
-
現在は、新たに追加された参照がコードで使用されるようにする必要があります。 それには、コード デザイナーに以下の行を追加します。
using System.Activities; using System.ComponentModel;using System.Activities; using System.ComponentModel;プロジェクトは次のようになります。

-
入力および出力パラメーターを追加します。 この例では、コードは次のようになります。
//Note that these attributes are localized so you need to localize this attribute for Studio languages other than English //Dots allow for hierarchy. App Integration.Excel is where Excel activities are. [Category("Category.Where.Your.Activity.Appears.In.Toolbox")] [DisplayName("Human readable name instead of class name")] [Description("The text of the tooltip")] public class MathSqSum : CodeActivity { //Note that these attributes are localized so you need to localize this attribute for Studio languages other than English [Category("Input")] [DisplayName("First Number")] [Description("Enter the first number")] [RequiredArgument] public InArgument<int> FirstNumber { get; set; } [Category("Input")] [DisplayName("Second Number")] [Description("Enter the second number")] [RequiredArgument] public InArgument<int> SecondNumber { get; set; } [Category("Output")] public OutArgument<int> ResultNumber { get; set; } protected override void Execute(CodeActivityContext context) { }//Note that these attributes are localized so you need to localize this attribute for Studio languages other than English //Dots allow for hierarchy. App Integration.Excel is where Excel activities are. [Category("Category.Where.Your.Activity.Appears.In.Toolbox")] [DisplayName("Human readable name instead of class name")] [Description("The text of the tooltip")] public class MathSqSum : CodeActivity { //Note that these attributes are localized so you need to localize this attribute for Studio languages other than English [Category("Input")] [DisplayName("First Number")] [Description("Enter the first number")] [RequiredArgument] public InArgument<int> FirstNumber { get; set; } [Category("Input")] [DisplayName("Second Number")] [Description("Enter the second number")] [RequiredArgument] public InArgument<int> SecondNumber { get; set; } [Category("Output")] public OutArgument<int> ResultNumber { get; set; } protected override void Execute(CodeActivityContext context) { }<DisplayName(" ")>属性は、Studio の [プロパティ] パネルの入力フィールドの前に表示されるラベルです。<Description(" ")>属性は、マウスをホバーしたときに表示されるツールチップのテキストです。![カスタム アクティビティの [プロパティ] パネル](https://dev-assets.cms.uipath.com/assets/images/sdk/sdk-properties-panel-of-your-custom-activity-105212-0c5adfcb-7854542a.webp)
宣言された要素を入力に必須にする場合は、
<ReguiredArgument>属性が必要です。入力されていない場合は、アクティビティのタイトル バーに警告アイコンが表示されます。 -
オーバーライドされた関数
<Execute( )>に機能を追加します。この場合、次のようになります。protected override void Execute(CodeActivityContext context) { var firstNumber = FirstNumber.Get(context); var secondNumber = SecondNumber.Get(context); var result = (int)Math.Pow(firstNumber + secondNumber, 2); ResultNumber.Set(context, result); }protected override void Execute(CodeActivityContext context) { var firstNumber = FirstNumber.Get(context); var secondNumber = SecondNumber.Get(context); var result = (int)Math.Pow(firstNumber + secondNumber, 2); ResultNumber.Set(context, result); }
(オプション)デザイナー インターフェイスを構築する
アクティビティにデザイナー インターフェイスを設定したくない場合は、[ライブラリの構築] セクションにスキップできます。
デザイナー インターフェイスを構築するには、 Windows Workflow Foundation コンポーネントが Visual Studio にインストールされている必要があります。Visual Studio インストーラーからコンポーネントを選択していない場合は、次の手順で追加できます。
- Visual Studio で [ ツール ] メニューをクリックし、[ ツールと機能の取得] を選択します。[Visual Studio インストーラー] ウィンドウが表示されます。
- [個々のコンポーネント] タブに切り替えて、Windows Workflow Foundation コンポーネントを検索します。これは [ 開発アクティビティ ] セクションの下にあります。
- Windows Workflow Foundation コンポーネントの前にあるチェック ボックスをオンにして、[変更] をクリックします。必要なコンポーネントがインストールされます。

-
プロパティパネルからプロジェクトを右クリックします(この例では、プロジェクトはMathSquareOfSumです)。コンテキスト メニューが表示されます。
-
[項目を追加] から [新しい項目...] を選択します。[ 新しい項目を追加 ] ウィンドウが表示されます。
-
左側のパネルの [インストール済み] カテゴリで [ワークフロー] を選択します。関連するすべての要素が表示されます。
-
[ アクティビティ デザイナー ] を選択して [ 追加 ] をクリックし、項目をプロジェクトに含めます。
![[新しい項目を追加] ウィンドウでアクティビティ デザイナーを選択する。](https://dev-assets.cms.uipath.com/assets/images/sdk/sdk-selecting-activity-designer-in-the-add-new-item-window-105716-d7867900-f1e67ea3.webp)
アクティビティ デザイナーの項目が追加され、対応する
.xamlファイルがすぐに開きます。次のようになります。
-
既存のアクティビティ デザイナーのコードを次のように置き換えます。
<sap:ActivityDesigner x:Class="MathSquareOfSum.MathSqSumDesigner" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation" xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation" xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"> <a href="https://docs.uipath.com/ja/sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a> <ResourceDictionary> <sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" /> </ResourceDictionary> </sap:ActivityDesigner.Resources> <DockPanel Width="300"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="90"></ColumnDefinition> <ColumnDefinition Width="210"></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Text="First Number"></TextBlock> <sapv:ExpressionTextBox Grid.Row="0" Grid.Column="1" OwnerActivity="{Binding Path=ModelItem}" ExpressionType="s:Int32" HintText="Enter first number" Expression="{Binding Path=ModelItem.FirstNumber, Converter={StaticResource ArgumentToExpressionConverter},ConverterParameter=In, Mode=TwoWay}" /> <TextBlock Grid.Row="1" Grid.Column="0" Text="Second Number"></TextBlock> <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1" OwnerActivity="{Binding Path=ModelItem}" ExpressionType="s:Int32" HintText="Enter second number" Expression="{Binding Path=ModelItem.SecondNumber, Converter={StaticResource ArgumentToExpressionConverter},ConverterParameter=In, Mode=TwoWay}" /> <TextBlock Grid.Row="2" Grid.Column="0" Text="Result"></TextBlock> <sapv:ExpressionTextBox Grid.Row="2" Grid.Column="1" OwnerActivity="{Binding Path=ModelItem}" ExpressionType="s:Int32" HintText="The sum of the numbers" UseLocationExpression="True" Expression="{Binding Path=ModelItem.ResultNumber, Converter={StaticResource ArgumentToExpressionConverter},ConverterParameter=Out, Mode=TwoWay}" /> </Grid> </DockPanel> </sap:ActivityDesigner><sap:ActivityDesigner x:Class="MathSquareOfSum.MathSqSumDesigner" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation" xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation" xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"> <a href="https://docs.uipath.com/ja/sap:ActivityDesigner.Resources">sap:ActivityDesigner.Resources</a> <ResourceDictionary> <sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" /> </ResourceDictionary> </sap:ActivityDesigner.Resources> <DockPanel Width="300"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="90"></ColumnDefinition> <ColumnDefinition Width="210"></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Text="First Number"></TextBlock> <sapv:ExpressionTextBox Grid.Row="0" Grid.Column="1" OwnerActivity="{Binding Path=ModelItem}" ExpressionType="s:Int32" HintText="Enter first number" Expression="{Binding Path=ModelItem.FirstNumber, Converter={StaticResource ArgumentToExpressionConverter},ConverterParameter=In, Mode=TwoWay}" /> <TextBlock Grid.Row="1" Grid.Column="0" Text="Second Number"></TextBlock> <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1" OwnerActivity="{Binding Path=ModelItem}" ExpressionType="s:Int32" HintText="Enter second number" Expression="{Binding Path=ModelItem.SecondNumber, Converter={StaticResource ArgumentToExpressionConverter},ConverterParameter=In, Mode=TwoWay}" /> <TextBlock Grid.Row="2" Grid.Column="0" Text="Result"></TextBlock> <sapv:ExpressionTextBox Grid.Row="2" Grid.Column="1" OwnerActivity="{Binding Path=ModelItem}" ExpressionType="s:Int32" HintText="The sum of the numbers" UseLocationExpression="True" Expression="{Binding Path=ModelItem.ResultNumber, Converter={StaticResource ArgumentToExpressionConverter},ConverterParameter=Out, Mode=TwoWay}" /> </Grid> </DockPanel> </sap:ActivityDesigner>アクティビティに対して定義された新しいレイアウトは、次のようになります。

-
アクティビティ (この場合は ActMathSquareOfSum) を右クリックし、[ 追加 ] メニューの [ クラス...] を選択します。[ 新しい項目を追加 ] ウィンドウが表示されます。
-
[クラス] 項目は既に選択されています。あとは、名前を DesignerMetadata.cs に変更して [ 追加] を選択するだけです。新しいクラスがアクティビティに追加され、新しいタブで開きます。
![[クラス] 項目の名前を DesignerMetadata.cs に変更します。](https://dev-assets.cms.uipath.com/assets/images/sdk/sdk-renaming-the-class-item-to-designermetadata-cs-105660-8ec8507c-93227e9b.webp)
-
新しく作成した DesignerMetadata クラスに次の内容を追加します。
using MathSquareOfSum; using System.Activities.Presentation.Metadata; using System.ComponentModel; namespace ActMathSquareOfSum { public class DesignerMetadata : IRegisterMetadata { public void Register() { AttributeTableBuilder attributeTableBuilder = new AttributeTableBuilder(); attributeTableBuilder.AddCustomAttributes(typeof(MathSqSum), new DesignerAttribute(typeof(MathSqSumDesigner))); MetadataStore.AddAttributeTable(attributeTableBuilder.CreateTable()); } } }using MathSquareOfSum; using System.Activities.Presentation.Metadata; using System.ComponentModel; namespace ActMathSquareOfSum { public class DesignerMetadata : IRegisterMetadata { public void Register() { AttributeTableBuilder attributeTableBuilder = new AttributeTableBuilder(); attributeTableBuilder.AddCustomAttributes(typeof(MathSqSum), new DesignerAttribute(typeof(MathSqSumDesigner))); MetadataStore.AddAttributeTable(attributeTableBuilder.CreateTable()); } } }