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
        protected override Expression VisitMember(MemberExpression node)
        {
            SPFieldMetadata     md       = SPFieldMetadata.Get((PropertyInfo)node.Member);
            CamlFieldExpression fieldExp = new CamlFieldExpression(md.InternalName, md.Type);

            if (!_withinExpression)
            {
                if (node.Type.Equals(typeof(bool)))
                {
                    return(new CamlComparisonExpression(SPQueryNodeType.Equals, fieldExp, new CamlValueExpression(true, node.Type)));
                }

                throw new NotSupportedException();
            }

            return(fieldExp);
        }
Exemplo n.º 3
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;
             }
         }
     }
 }
Exemplo n.º 4
0
        protected override Expression VisitMember(MemberExpression node)
        {
            SPFieldMetadata md = SPFieldMetadata.Get((PropertyInfo)node.Member);

            return(Expression.Constant(md.InternalName));
        }