public Result <Func <IFormattedValue, Task <ushort[]> > > GetFormatBackUshortsFunc(
            CodeFormatterExpression codeExpression,
            DeviceContext deviceContext, bool isLocal, IFormattedValueOwner formattedValueOwner)
        {
            try
            {
                if (_formatBackCache.TryGetValue(codeExpression.CodeStringFormatBack, out var cachedFunc))
                {
                    Task <ushort[]> FunFromCacheWithContext(IFormattedValue input) => cachedFunc(input,
                                                                                                 new RuleExecutionContext(deviceContext, isLocal).SetVariable(VariableNames.CURRENT_VALUE_OWNER,
                                                                                                                                                              formattedValueOwner));

                    return(Result <Func <IFormattedValue, Task <ushort[]> > > .Create(FunFromCacheWithContext, true));
                }

                var nodes = Evaluator.Initialize(codeExpression.CodeStringFormatBack, _lexemManager);

                Func <IFormattedValue, Task <ushort[]> > fun = (input) =>
                                                               Evaluator.ExecuteFormatBack(input,
                                                                                           new RuleExecutionContext(deviceContext, isLocal).SetVariable(VariableNames.CURRENT_VALUE_OWNER,
                                                                                                                                                        formattedValueOwner), nodes);

                _formatBackCache.TryAdd(codeExpression.CodeStringFormatBack,
                                        (input, context) => Evaluator.ExecuteFormatBack(input, context, nodes));


                return(Result <Func <IFormattedValue, Task <ushort[]> > > .Create(fun, true));
            }
            catch (Exception e)
            {
                return(Result <Func <IFormattedValue, Task <ushort[]> > > .CreateWithException(e));
            }
        }
        public Result <Func <BuiltExpressionFormatContext, Task <IFormattedValue> > > GetFormatUshortsFunc(
            CodeFormatterExpression codeExpression)
        {
            try
            {
                if (_formatCache.TryGetValue(codeExpression.CodeStringFormat, out var cachedFunc))
                {
                    Task <IFormattedValue> FunFromCacheWithContext(BuiltExpressionFormatContext context) =>
                    cachedFunc(context);

                    return(Result <Func <BuiltExpressionFormatContext, Task <IFormattedValue> > > .Create(
                               FunFromCacheWithContext, true));
                }


                var nodes = Evaluator.Initialize(codeExpression.CodeStringFormat, _lexemManager);

                _formatCache.TryAdd(codeExpression.CodeStringFormat,
                                    (context) => Evaluator.ExecuteFormat(context.DeviceValue,
                                                                         new RuleExecutionContext(context.DeviceContext, context.IsLocal).SetVariable(
                                                                             VariableNames.CURRENT_VALUE_OWNER, context.FormattedValueOwner), nodes));

                Func <BuiltExpressionFormatContext, Task <IFormattedValue> > fun = (context) =>
                                                                                   Evaluator.ExecuteFormat(context.DeviceValue,
                                                                                                           new RuleExecutionContext(context.DeviceContext, context.IsLocal).SetVariable(
                                                                                                               VariableNames.CURRENT_VALUE_OWNER, context.FormattedValueOwner), nodes);

                //    codeExpression.BuiltExpressionFormat = Result<Func<ushort[], Task<IFormattedValue>>>.Create(fun,true);

                return(Result <Func <BuiltExpressionFormatContext, Task <IFormattedValue> > > .Create(fun,
                                                                                                      true));
            }
            catch (Exception e)
            {
                return(Result <Func <BuiltExpressionFormatContext, Task <IFormattedValue> > > .CreateWithException(e));
            }
        }