public async ValueTask <IResolveResult> DeleteItemAsync(ResolverContext context) { var input = context.GetArgument <DeleteItemRequest>("input"); var result = await _cartServiceClient.DeleteItemAsync(input); return(As(result.ProductId)); }
protected override IEnumerable<string> ResolveItems(ResolverContext resolverContext) { Func<WebAsset, IEnumerable<string>> resolver = asset => Resolve(resolverContext, asset); var result = Filter(checker.IsAbsolute).SelectMany(resolver) .ToList(); if (group.UseTelerikContentDeliveryNetwork) { result.AddRange(Filter(checker.IsNative).SelectMany(resolver)); } if (group.Items.Any()) { string id = group.IsShared ? group.Name : HttpUtility.UrlEncode(serializer.Serialize(group)); var compressedUrl = "{0}?{1}={2}".FormatWith( resolverContext.HttpHandlerPath, HttpUtility.UrlEncode(WebAssetHttpHandler.IdParameterName), id ); result.Add(compressedUrl); } return result; }
public ClassVisitor(ResolverContext resolver, SymbolTable rootTable, LabelTable labelTable) : base(UdonSharpSyntaxWalkerDepth.ClassDefinitions, resolver, rootTable, labelTable) { methodVisitor = new MethodVisitor(resolver, rootTable, labelTable); classDefinition = new ClassDefinition(); }
public UdonTypeExposureTreeView(TreeViewState state) : base(state) { resolver = new ResolverContext(); rowLabelStyle = new GUIStyle(EditorStyles.label); Reload(); }
public async ValueTask <IResolveResult> DeleteReviewAsync(ResolverContext context) { var input = context.GetArgument <DeleteReviewRequest>("input"); var result = await _reviewServiceClient.DeleteReviewAsync(input); return(As(result.Id)); }
/// <summary> /// Executes and generate final result. /// </summary> /// <param name="graphContext">The <see cref="T:Dora.GraphQL.Executors.GraphContext" /> representing the current request based execution context.</param> /// <returns> /// The <see cref="T:Dora.GraphQL.Executors.ExecutionResult" /> used as the response contents. /// </returns> public async ValueTask <ExecutionResult> ExecuteAsync(GraphContext graphContext) { try { var selections = graphContext.SelectionSet; if (selections.Count == 1) { var selection = selections.OfType <IFieldSelection>().Single(); var resoloverContext = new ResolverContext(graphContext, graphContext.Operation, selection, null); var result = await ExecuteCoreAsync(resoloverContext); return(ExecutionResult.Success(result)); } var dictionary = new Dictionary <string, object>(); foreach (IFieldSelection subSelection in graphContext.SelectionSet) { var resoloverContext = new ResolverContext(graphContext, graphContext.Operation, subSelection, null); var result = await ExecuteCoreAsync(resoloverContext); dictionary[subSelection.Alias ?? subSelection.Name] = result; } return(ExecutionResult.Success(dictionary)); } catch (GraphException ex) { if (_logger.IsEnabled(LogLevel.Error)) { _log4Error(_logger, DateTimeOffset.Now, graphContext.OperationName, ErrorFormatter.Instance.Format(ex), null); } return(ExecutionResult.Fail(ex)); } }
public async ValueTask <IResolveResult> GetAvailabilityAsync(ResolverContext context) { var input = context.GetArgument <GetInventoryRequest>("input"); var result = await _inventoryServiceClient.GetInventoryAsync(input); return(As(result.Result)); }
public async ValueTask <IResolveResult> UpdateRatingAsync(ResolverContext context) { var input = context.GetArgument <UpdateRatingRequest>("input"); var result = await _ratingServiceClient.UpdateRatingAsync(input); return(As(result.Rating)); }
public async ValueTask <IResolveResult> CheckoutAsync(ResolverContext context) { var input = context.GetArgument <CheckoutRequest>("input"); var result = await _cartServiceClient.CheckoutAsync(input); return(As(result.IsSucceed)); }
public async ValueTask <IResolveResult> GetCartAsync(ResolverContext context) { var input = context.GetArgument <GetCartRequest>("input"); var result = await _cartServiceClient.GetCartAsync(input); return(As(result.Result)); }
public async ValueTask <IResolveResult> CreateProductAsync(ResolverContext context) { var input = context.GetArgument <CreateProductRequest>("input"); var result = await _catalogServiceClient.CreateProductAsync(input); return(As(result.Product)); }
/// <summary> /// Gets the argument value. /// </summary> /// <param name="context">The <see cref="ResolverContext"/>.</param> /// <param name="argumentName">Name of the argument.</param> /// <returns></returns> /// <exception cref="GraphException"></exception> public static object GetArgument(this ResolverContext context, string argumentName) { if (!context.Field.Arguments.TryGetValue(argumentName, out var fieldArgument)) { throw new GraphException($"The argument '{argumentName}' is not defined on the filed '{context.Field.Name}' of {context.Container.GetType()}"); } var graphType = fieldArgument.GraphType; if ((context.Selection).Arguments.TryGetValue(argumentName, out var argumentToken)) { object rawValue = argumentToken.ValueToken; if (rawValue is string && context.GraphContext.Variables.TryGetValue((string)rawValue, out var value1)) { rawValue = value1; return(graphType.Resolve(value1)); } if (!argumentToken.IsVaribleReference) { return(graphType.Resolve(rawValue)); } } if (context.GraphContext.Arguments.TryGetValue(argumentName, out var value2) && value2.DefaultValue != null) { return(graphType.Resolve(value2.DefaultValue)); } return(fieldArgument.DefaultValue == null ? null : graphType.Resolve(fieldArgument.DefaultValue)); }
public async ValueTask <IResolveResult> GetProductsAsync(ResolverContext context) { var input = context.GetArgument <GetProductsRequest>("input"); var results = await _catalogServiceClient.GetProductsAsync(input); return(As(results.Products)); }
public void Get_object_argument() { /* Given */ var arguments = new Dictionary <string, object> { { "input", new Dictionary <string, object> { { "name", "inputArg" } } } }; var sut = new ResolverContext( _objectType, _objectValue, _field, _selection, _fields, arguments, new NodePath(), null); /* When */ var value = sut.GetObjectArgument <InputArg>("input"); /* Then */ Assert.Equal("inputArg", value.Name); }
/// <summary> /// Resolves the value the current selection node. /// </summary> /// <param name="context">The <see cref="T:Dora.GraphQL.GraphTypes.ResolverContext" /> in which the field value is resoved.</param> /// <returns> /// The resolved field's value. /// </returns> public async ValueTask <object> ResolveAsync(ResolverContext context) { var arguments = new object[_operation.Parameters.Count]; var index = 0; foreach (var parameter in _operation.Parameters.Values) { var bindingContext = new ArgumentBinderContext(parameter, context); var result = await _binder.BindAsync(bindingContext); var value = result.IsArgumentBound ? result.Value : parameter.ParameterInfo.DefaultValue; arguments[index++] = value; } var serviceProvider = context.GraphContext.RequestServices; var service = ActivatorUtilities.CreateInstance(serviceProvider, _operation.Service.ServiceType); var returnType = _executor.MethodInfo.ReturnType; if (typeof(Task).IsAssignableFrom(returnType) || (returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(ValueTask <>))) { return(await _executor.ExecuteAsync(service, arguments)); } return(_executor.Execute(service, arguments)); }
protected override IEnumerable <string> ResolveItems(ResolverContext resolverContext) { Func <WebAsset, IEnumerable <string> > resolver = asset => Resolve(resolverContext, asset); var result = Filter(checker.IsAbsolute).SelectMany(resolver) .ToList(); if (group.UseTelerikContentDeliveryNetwork) { result.AddRange(Filter(checker.IsNative).SelectMany(resolver)); } if (group.Items.Any()) { string id = group.IsShared ? group.Name : HttpUtility.UrlEncode(serializer.Serialize(group)); var compressedUrl = "{0}?{1}={2}".FormatWith( resolverContext.HttpHandlerPath, HttpUtility.UrlEncode(WebAssetHttpHandler.IdParameterName), id ); result.Add(compressedUrl); } return(result); }
public string GetParentNameScoped() { using (var engine = ResolverContext.CreateNew()) { var parentService = engine.Resolve <ParentService>(); return(parentService.Name); } }
/// <summary> /// Resolves the value the current selection node. /// </summary> /// <param name="context">The <see cref="ResolverContext" /> in which the field value is resoved.</param> /// <returns> /// The resolved field's value. /// </returns> public async ValueTask <object> ResolveAsync(ResolverContext context) { var arguments = _prameterTypes.Select(it => it == typeof(ResolverContext) ? context : ActivatorUtilities.CreateInstance(context.GraphContext.RequestServices, it)); return(await _executor.ExecuteAsync(context.Container, arguments.ToArray())); }
public async Task <IResolveResult> GetCartAsync(ResolverContext context) { var id = context.Arguments["cartId"] ?? Guid.NewGuid(); return(await new ValueTask <IResolveResult>(As(new CartDto { Id = $"{id}" }))); }
public async Task <IResolveResult> GetAvailabilityAsync(ResolverContext context) { var id = context.Arguments["inventoryId"] ?? Guid.NewGuid(); return(await new ValueTask <IResolveResult>(As(new InventoryDto { Id = $"{id}" }))); }
public void ResolverContext_should_not_be_null() { IResolver resolver = Building(builder => { }); var resolverContext = new ResolverContext(resolver); resolverContext.Resolver.ShouldNotBeNull(); }
/// <summary> /// Gets the argument value. /// </summary> /// <typeparam name="T">The argument type.</typeparam> /// <param name="context">The <see cref="ResolverContext"/>.</param> /// <param name="argumentName">Name of the argument.</param> /// <returns>The argument value.</returns> public static T GetArgument <T>(this ResolverContext context, string argumentName) { Guard.ArgumentNotNullOrWhiteSpace(argumentName, nameof(argumentName)); var value = context.GetArgument(argumentName); return(value == null ? default : (T)value); }
public async Task <IResolveResult> GetProductAsync(ResolverContext context) { var id = context.Arguments["productId"] ?? Guid.NewGuid(); return(await new ValueTask <IResolveResult>(As(new CatalogProductDto { Name = $"{id}" }))); }
private async ValueTask <List <object?> > CreateStreamResultAsync( StreamDirective streamDirective) { IAsyncEnumerable <object?> enumerable = Selection.CreateStream(ResolverContext.Result !); IAsyncEnumerator <object?> enumerator = enumerable.GetAsyncEnumerator(); var next = true; try { var list = new List <object?>(); var initialCount = streamDirective.InitialCount; var count = 0; if (initialCount > 0) { while (next) { count++; next = await enumerator.MoveNextAsync().ConfigureAwait(false); list.Add(enumerator.Current); if (count >= initialCount) { break; } } } if (next) { // if the stream has more items than the initial requested items then we will // defer the rest of the stream. OperationContext.Scheduler.DeferredWork.Register( new DeferredStream( Selection, streamDirective.Label, ResolverContext.Path, ResolverContext.Parent <object>(), count - 1, enumerator, ResolverContext.ScopedContextData)); } return(list); } finally { if (!next) { // if there is no deferred work we will just dispose the enumerator. // in the case we have deferred work, the deferred stream handler is // responsible of handling the dispose. await enumerator.DisposeAsync().ConfigureAwait(false); } } }
public ValueTask <object> Resolve(ResolverContext context) { var lowerCase = context.GetArgument <bool>("lowerCase"); var result = lowerCase ? Email.ToLower() : Email; return(new ValueTask <object>(result)); }
IValueProvider IValueResolver.ResolveWeak(ResolverContext context, string reference) { if (context is TContext == false) { throw new InvalidOperationException("Context should be of type " + typeof(TContext).GetNiceName()); } return(this.Resolve(context as TContext, reference)); }
IValueProvider IProviderEvaluator.TryEvaluateWeak(ResolverContext context, string reference) { if (context is TContext == false) { throw new InvalidOperationException("Context must be of type " + typeof(TContext).GetNiceName()); } return(this.TryEvaluate(context as TContext, reference)); }
public async ValueTask <IResolveResult> AddMessageAsync(ResolverContext context) { var input = context.GetArgument <InputMessage>("message"); var message = await _chat.AddMessageAsync( "1", input.Content); return(Resolve.As(message)); }
public async Task <IResolveResult> GetAvailabilitiesAsync(ResolverContext context) { return(await new ValueTask <IResolveResult>( As(new List <InventoryDto> { new InventoryDto { Id = $"{Guid.NewGuid()}" } }))); }
public void Run(MetadataModel yaml, ResolverContext context) { TreeIterator.Preorder(yaml.TocYamlViewModel, null, s => s.IsInvalid ? null : s.Items, (current, parent) => { current.Parent = parent; return(true); }); }
protected virtual IEnumerable<string> ResolveItems(ResolverContext resolverContext) { return group.Items .SelectMany(asset => { var resolver = resolverFactory.Create(asset); return resolver.Resolve(resolverContext); }) .ToArray(); }
public void Run(MetadataModel yaml, ResolverContext context) { TreeIterator.Preorder(yaml.TocYamlViewModel, null, s => s.IsInvalid ? null : s.Items, (current, parent) => { current.Parent = parent; return true; }); }
protected virtual IEnumerable <string> ResolveItems(ResolverContext resolverContext) { return(group.Items .SelectMany(asset => { var resolver = resolverFactory.Create(asset); return resolver.Resolve(resolverContext); }) .ToArray()); }
public IEnumerable<string> Resolve(ResolverContext resolverContext, WebAssetCollection assets) { var resolvedUrls = new List<string>(); foreach (var asset in assets) { resolvedUrls.AddRange(resolverFactory.Create(asset).Resolve(resolverContext)); } return resolvedUrls .Distinct(StringComparer.OrdinalIgnoreCase) .Select((url) => urlResolver.Resolve(url)); }
public IEnumerable<string> Resolve(ResolverContext resolverContext) { string assetFileName = asset.FileName; string minifiedFileName = Path.ChangeExtension(assetFileName, (assetFileName.IndexOf(".min.") == -1 ? ".min" : "") + asset.Extension); return new[] { "{0}/{1}/{2}/{3}".FormatWith(GetBaseUrl(resolverContext), GetProductName(resolverContext), WebAssetDefaultSettings.Version, minifiedFileName ) }; }
public string GetBaseUrl(ResolverContext resolverContext) { var extension = asset.Extension; if (extension == ".js") { return resolverContext.IsSecureConnection ? WebAssetDefaultSettings.TelerikContentDeliveryNetworkSecureScriptUrl : WebAssetDefaultSettings.TelerikContentDeliveryNetworkScriptUrl; } if (extension == ".css") { return resolverContext.IsSecureConnection ? WebAssetDefaultSettings.TelerikContentDeliveryNetworkSecureStyleSheetUrl : WebAssetDefaultSettings.TelerikContentDeliveryNetworkStyleSheetUrl; } throw new NotSupportedException("Files with '{0}' extension are not supported by the Telerik CDN".FormatWith(extension)); }
public void Run(MetadataModel yaml, ResolverContext context) { TreeIterator.Preorder(yaml.TocYamlViewModel, null, s => { if (s.IsInvalid || (s.Type != MemberType.Namespace && s.Type != MemberType.Toc)) return null; else return s.Items; }, (member, parent) => { if (member.Type != MemberType.Toc) { yaml.Members.Add(member); } return true; }); }
public void Run(MetadataModel yaml, ResolverContext context) { TreeIterator.Preorder(yaml.TocYamlViewModel, null, s => s.IsInvalid ? null : s.Items, (current, parent) => { if (current.Type != MemberType.Toc) { if (current.Type.IsPageLevel()) { current.Href = current.Name + Constants.YamlExtension; } else { current.Href = parent.Href; } } return true; }); }
public IEnumerable<string> Resolve(ResolverContext resolverContext) { group.ContentType = resolverContext.ContentType; if (!group.Enabled) { return new string[0]; } if (group.ContentDeliveryNetworkUrl.HasValue()) { return new[] { group.ContentDeliveryNetworkUrl }; } group.Items.Each(asset => { asset.Version = group.Version; asset.UseTelerikContentDeliveryNetwork = group.UseTelerikContentDeliveryNetwork; }); return ResolveItems(resolverContext); }
private IEnumerable<string> Resolve(ResolverContext resolverContext, WebAsset asset) { return resolverFactory.Create(asset) .Resolve(resolverContext); }
public IEnumerable<string> Resolve(ResolverContext resolverContext) { return new[] { asset.Source }; }
public string GetProductName(ResolverContext resolverContext) { return resolverContext.SupportsCompression ? "mvcz" : "mvc"; }
public IEnumerable<string> Resolve(ResolverContext resolverContext) { return new[] { locator.Locate(asset.Source, asset.Version) }; }
public void Should_set_the_content_type_of_the_group() { group = new WebAssetGroup("foo", true); ResolverContext resolverContext = new ResolverContext { ContentType = "text/javascript" }; resolver = new CombinedWebAssetGroupResolver(group, resolverFactory.Object, checker.Object, serializer.Object); resolver.Resolve(resolverContext); Assert.Equal(group.ContentType, resolverContext.ContentType); }
public CdnWebAssetResolverTests() { resolverContext = new ResolverContext(); }
public void Run(MetadataModel yaml, ResolverContext context) { yaml.TocYamlViewModel = yaml.TocYamlViewModel.ShrinkToSimpleTocWithNamespaceNotEmpty(); }