View Sidebar

A Million Little Pieces Of My Mind

Organica Core: Document class

By: Paul S. Cilwa Viewed: 5/8/2024
Posted: 8/3/2018
Page Views: 672
Topics: #Computers #Programming #Organica #VB.NET
The base class for all Organica documents.

The Document class provides the basic functionality for all documents, including being able to create objects of the appropriate document type. It is the base class for all the document types. It also does double duty as the default class for unrecognized document types.

Documents.vb (append)

Public Class Document Public Visible As Boolean = True Public IconPath As String Private i_Pathname As String Private i_FileInfo As FileInfo
Public Shared Function CreateObject(a_Pathname As String) As Document Dim Test As New Document(a_Pathname) Select Case Test.DocumentType Case DocumentTypes.organica_Folder Return New FolderDocument(a_Pathname) Case DocumentTypes.organica_Profile Return New ProfileDocument(a_Pathname) Case DocumentTypes.organica_Link Return New LinkDocument(a_Pathname) Case Else Return New Document(a_Pathname) End Select Return Test End Function
Public ReadOnly Property IsFolder As Boolean Get Return (File.GetAttributes(Pathname) And _ FileAttributes.Directory) = FileAttributes.Directory End Get End Property
Private ReadOnly Property DocumentType As DocumentTypes Get If IsFolder Then Return DocumentTypes.organica_Folder End If Select Case i_FileInfo.Extension.ToLower Case ".ini" Return DocumentTypes.organica_Profile End Select Return DocumentTypes.organica_Unknown End Get End Property
Public Sub New(ByVal a_Pathname As String) i_FileInfo = New FileInfo(a_Pathname) i_Pathname = i_FileInfo.FullName End Sub
Public ReadOnly Property Pathname As String Get Return i_Pathname End Get End Property
Public Overridable Overloads ReadOnly Property Filename As String Get Return i_FileInfo.Name End Get End Property
Public ReadOnly Property Extension As String Get Return i_FileInfo.Extension End Get End Property
Public ReadOnly Property IsTemporary As Boolean Get Return (File.GetAttributes(Pathname) And FileAttributes.Temporary) = FileAttributes.Temporary End Get End Property
Public ReadOnly Property IsSystem As Boolean Get Return (File.GetAttributes(Pathname) And FileAttributes.System) = FileAttributes.System End Get End Property
Public ReadOnly Property IsHidden As Boolean Get Return (File.GetAttributes(Pathname) And FileAttributes.Hidden) = FileAttributes.Hidden End Get End Property
Public ReadOnly Property IsReadOnly As Boolean Get Return (File.GetAttributes(Pathname) And FileAttributes.ReadOnly) = FileAttributes.ReadOnly End Get End Property
Public ReadOnly Property Exists As Boolean Get Return File.Exists(Pathname) End Get End Property
Public ReadOnly Property DateCreated As Date Get Return File.GetCreationTime(Pathname) End Get End Property
Public Overridable Overloads Sub Populate() End Sub
Public Overridable Overloads Function Find(ByVal Key As String) As Document Return Nothing End Function
Public Overridable Overloads ReadOnly Property RenderHeader As String Get Dim Buffer As String Buffer = "<div class=organica_Document>" ConCat(Buffer, "<img src=TypeUnknown.png><div>") ConCat(Buffer, "<h1>" & Filename & "</h1>") ConCat(Buffer, "<p>" & Pathname & "</p>") ConCat(Buffer, "</div>") Return Buffer End Get End Property
Public Overridable Overloads ReadOnly Property RenderContent As String Get Return "" End Get End Property
Public Overridable Overloads ReadOnly Property RenderProperties As String Get Return "" End Get End Property
End Class