Exemplo n.º 1
0
        private void ReadFromListItem()
        {
            foreach (PropertyInfo pInfo in SPFieldMetadata.GetProperties(this.GetType()))
            {
                try
                {
                    SPFieldMetadata metadata = SPFieldMetadata.Get(pInfo);
                    object          value;
                    try { value = metadata.GetFieldValue(_item); }
                    catch (ArgumentException e)
                    {
                        if (_throwFieldErrors)
                        {
                            throw e;
                        }

                        continue;
                    }
                    pInfo.GetSetMethod(true).Invoke(this, new[] { value });
                }
                catch (Exception e)
                {
                    throw new Exception(string.Format("Error processing list item. Property: {0} -- Item: {1} -- Inner Exception: {2}", pInfo.Name, _item != null ? _item.Title : "NULL", e.ToString()));
                }
            }
        }
Exemplo n.º 2
0
 private void WriteToListItem()
 {
     foreach (PropertyInfo pInfo in SPFieldMetadata.GetProperties(this.GetType()))
     {
         SPFieldMetadata metadata = SPFieldMetadata.Get(pInfo);
         try
         {
             if (!metadata.ReadOnly)
             {
                 metadata.SetFieldValue(_item, pInfo.GetGetMethod(true).Invoke(this, null));
             }
         }
         catch (ArgumentException e)
         {
             if (_throwFieldErrors)
             {
                 throw e;
             }
         }
     }
 }