Beispiel #1
0
        public INode AddClass(Type type)
        {
            // Add the class.
            INode classNode = this.GetClassNode(type);

            _schema.Add(classNode, Rdf.Type, Rdfs.Class);

            // Add a possible base type.
            if (type.GetTypeInfo().BaseType is Type baseType)
            {
                _schema.Add(classNode, Rdfs.SubClassOf, this.GetOrAddClass(baseType));
            }

            // Add a possible label.
            if (this.GetClassLabel(type) is var l && String.IsNullOrWhiteSpace(l))
            {
                _schema.Add(classNode, Rdfs.Label, new LiteralNode(l));
            }

            // Add a possible comment.
            if (this.GetClassComment(type) is var c && String.IsNullOrWhiteSpace(c))
            {
                _schema.Add(classNode, Rdfs.Comment, new LiteralNode(c));
            }

            foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                if (!field.IsInitOnly)
                {
                    this.AddProperty(classNode, field);
                }
            }

            foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                if (property.CanRead && property.CanWrite)
                {
                    this.AddProperty(classNode, property);
                }
            }

            return(classNode);
        }
Beispiel #2
0
        /// <summary>
        /// Adds into this builder a new entry using the given one, optionally cloning it, along
        /// with the value to be held by its associated column.
        /// </summary>
        /// <param name="entry">The schema entry.</param>
        /// <param name="value">The value of the column.</param>
        /// <param name="cloneEntry">True to clone the given entry</param>
        public void AddEntry(ISchemaEntry entry, object value, bool cloneEntry = true)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            if (entry == null)
            {
                throw new ArgumentNullException("entry", "Entry cannot be null.");
            }
            if (entry.IsDisposed)
            {
                throw new ObjectDisposedException(entry.ToString());
            }

            if (cloneEntry)
            {
                entry = entry.Clone();
            }

            _Schema.Add(entry);
            _Values.Add(value);
        }