/// <summary> /// Tries to get the value for the specified key. /// </summary> /// <remarks> /// This method will also materialize <see cref="IMetadataValue"/> and /// evaluate script strings (a key that starts with "=>" will be treated /// as a script and evaluated). /// </remarks> /// <param name="metadata">The metadata instance.</param> /// <typeparam name="TValue">The desired return type.</typeparam> /// <param name="key">The key of the value to get. If the key is <c>null</c>, this will return the default value.</param> /// <param name="value">The value of the key if it was found and could be converted to the desired return type.</param> /// <returns><c>true</c> if the key was found and the value could be converted to the desired return type, <c>false</c> otherwise.</returns> public static bool TryGetValue <TValue>( this IMetadata metadata, string key, out TValue value) { if (metadata != null && key != null) { // Script if (IScriptHelper.TryGetScriptString(key, out string script)) { IExecutionContext context = IExecutionContext.Current; object result = context.ScriptHelper.EvaluateAsync(script, metadata).GetAwaiter().GetResult(); return(TypeHelper.TryExpandAndConvert(result, metadata, out value)); } // Value if (metadata.TryGetRaw(key, out object raw)) { return(TypeHelper.TryExpandAndConvert(raw, metadata, out value)); } } value = default; return(false); }
public void InitializeScripts(IScriptHelper withThisHelper) { foreach (var s in this.ftpFileScripts) { s.Initialize(withThisHelper); } foreach (var x in this.ftpFolderScripts) { x.Initialize(withThisHelper); } foreach (var script in this.fileScripts) { script.Initialize(withThisHelper); } foreach (var script in this.folderScripts) { script.Initialize(withThisHelper); } foreach (var script in this.ServiceScripts) { script.Initialize(withThisHelper); } }
public static bool TryGetScriptMetadataValue(string key, object value, IExecutionState executionState, out ScriptMetadataValue scriptMetadataValue) { scriptMetadataValue = default; if (value is string stringValue && IScriptHelper.TryGetScriptString(stringValue, out string script)) { scriptMetadataValue = new ScriptMetadataValue( key, stringValue.Substring(0, stringValue.Length - script.Length), script, executionState); return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="Keeper.OfScripts.ScriptKeeper"/> class. /// </summary> /// <param name='scriptHelper'> /// The script helper that is responsible for resolving paths, etc. /// </param> /// <exception cref='ArgumentNullException'> /// Thrown when <paramref name="scriptHelper"/> is <see langword="null" /> . /// </exception> public ScriptKeeper(IScriptHelper scriptHelper) { if (scriptHelper == null) { throw new ArgumentNullException("scriptHelper"); } _Helper = scriptHelper; _Local = new LocalScriptGroup { Name = "Local", Helper = _Helper.Local }; _Remote = new RemoteScriptGroup { Name = "Remote" }; _Inline = new InlineScriptGroup { Name = "Inline" }; }
public Dir2ArkApp(IScriptHelper scriptHelper) { ScriptHelper = scriptHelper; }
public BodyTagHelper(IScriptHelper scriptHelper) { _scriptHelper = scriptHelper; }
public UtbTagHelper(IHtmlGenerator htmlGenerator, IScriptHelper scriptHelper, IUtbService baseService) { _htmlGenerator = htmlGenerator; _scriptHelper = scriptHelper; _baseService = baseService; }
public Ark2DirApp(IScriptHelper scriptHelper) { ScriptHelper = scriptHelper; }
public AEStrategy(IScriptHelper helper) : base(helper) { }
public ClickStrategy(IScriptHelper helper) : base(helper) { }
public TableNameTagHelper(IScriptHelper scriptHelper) { _scriptHelper = scriptHelper; }
public DateTagHelper(IHtmlGenerator htmlGenerator, IScriptHelper scriptHelper) { _htmlGenerator = htmlGenerator; _scriptHelper = scriptHelper; }
public DropDownTagHelper(IHtmlGenerator htmlGenerator, IScriptHelper scriptHelper) { _scriptHelper = scriptHelper; _htmlGenerator = htmlGenerator; }
public SwipeStrategy(IScriptHelper helper) : base(helper) { }
public void InitializeScripts(IScriptHelper withThisHelper) { foreach (var s in this.ftpFileScripts) { s.Initialize(withThisHelper); } foreach (var x in this.ftpFolderScripts) { x.Initialize(withThisHelper); } foreach ( var script in this.fileScripts ) { script.Initialize( withThisHelper ); } foreach ( var script in this.folderScripts ) { script.Initialize( withThisHelper ); } foreach (var script in this.ServiceScripts) { script.Initialize(withThisHelper); } }
public ActionGroupStrategy(IActionToScriptFactory actionToScriptFactory, IScriptHelper helper) : base(helper) { this.actionToScriptFactory = actionToScriptFactory; }
public void Initialize(IScriptHelper x) { this.scriptHelper = x; }
public AutoSaveTagHelper(IScriptHelper scriptHelper, IHttpContextAccessor httpContextAccessor) { _scriptHelper = scriptHelper; _httpContextAccessor = httpContextAccessor; }
public Dir2ArkApp(ICacheHelper cacheHelper, IScriptHelper scriptHelper) { CacheHelper = cacheHelper; ScriptHelper = scriptHelper; }
public WaitStrategy(IScriptHelper helper) : base(helper) { }
public DeleteRecordTagHelper(IScriptHelper scriptHelper, IHttpContextAccessor httpContextAccessor) { _scriptHelper = scriptHelper; _httpContextAccessor = httpContextAccessor; }
public BaseScriptGenerateStragegy(IScriptHelper helper) { this.helper = helper; }
public PatchCreatorApp(IScriptHelper scriptHelper) { ScriptHelper = scriptHelper; }
public PieDoughnutChartTagHelper(IScriptHelper scriptHelper) { _scriptHelper = scriptHelper; }
public LineChartTagHelper(IScriptHelper scriptHelper) { _scriptHelper = scriptHelper; }