예제 #1
0
        /// <summary>
        /// Sets the property of this object to the specified value
        /// </summary>
        /// <param name="type">The type of the property to set</param>
        /// <param name="value">The new value of the property</param>
        /// <param name="langCode">OPTIONAL : the language code for the new literal. This parameter is ignored if <paramref name="value"/> is an <see cref="IDataObject"/></param>
        /// <returns>This IDataObject to allow chained calls</returns>
        /// <remarks>This method will remove all existing properties of type <paramref name="type"/> from this data object
        /// and add a single replacement property of the same type with <paramref name="value"/> as the property value.</remarks>
        public IDataObject SetProperty(IDataObject type, object value, string langCode = null)
        {
            if (value is IDataObject)
            {
                return(SetRelatedObject(type, value as IDataObject));
            }
            if (value is Uri)
            {
                return(SetRelatedObject(type, _store.MakeDataObject(value.ToString())));
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            string dataType  = RdfDatatypes.GetRdfDatatype(value.GetType());
            string litString = RdfDatatypes.GetLiteralString(value);

            SetPropertyLiteral(type, litString, dataType, langCode);
            return(this);
        }
예제 #2
0
 /// <summary>
 /// Sets the property of this object to the specified value
 /// </summary>
 /// <param name="type">The type of the property to set as a CURIE or URI string</param>
 /// <param name="value">The new value of the property</param>
 /// <param name="langCode">OPTIONAL: The language code for the new literal. This parameter is ignored if <paramref name="value"/> is an <see cref="IDataObject"/></param>
 /// <returns>This IDataObject to allow chained calls</returns>
 /// <remarks>This method will remove all existing properties of type <paramref name="type"/> from this data object
 /// and add a single replacement property of the same type with <paramref name="value"/> as the property value.</remarks>
 public IDataObject SetProperty(string type, object value, string langCode = null)
 {
     return(SetProperty(_store.MakeDataObject(type), value, langCode));
 }