Esempio n. 1
0
        /// <summary>
        /// Load property value (used by stores)
        /// </summary>
        /// <param name="name">Property name</param>
        /// <param name="age">Property age</param>
        /// <param name="value">Property value</param>
        /// <returns></returns>
        public bool LoadProperty(string name, ulong age, DateTime modificationDate, object value)
        {
            var pt = template.GetPropertyTemplate(name);

            if (pt == null)
            {
                return(false);
            }

#if NETSTANDARD1_5
            var pi = resource.GetType().GetTypeInfo().GetProperty(name);
#else
            var pi = resource.GetType().GetProperty(pt.Name);
#endif
            if (pi.PropertyType == typeof(DistributedPropertyContext))
            {
                return(false);
            }


            try
            {
                if (pi.CanWrite)
                {
                    pi.SetValue(resource, DC.CastConvert(value, pi.PropertyType));
                }
            }
            catch (Exception ex)
            {
                //Console.WriteLine(resource.ToString() + " " + name);
                Global.Log(ex);
            }

            SetAge(pt.Index, age);
            SetModificationDate(pt.Index, modificationDate);

            return(true);
        }