public ValueTask <IService> CreateService(IFactoryContext factoryContext,
                                                      Uri?baseUri,
                                                      InvokeData invokeData,
                                                      IServiceCommunication serviceCommunication,
                                                      CancellationToken token)
            {
                switch (_creators[invokeData.Type])
                {
                case IServiceCatalog.Creator creator:
                    var service = creator();

                    service.Start(baseUri, invokeData, serviceCommunication);

                    return(new ValueTask <IService>(service));

                case IServiceCatalog.ServiceCreator creator:
                    return(new ValueTask <IService>(creator(baseUri, invokeData, serviceCommunication)));

                case IServiceCatalog.ServiceCreatorAsync creator:
                    return(creator(factoryContext, baseUri, invokeData, serviceCommunication, token));

                default:
                    return(Infra.Unexpected <ValueTask <IService> >(_creators[invokeData.Type]?.GetType()));
                }
            }
Beispiel #2
0
        private async ValueTask <bool> Read(bool useAsync)
        {
            while (true)
            {
                var result = await ReadNext(useAsync).ConfigureAwait(false);

                switch (result)
                {
                case ProcessNodeResult.Ready:    return(true);

                case ProcessNodeResult.Complete: return(false);

                case ProcessNodeResult.Continue: break;

                default:                         return(Infra.Unexpected <bool>(result));
                }
            }
        }
Beispiel #3
0
        public EcmaScriptLocationExpressionEvaluator(ILocationExpression locationExpression, Program program, Expression?leftExpression)
        {
            _locationExpression = locationExpression;
            _program            = program;
            _leftExpression     = leftExpression;

            switch (leftExpression)
            {
            case null:
                break;

            case JintIdentifier identifier:
                _name    = identifier.Name;
                _declare = CreateDeclareStatement(identifier);
                break;

            case MemberExpression memberExpression:
                _name = ((JintIdentifier)memberExpression.Property).Name;
                break;

            default:
                throw Infra.Unexpected <Exception>(leftExpression);
            }
        }