Esempio n. 1
0
        /// <summary>
        /// Return value from path going from this object
        /// </summary>
        /// <param name="propertyPath"> Path formated like <ObjectReference>.<ListProperty>.<ListIndex>.<PropertyName> </param>
        /// <returns></returns>
        public NdfValueWrapper GetValueFromQuery(string query)
        {
            string rest = string.Empty;
            string next = NdfQueryReader.ParseNextStep(query, out rest);

            if (!string.IsNullOrEmpty(next))
            {
                NdfPropertyValue nextproperty = GetProperty(next);
                if (nextproperty == null)
                {
                    switch (nextproperty.Type)
                    {
                        case Types.NdfType.ObjectReference:
                            NdfObjectReference reference = nextproperty.Value as NdfObjectReference;
                            return reference.Instance.GetValueFromQuery(rest);

                        case Types.NdfType.MapList:
                            NdfMapList mapList = nextproperty.Value as NdfMapList;
                            return mapList.GetValueFromQuery(rest); 

                        case Types.NdfType.List:
                            NdfCollection list = nextproperty.Value as NdfCollection;
                            return list.GetValueFromQuery(rest); 

                        default:
                            return nextproperty.Value;
                    }
                }
            }

            throw(new Exception("Something went wrong with this path: " + query != string.Empty ? query:"Empty Path"));
        }
Esempio n. 2
0
        /// <summary>
        /// Return value from property name
        /// </summary>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        public NdfValueWrapper GetValueOfProperty(string propertyName)
        {

            NdfPropertyValue propval = GetProperty(propertyName);
            if (propval != null)
                return propval.Value;
            return null;
        }
Esempio n. 3
0
 /// <summary>
 /// Return true if it succeded getting a property and output it.
 /// </summary>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 public bool TryGetProperty(string propName, out NdfPropertyValue value)
 {
     value = GetProperty(propName);
     return value != null;
 }