/// <summary> /// Add a schema to be used during the validation of the XML document /// </summary> /// <param name="schemaFileLocation">The file path for the XSD schema file to be added for validation</param> /// <returns>True if the schema file was successfully loaded, else false (if false, view Errors/Warnings for reason why)</returns> public bool AddSchema(string schemaFileLocation) { if (String.IsNullOrEmpty(schemaFileLocation)) { return(false); } if (!File.Exists(schemaFileLocation)) { return(false); } // Reset the Error/Warning collections Errors = new List <string>(); Warnings = new List <string>(); XmlSchema schema; using (var fs = File.OpenRead(schemaFileLocation)) { schema = XmlSchema.Read(fs, ValidationEventHandler); } var isValid = !(Errors.Count > 0) && !(Warnings.Count > 0); if (isValid) { Schemas.Add(schema); } return(isValid); }
protected override string AddType(Type type) { var schemaName = type.Name.Replace("`", string.Empty); if (Types.Contains(type)) { return(schemaName); } var schema = schemaBuilder.Get(type); if (string.IsNullOrWhiteSpace(schema)) { return(string.Empty); } // handle case of different types with same class name if (Schemas.ContainsKey(schemaName)) { schemaName = GetUniqueSchemaName(schemaName); } Schemas.Add(schemaName, schema); Types.Add(type); return(schemaName); }
///<summary> ///</summary> ///<param name="schema"></param> ///<param name="fileName"></param> public void AddSchema(XmlSchema schema, string fileName) { Schemas.Add(new SchemaInfo(schema, fileName)); if (SchemaAdded != null) { SchemaAdded(this, new SchemaAddedEventArgs(fileName, progress)); } }
public ResourceRegistry(ISchemaBuilder schemaBulder, IEnumerable <ResourceRegistryRegistration> registrations) { foreach (var registration in registrations) { Schemas.Add(registration.ResourceName, schemaBulder.BuildSchema(registration.Type)); Types.Add(registration.ResourceName, registration.Type); } }
public void AddSchemaFor(Type type, OpenApiSchema schema) { if (!_reservedIds.TryGetValue(type, out string schemaId)) { throw new InvalidOperationException("TODO:"); } Schemas.Add(schemaId, schema); }
private string AddNameSpace(string prefix, string url) { Schemas.Add(prefix, url); Manager.AddNamespace(prefix, url); string str = String.Format("xmlns:{0}=\"{1}\" s", prefix, url); preXml += str; return(str); }
/// <summary> /// Sets the document schemas to be used in the execution request. /// </summary> /// <remarks>For more details about schemas, check /// <a href="https://doc.nuxeo.com/display/NXDOC60/How+to+Override+Existing+Document+Types">Nuxeo Documentation Center</a>. /// </remarks> /// <param name="schemas">A collection of strings containing the schema names.</param> /// <returns>The current <see cref="Operation"/> instance.</returns> public Operation SetSchemas(ICollection <string> schemas) { Schemas?.Clear(); Schemas = Schemas ?? new List <string>(); foreach (string schema in schemas) { Schemas.Add(schema); } return(this); }
/// <summary> /// Sets a list document schemas to be sent in the next request. /// </summary> /// <remarks>For more details about schemas, check /// <a href="https://doc.nuxeo.com/display/NXDOC60/How+to+Override+Existing+Document+Types">Nuxeo Documentation Center</a>. /// </remarks> /// <param name="schemas">A list of document schema names.</param> /// <returns>The current <see cref="Document"/> instance.</returns> public Document SetSchemas(string[] schemas) { Schemas?.Clear(); Schemas = Schemas ?? new List <string>(); foreach (string schema in schemas) { Schemas.Add(schema); } return(this); }
protected override void Visit(XmlSchema schema) { if (schema.TargetNamespace != _targetNamespace || _schemaSetManager.IsDependencySchema(schema)) { return; } Schemas.Add(schema); base.Visit(schema); }
public OpenApiSchema AddDefinition(string schemaId, OpenApiSchema schema) { Schemas.Add(schemaId, schema); return(new OpenApiSchema { Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = schemaId } }); }
///<summary> ///</summary> ///<param name="schema"></param> ///<param name="fileName"></param> public SchemaInfo AddSchema(XmlSchema schema, string fileName, UpccSchematype schematype) { var schemaInfo = new SchemaInfo(schema, fileName, schematype); Schemas.Add(schemaInfo); if (SchemaAdded != null) { SchemaAdded(this, new SchemaAddedEventArgs(fileName, progress)); } return(schemaInfo); }
private SqlSchemaName AddSchemaIfNotExists(string schemaName) { if (!Schemas.Any(x => x.Name.Equals(schemaName, StringComparison.OrdinalIgnoreCase))) { Schemas.Add(new SqlSchemaName(schemaName) { Database = this }); } return(Schemas.Get(schemaName)); }
public Schema CreateSchema(Schema model) { var dbSchema = Schemas.Add(new DbSchema { Name = model.Name }); SafelyExecuteChanges(model.GetCreateScripts()); // we do not need to create the schema as an entit yin the database, becuase // it doesn't exist without an entity to be contained within it. SaveChanges(); return(model); }
protected Schemas GetSchemas() { Schemas ListSchema = new Schemas(); using (Connection) { Connection.Open(); #region reader using (SqlDataReader _reader = Command.ExecuteReader()) { while (_reader.Read()) { Schema schema = new Schema(); #region reflection 寫法 不要用. PropertyInfo[] props = schema.GetType().GetProperties(); foreach (PropertyInfo prop in props) { try { int idx = _reader.GetOrdinal(prop.Name); if (idx != -1) { if (prop.PropertyType.Name.ToLower() == "string") { string value = _reader.GetString(idx); prop.SetValue(schema, value, null); } else if (prop.PropertyType.Name.ToLower() == "int32") { int value = (_reader.IsDBNull(idx))? 0:_reader.GetInt32(idx); prop.SetValue(schema, value, null); } } } catch { } } #endregion ListSchema.Add(schema); } } #endregion Connection.Close(); } return(ListSchema); }
public void AssignPhaseData(DatabaseObjectInfo source, DatabaseAnalysePhase phase) { var src = (DatabaseInfo)source; if ((phase & DatabaseAnalysePhase.Tables) != 0) { Tables.Clear(); foreach (var obj in src.Tables) { Tables.Add(obj.CloneTable(this)); } } if ((phase & DatabaseAnalysePhase.Views) != 0) { Views.Clear(); foreach (var obj in src.Views) { Views.Add(obj.CloneView(this)); } } if ((phase & DatabaseAnalysePhase.Functions) != 0) { StoredProcedures.Clear(); Functions.Clear(); Triggers.Clear(); foreach (var obj in src.StoredProcedures) { StoredProcedures.Add(obj.CloneStoredProcedure(this)); } foreach (var obj in src.Functions) { Functions.Add(obj.CloneFunction(this)); } foreach (var obj in src.Triggers) { Triggers.Add(obj.CloneTrigger(this)); } } if ((phase & DatabaseAnalysePhase.Settings) != 0) { Schemas.Clear(); foreach (var obj in src.Schemas) { Schemas.Add(obj.CloneSchema(this)); } DefaultSchema = src.DefaultSchema; } }
protected void AddArgument(string name, string shortName = "", string description = "", bool isReqruied = false, bool isUnary = false, string format = null) { if (Schemas.Any(c => c.Name.Equals(name))) { throw new ArgumentException($"Argument {name} is already defined."); } Schemas.Add(new CommandArgument { Name = name, ShortName = shortName, Description = description, IsRequired = isReqruied, IsUninary = isUnary, Format = format }); }
private void ExportSerializationSchema() { if (!Schemas.Contains(Globals.SerializationNamespace)) { StringReader reader = new StringReader(Globals.SerializationSchema); XmlSchema schema = XmlSchema.Read(new XmlTextReader(reader) { DtdProcessing = DtdProcessing.Prohibit }, null); if (schema == null) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.CouldNotReadSerializationSchema, Globals.SerializationNamespace))); } Schemas.Add(schema); } }
/// <summary> /// Add a schema to be used during the validation of the XML document /// </summary> /// <param name="s">The stream containing the schema.</param> /// <returns>True if the schema file was successfully loaded, else false (if false, view Errors/Warnings for reason why)</returns> public bool AddSchema(Stream s) { // Reset the Error/Warning collections Errors = new List <string>(); Warnings = new List <string>(); XmlSchema schema; schema = XmlSchema.Read(s, ValidationEventHandler); var isValid = !Errors.Any() && !Warnings.Any(); if (isValid) { Schemas.Add(schema); } return(isValid); }
public IDbKeeperNetBuilder AddSchema(string schemaNamespace, Func <XmlReader> schema, params Type[] types) { Schemas.Add(new SchemaReference(schemaNamespace, schema, types)); return(this); }
/// <summary> /// Adds a document schema to be sent in the next request. /// </summary> /// <remarks>For more details about schemas, check /// <a href="https://doc.nuxeo.com/display/NXDOC60/How+to+Override+Existing+Document+Types">Nuxeo Documentation Center</a>. /// </remarks> /// <param name="schema">The schema's name.</param> /// <returns>The current <see cref="Document"/> instance.</returns> public Document AddSchema(string schema) { Schemas = Schemas ?? new List <string>(); Schemas.Add(schema); return(this); }
public PgDatabase() { Schemas.Add(new PgSchema("public")); DefaultSchema = Schemas[0]; }
public void RegisterResource <T>(string resourceName) { Schemas.Add(resourceName, SchemaBuilder.BuildSchema <T>()); Types.Add(resourceName, typeof(T)); }
/// <summary> /// Adds a schema object to generate code for. /// </summary> /// <param name="schema">schema object.</param> public virtual void AddSchema(Schema schema) { Schemas.Add(schema); }
protected Schemas GetSchemas() { Schemas ListSchema = new Schemas(); using (Connection) { Connection.Open(); #region reader using (SqlDataReader _reader = Command.ExecuteReader()) { while (_reader.Read()) { Schema schema = new Schema(); #region reflection 寫法 不要用. PropertyInfo[] props = schema.GetType().GetProperties(); foreach (PropertyInfo prop in props) { try { int idx = _reader.GetOrdinal(prop.Name); if (idx != -1) { if (prop.PropertyType.Name.ToLower() == "string") { string value = _reader.GetString(idx); prop.SetValue(schema, value, null); } else if (prop.PropertyType.Name.ToLower() == "int32") { int value = (_reader.IsDBNull(idx))? 0:_reader.GetInt32(idx); prop.SetValue(schema, value, null); } } } catch { } } #endregion ListSchema.Add(schema); } } #endregion Connection.Close(); } return ListSchema; }
public ITransformFixtureXmlOutputSetup ConformingTo <T>() where T : SchemaBase, new() { Schemas.Add(new T().CreateResolvedSchema()); return(this); }
public async Task MaterializeAsync(ILogStore store, byte[] secretKey = default, long?startingFrom = default, CancellationToken cancellationToken = default) { if (startingFrom == default) { startingFrom = Interlocked.Read(ref _index) + 1; } foreach (var entry in store.StreamEntries((ulong)startingFrom, secretKey)) { Interlocked.Exchange(ref _index, (long)entry.Index.GetValueOrDefault()); foreach (var @object in entry.Objects) { switch (@object.Data) { case Namespace ns: { var key = ns; Namespaces.Add(key); _namespace = key; if (!Revisions.ContainsKey(_namespace.Value)) { Revisions.Add(_namespace.Value, new Dictionary <string, ulong>(StringComparer.OrdinalIgnoreCase)); } if (!Manifest.ContainsKey(_namespace.Value)) { Manifest.Add(_namespace.Value, new Dictionary <ulong, List <Schema> >()); } if (!Roles.ContainsKey(_namespace.Value)) { Roles.Add(_namespace.Value, new List <string>()); } break; } case Schema schema: { var key = schema.Name; if (!Revisions[_namespace.Value].TryGetValue(key, out var revision)) { Revisions[_namespace.Value].Add(key, revision = 1); } if (!Manifest[_namespace.Value].TryGetValue(revision, out var manifest)) { Manifest[_namespace.Value].Add(revision, manifest = new List <Schema>()); } if (!Schemas.TryGetValue(key, out var schemaMap)) { Schemas.Add(key, schemaMap = new Dictionary <ulong, List <Schema> >()); } if (!schemaMap.TryGetValue(revision, out var list)) { schemaMap.Add(revision, list = new List <Schema>()); } manifest.Add(schema); list.Add(schema); await _events.OnSchemaAddedAsync(store, schema, cancellationToken); break; } case RevokeRole revokeRole: { if (!revokeRole.Verify()) { throw new InvalidOperationException($"invalid {revokeRole.Type}"); } if (RoleGrants.TryGetValue(_namespace.Value, out var lookup) && lookup.Count == 1 && lookup[Constants.DefaultOwnerRole].Count == 1) { throw new CannotRemoveSingleOwnerException("cannot revoke admin rights of only owner"); } break; } default: throw new NotImplementedException(@object.Data.GetType().Name); } } } }
/// <summary> /// Adds a document schema to be used in the execution request. /// </summary> /// <remarks>For more details about schemas, check /// <a href="https://doc.nuxeo.com/display/NXDOC60/How+to+Override+Existing+Document+Types">Nuxeo Documentation Center</a>. /// </remarks> /// <param name="schema">The schema name.</param> /// <returns>The current <see cref="Operation"/> instance.</returns> public Operation AddSchema(string schema) { Schemas = Schemas ?? new List <string>(); Schemas.Add(schema); return(this); }