CmisSync.Lib.Cmis.ConvenienceExtenders.CmisConvenienceExtenders.CreateDocument C# (CSharp) Метод

CreateDocument() публичный статический Метод

Creates a document.
public static CreateDocument ( this folder, string name, string content, bool checkedOut = false ) : IDocument
folder this Parent folder.
name string Name of the document.
content string If content is not null, a content stream containing the given content will be added.
checkedOut bool If true, the new document will be created in checked out state.
Результат IDocument
        public static IDocument CreateDocument(this IFolder folder, string name, string content, bool checkedOut = false) {
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties.Add(PropertyIds.Name, name);
            properties.Add(PropertyIds.ObjectTypeId, BaseTypeId.CmisDocument.GetCmisValue());

            if (string.IsNullOrEmpty(content)) {
                return folder.CreateDocument(properties, null, checkedOut ? (VersioningState?)VersioningState.CheckedOut : (VersioningState?)null);
            }

            ContentStream contentStream = new ContentStream();
            contentStream.FileName = name;
            contentStream.MimeType = MimeType.GetMIMEType(name);
            contentStream.Length = content.Length;
            IDocument doc = null;
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content))) {
                contentStream.Stream = stream;
                doc = folder.CreateDocument(properties, contentStream, checkedOut ? (VersioningState?)VersioningState.CheckedOut : (VersioningState?)null);
            }

            return doc;
        }