public static Field GetCamlField(this XElement xmlNode) { Field field = new Field(); field.Name = xmlNode.Attribute("Name").Value; field.IsRequired = xmlNode.AttributeBoolOrFalse("Required"); field.IsReadOnly = xmlNode.AttributeBoolOrFalse("ReadOnly"); field.IsHidden = xmlNode.AttributeBoolOrFalse("Hidden"); field.FieldType = xmlNode.Attribute("Type").Value; field.DisplayName = xmlNode.Attribute("DisplayName").Value; field.IsIndexed = xmlNode.AttributeBoolOrFalse("Indexed"); field.List = xmlNode.AttributeValueOrDefault("List"); field.IsPrimaryKey = xmlNode.AttributeBoolOrFalse("PrimaryKey"); return field; }
public static ChangeLog GetCamlChangeLog(this XElement xmlNode) { ChangeLog log = new ChangeLog( xmlNode.Elements(xmlNode.GetDefaultNamespace() + "Id").Select(c => c.GetCamlChangeItem()) ); log.MoreChanges = xmlNode.AttributeBoolOrFalse("MoreChanges"); log.NextLastChangeToken = xmlNode.AttributeValueOrDefault("LastChangeToken"); XElement newListDef = xmlNode.Element(xmlNode.GetDefaultNamespace() + "List"); if (newListDef != null) log.NewListDef = newListDef.GetCamlListDef(); else log.NewListDef = null; return log; }
public static List GetCamlList(this XElement xmlNode) { List list = new List(); list.Name = xmlNode.Attribute("Title").Value; list.ID = new Guid(xmlNode.Attribute("ID").Value); list.Description = xmlNode.AttributeValueOrDefault("Description"); list.InternalName = xmlNode.Attribute("Name").Value; list.Version = Int32.Parse(xmlNode.Attribute("Version").Value); list.IsHidden = xmlNode.AttributeBoolOrFalse("Hidden"); list.IsOrdered = xmlNode.AttributeBoolOrFalse("Ordered"); return list; }
private static bool AttributeBoolOrFalse(this XElement xmlNode, string attribute) { string b = xmlNode.AttributeValueOrDefault(attribute); return b != null && (b.ToUpper() == "YES" || b.ToUpper() == "TRUE"); }
public static ListItemCollection GetCamlListItemCollection(this XElement xmlNode) { XNamespace zns = xmlNode.GetNamespaceOfPrefix("z"); if (zns != null) { ListItemCollection items = new ListItemCollection( xmlNode .Elements(zns + "row") .Select(e => e.GetCamlListItem())); items.NextPage = xmlNode.AttributeValueOrDefault("ListItemCollectionPositionNext"); items.ItemCount = Int32.Parse(xmlNode.Attribute("ItemCount").Value); return items; } else return new ListItemCollection(new List<ListItem>()); }
public static string AttributeValueOrEmpty(this XElement xElement, string attributeName) { return xElement.AttributeValueOrDefault(attributeName, string.Empty); }
public static DateTime? AttributeValueAsDate(this XElement xElement, string attributeName) { var date = xElement.AttributeValueOrDefault(attributeName, string.Empty); DateTime result; return (DateTime.TryParse(date, out result)) ? result : (DateTime?)null; }