/// <summary> /// Retrieve the CMIS metadata of a document. /// </summary> /// <returns>a dictionary in which each key is a type id and each value is a couple indicating the mode ("readonly" or "ReadWrite") and the value itself.</returns> public static Dictionary <string, string[]> FetchMetadata(ICmisObject o, IObjectType typeDef) { Dictionary <string, string[]> metadata = new Dictionary <string, string[]>(); IList <IPropertyDefinition> propertyDefs = typeDef.PropertyDefinitions; // Get metadata. foreach (IProperty property in o.Properties) { // Mode string mode = "readonly"; foreach (IPropertyDefinition propertyDef in propertyDefs) { if (propertyDef.Id.Equals("cmis:name")) { Updatability updatability = propertyDef.Updatability; mode = updatability.ToString(); } } // Value if (property.IsMultiValued) { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValuesAsString }); } else { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValueAsString }); } } return(metadata); }
/// <summary> /// Retrieve the CMIS metadata of a document. /// </summary> /// <returns>a dictionary in which each key is a type id and each value is a couple indicating the mode ("readonly" or "ReadWrite") and the value itself.</returns> private Dictionary <string, string[]> FetchMetadata(IDocument document) { Dictionary <string, string[]> metadata = new Dictionary <string, string[]>(); IObjectType typeDef = session.GetTypeDefinition(document.ObjectType.Id /*"cmis:document" not Name FullName*/); // TODO cache IList <IPropertyDefinition> propertyDefs = typeDef.PropertyDefinitions; // Get metadata. foreach (IProperty property in document.Properties) { // Mode string mode = "readonly"; foreach (IPropertyDefinition propertyDef in propertyDefs) { if (propertyDef.Id.Equals("cmis:name")) { Updatability updatability = propertyDef.Updatability; mode = updatability.ToString(); } } // Value if (property.IsMultiValued) { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValuesAsString }); } else { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValueAsString }); } } return(metadata); }