Skip to content

Commit

Permalink
code moved from "trunk"
Browse files Browse the repository at this point in the history
  • Loading branch information
sensboston committed Dec 18, 2018
1 parent 6309463 commit 2e11ef1
Show file tree
Hide file tree
Showing 118 changed files with 13,459 additions and 13,486 deletions.
180 changes: 90 additions & 90 deletions trunk/TinyOPDS/Data/Book.cs → TinyOPDS/Data/Book.cs
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
/***********************************************************
* This file is a part of TinyOPDS server project
*
* Copyright (c) 2013 SeNSSoFT
*
* This code is licensed under the Microsoft Public License,
* see http://tinyopds.codeplex.com/license for the details.
*
* This module defines the Book class
*
************************************************************/

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Drawing;

namespace TinyOPDS.Data
{
/// <summary>
/// Supported book types
/// </summary>
public enum BookType
{
FB2,
EPUB,
}

/// <summary>
/// Base data class
/// </summary>
public class Book
{
public Book(string fileName = "")
{
Version = 1;
FileName = fileName;
if (!string.IsNullOrEmpty(FileName) && FileName.IndexOf(Library.LibraryPath)==0)
{
FileName = FileName.Substring(Library.LibraryPath.Length+1);
}
Title = Sequence = Annotation = Language = string.Empty;
HasCover = false;
BookDate = DocumentDate = DateTime.MinValue;
NumberInSequence = 0;
Authors = new List<string>();
Translators = new List<string>();
Genres = new List<string>();
}
private string _id = string.Empty;
public string ID
{
get { return _id; }
set
{
// Book ID always must be in GUID form
Guid guid;
if (!string.IsNullOrEmpty(value) && Guid.TryParse(value, out guid)) _id = value; else _id = Utils.CreateGuid(Utils.IsoOidNamespace, FileName).ToString();
_id = _id.Replace("{", "").Replace("}", "");
}
}
public float Version { get; set; }
public string FileName { get; private set; }
public string FilePath
{
get
{
string path = Path.Combine(Library.LibraryPath, FileName).Replace ("\\\\", "\\");
return Utils.IsLinux ? path.Replace('\\', '/') : path;
}
}
public string Title { get; set; }
public string Language { get; set; }
public bool HasCover { get; set; }
public DateTime BookDate { get; set; }
public DateTime DocumentDate { get; set; }
public string Sequence { get; set; }
public UInt32 NumberInSequence { get; set; }
public string Annotation { get; set; }
public UInt32 DocumentSize { get; set; }
public List<string> Authors { get; set; }
public List<string> Translators { get; set; }
public List<string> Genres { get; set; }
public BookType BookType { get { return Path.GetExtension(FilePath).ToLower().Contains("epub") ? BookType.EPUB : Data.BookType.FB2; } }
public bool IsValid { get { return (!string.IsNullOrEmpty(Title) && Title.IsValidUTF() && Authors.Count > 0 && Genres.Count > 0); } }
public DateTime AddedDate { get; set; }
}
}
/***********************************************************
* This file is a part of TinyOPDS server project
*
* Copyright (c) 2013 SeNSSoFT
*
* This code is licensed under the Microsoft Public License,
* see http://tinyopds.codeplex.com/license for the details.
*
* This module defines the Book class
*
************************************************************/

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Drawing;

namespace TinyOPDS.Data
{
/// <summary>
/// Supported book types
/// </summary>
public enum BookType
{
FB2,
EPUB,
}

/// <summary>
/// Base data class
/// </summary>
public class Book
{
public Book(string fileName = "")
{
Version = 1;
FileName = fileName;
if (!string.IsNullOrEmpty(FileName) && FileName.IndexOf(Library.LibraryPath)==0)
{
FileName = FileName.Substring(Library.LibraryPath.Length+1);
}
Title = Sequence = Annotation = Language = string.Empty;
HasCover = false;
BookDate = DocumentDate = DateTime.MinValue;
NumberInSequence = 0;
Authors = new List<string>();
Translators = new List<string>();
Genres = new List<string>();
}
private string _id = string.Empty;
public string ID
{
get { return _id; }
set
{
// Book ID always must be in GUID form
Guid guid;
if (!string.IsNullOrEmpty(value) && Guid.TryParse(value, out guid)) _id = value; else _id = Utils.CreateGuid(Utils.IsoOidNamespace, FileName).ToString();
_id = _id.Replace("{", "").Replace("}", "");
}
}
public float Version { get; set; }
public string FileName { get; private set; }
public string FilePath
{
get
{
string path = Path.Combine(Library.LibraryPath, FileName).Replace ("\\\\", "\\");
return Utils.IsLinux ? path.Replace('\\', '/') : path;
}
}
public string Title { get; set; }
public string Language { get; set; }
public bool HasCover { get; set; }
public DateTime BookDate { get; set; }
public DateTime DocumentDate { get; set; }
public string Sequence { get; set; }
public UInt32 NumberInSequence { get; set; }
public string Annotation { get; set; }
public UInt32 DocumentSize { get; set; }
public List<string> Authors { get; set; }
public List<string> Translators { get; set; }
public List<string> Genres { get; set; }
public BookType BookType { get { return Path.GetExtension(FilePath).ToLower().Contains("epub") ? BookType.EPUB : Data.BookType.FB2; } }
public bool IsValid { get { return (!string.IsNullOrEmpty(Title) && Title.IsValidUTF() && Authors.Count > 0 && Genres.Count > 0); } }
public DateTime AddedDate { get; set; }
}
}
Loading

0 comments on commit 2e11ef1

Please sign in to comment.