private void LoadFromContract(Contracts.Snak snak) { Debug.Assert(snak != null); SnakType = ParseSnakType(snak.SnakType); Hash = snak.Hash; RawDataValue = snak.DataValue; DataType = BuiltInDataTypes.Get(snak.DataType) ?? MissingPropertyType.Get(snak.DataType, (string)snak.DataValue?["type"]); }
/// <summary> /// Initializes a new <see cref="Claim"/> instance with the main snak set to property id and value. /// </summary> /// <param name="propertyId">The property ID of the auto-constructed main snak.</param> /// <param name="dataValue">The data value of the main snak.</param> /// <param name="dataType">The data type of the main snak.</param> /// <exception cref="ArgumentNullException"><paramref name="propertyId"/> or <paramref name="dataType"/> is <c>null</c>.</exception> public Claim(string propertyId, object dataValue, WikibaseDataType dataType) { MainSnak = new Snak(propertyId, dataValue, dataType); }
/// <summary> /// Initializes a snak with specified property ID and raw data value. /// </summary> /// <param name="propertyId">The property id.</param> /// <param name="rawDataValue">The raw JSON data value of the property.</param> /// <param name="dataType">The data value type.</param> /// <exception cref="ArgumentNullException"><paramref name="propertyId"/> or <paramref name="dataType"/> is <c>null</c>.</exception> public Snak(string propertyId, JObject rawDataValue, WikibaseDataType dataType) { PropertyId = propertyId ?? throw new ArgumentNullException(nameof(propertyId)); DataType = dataType ?? throw new ArgumentNullException(nameof(dataType)); RawDataValue = rawDataValue; }