/// <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);
        }
Example #2
0
        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);
            }
        }
Example #3
0
 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);
 }
Example #4
0
        /// <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"
            };
        }
Example #5
0
 public Dir2ArkApp(IScriptHelper scriptHelper)
 {
     ScriptHelper = scriptHelper;
 }
 public BodyTagHelper(IScriptHelper scriptHelper)
 {
     _scriptHelper = scriptHelper;
 }
Example #7
0
 public UtbTagHelper(IHtmlGenerator htmlGenerator, IScriptHelper scriptHelper, IUtbService baseService)
 {
     _htmlGenerator = htmlGenerator;
     _scriptHelper  = scriptHelper;
     _baseService   = baseService;
 }
Example #8
0
 public Ark2DirApp(IScriptHelper scriptHelper)
 {
     ScriptHelper = scriptHelper;
 }
Example #9
0
 public AEStrategy(IScriptHelper helper) : base(helper)
 {
 }
Example #10
0
 public ClickStrategy(IScriptHelper helper) : base(helper)
 {
 }
 public TableNameTagHelper(IScriptHelper scriptHelper)
 {
     _scriptHelper = scriptHelper;
 }
Example #12
0
 public DateTagHelper(IHtmlGenerator htmlGenerator, IScriptHelper scriptHelper)
 {
     _htmlGenerator = htmlGenerator;
     _scriptHelper  = scriptHelper;
 }
Example #13
0
 public DropDownTagHelper(IHtmlGenerator htmlGenerator, IScriptHelper scriptHelper)
 {
     _scriptHelper  = scriptHelper;
     _htmlGenerator = htmlGenerator;
 }
Example #14
0
 public SwipeStrategy(IScriptHelper helper) : base(helper)
 {
 }
Example #15
0
        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);
            }
        }
Example #16
0
 public ActionGroupStrategy(IActionToScriptFactory actionToScriptFactory, IScriptHelper helper) : base(helper)
 {
     this.actionToScriptFactory = actionToScriptFactory;
 }
Example #17
0
 public void Initialize(IScriptHelper x)
 {
     this.scriptHelper = x;
 }
 public AutoSaveTagHelper(IScriptHelper scriptHelper, IHttpContextAccessor httpContextAccessor)
 {
     _scriptHelper        = scriptHelper;
     _httpContextAccessor = httpContextAccessor;
 }
Example #19
0
 public Dir2ArkApp(ICacheHelper cacheHelper, IScriptHelper scriptHelper)
 {
     CacheHelper  = cacheHelper;
     ScriptHelper = scriptHelper;
 }
Example #20
0
 public WaitStrategy(IScriptHelper helper) : base(helper)
 {
 }
 public DeleteRecordTagHelper(IScriptHelper scriptHelper, IHttpContextAccessor httpContextAccessor)
 {
     _scriptHelper        = scriptHelper;
     _httpContextAccessor = httpContextAccessor;
 }
Example #22
0
 public BaseScriptGenerateStragegy(IScriptHelper helper)
 {
     this.helper = helper;
 }
Example #23
0
 public PatchCreatorApp(IScriptHelper scriptHelper)
 {
     ScriptHelper = scriptHelper;
 }
Example #24
0
 public PieDoughnutChartTagHelper(IScriptHelper scriptHelper)
 {
     _scriptHelper = scriptHelper;
 }
 public LineChartTagHelper(IScriptHelper scriptHelper)
 {
     _scriptHelper = scriptHelper;
 }
Example #26
0
 public void Initialize(IScriptHelper x)
 {
     this.scriptHelper = x;
 }