private static void AddAudioDocument(string[] attributes) { var document = new AudioDocument(); SetDocumentProperties(document, attributes); AddDocument(document); }
private static void AddAudioDocument(string[] attributes) { string temp = null; string name = null; string content = null; int? length = null; ulong? size = null; int? samplerate = null; int index; for (int i = 0; i < attributes.Length; i++) { if (attributes[i].Contains("name")) { name = attributes[i]; index = name.IndexOf('='); name = name.Substring(index + 1); } if (attributes[i].Contains("length")) { temp = attributes[i]; index = temp.IndexOf('='); length = Convert.ToInt32(temp.Substring(index + 1)); } if (attributes[i].Contains("samplerate")) { temp = attributes[i]; index = temp.IndexOf('='); samplerate = Convert.ToInt32(temp.Substring(index + 1)); } if (attributes[i].Contains("content")) { content = attributes[i]; index = content.IndexOf('='); content = content.Substring(index + 1); } if (attributes[i].Contains("size")) { temp = attributes[i]; index = temp.IndexOf('='); size = (ulong)Convert.ToInt64(temp.Substring(index + 1)); } } if (name != null) { var audioDoc = new AudioDocument(name, content, size, length, samplerate); Console.WriteLine("Document added: {0}", name); documents.Add(audioDoc); } else { Console.WriteLine("Document has no name"); } }
private static void AddAudioDocument(string[] attributes) { AudioDocument doc = new AudioDocument(); AddDocument(attributes, doc); }
public string AddAudioDocument(string[] attributes) { var document = new AudioDocument(); return this.AddDocument(document, attributes); }
public string AddAudioDocument(string[] attributes) { var document = new AudioDocument(); return(this.AddDocument(document, attributes)); }
private static void ListDocuments() { // if (documents.Count == 0) { Console.WriteLine("No documents found"); } foreach (var item in documents) { if (item is IEncryptable) { IEncryptable obj = item as IEncryptable; if (obj.IsEncrypted == true) { Console.WriteLine("{0}[encrypted]", obj.GetType().Name); continue; } } Type type = item.GetType(); StringBuilder sb = new StringBuilder(); sb.Append(type.Name + "["); if (type.Name == "TextDocument") { TextDocument doc = item as TextDocument; if (doc.Charset != null) { sb.AppendFormat("charset={0};", doc.Charset); } if (doc.Content != null) { sb.AppendFormat("content={0};", doc.Content); } sb.AppendFormat("name={0}", doc.Name); } else if (type.Name == "PDFDocument") { PDFDocument doc = item as PDFDocument; if (doc.Content != null) { sb.AppendFormat("content={0};", doc.Content); } sb.AppendFormat("name={0}", doc.Name); if (doc.Pages != null) { sb.AppendFormat(";pages={0}", doc.Pages); } if (doc.Size != null) { sb.AppendFormat(";size={0}", doc.Size); } } else if (type.Name == "WordDocument") { WordDocument doc = item as WordDocument; if (doc.Chars != null) { sb.AppendFormat("chars={0};", doc.Chars); } if (doc.Content != null) { sb.AppendFormat("content={0};", doc.Content); } sb.AppendFormat("name={0}", doc.Name); if (doc.Size != null) { sb.AppendFormat(";size={0}", doc.Size); } if (doc.Version != null) { sb.AppendFormat(";version={0}", doc.Version); } } else if (type.Name == "ExcelDocument") { ExcelDocument doc = item as ExcelDocument; if (doc.Cols != null) { sb.AppendFormat("cols={0};", doc.Cols); } if (doc.Content != null) { sb.AppendFormat("content={0};", doc.Content); } sb.AppendFormat("name={0}", doc.Name); if (doc.Rows != null) { sb.AppendFormat(";rows={0}", doc.Rows); } if (doc.Size != null) { sb.AppendFormat(";size={0}", doc.Size); } if (doc.Version != null) { sb.AppendFormat(";version={0}", doc.Version); } } else if (type.Name == "AudioDocument") { AudioDocument doc = item as AudioDocument; if (doc.Content != null) { sb.AppendFormat("content={0};", doc.Content); } if (doc.Length != null) { sb.AppendFormat("length={0};", doc.Length); } sb.AppendFormat("name={0}", doc.Name); if (doc.Samplerate != null) { sb.AppendFormat(";samplerate={0}", doc.Samplerate); } if (doc.Size != null) { sb.AppendFormat(";size={0}", doc.Size); } } else if (type.Name == "VideoDocument") { VideoDocument doc = item as VideoDocument; if (doc.Content != null) { sb.AppendFormat("content={0};", doc.Content); } if (doc.Framerate != null) { sb.AppendFormat("framerate={0};", doc.Framerate); } sb.AppendFormat("name={0}", doc.Name); if (doc.Length != null) { sb.AppendFormat(";length={0}", doc.Length); } if (doc.Size != null) { sb.AppendFormat(";size={0}", doc.Size); } } sb.Append("]"); Console.WriteLine(sb.ToString()); } }