public AssemblyFile(ISchema parent, AssemblyFile assemblyFile, ObjectStatus status) : base(parent, MsSql.ObjectType1.AssemblyFile) { Name = assemblyFile.Name; content = assemblyFile.content; Status = status; }
public static IGraphType GraphTypeFromType(this IType type, ISchema schema) { if (type is NonNullType) { var nonnull = (NonNullType)type; var ofType = GraphTypeFromType(nonnull.Type, schema); var nonnullGraphType = typeof(NonNullGraphType<>).MakeGenericType(ofType.GetType()); var instance = (NonNullGraphType)Activator.CreateInstance(nonnullGraphType); instance.ResolvedType = ofType; return instance; } if (type is ListType) { var list = (ListType)type; var ofType = GraphTypeFromType(list.Type, schema); var listGraphType = typeof(ListGraphType<>).MakeGenericType(ofType.GetType()); var instance = (ListGraphType)Activator.CreateInstance(listGraphType); instance.ResolvedType = ofType; return instance; } if (type is NamedType) { var named = (NamedType)type; return schema.FindType(named.Name); } return null; }
public DatabaseController(ISchema schemaRepository, ISettings settingsRepository, IPathMapper pathMapper) { _schemaRepository = schemaRepository; _settingsRepository = settingsRepository; _pathMapper = pathMapper; _dbContext = new DbContext(); }
public IValidationResult Validate( string originalQuery, ISchema schema, Document document, IEnumerable<IValidationRule> rules = null) { var context = new ValidationContext { OriginalQuery = originalQuery, Schema = schema, Document = document, TypeInfo = new TypeInfo(schema) }; if (rules == null) { rules = CoreRules(); } var visitors = rules.Select(x => x.Validate(context)).ToList(); visitors.Insert(0, context.TypeInfo); #if DEBUG visitors.Insert(1, new DebugNodeVisitor()); #endif var basic = new BasicVisitor(visitors.ToArray()); basic.Visit(document); var result = new ValidationResult(); result.Errors.AddRange(context.Errors); return result; }
public ExecutionContext BuildExecutionContext( ISchema schema, object root, Document document, string operationName, Inputs inputs, CancellationToken cancellationToken) { var context = new ExecutionContext(); context.Schema = schema; context.RootObject = root; var operation = !string.IsNullOrWhiteSpace(operationName) ? document.Operations.WithName(operationName) : document.Operations.FirstOrDefault(); if (operation == null) { context.Errors.Add(new ExecutionError("Unknown operation name: {0}".ToFormat(operationName))); return context; } context.Operation = operation; context.Variables = GetVariableValues(schema, operation.Variables, inputs); context.Fragments = document.Fragments; context.CancellationToken = cancellationToken; return context; }
/// <summary> /// Invoked when disposing or finalizing this instance. /// </summary> /// <param name="disposing">True if the object is being disposed, false otherwise.</param> protected virtual void OnDispose(bool disposing) { if (disposing) { try { if (_Owner != null) { var temp = _Owner; _Owner = null; if (temp != null && !temp.IsDisposed) temp.Remove(this); } if (_Metadata != null) _Metadata.Clear(); if (_EntryMetadata != null) _EntryMetadata._Entry = null; if (_EntryTags != null) _EntryTags._Entry = null; } catch { } } _Owner = null; _Metadata = null; _EntryMetadata = null; _EntryTags = null; _IsDisposed = true; }
public string Generate(ISchema schema) { StringBuilder sb = new StringBuilder(string.Format(@" @using Kooboo.CMS.Content.Models; @using Kooboo.CMS.Content.Query; @{{ var schema = (Kooboo.CMS.Content.Models.Schema)ViewData[""Schema""]; var allowedEdit = (bool)ViewData[""AllowedEdit""]; var allowedView = (bool)ViewData[""AllowedView""]; var parentUUID = ViewContext.RequestContext.AllRouteValues()[""parentUUID""]; var parentFolder=ViewContext.RequestContext.AllRouteValues()[""parentFolder""]; }} @using(Html.BeginForm(ViewContext.RequestContext.AllRouteValues()[""action""].ToString() , ViewContext.RequestContext.AllRouteValues()[""controller""].ToString() , ViewContext.RequestContext.AllRouteValues() , FormMethod.Post , new RouteValueDictionary(new {{ enctype = ""{0}"" }}))) {{ <table>", FormHelper.Enctype(schema))); foreach (var item in schema.Columns.OrderBy(it => it.Order)) { sb.Append(item.Render(schema, false)); } sb.Append(@" @Html.Action(""Categories"", ViewContext.RequestContext.AllRouteValues()) </table> }"); return sb.ToString(); }
protected override void OnSetup() { base.OnSetup(); _urlBase = Settings.Url; _schema = ODataClient.GetSchema(_urlBase); }
public void DecorateClass(CodeTypeDeclaration typeDeclaration, ISchema schema, IDictionary<JsonSchema, SchemaImplementationDetails> implDetails, INestedClassProvider internalClassProvider) { typeDeclaration.ThrowIfNull("typeDeclaration"); schema.ThrowIfNull("schema"); implDetails.ThrowIfNull("implDetails"); internalClassProvider.ThrowIfNull("internalClassProvider"); JsonSchema details = schema.SchemaDetails; details.ThrowIfNull("schemaDetails"); // Check if this decorator can be applied to the schema); if (details.Type != JsonSchemaType.Array) { return; } if (details.Items == null || details.Items.Count != 1) { logger.Warning("Found array scheme of unhandled type. {0}", details); return; // not supported } // Generate or find the nested type JsonSchema itemScheme = details.Items[0]; SchemaImplementationDetails implDetail = implDetails[itemScheme]; implDetail.ProposedName = "Entry"; // Change the name to a custom one. CodeTypeReference item = SchemaDecoratorUtil.GetCodeType(itemScheme, implDetail, internalClassProvider); // Insert the base type before any interface declaration var baseType = string.Format("List<{0}>", item.BaseType); typeDeclaration.BaseTypes.Insert(0, new CodeTypeReference(baseType)); }
public ColumnSchema (ISchemaProvider schemaProvider, ISchema parent, string name) : base (schemaProvider) { this.constraints = new ConstraintSchemaCollection (); this.parent = parent; this.name = name; }
internal FluentCommand(FluentCommand ancestor) { _schema = ancestor._schema; _parent = ancestor._parent; _collectionName = ancestor._collectionName; _collectionExpression = ancestor._collectionExpression; _derivedCollectionName = ancestor._derivedCollectionName; _derivedCollectionExpression = ancestor._derivedCollectionExpression; _functionName = ancestor._functionName; _keyValues = ancestor._keyValues; _namedKeyValues = ancestor._namedKeyValues; _entryData = ancestor._entryData; _parameters = ancestor._parameters; _filter = ancestor._filter; _filterExpression = ancestor._filterExpression; _filterExpression = ancestor._filterExpression; _skipCount = ancestor._skipCount; _topCount = ancestor._topCount; _expandAssociations = ancestor._expandAssociations; _selectColumns = ancestor._selectColumns; _orderbyColumns = ancestor._orderbyColumns; _computeCount = ancestor._computeCount; _inlineCount = ancestor._inlineCount; _linkName = ancestor._linkName; _linkExpression = ancestor._linkExpression; }
/// <summary> /// Initializes a new instance of the <see cref="ResolveFieldContext"/> class. /// </summary> /// <param name="fieldName">Name of the field.</param> /// <param name="fieldAst">The field ast.</param> /// <param name="fieldDefinition">The field definition.</param> /// <param name="returnType">Type of the return.</param> /// <param name="parentType">Type of the parent.</param> /// <param name="arguments">The arguments.</param> /// <param name="rootValue">The root value.</param> /// <param name="source">The source.</param> /// <param name="schema">The schema.</param> /// <param name="operation">The operation.</param> /// <param name="fragments">The fragments.</param> /// <param name="variables">The variables.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="userContext">The user context.</param> public ResolveFieldContext( string fieldName, Field fieldAst, FieldType fieldDefinition, GraphType returnType, ObjectGraphType parentType, IReadOnlyDictionary<string, object> arguments, object rootValue, object source, ISchema schema, Operation operation, IEnumerable<IFragment> fragments, IEnumerable<Variable> variables, CancellationToken cancellationToken, object userContext) { FieldName = fieldName; FieldAst = fieldAst; FieldDefinition = fieldDefinition; ReturnType = returnType; ParentType = parentType; Arguments = arguments; RootValue = rootValue; Source = source; Schema = schema; Operation = operation; Fragments = fragments; Variables = variables; CancellationToken = cancellationToken; UserContext = userContext; }
public static string Render(this IColumn column, ISchema schema, bool isUpdate) { var controlType = column.ControlType; if (isUpdate && !column.Modifiable) { controlType = "Hidden"; } if (string.IsNullOrEmpty(controlType)) { return string.Empty; } if (!Contains(controlType)) { throw new Exception(string.Format("Control type {0} does not exists.", controlType)); } string controlHtml = string.Empty; controlHtml = controls[controlType].Render(schema, column); if (string.Equals(column.Name, "published", StringComparison.OrdinalIgnoreCase)) { controlHtml = AllowedEditWraper(controlHtml); } return controlHtml; }
public void ContainsTypeNames(ISchema schema, params string[] typeNames) { typeNames.Apply(typeName => { var type = schema.FindType(typeName); type.ShouldNotBeNull("Did not find {0} in type lookup.".ToFormat(typeName)); }); }
public void DecorateClass(CodeTypeDeclaration typeDeclaration, ISchema schema, IDictionary<JsonSchema, SchemaImplementationDetails> implDetails, INestedClassProvider internalClassProvider) { schema.ThrowIfNull("schema"); ImplementAdditionalProperties(typeDeclaration, schema.SchemaDetails, implDetails, internalClassProvider); }
/// <summary> /// Attempts to interpret a TaggedGenericType instance as /// a specific type /// </summary> /// <param name="value">The value to interpet</param> /// <param name="schema">The type to interpret as</param> /// <param name="output">The output type</param> /// <returns>True if the interpretation succeeds, false otherwise</returns> public IValueStream CreateStream(GenericValue value, ISchema schema) { var tagged = (TaggedGenericValue)value; MemoryStream ms = new MemoryStream(tagged.tag, tagged.offset, tagged.end - tagged.offset); TagReader reader = new TagReader(ms); TagReaderStream stream = new TagReaderStream(reader, schema); return stream; }
public ODataClient(ODataBatch batch) { _urlBase = batch.RequestBuilder.UrlBase; _schema = Client.Schema.Get(_urlBase); _requestBuilder = batch.RequestBuilder; _requestRunner = batch.RequestRunner; }
public ODataClient(ODataBatch batch) { _settings = batch.Settings; _schema = Client.Schema.Get(_settings.UrlBase, _settings.Credentials); _requestBuilder = batch.RequestBuilder; _requestRunner = batch.RequestRunner; }
public ODataClient(string urlBase) { _urlBase = urlBase; _schema = Client.Schema.Get(urlBase); _requestBuilder = new CommandRequestBuilder(_urlBase); _requestRunner = new CommandRequestRunner(); }
public override string Render(ISchema schema, IColumn column) { string html = string.Format(CheckBoxTemplate, column.Name, (string.IsNullOrEmpty(column.Label) ? column.Name : column.Label).RazorHtmlEncode(), RenderInput(column), FormHelper.Tooltip(column.Tooltip)); return html; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="caseSensitiveNames">Whether the table and column names of the members /// of this collection are case sensitive or not.</param> public RecordBuilder( bool caseSensitiveNames = Schema.DEFAULT_CASESENSITIVE_NAMES) { _CaseSensitiveNames = caseSensitiveNames; if ((_Schema = CreateEmptySchema()) == null) throw new CannotCreateException("Cannot create an empty schema for this instance."); }
internal string Format(ISchema schema, Table table) { return this.Format(new ExpressionContext() { Schema = schema, Table = table }); }
public virtual string Render(ISchema schema, IColumn column) { string html = string.Format(EditorTemplate, column.Name, (string.IsNullOrEmpty(column.Label) ? column.Name : column.Label).RazorHtmlEncode(), RenderInput(column), string.IsNullOrEmpty(column.Tooltip) ? "" : string.Format(@"<a href=""javascript:;"" class=""tooltip-link"" title='{0}'></a>", (column.Tooltip).RazorHtmlEncode())); return html; }
public async Task<ExecutionResult> Execute( ISchema schema, object rootObject, string query, string operationName = null, Inputs inputs = null) { return await _executer.ExecuteAsync(schema, rootObject, query, operationName); }
public UserImpl(ISchema schema, UserModel model) { Schema = schema; Login = model.Login; Name = model.Name; Email = model.Email; Active = model.Active; PasswordHash = model.PasswordHash; }
public SchemaPrinter(ISchema schema, IEnumerable<string> customScalars = null) { _schemaReference = new WeakReference<ISchema>(schema); if (customScalars != null) { _scalars.Fill(customScalars); } }
protected override void OnSetup() { base.OnSetup(); var odataFeed = new ODataFeed(this.Settings); _clientSettings = odataFeed.ClientSettings; _schema = Utils.ExecuteAndUnwrap(() => ODataClient.GetSchemaAsync(_clientSettings.UrlBase, _clientSettings.Credentials)); }
public string Generate(ISchema schema) { StringBuilder sb = new StringBuilder(string.Format(@" @using Kooboo.CMS.Content.Models; @using Kooboo.CMS.Content.Query; @if(Model==null) {{ @(""The content was deleted."".Localize()) }} else {{ var schema = (Kooboo.CMS.Content.Models.Schema)ViewData[""Schema""]; var allowedEdit = (bool)ViewData[""AllowedEdit""]; var allowedView = (bool)ViewData[""AllowedView""]; var workflowItem = Model._WorkflowItem_; var hasWorkflowItem = workflowItem!=null; var availableEdit = hasWorkflowItem || (!hasWorkflowItem && allowedEdit); using(Html.BeginForm(ViewContext.RequestContext.AllRouteValues()[""action""].ToString() , ViewContext.RequestContext.AllRouteValues()[""controller""].ToString() , ViewContext.RequestContext.AllRouteValues() , FormMethod.Post, new RouteValueDictionary(new {{ enctype = ""{0}"" }}))) {{ <div class=""common-form""> <fieldset> <table>", FormHelper.Enctype(schema))); foreach (var item in schema.Columns.OrderBy(it => it.Order)) { sb.Append(item.Render(schema, true)); } sb.Append(@" @Html.Action(""Categories"", ViewContext.RequestContext.AllRouteValues()) </table> </fieldset> <p class=""buttons""> @if(availableEdit){ <button type=""submit"">@(""Save"".Localize())</button> if(Model.IsLocalized !=null && Model.IsLocalized == false){<button type=""submit"" name=""Localize"" value=""true"">Localize</button>} <a href=""javascript:;"" class=""dialog-close button"">@(""Close"".Localize())</a> } else { <a href=""javascript:;"" class=""dialog-close button"">@(""Close"".Localize())</a> <a href=""@Url.Action(""WorkflowHistory"",""PendingWorkflow"",ViewContext.RequestContext.AllRouteValues().Merge(""UserKey"", (object)(Model.UserKey)).Merge(""UUID"",(object)(Model.UUID)))"" title=""@(""View workflow history"".Localize())"" class=""button dialog-link"">@(""View workflow history"".Localize())</a> <a href=""javascript:;"" class=""tooltip-link"" title=""@(""The content is approving or you have not permission to publish."".Localize())""></a> } </p> </div> } }"); return sb.ToString(); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="schema">The schema this record will be associated with.</param> public Record(ISchema schema) { if (schema == null) throw new ArgumentNullException("schema", "Schema cannot be null."); if (schema.IsDisposed) throw new ObjectDisposedException(schema.ToString()); var count = schema.Count; if (count < 1) throw new EmptyException("Schema is empty"); _Values = new object[count]; Array.Clear(_Values, 0, count); _Schema = schema; }
public ODataClient(ODataClientSettings settings) { _settings = settings; _schema = Client.Schema.Get(_settings.UrlBase, _settings.Credentials); _requestBuilder = new CommandRequestBuilder(_settings.UrlBase, _settings.Credentials); _requestRunner = new CommandRequestRunner(_settings); _requestRunner.BeforeRequest = _settings.BeforeRequest; _requestRunner.AfterResponse = _settings.AfterResponse; }
public async Task BuildAsync() { if (_output is null) { throw new InvalidOperationException( "You have to specify a field output handler before you " + "can generate any client APIs."); } if (_schemas.Count == 0) { throw new InvalidOperationException( "You have to specify at least one schema file before you " + "can generate any client APIs."); } if (_queries.Count == 0) { throw new InvalidOperationException( "You have to specify at least one query file before you " + "can generate any client APIs."); } IDocumentHashProvider hashProvider = _hashProvider ?? new MD5DocumentHashProvider(HashFormat.Hex); _namespace = _namespace ?? "StrawberryShake.Client"; // create schema DocumentNode mergedSchema = MergeSchema(); mergedSchema = MergeSchemaExtensions(mergedSchema); ISchema schema = CreateSchema(mergedSchema); InitializeScalarTypes(schema); // parse queries IReadOnlyList <HCError> errors = ValidateQueryDocuments(schema); if (errors.Count > 0) { throw new GeneratorException(errors); } IReadOnlyList <IQueryDescriptor> queries = await ParseQueriesAsync(hashProvider) .ConfigureAwait(false); // generate abstract client models var usedNames = new HashSet <string>(); var descriptors = new List <ICodeDescriptor>(); var fieldTypes = new Dictionary <FieldNode, string>(); GenerateModels(schema, queries, usedNames, descriptors, fieldTypes); var typeLookup = new TypeLookup( _options.LanguageVersion, _leafTypes.Values, fieldTypes, _namespace); // generate code from models foreach (ICodeGenerator generator in CreateGenerators(_options)) { foreach (ICodeDescriptor descriptor in descriptors) { if (generator.CanHandle(descriptor)) { _output.Register(descriptor, generator); } } } await _output.WriteAllAsync(typeLookup) .ConfigureAwait(false); }
private InputObjectType CreateInputType() { ISchema schema = CreateSchema(); return(schema.GetType <InputObjectType>("GeoJSONLineStringInput")); }
/// <summary> /// Scans the calling assembly for classes that inherit from <see cref="ObjectGraphType{TSourceType}"/>, /// <see cref="InputObjectGraphType{TSourceType}"/>, or <see cref="EnumerationGraphType{TEnum}"/>, and /// registers clr type mappings on the schema between that class and the source type or underlying enum type. /// Skips classes where the source type is <see cref="object"/>, or where the class is marked with /// the <see cref="DoNotMapClrTypeAttribute"/>. /// </summary> /// <remarks> /// This method uses reflection and therefor is inheritly slow, especially with a large assembly. /// When using a scoped schema, it is faster to call /// <see cref="GraphQLBuilderExtensions.AddClrTypeMappings(DI.IGraphQLBuilder)"/> as it will precompute /// the mappings prior to execution. /// </remarks> public static void RegisterTypeMappings(this ISchema schema) => schema.RegisterTypeMappings(Assembly.GetCallingAssembly());
public ITypedMessageBuilder <V> NewMessage <V>(ISchema <V> schema) { Condition.CheckArgument(schema != null); return(new TypedMessageBuilder <V>(_producerActor, schema, _conf)); }
/// <summary> /// Adds the specified graph type to the schema. /// <br/><br/> /// Not typically required as schema initialization will scan the <see cref="ISchema.Query"/>, /// <see cref="ISchema.Mutation"/> and <see cref="ISchema.Subscription"/> graphs, creating /// instances of <see cref="IGraphType"/>s referenced therein as necessary. /// </summary> public static void RegisterType <T>(this ISchema schema) where T : IGraphType { schema.RegisterType(typeof(T)); }
private void RunCore(IChannel ch, string cmd) { Host.AssertValue(ch); Host.AssertNonEmpty(cmd); ch.Trace("Constructing trainer"); ITrainer trainer = _trainer.CreateComponent(Host); IPredictor inputPredictor = null; if (Args.ContinueTrain && !TrainUtils.TryLoadPredictor(ch, Host, Args.InputModelFile, out inputPredictor)) { ch.Warning("No input model file specified or model file did not contain a predictor. The model state cannot be initialized."); } ch.Trace("Constructing data pipeline"); IDataView view = CreateLoader(); ISchema schema = view.Schema; var label = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.LabelColumn), _labelColumn, DefaultColumnNames.Label); var feature = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.FeatureColumn), _featureColumn, DefaultColumnNames.Features); var group = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.GroupColumn), _groupColumn, DefaultColumnNames.GroupId); var weight = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.WeightColumn), _weightColumn, DefaultColumnNames.Weight); var name = TrainUtils.MatchNameOrDefaultOrNull(ch, schema, nameof(Arguments.NameColumn), _nameColumn, DefaultColumnNames.Name); TrainUtils.AddNormalizerIfNeeded(Host, ch, trainer, ref view, feature, Args.NormalizeFeatures); ch.Trace("Binding columns"); var customCols = TrainUtils.CheckAndGenerateCustomColumns(ch, Args.CustomColumn); var data = new RoleMappedData(view, label, feature, group, weight, name, customCols); // REVIEW: Unify the code that creates validation examples in Train, TrainTest and CV commands. RoleMappedData validData = null; if (!string.IsNullOrWhiteSpace(Args.ValidationFile)) { if (!trainer.Info.SupportsValidation) { ch.Warning("Ignoring validationFile: Trainer does not accept validation dataset."); } else { ch.Trace("Constructing the validation pipeline"); IDataView validPipe = CreateRawLoader(dataFile: Args.ValidationFile); validPipe = ApplyTransformUtils.ApplyAllTransformsToData(Host, view, validPipe); validData = new RoleMappedData(validPipe, data.Schema.GetColumnRoleNames()); } } // In addition to the training set, some trainers can accept two extra data sets, validation set and test set, // in training phase. The major difference between validation set and test set is that training process may // indirectly use validation set to improve the model but the learned model should totally independent of test set. // Similar to validation set, the trainer can report the scores computed using test set. RoleMappedData testDataUsedInTrainer = null; if (!string.IsNullOrWhiteSpace(Args.TestFile)) { // In contrast to the if-else block for validation above, we do not throw a warning if test file is provided // because this is TrainTest command. if (trainer.Info.SupportsTest) { ch.Trace("Constructing the test pipeline"); IDataView testPipeUsedInTrainer = CreateRawLoader(dataFile: Args.TestFile); testPipeUsedInTrainer = ApplyTransformUtils.ApplyAllTransformsToData(Host, view, testPipeUsedInTrainer); testDataUsedInTrainer = new RoleMappedData(testPipeUsedInTrainer, data.Schema.GetColumnRoleNames()); } } var predictor = TrainUtils.Train(Host, ch, data, trainer, validData, Args.Calibrator, Args.MaxCalibrationExamples, Args.CacheData, inputPredictor, testDataUsedInTrainer); using (var file = Host.CreateOutputFile(Args.OutputModelFile)) TrainUtils.SaveModel(Host, ch, file, predictor, data, cmd); }
public override void VisitDirectiveArgumentDefinition(QueryArgument argument, Directive directive, ISchema schema) => Replace(argument);
public static QuantileRegressionPerInstanceEvaluator Create(IHostEnvironment env, ModelLoadContext ctx, ISchema schema) { Contracts.CheckValue(env, nameof(env)); env.CheckValue(ctx, nameof(ctx)); ctx.CheckAtModel(GetVersionInfo()); return(new QuantileRegressionPerInstanceEvaluator(env, ctx, schema)); }
private QuantileRegressionPerInstanceEvaluator(IHostEnvironment env, ModelLoadContext ctx, ISchema schema) : base(env, ctx, schema) { CheckInputColumnTypes(schema); // *** Binary format ** // base // int: _scoreSize // int[]: Ids of the quantile names _scoreSize = ctx.Reader.ReadInt32(); Host.CheckDecode(_scoreSize > 0); _quantiles = new ReadOnlyMemory <char> [_scoreSize]; for (int i = 0; i < _scoreSize; i++) { _quantiles[i] = ctx.LoadNonEmptyString().AsMemory(); } _outputType = new VectorType(NumberType.R8, _scoreSize); }
public ArgumentNamesVisitor(ISchema schema) : base(schema) { _directives = schema.DirectiveTypes.ToDictionary(t => t.Name); }
public FragmentSpreadIsPossibleVisitor(ISchema schema) : base(schema) { }
public DataRow(ISchema schema) : base(schema) { }
private FieldType BuildSchemaBasedFieldType(ISchema schema, SqlQuery query, JToken querySchema) { var typetype = new ObjectGraphType <JObject> { Name = query.Name }; var properties = querySchema["Properties"]; foreach (var child in properties.Children()) { var name = ((JProperty)child).Name; var nameLower = name.Replace('.', '_'); var type = child["type"].ToString(); if (type == "String") { var field = typetype.Field( typeof(StringGraphType), nameLower, resolve: context => { var source = context.Source; return(source[context.FieldDefinition.Metadata["Name"].ToString()].ToObject <string>()); }); field.Metadata.Add("Name", name); } if (type == "Integer") { var field = typetype.Field( typeof(IntGraphType), nameLower, resolve: context => { var source = context.Source; return(source[context.FieldDefinition.Metadata["Name"].ToString()].ToObject <int>()); }); field.Metadata.Add("Name", name); } } var fieldType = new FieldType { Arguments = new QueryArguments( new QueryArgument <StringGraphType> { Name = "parameters" } ), Name = query.Name, ResolvedType = new ListGraphType(typetype), Resolver = new AsyncFieldResolver <object, object>(async context => { var queryManager = _httpContextAccessor.HttpContext.RequestServices.GetService <IQueryManager>(); var iquery = await queryManager.GetQueryAsync(context.FieldName); var parameters = context.GetArgument <string>("parameters"); var queryParameters = parameters != null ? JsonConvert.DeserializeObject <Dictionary <string, object> >(parameters) : new Dictionary <string, object>(); return(await queryManager.ExecuteQueryAsync(iquery, queryParameters)); }), Type = typeof(ListGraphType <ObjectGraphType <JObject> >) }; return(fieldType); }
// Factory method for SignatureLoadRowMapper. private static IRowMapper Create(IHostEnvironment env, ModelLoadContext ctx, ISchema inputSchema) => Create(env, ctx).MakeRowMapper(inputSchema);
public override void VisitInterfaceFieldArgumentDefinition(QueryArgument argument, FieldType field, IInterfaceGraphType type, ISchema schema) => Replace(argument);
public static IQueryExecutor BuildDefault(ISchema schema) => New().UseDefaultPipeline().Build(schema);
protected override RegressionPredictionTransformer <LightGbmRegressionPredictor> MakeTransformer(LightGbmRegressionPredictor model, ISchema trainSchema) => new RegressionPredictionTransformer <LightGbmRegressionPredictor>(Host, model, trainSchema, FeatureColumn.Name);
private string print(ISchema schema, SchemaPrinterOptions options = null) { var printer = new SchemaPrinter(schema, options); return(Environment.NewLine + printer.Print()); }
public InputObjectFieldUniquenessVisitor(ISchema schema) : base(schema) { }
public override void VisitObjectFieldDefinition(FieldType field, IObjectGraphType type, ISchema schema) => Replace(field);
/// <summary> /// Runs the specified visitor on the specified schema. This method traverses /// all the schema elements and calls the appropriate visitor methods. /// </summary> public static void Run(this ISchemaNodeVisitor visitor, ISchema schema) { visitor.VisitSchema(schema); foreach (var directive in schema.Directives.List) { visitor.VisitDirective(directive, schema); if (directive.Arguments?.Count > 0) { foreach (var argument in directive.Arguments.List !) { visitor.VisitDirectiveArgumentDefinition(argument, directive, schema); } } } foreach (var item in schema.AllTypes.Dictionary) { switch (item.Value) { case EnumerationGraphType e: visitor.VisitEnum(e, schema); foreach (var value in e.Values) //ISSUE:allocation { visitor.VisitEnumValue(value, e, schema); } break; case ScalarGraphType scalar: visitor.VisitScalar(scalar, schema); break; case UnionGraphType union: visitor.VisitUnion(union, schema); break; case IInterfaceGraphType iface: visitor.VisitInterface(iface, schema); foreach (var field in iface.Fields.List) // List is always non-null { visitor.VisitInterfaceFieldDefinition(field, iface, schema); if (field.Arguments?.Count > 0) { foreach (var argument in field.Arguments.List !) { visitor.VisitInterfaceFieldArgumentDefinition(argument, field, iface, schema); } } } break; case IObjectGraphType output: visitor.VisitObject(output, schema); foreach (var field in output.Fields.List) // List is always non-null { visitor.VisitObjectFieldDefinition(field, output, schema); if (field.Arguments?.Count > 0) { foreach (var argument in field.Arguments.List !) { visitor.VisitObjectFieldArgumentDefinition(argument, field, output, schema); } } } break; case IInputObjectGraphType input: visitor.VisitInputObject(input, schema); foreach (var field in input.Fields.List) // List is always non-null { visitor.VisitInputObjectFieldDefinition(field, input, schema); } break; } } }
protected override RegressionPredictionTransformer <FastTreeTweediePredictor> MakeTransformer(FastTreeTweediePredictor model, ISchema trainSchema) => new RegressionPredictionTransformer <FastTreeTweediePredictor>(Host, model, trainSchema, FeatureColumn.Name);
/// <summary> /// Adds the specified visitor type to the schema. When initializing a schema, all /// registered visitors will be executed on each schema element when it is traversed. /// </summary> public static void RegisterVisitor <TVisitor>(this ISchema schema) where TVisitor : ISchemaNodeVisitor { schema.RegisterVisitor(typeof(TVisitor)); }
public override void VisitObjectFieldArgumentDefinition(QueryArgument argument, FieldType field, IObjectGraphType type, ISchema schema) => Replace(argument);
/// <summary> /// Registers type mapping from CLR type to <see cref="AutoRegisteringObjectGraphType{T}"/> and/or <see cref="AutoRegisteringInputObjectGraphType{T}"/>. /// <br/> /// These mappings are used for type inference when constructing fields using expressions: /// <br/> /// <c> /// Field(x => x.Filters); /// </c> /// </summary> /// <param name="schema">The schema for which the mapping is registered.</param> /// <typeparam name="TClrType">The CLR property type from which to infer the GraphType.</typeparam> /// <param name="mode">Which registering mode to use - input only, output only or both.</param> public static void AutoRegister <TClrType>(this ISchema schema, AutoRegisteringMode mode = AutoRegisteringMode.Both) { schema.AutoRegister(typeof(TClrType), mode); }
public override void VisitInterfaceFieldDefinition(FieldType field, IInterfaceGraphType type, ISchema schema) => Replace(field);
public static IQueryExecutor BuildDefault(ISchema schema, IQueryExecutionOptionsAccessor options) => New().UseDefaultPipeline(options).Build(schema);
/// <summary> /// Registers type mapping from CLR type to GraphType. /// <br/> /// These mappings are used for type inference when constructing fields using expressions: /// <br/> /// <c> /// Field(x => x.Filters); /// </c> /// </summary> /// <typeparam name="TClrType">The CLR property type from which to infer the GraphType.</typeparam> /// <typeparam name="TGraphType">Inferred GraphType.</typeparam> public static void RegisterTypeMapping <TClrType, TGraphType>(this ISchema schema) where TGraphType : IGraphType { schema.RegisterTypeMapping(typeof(TClrType), typeof(TGraphType)); }
public TypeInfo(ISchema schema) { _schema = schema; }
/// <summary> /// 生成Schema模板 /// </summary> /// <param name="schema">The schema.</param> /// <param name="formType">Type of the form.</param> /// <returns></returns> public static string GenerateForm(this Schema schema, FormType formType) { ISchema iSchema = schema.AsActual(); return(iSchema.Generate(formType.ToString())); }