示例#1
0
        /// <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));
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
        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);
 }
示例#9
0
        protected override void Visit(XmlSchema schema)
        {
            if (schema.TargetNamespace != _targetNamespace ||
                _schemaSetManager.IsDependencySchema(schema))
            {
                return;
            }

            Schemas.Add(schema);
            base.Visit(schema);
        }
示例#10
0
        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);
        }
示例#12
0
        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));
        }
示例#13
0
        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);
        }
示例#14
0
        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);
        }
示例#15
0
        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;
            }
        }
示例#16
0
 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
     });
 }
示例#17
0
 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);
     }
 }
示例#18
0
        /// <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);
        }
示例#19
0
        public IDbKeeperNetBuilder AddSchema(string schemaNamespace, Func <XmlReader> schema, params Type[] types)
        {
            Schemas.Add(new SchemaReference(schemaNamespace, schema, types));

            return(this);
        }
示例#20
0
 /// <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);
 }
示例#21
0
 public PgDatabase()
 {
     Schemas.Add(new PgSchema("public"));
     DefaultSchema = Schemas[0];
 }
示例#22
0
 public void RegisterResource <T>(string resourceName)
 {
     Schemas.Add(resourceName, SchemaBuilder.BuildSchema <T>());
     Types.Add(resourceName, typeof(T));
 }
示例#23
0
文件: CodeGen.cs 项目: yanivru/avro
 /// <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);
 }
示例#24
0
        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;
        }
示例#25
0
 public ITransformFixtureXmlOutputSetup ConformingTo <T>() where T : SchemaBase, new()
 {
     Schemas.Add(new T().CreateResolvedSchema());
     return(this);
 }
示例#26
0
        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);
 }