Пример #1
0
        public override void GenerateCode(IGenerationModel generationModel, ISourceWriter writer)
        {
            var callingCode = $"{Method.Name}({_variables.Select(x => x.Usage).Join(", ")})";
            var target      = Method.IsStatic
                ? HandlerType.NameInCode()
                : _target.Usage;

            var returnValue = "";
            var suffix      = "";

            if (IsAsync)
            {
                if (generationModel.AsyncMode == AsyncMode.ReturnFromLastNode)
                {
                    returnValue = "return ";
                }
                else
                {
                    returnValue = "await ";
                    suffix      = ".ConfigureAwait(false)";
                }
            }

            if (ReturnVariable != null)
            {
                returnValue = $"var {ReturnVariable.Usage} = {returnValue}";
            }

            // TODO -- will need to see if it's IDisposable too

            writer.Write($"{returnValue}{target}.{callingCode}{suffix};");

            Next?.GenerateCode(generationModel, writer);
        }