コード例 #1
0
        /// <summary>
        /// Helper to create a new instance of GraphProperty more efficiently
        /// </summary>
        /// <example>
        /// To create an instance for the Country property with multiple values and additional meta informations:
        ///
        /// person.Country = GraphProperty.Create("Country","AT","Meta1","Austria").AddValue("DE","Meta1","Germany");
        ///
        /// </example>
        /// <param name="propertyName">Name of the property as stored in the GraphDB</param>
        /// <param name="properties">first element represents the value, then Tuples-2 follow for MetaInformation (Key/Value) </param>
        /// <returns></returns>
        public static GraphProperty Create(string propertyName, params object[] properties)
        {
            if (properties.Length < 1)
            {
                throw new Exception("At least a value is required!");
            }
            if ((properties.Length > 1) && ((properties.Length - 1) % 2 != 0))
            {
                throw new Exception("Some meta properties are lacking its value!");
            }
            GraphProperty newProperty = new GraphProperty();

            GraphPropertyValue newPropertyValue = new GraphPropertyValue();

            newProperty.Name       = propertyName;
            newPropertyValue.Value = properties[0];
            if (properties.Length > 1)
            {
                for (int i = 1; i < properties.Length; i += 2)
                {
                    newPropertyValue.Meta.Add(properties[i].ToString(), properties[i + 1].ToString());
                }
            }
            newProperty.Values.Add(newPropertyValue.Id, newPropertyValue);
            return(newProperty);
        }
コード例 #2
0
        public GraphProperty AddValue(params object[] properties)
        {
            if (properties.Length < 1)
            {
                throw new Exception("At least a Value is required!");
            }
            if ((properties.Length > 1) && ((properties.Length - 1) % 2 != 0))
            {
                throw new Exception("Some meta properties are lacking its value!");
            }

            GraphPropertyValue newPropertyValue = new GraphPropertyValue()
            {
                Value = properties[0]
            };

            if (properties.Length > 1)
            {
                for (int i = 1; i < properties.Length; i += 2)
                {
                    newPropertyValue.Meta.Add(properties[i].ToString(), properties[i + 1].ToString());
                }
            }
            this.Values.Add(newPropertyValue.Id, newPropertyValue);
            return(this);
        }
コード例 #3
0
 public void Add(GraphPropertyValue value)
 {
     this.Values.Add(value.Id, value);
 }