Schema

Namespace: Avro
We found 10 examples in language CSharp for this search. You will see 33 fragments of code.

Other methods


        private Schema CreateReferenceSchema(Type type, Queue<Type> referencedTypes)
        {
            referencedTypes.Enqueue(type);
            return new Schema { Ref = "#/definitions/" + _schemaIdManager.IdFor(type) };
        }

        private Schema CreateArraySchema(JsonArrayContract arrayContract, Queue<Type> referencedTypes)
        {
            var itemType = arrayContract.CollectionItemType ?? typeof(object);
            return new Schema
            {
                Type = "array",
                Items = CreateSchema(itemType, referencedTypes)
            };
        }


        internal JsonSchema Read(JsonReader reader)
        {
            JToken schemaToken = JToken.ReadFrom(reader);

            _rootSchema = schemaToken as JObject;

            JsonSchema schema = BuildSchema(schemaToken);

            ResolveReferences(schema);

            return schema;
        }


        private void ReferenceOrWriteSchema(JsonSchema schema)
        {
            if (schema.Id != null && _resolver.GetSchema(schema.Id) != null)
            {
                _writer.WriteStartObject();
                _writer.WritePropertyName(JsonTypeReflector.RefPropertyName);
                _writer.WriteValue(schema.Id);
                _writer.WriteEndObject();
            }
            else
            {
                WriteSchema(schema);
            }
        }


        static XmlSchema CreateSchema(string ns, XmlSchemaSet schemas)
        {
            XmlSchema schema = new XmlSchema();

            schema.ElementFormDefault = XmlSchemaForm.Qualified;
            if (ns.Length > 0)
            {
                schema.TargetNamespace = ns;
                schema.Namespaces.Add(Globals.TnsPrefix, ns);
            }


            schemas.Add(schema);
            return schema;
        }

        internal static void AddElementForm(XmlSchemaElement element, XmlSchema schema)
        {
            if (schema.ElementFormDefault != XmlSchemaForm.Qualified)
            {
                element.Form = XmlSchemaForm.Qualified;
            }
        }


        static void AddImport(XmlSchema schema, string importNamespace)
        {
            XmlSchemaImport importElement = new XmlSchemaImport();
            importElement.Namespace = importNamespace;
            schema.Includes.Add(importElement);
        }

        static void AddScopesElement(DiscoveryVersion discoveryVersion, XmlSchema schema)
        {
            // <xs:element name="Scopes" type="tns:ScopesType" />
            XmlSchemaElement scopesElement = new XmlSchemaElement();
            scopesElement.Name = ProtocolStrings.SchemaNames.ScopesElement;
            scopesElement.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.ScopesType;

            schema.Items.Add(scopesElement);
        }

        static void AddTypesElement(DiscoveryVersion discoveryVersion, XmlSchema schema)
        {
            // <xs:element name="Types" type="tns:QNameListType" />
            XmlSchemaElement typesElement = new XmlSchemaElement();
            typesElement.Name = ProtocolStrings.SchemaNames.TypesElement;
            typesElement.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.QNameListType;

            schema.Items.Add(typesElement);
        }

        static void AddXAddrsElement(DiscoveryVersion discoveryVersion, XmlSchema schema)
        {
            // <xs:element name="XAddrs" type="tns:UriListType" />
            XmlSchemaElement xAddrsElement = new XmlSchemaElement();
            xAddrsElement.Name = ProtocolStrings.SchemaNames.XAddrsElement;
            xAddrsElement.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.UriListType;

            schema.Items.Add(xAddrsElement);
        }

        static XmlSchema CreateSchema(DiscoveryVersion discoveryVersion)
        {
            XmlSchema schema = new XmlSchema();
            schema.TargetNamespace = discoveryVersion.Namespace;
            schema.Namespaces.Add("tns", discoveryVersion.Namespace);
            schema.ElementFormDefault = XmlSchemaForm.Qualified;
            schema.BlockDefault = XmlSchemaDerivationMethod.All;

            return schema;
        }


        /// <include file='doc\XmlSchemaSet.uex' path='docs/doc[@for="XmlSchemaSet.Add6"]/*' />
        public XmlSchema Add(XmlSchema schema) {
            if (schema == null) {
                throw new ArgumentNullException("schema");
            }
            lock (InternalSyncObject) {
                if (schemas.ContainsKey(schema.SchemaId)) {
                    return schema;
                }
                return Add(schema.TargetNamespace, schema);
            }
        }

        /// <include file='doc\XmlSchemaSet.uex' path='docs/doc[@for="XmlSchemaSet.Remove"]/*' />
        public XmlSchema Remove(XmlSchema schema) {
            return Remove(schema, true);
        }
        
        /// <include file='doc\XmlSchemaSet.uex' path='docs/doc[@for="XmlSchemaSet.Contains2"]/*' />
        public bool Contains(XmlSchema schema) {
            if (schema == null) {
                throw new ArgumentNullException("schema");
            }
            return schemas.ContainsValue(schema);
        }

        internal bool GetSchemaByUri(Uri schemaUri, out XmlSchema schema) {
            schema = null;
            if (schemaUri == null || schemaUri.OriginalString.Length == 0) {
                return false;                    
            }                    
            schema = (XmlSchema)schemaLocations[schemaUri];
            if (schema != null) {
                return true;
            }
            return false;
        }

        internal string GetTargetNamespace(XmlSchema schema) {
            return schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace;
        }


            private IEnumerable<string> GetRequiredProperties(JsonSchemaModel schema)
            {
                if (schema == null || schema.Properties == null)
                {
                    return Enumerable.Empty<string>();
                }

                return schema.Properties.Where(p => p.Value.Required).Select(p => p.Key);
            }

        private void ValidateNull(JsonSchemaModel schema)
        {
            if (schema == null)
            {
                return;
            }

            if (!TestType(schema, JsonSchemaType.Null))
            {
                return;
            }

            ValidateNotDisallowed(schema);
        }

        private void ValidateBoolean(JsonSchemaModel schema)
        {
            if (schema == null)
            {
                return;
            }

            if (!TestType(schema, JsonSchemaType.Boolean))
            {
                return;
            }

            ValidateNotDisallowed(schema);
        }

        private bool ValidateArray(JsonSchemaModel schema)
        {
            if (schema == null)
            {
                return true;
            }

            return (TestType(schema, JsonSchemaType.Array));
        }

        private bool ValidateObject(JsonSchemaModel schema)
        {
            if (schema == null)
            {
                return true;
            }

            return (TestType(schema, JsonSchemaType.Object));
        }


        private void Push(TypeSchema typeSchema)
        {
            _currentSchema = typeSchema.Schema;
            _stack.Add(typeSchema);
            _resolver.LoadedSchemas.Add(typeSchema.Schema);
        }

        private TypeSchema Pop()
        {
            TypeSchema popped = _stack[_stack.Count - 1];
            _stack.RemoveAt(_stack.Count - 1);
            TypeSchema newValue = _stack.LastOrDefault();
            if (newValue != null)
            {
                _currentSchema = newValue.Schema;
            }
            else
            {
                _currentSchema = null;
            }

            return popped;
        }

        internal int Add(XmlSchema schema, bool delay) {
            if (delay) {
                if (delayedSchemas[schema] == null)
                    delayedSchemas.Add(schema, schema);
                return -1;
            }
            else {
                return Add(schema);
            }
        }

        /// <include file='doc\XmlSchemas.uex' path='docs/doc[@for="XmlSchemas.Add"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public int Add(XmlSchema schema) {
            if (List.Contains(schema))
                return List.IndexOf(schema);
            return List.Add(schema);
        }

        /// <include file='doc\XmlSchemas.uex' path='docs/doc[@for="XmlSchemas.Add"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public int Add(XmlSchema schema, Uri baseUri) {
            if (List.Contains(schema))
                return List.IndexOf(schema);
            if (baseUri != null)
                schema.BaseUri = baseUri;
            return List.Add(schema);
        }

        /// <include file='doc\XmlSchemas.uex' path='docs/doc[@for="XmlSchemas.Add1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Add(XmlSchemas schemas) {
            foreach (XmlSchema schema in schemas) {
                Add(schema);
            }
        }

        /// <include file='doc\XmlSchemas.uex' path='docs/doc[@for="XmlSchemas.AddReference"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void AddReference(XmlSchema schema) {
            References[schema] = schema;
        }

        /// <include file='doc\XmlSchemas.uex' path='docs/doc[@for="XmlSchemas.Insert"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Insert(int index, XmlSchema schema) {
            List.Insert(index, schema);
        }


        public JsonSchemaModel Build(JsonSchema schema)
        {
            _nodes = new JsonSchemaNodeCollection();
            _node = AddSchema(null, schema);

            _nodeModels = new Dictionary<JsonSchemaNode, JsonSchemaModel>();
            JsonSchemaModel model = BuildNodeModel(_node);

            return model;
        }

        public void AddProperty(IDictionary<string, JsonSchemaNode> target, string propertyName, JsonSchema schema)
        {
            JsonSchemaNode propertyNode;
            target.TryGetValue(propertyName, out propertyNode);

            target[propertyName] = AddSchema(propertyNode, schema);
        }

        public void AddAdditionalProperties(JsonSchemaNode parentNode, JsonSchema schema)
        {
            parentNode.AdditionalProperties = AddSchema(parentNode.AdditionalProperties, schema);
        }

        public void AddAdditionalItems(JsonSchemaNode parentNode, JsonSchema schema)
        {
            parentNode.AdditionalItems = AddSchema(parentNode.AdditionalItems, schema);
        }

Avro.Schema : Object

Methods :

public Type get_Tag()
public abstract String get_Name()
public static Schema Parse(String json = )
public String ToString()
public static String GetTypeString(Type type = )
public String GetProperty(String key = )
public Int32 GetHashCode()
public Boolean CanRead(Schema writerSchema = )
public Type GetType()
public Boolean Equals(Object obj = )

Other methods