private DocumentNode RewriteTypes( ISchemaInfo schema, DocumentNode document) { if (_typeRewriters.Count == 0) { return(document); } var definitions = new List <IDefinitionNode>(); foreach (IDefinitionNode definition in document.Definitions) { if (definition is ITypeDefinitionNode typeDefinition) { foreach (ITypeRewriter rewriter in _typeRewriters) { typeDefinition = rewriter.Rewrite( schema, typeDefinition); } definitions.Add(typeDefinition); } else { definitions.Add(definition); } } return(document.WithDefinitions(definitions)); }
/// <summary> /// Renames files when neccessary. /// </summary> /// <param name="schema"></param> /// <param name="definitionSchema"></param> /// <returns></returns> private DocumentNode RewriteDocument(ISchemaInfo schema, DocumentNode definitionSchema) { var definitions = new List <IDefinitionNode>(); var schemaName = schema.Name.Value; if (schemaName.Contains("api")) { schemaName = schemaName.Substring(0, schemaName.Length - 3); } else if (schemaName.Contains("service")) { schemaName = schemaName.Substring(0, schemaName.Length - 7); } foreach (var definition in definitionSchema.Definitions) { if (definition is ObjectTypeDefinitionNode typeDefinition) { if (!(typeDefinition.Name.Value.ToLower().Contains(schemaName))) { definitions.Add(typeDefinition.WithName(new NameNode(schemaName + "_" + typeDefinition.Name.Value))); continue; } } definitions.Add(definition); } return(definitionSchema.WithDefinitions(definitions)); }
public ITypeDefinitionNode Rewrite( ISchemaInfo schema, ITypeDefinitionNode typeDefinition) { if (SchemaName.HasValue && !SchemaName.Value.Equals(schema.Name)) { return(typeDefinition); } NameString typeName = typeDefinition.GetOriginalName(schema.Name); if (!Field.TypeName.Equals(typeName)) { return(typeDefinition); } switch (typeDefinition) { case InputObjectTypeDefinitionNode iotd: return(RenameFields(iotd, schema.Name)); case ObjectTypeDefinitionNode otd: return(RenameFields(otd, schema.Name, f => otd.WithFields(f))); case InterfaceTypeDefinitionNode itd: return(RenameFields(itd, schema.Name, f => itd.WithFields(f))); default: return(typeDefinition); } }
/// <summary> /// Encode key & value into schema into a KeyValue schema. /// </summary> /// <param name="schemaName"> the final schema name </param> /// <param name="keySchemaInfo"> the key schema info </param> /// <param name="valueSchemaInfo"> the value schema info </param> /// <param name="keyValueEncodingType"> the encoding type to encode and decode key value pair </param> /// <returns> the final schema info </returns> public static ISchemaInfo EncodeKeyValueSchemaInfo(string schemaName, ISchemaInfo keySchemaInfo, ISchemaInfo valueSchemaInfo, KeyValueEncodingType keyValueEncodingType) { Condition.CheckNotNull(keyValueEncodingType, "Null encoding type is provided"); if (keySchemaInfo == null || valueSchemaInfo == null) { // schema is not ready return(null); } // process key/value schema data byte[] schemaData = KeyValue <ISchemaInfo, ISchemaInfo> .Encode(keySchemaInfo, _schemaInfoWriter, valueSchemaInfo, _schemaInfoWriter); // process key/value schema properties IDictionary <string, string> Properties = new Dictionary <string, string>(); EncodeSubSchemaInfoToParentSchemaProperties(keySchemaInfo, KEY_SCHEMA_NAME, KEY_SCHEMA_TYPE, KEY_SCHEMA_PROPS, Properties); EncodeSubSchemaInfoToParentSchemaProperties(valueSchemaInfo, VALUE_SCHEMA_NAME, VALUE_SCHEMA_TYPE, VALUE_SCHEMA_PROPS, Properties); Properties[KV_ENCODING_TYPE] = keyValueEncodingType.ToString(); // generate the final schema info return(new SchemaInfo { Name = schemaName, Type = SchemaType.KeyValue, Schema = schemaData, Properties = Properties }); }
public static ITypeInfo Create( ITypeDefinitionNode typeDefinition, ISchemaInfo schema) { switch (typeDefinition) { case ObjectTypeDefinitionNode otd: return(new ObjectTypeInfo(otd, schema)); case InterfaceTypeDefinitionNode itd: return(new InterfaceTypeInfo(itd, schema)); case UnionTypeDefinitionNode utd: return(new UnionTypeInfo(utd, schema)); case InputObjectTypeDefinitionNode iotd: return(new InputObjectTypeInfo(iotd, schema)); case EnumTypeDefinitionNode etd: return(new EnumTypeInfo(etd, schema)); case ScalarTypeDefinitionNode std: return(new ScalarTypeInfo(std, schema)); default: throw new NotSupportedException(); } }
public User AttachItem(UserInfo source, ISchemaInfo schema) { User item = GetItem(source.Oid); if (item == null) { item = User.Get(source.Oid); if (item == null) { item = User.New(); item.CopyFrom(source); } item.MarkItemChild(); this.Add(item); item.MarkItemOld(); } else if (item.EEstado == EEstadoItem.Registered) { return(null); } item.AttachSchema(schema); item.SessionCode = SessionCode; item.EEstado = EEstadoItem.Registered; return(item); }
public DirectiveTypeInfo( DirectiveDefinitionNode definition, ISchemaInfo schema) { Definition = definition; Schema = schema; }
public ITypeDefinitionNode Rewrite( ISchemaInfo schema, ITypeDefinitionNode typeDefinition) { if (typeDefinition.Name.Value.Equals("Query") && typeDefinition is ObjectTypeDefinitionNode objectType) { var path = new SelectionPathComponent( new NameNode("foo"), new[] { new ArgumentNode( "a", new ScopedVariableNode( ScopeNames.ContextData, "foo_a")) }); Dictionary <string, FieldDefinitionNode> fields = objectType.Fields.ToDictionary(t => t.Name.Value); fields["foo"] = fields["foo"] .WithArguments(Array.Empty <InputValueDefinitionNode>()) .AddDelegationPath("someSchema", path); return(objectType.WithFields(fields.Values.ToArray())); } return(typeDefinition); }
public EComponentStatus CheckStatus(ISchemaInfo schema) { switch (Status) { case EComponentStatus.DISABLED: case EComponentStatus.WORKING: { return(Status); } default: { //Para la primera vez que se consulta if (!LastExecutions.ContainsKey(schema.Oid)) { UpdateLastExecution(schema); #if DEBUG LastExecutions[schema.Oid] = DateTime.MinValue; #endif } if (DateAndTime.DateDiff(DateInterval.Second, LastExecutions[schema.Oid], DateTime.Now) < Interval) { return(EComponentStatus.UNAVAILABLE); } return(EComponentStatus.READY); } } }
protected override void GetFormSourceData(object[] parameters) { ISchemaInfo schema = parameters[0] as ISchemaInfo; _usuarios = Users.GetList(schema); _usuarios.BeginEdit(); }
/// <summary> /// Establece un objeto como esquema principal de datos. /// Esto indica al sistema que trabaje con los datos de este esquema /// </summary> public virtual void LoadSchema(ISchemaInfo schema) { _schema = schema; PgMng.Reset(4, 1, Resources.Messages.LOADING_SCHEMA, (_parent != null) ? _parent : this); _back_job = BackJob.LoadSchema; //PgMng.StartBackJob(this); DoLoadSchema(); }
public UsersUIForm(ISchemaInfo schema, Form parent) : base(-1, new object[1] { schema }, true, parent) { InitializeComponent(); SetFormData(); }
public BytesSchema() { var s = new SchemaInfo { Name = "Bytes", Type = SchemaType.BYTES, Schema = new byte[0] }; SchemaInfo = s; }
public override void Up(IDriver driver, ILogger logger, ISchemaInfo schemaInfo) { using (var trans = driver.Database.BeginTransaction()) { base.Up(driver, logger, schemaInfo); trans.Commit(); } }
public override void LoadSchema(ISchemaInfo schema) { base.LoadSchema(schema); //Company currency configuration CompanyInfo company = CompanyInfo.Get(AppContext.ActiveSchema.Oid, false); company.SetCurrency(); }
public SerializationContext(IDomainModel domainModel, Identity id, ISchemaInfo schemaElement) { Contract.Requires(domainModel, "domainModel"); Contract.Requires(id, "id"); Contract.Requires(schemaElement, "schemaElement"); Id = id; DomainModel = domainModel; Schema = schemaElement; }
protected TypeInfo( ITypeDefinitionNode typeDefinition, ISchemaInfo schema) { Definition = typeDefinition ?? throw new ArgumentNullException(nameof(typeDefinition)); Schema = schema ?? throw new ArgumentNullException(nameof(schema)); IsRootType = schema.IsRootType(typeDefinition); }
public void DettachItem(User source, ISchemaInfo schema) { if (source.EEstado == EEstadoItem.Baja) { return; } source.DettachSchema(schema); source.EEstado = EEstadoItem.Baja; }
protected override void ResumenPreguntasAction() { if (_entity.MemoPreguntas == string.Empty) { return; } ExamenReportMng reportMng = new ExamenReportMng(AppContext.ActiveSchema); string lista = _entity.MemoPreguntas.Replace(';', ','); lista = lista.Substring(0, lista.Length - 1); bool defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting(); CompanyInfo empresa = null; if (defecto) { empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false); } while (empresa == null) { moleQule.Face.Common.CompanySelectForm form = new Common.CompanySelectForm(this); DialogResult result = form.ShowDialog(); try { if (result == DialogResult.OK) { empresa = form.Selected as CompanyInfo; } } catch { empresa = null; } } ISchemaInfo schema = AppContext.ActiveSchema; try { schema = empresa as ISchemaInfo; if (schema == null) { schema = AppContext.ActiveSchema; } } catch { } ReportViewer.SetReport(reportMng.GetDetailResumenExamenReport(EntityInfo, PreguntaList.GetListaExamen(lista), null, empresa)); ReportViewer.ShowDialog(); }
/// <summary> /// Decode the key/value schema info to get key schema info and value schema info. /// </summary> /// <param name="schemaInfo"> key/value schema info. </param> /// <returns> the pair of key schema info and value schema info </returns> public static KeyValue <ISchemaInfo, ISchemaInfo> DecodeKeyValueSchemaInfo(ISchemaInfo SchemaInfo) { Condition.CheckArgument(SchemaType.KeyValue == SchemaInfo.Type, "Not a KeyValue schema"); return(KeyValue <ISchemaInfo, ISchemaInfo> .Decode(SchemaInfo.Schema, (keyBytes, valueBytes) => { ISchemaInfo KeySchemaInfo = DecodeSubSchemaInfo(SchemaInfo, KEY_SCHEMA_NAME, KEY_SCHEMA_TYPE, KEY_SCHEMA_PROPS, keyBytes); ISchemaInfo ValueSchemaInfo = DecodeSubSchemaInfo(SchemaInfo, VALUE_SCHEMA_NAME, VALUE_SCHEMA_TYPE, VALUE_SCHEMA_PROPS, valueBytes); return new KeyValue <ISchemaInfo, ISchemaInfo>(KeySchemaInfo, ValueSchemaInfo); })); }
protected void UpdateLastExecution(ISchemaInfo schema) { if (LastExecutions.ContainsKey(schema.Oid)) { LastExecutions[schema.Oid] = DateTime.Now; } else { LastExecutions.Add(schema.Oid, DateTime.Now); } }
internal SerializationContext(IDomainModel domainModel, ISchemaInfo schemaElement, GraphNode v) { Contract.Requires(domainModel, "domainModel"); Contract.Requires(v, "v"); Id = v.Id; DomainModel = domainModel; StartId = v.StartId; EndId = v.EndId; Schema = schemaElement; }
static DateSchema() { var info = new SchemaInfo { Name = "Date", Type = SchemaType.DATE, Schema = new byte[0] }; _schemaInfo = info; _instance = new DateSchema(); }
/// <summary> /// warning : /// we suggest migrate GenericSchemaImpl.of() to <GenericSchema Implementor>.of() method (e.g. GenericJsonSchema 、GenericAvroSchema ) </summary> /// <param name="schemaInfo"> <seealso cref="SchemaInfo"/> </param> /// <param name="useProvidedSchemaAsReaderSchema"> <seealso cref="Boolean"/> </param> /// <returns> generic schema implementation </returns> public static GenericSchema Of(ISchemaInfo schemaInfo, bool useProvidedSchemaAsReaderSchema) { switch (schemaInfo.Type.Name) { case "AVRO": case "JSON": return(new GenericAvroSchema(schemaInfo)); default: throw new NotSupportedException("Generic schema is not supported on schema type " + schemaInfo.Type + "'"); } }
static IntSchema() { var info = new SchemaInfo { Name = "INT32", Type = SchemaType.INT32, Schema = new byte[0] }; _schemaInfo = info; _instance = new IntSchema(); }
static ShortSchema() { var info = new SchemaInfo { Name = "INT16", Type = SchemaType.INT16, Schema = new byte[0] }; _schemaInfo = info; _instance = new ShortSchema(); }
static TimeSchema() { var info = new SchemaInfo { Name = "Time", Type = SchemaType.TIME, Schema = new byte[0] }; _schemaInfo = info; _instance = new TimeSchema(); }
static DoubleSchema() { var info = new SchemaInfo { Name = "Double", Type = SchemaType.DOUBLE, Schema = new byte[0] }; _schemaInfo = info; _instance = new DoubleSchema(); }
static LongSchema() { var info = new SchemaInfo { Name = "INT64", Type = SchemaType.INT64, Schema = new byte[0] }; _schemaInfo = info; _instance = new LongSchema(); }
static LocalDateTimeSchema() { var info = new SchemaInfo { Name = "LocalDateTime", Type = SchemaType.LocalDateTime, Schema = new byte[0] }; _schemaInfo = info; _instance = new LocalDateTimeSchema(); }
static ByteSchema() { var info = new SchemaInfo { Name = "INT8", Type = SchemaType.INT8, Schema = new byte[0] }; _schemaInfo = info; _instance = new ByteSchema(); }
/// <summary> /// Construct a new Migrator. /// This is the main entry point and the core algorighm used to run migrations against a database. /// </summary> /// <param name="logger">An ILogger to use in the system to print info, errors and SQL output.</param> /// <param name="driverAssembly">The assembly name of the Driver assembly that contains the implementation for your database.</param> /// <param name="migrationsAssemblyPath">The path to a DLL containing Migrations.</param> /// <param name="connectionString">The database connection string needed to connect to the database.</param> public Migrator(ILogger logger, string driverAssembly, string migrationsAssemblyPath, string connectionString) { Logger = logger; var driverAssem = driverLoader.GetAssemblyByName(driverAssembly); var migrationsAssem = driverLoader.GetAssemblyFromPath(migrationsAssemblyPath); migrationAssemblyName = migrationsAssem.GetName().Name; Driver = driverLoader.GetDriver(driverAssem, connectionString, Logger); SetupType = SetupAttribute.GetSetupClass(migrationsAssem); Migrations = new Dictionary<long, IMigration>(); migrationLoader.GetMigrations(migrationsAssem).ForEach(m => Migrations.Add(m.Version, m)); schemaInfo = new SchemaInfo(Driver); AppliedMigrations = schemaInfo.AppliedMigrations(migrationAssemblyName); }
public virtual void Down(IDriver driver, ILogger logger, ISchemaInfo schemaInfo) { driver.BeforeDown(Version); var methods = GetDownMethods(migration.GetType(), driver); try { methods.ForEach(method => method.Invoke(migration, new[] { NewRunner(method, driver) })); } catch (ArgumentException) { throw new MigrationContractException("[Down] methods must take a single Runner parameter as an argument.", type); } catch (TargetInvocationException ex) { Console.Out.WriteLine(ex.InnerException.Message); throw ex.InnerException; } driver.AfterDown(Version); schemaInfo.DeleteSchemaVersion(Version, type.Assembly.GetName().Name); }
public void Setup() { mocks = new MockRepository(); opRepos = mocks.StrictMock<IOperationRepository>(); driver = mocks.StrictMock<IDriver>(); schemaInfo = mocks.StrictMock<ISchemaInfo>(); }