История страницы
...
Блок кода | ||||||
---|---|---|---|---|---|---|
| ||||||
using System.Collections.Generic; using System.Linq; using Robin.ActionSDK; using Robin.Engine.Services.Interfaces; namespace Robin.SdkExamples { public class GetConfigValue : BaseRobinAction { private readonly IConfigurationService _configurationService; public GetConfigValue(IActionLogger logger, IConfigurationService configurationService) : base(logger) { _configurationService = configurationService; } public override IDictionary<string, object> Execute(IDictionary<string, object> parameters) { var key = (string)parameters["key"]; var pattern = (string)parameters["pattern"]; var valueByKey = _configurationService.GetConfigValue(key); var allKeys = _configurationService.GetKeys(pattern); return new Dictionary<string, object> { { "value", valueByKey }, { "keys", allKeys.Cast<object>().ToList() } }; } } } |
...
ConverterService
Сервис для получения презентационного значения для объекта (не путать с конвертацией в строку). Сервис возвращает значение объекта, представленное в удобном для чтения виде.
Методы
Блок кода | ||||
---|---|---|---|---|
| ||||
string GetDisplayValue(object nativeObject); |
Примеры использования
Блок кода | ||||||
---|---|---|---|---|---|---|
| ||||||
using System.Collections.Generic;
using Robin.ActionSDK;
using Robin.Engine.Services.Interfaces;
namespace Robin.SdkExamples
{
public class CheckCollection : BaseRobinAction
{
private readonly IConverterService _converterService;
public CheckCollection(IActionLogger logger, IConverterService converterService) : base(logger)
{
_converterService = converterService;
}
public override IDictionary<string, object> Execute(IDictionary<string, object> parameters)
{
var collection = (List<object>)parameters["collection"];
var displayValue = _converterService.GetDisplayValue(collection);
return new Dictionary<string, object>
{
{"displayValue", displayValue }
};
}
}
} |
DisposeService
Сервис для освобождения неуправляемых ресурсов. Метод Dispose будет вызван при завершении работы системы исполнения, даже если робот будет завершаться с ошибкой.
Методы
Блок кода | ||||
---|---|---|---|---|
| ||||
void RegisterResource(IDisposable disposableResource); |
...
Блок кода | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
using System; using System.Collections.Generic; using Robin.ActionSDK; using Robin.Engine.Services.Interfaces; using Robin.Types; namespace Robin.SdkExamples { public class OpenFile : BaseRobinAction { private readonly IDisposeService _disposeService; public OpenFile(IActionLogger logger, IDisposeService disposeService) : base(logger) { _disposeService = disposeService; } public override IDictionary<string, object> Execute(IDictionary<string, object> parameters) { var filePath = ((RobinFilePath)parameters["filePath"]).Value; var file = new File(filePath); file.Open(); _disposeService.RegisterResource(file); return new Dictionary<string, object> { { "file", file } }; } } internal class File : IDisposable { private readonly string _filePath; private bool _isDisposed; public File(string filePath) { _filePath = filePath; } public void Open() { } public bool TryReadNextLine(out string line) { } public void Close() { } public void Dispose() { if (_isDisposed) return; Close(); _isDisposed = true; } } } |
...
ArtifactsFolderService
ResourcesFolderService
...
Обзор
Инструменты контента