/// <summary> /// Reduces a GraphQL type to one that can be represented in .NET. /// </summary> /// <param name="type">The type.</param> /// <returns>The reduced type.</returns> /// <remarks> /// The GraphQL type system can represent more types than .NET can - for example a /// non-null object type does not exist in .NET. /// </remarks> public static TypeModel ReduceType(TypeModel type) { if (type == null) { return(null); } else if (type.Kind == TypeKind.NonNull) { if (IsValueType(type.OfType)) { return(type); } else { var result = type.OfType.Clone(); result.OfType = ReduceType(result.OfType); return(result); } } else if (type.Kind == TypeKind.List) { var result = type.Clone(); result.OfType = ReduceType(result.OfType); return(result); } return(type); }
private static string GenerateStub(TypeModel type, string rootNamespace) { var stubType = type.Clone(); stubType.Name = "Stub" + TypeUtilities.GetInterfaceName(type); stubType.Kind = TypeKind.Object; stubType.Interfaces = new[] { type }; return(EntityGenerator.Generate(stubType, rootNamespace + ".Internal", "internal ", false, rootNamespace)); }
private static string GenerateStub(TypeModel type, string entityNamespace, string queryType) { var stubType = type.Clone(); stubType.Name = "Stub" + TypeUtilities.GetInterfaceName(type); stubType.Kind = TypeKind.Object; stubType.Interfaces = new[] { type }; return(EntityGenerator.Generate(stubType, entityNamespace + ".Internal", queryType, entityNamespace: entityNamespace, modifiers: "internal ", generateDocComments: false)); }
private void EditType() { var window = new NewType(); window.Type = selectedType.Clone(); if (window.ShowDialog() == true) { App.TypeRepository.Update(window.Type.ToRepositoryModel()); LoadTypes(); } }