Document class for various formatsType-safe Dictionary for various typesInverse Document Frequency (IDF)...

Are there any consumables that function as addictive (psychedelic) drugs?

Is it possible to make sharp wind that can cut stuff from afar?

New order #4: World

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

Simulate Bitwise Cyclic Tag

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

A Journey Through Space and Time

What typically incentivizes a professor to change jobs to a lower ranking university?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

I probably found a bug with the sudo apt install function

How old can references or sources in a thesis be?

Do airline pilots ever risk not hearing communication directed to them specifically, from traffic controllers?

How do I create uniquely male characters?

Shell script can be run only with sh command

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

Concept of linear mappings are confusing me

Patience, young "Padovan"

Why Is Death Allowed In the Matrix?

Should I join an office cleaning event for free?

Why can't I see bouncing of a switch on an oscilloscope?

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

What makes Graph invariants so useful/important?

How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?

Japan - Plan around max visa duration



Document class for various formats


Type-safe Dictionary for various typesInverse Document Frequency (IDF) implementationConcerned with Enums, JSON, and ASP.NET MVCXML document parser with XPathSelecting control class in a document assemblerEnsuring specific columns in an ExcelWorksheet format as ShortDateTextBoxes for various number typesGetting the Twitter account from various input formatsGenerate URLs, Download, extract and add filesPrinting lines of “*” of various lengths






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3












$begingroup$


I must to model Document class. I receive document as bytes array.
I can receive pdf, zip, text and xml documents. After few operation I must store documents. If document is in xml format I can get some nodes or transform it by xlst and then store.How can I improve my code? Is it good idea to use here builder or factory method patterns?



 class Program
{
static void Main(string[] args)
{
string document1 = "<document>Content</document>";
byte[] document2 = new byte[] { 80, 65, 78, 75, 65, 74 };
byte[] document3 = new byte[] { 8, 68, 78, 78, 60, 73 };

var document1Binary = Encoding.UTF8.GetBytes(document1);
var binaryDocumentDetails = new DocumentDetails(1, "DefaultXml.xml", DocFormat.Xml, DocType.External);
var documentXml = new XmlDocument(document1Binary, binaryDocumentDetails, "Test.xml");

var binaryDocumentDetails1 = new DocumentDetails(1, "DefaultBinary.bin", DocFormat.Bin, DocType.Inner);
var binaryDocument1 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails1, "Test.bin");

var binaryDocumentDetails2 = new DocumentDetails(1, "DefaultPdf.pdf", DocFormat.Bin, DocType.Inner);
var binaryDocument2 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails2, "TestDocument.pdf");

var documentRepository = new List<BinaryDocument>();
documentRepository.Add(documentXml);
documentRepository.Add(binaryDocument1);
documentRepository.Add(binaryDocument2);
}
}

public enum DocFormat { Bin, Xml }
public enum DocType { Inner, External }
public enum Compression { Gzip, Zip}

public class DocumentDetails
{
public byte DocTypeId { get; set; }
public string DefaultFileName { get; }
public string FileExtension { get; set; }
public DocFormat Format { get; set; }
public DocType FormType { get; set; }
public DocumentDetails(byte docTypeId, string defaultFileName, DocFormat format, DocType formType)
{
DocTypeId = docTypeId;
DefaultFileName = defaultFileName;
Format = format;
FormType = formType;
}
}
public abstract class Document
{
public byte[] Body { get; protected set; }
public string FileName { get; private set; }
public Encoding Encoding { get; protected set; }
protected Document(byte[] body, string fileName, Encoding encoding)
{
Body = body;
Encoding = encoding;
FileName = fileName;
}
public void ChangeContent(Document sourceDocument)
{
Body = sourceDocument.Body;
Encoding = sourceDocument.Encoding;
FileName = sourceDocument.FileName;
}
}

public class BinaryDocument : Document
{
public bool IsActive { get; set; }
public bool AllowOverwrite { get; set; }
public Compression Compression { get; set; }
public DocumentDetails DocumentDetails { get; set; }

public BinaryDocument(byte[] content, DocumentDetails documentDetails, string fileName) : this(content, Encoding.UTF8, documentDetails, fileName)
{

}
public BinaryDocument(byte[] content, Encoding encoding, DocumentDetails documentDetails, string fileName) : base(content, fileName, encoding)
{
IsActive = true;
DocumentDetails = documentDetails;
}
protected BinaryDocument(BinaryDocument binaryDocument) : base(binaryDocument.Body, binaryDocument.FileName, binaryDocument.Encoding)
{
IsActive = binaryDocument.IsActive;
AllowOverwrite = binaryDocument.AllowOverwrite;
Compression = binaryDocument.Compression;
DocumentDetails = binaryDocument.DocumentDetails;
}

public void UpdateCompression(Compression compression)
{
Compression = compression;
}
public void UpdateDocumentDetails(DocumentDetails documentDetails)
{
DocumentDetails = documentDetails;
}

public string GetContentAsString()
{
return Encoding.GetString(Body);
}

public void UpdateDocument(byte[] body, Encoding encoding)
{
Body = body;
Encoding = encoding;
}
}

public class XmlDocument : BinaryDocument
{
public XDocument LoadedXmlDocument { get; set; }

public XmlDocument(byte[] content, DocumentDetails documentForm, string fileName) : base(content, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(byte[] content, Encoding encoding, DocumentDetails documentForm, string fileName) : base(content, encoding, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(BinaryDocument documentPart)
: this(documentPart.Body, documentPart.Encoding, documentPart.DocumentDetails, documentPart.FileName)
{
}

private XDocument Load()
{
XDocument loadedXml;
using (var ms = new MemoryStream(Body))
{
using (var xr = XmlReader.Create(ms))
{
loadedXml = XDocument.Load(xr);
}
}
return loadedXml;
}

public static bool TryParse(BinaryDocument documentPart)
{
bool result = true;

var readerSettings = new XmlReaderSettings
{
ConformanceLevel = ConformanceLevel.Document,
CheckCharacters = true,
ValidationType = ValidationType.None
};

var stream = documentPart.GetContentAsString();
try
{
using (var reader = XmlReader.Create(stream, readerSettings))
{
while (reader.Read()) { }
}
}
catch
{
result = false;
}
return result;
}
}









share|improve this question











$endgroup$












  • $begingroup$
    Do you have other document types than BinaryDocument that derives from Document?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 6:50










  • $begingroup$
    No, It's only BinaryDocument class
    $endgroup$
    – dMilan
    Apr 2 at 7:02










  • $begingroup$
    It's a good question, but I think, your use case is poor. You write, that you receive the data as byte arrays, but you show document1 as a string. It's also unclear from where you have or how you determine the metadata for each document. Could you provide an example that is a little more like the actual use?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 12:06


















3












$begingroup$


I must to model Document class. I receive document as bytes array.
I can receive pdf, zip, text and xml documents. After few operation I must store documents. If document is in xml format I can get some nodes or transform it by xlst and then store.How can I improve my code? Is it good idea to use here builder or factory method patterns?



 class Program
{
static void Main(string[] args)
{
string document1 = "<document>Content</document>";
byte[] document2 = new byte[] { 80, 65, 78, 75, 65, 74 };
byte[] document3 = new byte[] { 8, 68, 78, 78, 60, 73 };

var document1Binary = Encoding.UTF8.GetBytes(document1);
var binaryDocumentDetails = new DocumentDetails(1, "DefaultXml.xml", DocFormat.Xml, DocType.External);
var documentXml = new XmlDocument(document1Binary, binaryDocumentDetails, "Test.xml");

var binaryDocumentDetails1 = new DocumentDetails(1, "DefaultBinary.bin", DocFormat.Bin, DocType.Inner);
var binaryDocument1 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails1, "Test.bin");

var binaryDocumentDetails2 = new DocumentDetails(1, "DefaultPdf.pdf", DocFormat.Bin, DocType.Inner);
var binaryDocument2 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails2, "TestDocument.pdf");

var documentRepository = new List<BinaryDocument>();
documentRepository.Add(documentXml);
documentRepository.Add(binaryDocument1);
documentRepository.Add(binaryDocument2);
}
}

public enum DocFormat { Bin, Xml }
public enum DocType { Inner, External }
public enum Compression { Gzip, Zip}

public class DocumentDetails
{
public byte DocTypeId { get; set; }
public string DefaultFileName { get; }
public string FileExtension { get; set; }
public DocFormat Format { get; set; }
public DocType FormType { get; set; }
public DocumentDetails(byte docTypeId, string defaultFileName, DocFormat format, DocType formType)
{
DocTypeId = docTypeId;
DefaultFileName = defaultFileName;
Format = format;
FormType = formType;
}
}
public abstract class Document
{
public byte[] Body { get; protected set; }
public string FileName { get; private set; }
public Encoding Encoding { get; protected set; }
protected Document(byte[] body, string fileName, Encoding encoding)
{
Body = body;
Encoding = encoding;
FileName = fileName;
}
public void ChangeContent(Document sourceDocument)
{
Body = sourceDocument.Body;
Encoding = sourceDocument.Encoding;
FileName = sourceDocument.FileName;
}
}

public class BinaryDocument : Document
{
public bool IsActive { get; set; }
public bool AllowOverwrite { get; set; }
public Compression Compression { get; set; }
public DocumentDetails DocumentDetails { get; set; }

public BinaryDocument(byte[] content, DocumentDetails documentDetails, string fileName) : this(content, Encoding.UTF8, documentDetails, fileName)
{

}
public BinaryDocument(byte[] content, Encoding encoding, DocumentDetails documentDetails, string fileName) : base(content, fileName, encoding)
{
IsActive = true;
DocumentDetails = documentDetails;
}
protected BinaryDocument(BinaryDocument binaryDocument) : base(binaryDocument.Body, binaryDocument.FileName, binaryDocument.Encoding)
{
IsActive = binaryDocument.IsActive;
AllowOverwrite = binaryDocument.AllowOverwrite;
Compression = binaryDocument.Compression;
DocumentDetails = binaryDocument.DocumentDetails;
}

public void UpdateCompression(Compression compression)
{
Compression = compression;
}
public void UpdateDocumentDetails(DocumentDetails documentDetails)
{
DocumentDetails = documentDetails;
}

public string GetContentAsString()
{
return Encoding.GetString(Body);
}

public void UpdateDocument(byte[] body, Encoding encoding)
{
Body = body;
Encoding = encoding;
}
}

public class XmlDocument : BinaryDocument
{
public XDocument LoadedXmlDocument { get; set; }

public XmlDocument(byte[] content, DocumentDetails documentForm, string fileName) : base(content, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(byte[] content, Encoding encoding, DocumentDetails documentForm, string fileName) : base(content, encoding, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(BinaryDocument documentPart)
: this(documentPart.Body, documentPart.Encoding, documentPart.DocumentDetails, documentPart.FileName)
{
}

private XDocument Load()
{
XDocument loadedXml;
using (var ms = new MemoryStream(Body))
{
using (var xr = XmlReader.Create(ms))
{
loadedXml = XDocument.Load(xr);
}
}
return loadedXml;
}

public static bool TryParse(BinaryDocument documentPart)
{
bool result = true;

var readerSettings = new XmlReaderSettings
{
ConformanceLevel = ConformanceLevel.Document,
CheckCharacters = true,
ValidationType = ValidationType.None
};

var stream = documentPart.GetContentAsString();
try
{
using (var reader = XmlReader.Create(stream, readerSettings))
{
while (reader.Read()) { }
}
}
catch
{
result = false;
}
return result;
}
}









share|improve this question











$endgroup$












  • $begingroup$
    Do you have other document types than BinaryDocument that derives from Document?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 6:50










  • $begingroup$
    No, It's only BinaryDocument class
    $endgroup$
    – dMilan
    Apr 2 at 7:02










  • $begingroup$
    It's a good question, but I think, your use case is poor. You write, that you receive the data as byte arrays, but you show document1 as a string. It's also unclear from where you have or how you determine the metadata for each document. Could you provide an example that is a little more like the actual use?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 12:06














3












3








3





$begingroup$


I must to model Document class. I receive document as bytes array.
I can receive pdf, zip, text and xml documents. After few operation I must store documents. If document is in xml format I can get some nodes or transform it by xlst and then store.How can I improve my code? Is it good idea to use here builder or factory method patterns?



 class Program
{
static void Main(string[] args)
{
string document1 = "<document>Content</document>";
byte[] document2 = new byte[] { 80, 65, 78, 75, 65, 74 };
byte[] document3 = new byte[] { 8, 68, 78, 78, 60, 73 };

var document1Binary = Encoding.UTF8.GetBytes(document1);
var binaryDocumentDetails = new DocumentDetails(1, "DefaultXml.xml", DocFormat.Xml, DocType.External);
var documentXml = new XmlDocument(document1Binary, binaryDocumentDetails, "Test.xml");

var binaryDocumentDetails1 = new DocumentDetails(1, "DefaultBinary.bin", DocFormat.Bin, DocType.Inner);
var binaryDocument1 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails1, "Test.bin");

var binaryDocumentDetails2 = new DocumentDetails(1, "DefaultPdf.pdf", DocFormat.Bin, DocType.Inner);
var binaryDocument2 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails2, "TestDocument.pdf");

var documentRepository = new List<BinaryDocument>();
documentRepository.Add(documentXml);
documentRepository.Add(binaryDocument1);
documentRepository.Add(binaryDocument2);
}
}

public enum DocFormat { Bin, Xml }
public enum DocType { Inner, External }
public enum Compression { Gzip, Zip}

public class DocumentDetails
{
public byte DocTypeId { get; set; }
public string DefaultFileName { get; }
public string FileExtension { get; set; }
public DocFormat Format { get; set; }
public DocType FormType { get; set; }
public DocumentDetails(byte docTypeId, string defaultFileName, DocFormat format, DocType formType)
{
DocTypeId = docTypeId;
DefaultFileName = defaultFileName;
Format = format;
FormType = formType;
}
}
public abstract class Document
{
public byte[] Body { get; protected set; }
public string FileName { get; private set; }
public Encoding Encoding { get; protected set; }
protected Document(byte[] body, string fileName, Encoding encoding)
{
Body = body;
Encoding = encoding;
FileName = fileName;
}
public void ChangeContent(Document sourceDocument)
{
Body = sourceDocument.Body;
Encoding = sourceDocument.Encoding;
FileName = sourceDocument.FileName;
}
}

public class BinaryDocument : Document
{
public bool IsActive { get; set; }
public bool AllowOverwrite { get; set; }
public Compression Compression { get; set; }
public DocumentDetails DocumentDetails { get; set; }

public BinaryDocument(byte[] content, DocumentDetails documentDetails, string fileName) : this(content, Encoding.UTF8, documentDetails, fileName)
{

}
public BinaryDocument(byte[] content, Encoding encoding, DocumentDetails documentDetails, string fileName) : base(content, fileName, encoding)
{
IsActive = true;
DocumentDetails = documentDetails;
}
protected BinaryDocument(BinaryDocument binaryDocument) : base(binaryDocument.Body, binaryDocument.FileName, binaryDocument.Encoding)
{
IsActive = binaryDocument.IsActive;
AllowOverwrite = binaryDocument.AllowOverwrite;
Compression = binaryDocument.Compression;
DocumentDetails = binaryDocument.DocumentDetails;
}

public void UpdateCompression(Compression compression)
{
Compression = compression;
}
public void UpdateDocumentDetails(DocumentDetails documentDetails)
{
DocumentDetails = documentDetails;
}

public string GetContentAsString()
{
return Encoding.GetString(Body);
}

public void UpdateDocument(byte[] body, Encoding encoding)
{
Body = body;
Encoding = encoding;
}
}

public class XmlDocument : BinaryDocument
{
public XDocument LoadedXmlDocument { get; set; }

public XmlDocument(byte[] content, DocumentDetails documentForm, string fileName) : base(content, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(byte[] content, Encoding encoding, DocumentDetails documentForm, string fileName) : base(content, encoding, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(BinaryDocument documentPart)
: this(documentPart.Body, documentPart.Encoding, documentPart.DocumentDetails, documentPart.FileName)
{
}

private XDocument Load()
{
XDocument loadedXml;
using (var ms = new MemoryStream(Body))
{
using (var xr = XmlReader.Create(ms))
{
loadedXml = XDocument.Load(xr);
}
}
return loadedXml;
}

public static bool TryParse(BinaryDocument documentPart)
{
bool result = true;

var readerSettings = new XmlReaderSettings
{
ConformanceLevel = ConformanceLevel.Document,
CheckCharacters = true,
ValidationType = ValidationType.None
};

var stream = documentPart.GetContentAsString();
try
{
using (var reader = XmlReader.Create(stream, readerSettings))
{
while (reader.Read()) { }
}
}
catch
{
result = false;
}
return result;
}
}









share|improve this question











$endgroup$




I must to model Document class. I receive document as bytes array.
I can receive pdf, zip, text and xml documents. After few operation I must store documents. If document is in xml format I can get some nodes or transform it by xlst and then store.How can I improve my code? Is it good idea to use here builder or factory method patterns?



 class Program
{
static void Main(string[] args)
{
string document1 = "<document>Content</document>";
byte[] document2 = new byte[] { 80, 65, 78, 75, 65, 74 };
byte[] document3 = new byte[] { 8, 68, 78, 78, 60, 73 };

var document1Binary = Encoding.UTF8.GetBytes(document1);
var binaryDocumentDetails = new DocumentDetails(1, "DefaultXml.xml", DocFormat.Xml, DocType.External);
var documentXml = new XmlDocument(document1Binary, binaryDocumentDetails, "Test.xml");

var binaryDocumentDetails1 = new DocumentDetails(1, "DefaultBinary.bin", DocFormat.Bin, DocType.Inner);
var binaryDocument1 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails1, "Test.bin");

var binaryDocumentDetails2 = new DocumentDetails(1, "DefaultPdf.pdf", DocFormat.Bin, DocType.Inner);
var binaryDocument2 = new BinaryDocument(document2, Encoding.UTF8, binaryDocumentDetails2, "TestDocument.pdf");

var documentRepository = new List<BinaryDocument>();
documentRepository.Add(documentXml);
documentRepository.Add(binaryDocument1);
documentRepository.Add(binaryDocument2);
}
}

public enum DocFormat { Bin, Xml }
public enum DocType { Inner, External }
public enum Compression { Gzip, Zip}

public class DocumentDetails
{
public byte DocTypeId { get; set; }
public string DefaultFileName { get; }
public string FileExtension { get; set; }
public DocFormat Format { get; set; }
public DocType FormType { get; set; }
public DocumentDetails(byte docTypeId, string defaultFileName, DocFormat format, DocType formType)
{
DocTypeId = docTypeId;
DefaultFileName = defaultFileName;
Format = format;
FormType = formType;
}
}
public abstract class Document
{
public byte[] Body { get; protected set; }
public string FileName { get; private set; }
public Encoding Encoding { get; protected set; }
protected Document(byte[] body, string fileName, Encoding encoding)
{
Body = body;
Encoding = encoding;
FileName = fileName;
}
public void ChangeContent(Document sourceDocument)
{
Body = sourceDocument.Body;
Encoding = sourceDocument.Encoding;
FileName = sourceDocument.FileName;
}
}

public class BinaryDocument : Document
{
public bool IsActive { get; set; }
public bool AllowOverwrite { get; set; }
public Compression Compression { get; set; }
public DocumentDetails DocumentDetails { get; set; }

public BinaryDocument(byte[] content, DocumentDetails documentDetails, string fileName) : this(content, Encoding.UTF8, documentDetails, fileName)
{

}
public BinaryDocument(byte[] content, Encoding encoding, DocumentDetails documentDetails, string fileName) : base(content, fileName, encoding)
{
IsActive = true;
DocumentDetails = documentDetails;
}
protected BinaryDocument(BinaryDocument binaryDocument) : base(binaryDocument.Body, binaryDocument.FileName, binaryDocument.Encoding)
{
IsActive = binaryDocument.IsActive;
AllowOverwrite = binaryDocument.AllowOverwrite;
Compression = binaryDocument.Compression;
DocumentDetails = binaryDocument.DocumentDetails;
}

public void UpdateCompression(Compression compression)
{
Compression = compression;
}
public void UpdateDocumentDetails(DocumentDetails documentDetails)
{
DocumentDetails = documentDetails;
}

public string GetContentAsString()
{
return Encoding.GetString(Body);
}

public void UpdateDocument(byte[] body, Encoding encoding)
{
Body = body;
Encoding = encoding;
}
}

public class XmlDocument : BinaryDocument
{
public XDocument LoadedXmlDocument { get; set; }

public XmlDocument(byte[] content, DocumentDetails documentForm, string fileName) : base(content, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(byte[] content, Encoding encoding, DocumentDetails documentForm, string fileName) : base(content, encoding, documentForm, fileName)
{
LoadedXmlDocument = Load();
}

public XmlDocument(BinaryDocument documentPart)
: this(documentPart.Body, documentPart.Encoding, documentPart.DocumentDetails, documentPart.FileName)
{
}

private XDocument Load()
{
XDocument loadedXml;
using (var ms = new MemoryStream(Body))
{
using (var xr = XmlReader.Create(ms))
{
loadedXml = XDocument.Load(xr);
}
}
return loadedXml;
}

public static bool TryParse(BinaryDocument documentPart)
{
bool result = true;

var readerSettings = new XmlReaderSettings
{
ConformanceLevel = ConformanceLevel.Document,
CheckCharacters = true,
ValidationType = ValidationType.None
};

var stream = documentPart.GetContentAsString();
try
{
using (var reader = XmlReader.Create(stream, readerSettings))
{
while (reader.Read()) { }
}
}
catch
{
result = false;
}
return result;
}
}






c# beginner






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 1 at 10:13









t3chb0t

35.1k754125




35.1k754125










asked Apr 1 at 9:48









dMilandMilan

1253




1253












  • $begingroup$
    Do you have other document types than BinaryDocument that derives from Document?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 6:50










  • $begingroup$
    No, It's only BinaryDocument class
    $endgroup$
    – dMilan
    Apr 2 at 7:02










  • $begingroup$
    It's a good question, but I think, your use case is poor. You write, that you receive the data as byte arrays, but you show document1 as a string. It's also unclear from where you have or how you determine the metadata for each document. Could you provide an example that is a little more like the actual use?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 12:06


















  • $begingroup$
    Do you have other document types than BinaryDocument that derives from Document?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 6:50










  • $begingroup$
    No, It's only BinaryDocument class
    $endgroup$
    – dMilan
    Apr 2 at 7:02










  • $begingroup$
    It's a good question, but I think, your use case is poor. You write, that you receive the data as byte arrays, but you show document1 as a string. It's also unclear from where you have or how you determine the metadata for each document. Could you provide an example that is a little more like the actual use?
    $endgroup$
    – Henrik Hansen
    Apr 2 at 12:06
















$begingroup$
Do you have other document types than BinaryDocument that derives from Document?
$endgroup$
– Henrik Hansen
Apr 2 at 6:50




$begingroup$
Do you have other document types than BinaryDocument that derives from Document?
$endgroup$
– Henrik Hansen
Apr 2 at 6:50












$begingroup$
No, It's only BinaryDocument class
$endgroup$
– dMilan
Apr 2 at 7:02




$begingroup$
No, It's only BinaryDocument class
$endgroup$
– dMilan
Apr 2 at 7:02












$begingroup$
It's a good question, but I think, your use case is poor. You write, that you receive the data as byte arrays, but you show document1 as a string. It's also unclear from where you have or how you determine the metadata for each document. Could you provide an example that is a little more like the actual use?
$endgroup$
– Henrik Hansen
Apr 2 at 12:06




$begingroup$
It's a good question, but I think, your use case is poor. You write, that you receive the data as byte arrays, but you show document1 as a string. It's also unclear from where you have or how you determine the metadata for each document. Could you provide an example that is a little more like the actual use?
$endgroup$
– Henrik Hansen
Apr 2 at 12:06










0






active

oldest

votes












Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");

StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216638%2fdocument-class-for-various-formats%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Code Review Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216638%2fdocument-class-for-various-formats%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...