internal static SharepointPropertyDefinition[] PropertyDefinitionsToSharepointPropertyDefinitions(Schema schema, ICollection <PropertyDefinition> propDefs) { List <SharepointPropertyDefinition> list = new List <SharepointPropertyDefinition>(propDefs.Count); foreach (PropertyDefinition propDef in propDefs) { list.Add(SharepointPropertyDefinition.PropertyDefinitionToSharepointPropertyDefinition(schema, propDef)); } return(list.ToArray()); }
internal static SharepointPropertyDefinition PropertyDefinitionToSharepointPropertyDefinition(Schema schema, PropertyDefinition propDef) { SharepointPropertyDefinition sharepointPropertyDefinition = propDef as SharepointPropertyDefinition; DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propDef as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition == null) { throw new ArgumentException("propDefs"); } if (sharepointPropertyDefinition == null && schema.IdToPropertyMap.ContainsKey(documentLibraryPropertyDefinition.PropertyId)) { sharepointPropertyDefinition = (schema.IdToPropertyMap[documentLibraryPropertyDefinition.PropertyId] as SharepointPropertyDefinition); } return(sharepointPropertyDefinition); }
internal static object[] GetValuesFromCAMLView(Schema schema, XmlNode xmlNode, CultureInfo cultureInfo, IList <PropertyDefinition> propertyDefinitions) { object[] array = new object[propertyDefinitions.Count]; string str = string.Empty; if (xmlNode.LocalName == "row") { str = "ows_"; } int i = 0; while (i < propertyDefinitions.Count) { SharepointPropertyDefinition sharepointPropertyDefinition = SharepointPropertyDefinition.PropertyDefinitionToSharepointPropertyDefinition(schema, propertyDefinitions[i]); if (sharepointPropertyDefinition != null) { string name = str + sharepointPropertyDefinition.SharepointName; try { if (xmlNode.Attributes[name] == null || (array[i] = sharepointPropertyDefinition.FromSharepoint(xmlNode.Attributes[name].Value, cultureInfo)) == null) { array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.NotFound); } goto IL_DC; } catch (FormatException) { array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.CorruptData); goto IL_DC; } goto IL_AC; } goto IL_AC; IL_DC: i++; continue; IL_AC: if (propertyDefinitions[i] is DocumentLibraryPropertyDefinition) { array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.NotFound); goto IL_DC; } array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.NotSupported); goto IL_DC; } return(array); }
internal static XmlNode GenerateViewFieldCAML(Schema schema, ICollection <PropertyDefinition> propertyDefinitions) { XmlDocument xmlDocument = new SafeXmlDocument(); XmlNode xmlNode = xmlDocument.CreateElement("ViewFields"); foreach (SharepointPropertyDefinition sharepointPropertyDefinition in SharepointPropertyDefinition.PropertyDefinitionsToSharepointPropertyDefinitions(schema, propertyDefinitions)) { if (sharepointPropertyDefinition != null) { XmlNode xmlNode2 = xmlDocument.CreateElement("FieldRef"); xmlNode2.Attributes.Append(xmlDocument.CreateAttribute("Name")); xmlNode2.Attributes["Name"].Value = sharepointPropertyDefinition.SharepointName; xmlNode.AppendChild(xmlNode2); } } return(xmlNode); }
private static XmlNode GenerateQueryCAMLHelper(QueryFilter query, XmlDocument xmlDoc, int depth) { if (depth >= SharepointHelpers.MaxFilterHierarchyDepth) { throw new ArgumentException("filter"); } XmlNode xmlNode = null; if (query is AndFilter) { AndFilter andFilter = (AndFilter)query; using (ReadOnlyCollection <QueryFilter> .Enumerator enumerator = andFilter.Filters.GetEnumerator()) { while (enumerator.MoveNext()) { QueryFilter query2 = enumerator.Current; if (xmlNode == null) { xmlNode = SharepointHelpers.GenerateQueryCAMLHelper(query2, xmlDoc, depth + 1); } else { XmlNode newChild = xmlNode; xmlNode = xmlDoc.CreateElement("And"); xmlNode.AppendChild(newChild); xmlNode.AppendChild(SharepointHelpers.GenerateQueryCAMLHelper(query2, xmlDoc, depth + 1)); } } return(xmlNode); } } if (query is OrFilter) { OrFilter orFilter = (OrFilter)query; using (ReadOnlyCollection <QueryFilter> .Enumerator enumerator2 = orFilter.Filters.GetEnumerator()) { while (enumerator2.MoveNext()) { QueryFilter query3 = enumerator2.Current; if (xmlNode == null) { xmlNode = SharepointHelpers.GenerateQueryCAMLHelper(query3, xmlDoc, depth + 1); } else { XmlNode newChild2 = xmlNode; xmlNode = xmlDoc.CreateElement("Or"); xmlNode.AppendChild(newChild2); xmlNode.AppendChild(SharepointHelpers.GenerateQueryCAMLHelper(query3, xmlDoc, depth + 1)); } } return(xmlNode); } } if (!(query is ComparisonFilter)) { throw new NotSupportedException(Strings.ExFilterNotSupported(query.GetType())); } ComparisonFilter comparisonFilter = (ComparisonFilter)query; switch (comparisonFilter.ComparisonOperator) { case ComparisonOperator.Equal: xmlNode = xmlDoc.CreateElement("Eq"); break; case ComparisonOperator.NotEqual: xmlNode = xmlDoc.CreateElement("Neq"); break; case ComparisonOperator.LessThan: xmlNode = xmlDoc.CreateElement("Lt"); break; case ComparisonOperator.LessThanOrEqual: xmlNode = xmlDoc.CreateElement("Leq"); break; case ComparisonOperator.GreaterThan: xmlNode = xmlDoc.CreateElement("Gt"); break; case ComparisonOperator.GreaterThanOrEqual: xmlNode = xmlDoc.CreateElement("Geq"); break; default: throw new InvalidOperationException("Invalid comparison operator"); } SharepointPropertyDefinition sharepointPropertyDefinition = (SharepointPropertyDefinition)comparisonFilter.Property; xmlNode.InnerXml = string.Format("<FieldRef Name=\"{0}\" /><Value Type=\"{1}\">{2}</Value>", sharepointPropertyDefinition.SharepointName, sharepointPropertyDefinition.FieldTypeAsString, sharepointPropertyDefinition.ToSharepoint(comparisonFilter.PropertyValue, null)); return(xmlNode); }