Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. Advices designing a document-centric application

Advices designing a document-centric application

Scheduled Pinned Locked Moved Design and Architecture
helpquestiondesigntutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    crs21
    wrote on last edited by
    #1

    Hi there, I am seeking help for building a document-centric application. More specifically, handling extensions and icons for the different file types the application is going to manage. I know how to register extensions within windows, I'm just unsure how to do it inside my own application! My current design is something like this: Each document has it own class (the documents are actually just the objects serialized, gzipped and stored on the disk). Those can be extended through a plugin system (with external dlls being loaded during runtime), so the number of file types may be extended at will. Each file type should have its own extension and can have its own icon. I'm using multidotted extensions to keep the naming scheme sane. To define a new document, thus a new file type, one has to implement a interface, lets say, IDocument, which has common properties like Name, Description and Remarks, and then define what his document will contain. Now, the problem is: Where should I specify which will be the default extension and icon for a particular document class I'm writing? At first I thought about adding static properties to the interface in order to ensure its implementation, but I know interfaces cant have such things. I also need to be able to, given an extension, return the System.Type of the related document, or given a Type, return its extension. I could write a table of extensions and related types, but then how could I enforce every class that inherits from IDocument will register itself into this table? It should be mandatory for a document to have a extension, but I can not think of a way to enforce this rule. Sorry for the long question, but I hope I could explain what I'm trying to achieve. Thanks in advance, C

    P J 2 Replies Last reply
    0
    • C crs21

      Hi there, I am seeking help for building a document-centric application. More specifically, handling extensions and icons for the different file types the application is going to manage. I know how to register extensions within windows, I'm just unsure how to do it inside my own application! My current design is something like this: Each document has it own class (the documents are actually just the objects serialized, gzipped and stored on the disk). Those can be extended through a plugin system (with external dlls being loaded during runtime), so the number of file types may be extended at will. Each file type should have its own extension and can have its own icon. I'm using multidotted extensions to keep the naming scheme sane. To define a new document, thus a new file type, one has to implement a interface, lets say, IDocument, which has common properties like Name, Description and Remarks, and then define what his document will contain. Now, the problem is: Where should I specify which will be the default extension and icon for a particular document class I'm writing? At first I thought about adding static properties to the interface in order to ensure its implementation, but I know interfaces cant have such things. I also need to be able to, given an extension, return the System.Type of the related document, or given a Type, return its extension. I could write a table of extensions and related types, but then how could I enforce every class that inherits from IDocument will register itself into this table? It should be mandatory for a document to have a extension, but I can not think of a way to enforce this rule. Sorry for the long question, but I hope I could explain what I'm trying to achieve. Thanks in advance, C

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Well, you could always implement an abstract base class that your document classes must inherit from, and put rules inside here to ensure that a document has an extension and icon.

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      My blog | My articles | MoXAML PowerToys

      C 1 Reply Last reply
      0
      • C crs21

        Hi there, I am seeking help for building a document-centric application. More specifically, handling extensions and icons for the different file types the application is going to manage. I know how to register extensions within windows, I'm just unsure how to do it inside my own application! My current design is something like this: Each document has it own class (the documents are actually just the objects serialized, gzipped and stored on the disk). Those can be extended through a plugin system (with external dlls being loaded during runtime), so the number of file types may be extended at will. Each file type should have its own extension and can have its own icon. I'm using multidotted extensions to keep the naming scheme sane. To define a new document, thus a new file type, one has to implement a interface, lets say, IDocument, which has common properties like Name, Description and Remarks, and then define what his document will contain. Now, the problem is: Where should I specify which will be the default extension and icon for a particular document class I'm writing? At first I thought about adding static properties to the interface in order to ensure its implementation, but I know interfaces cant have such things. I also need to be able to, given an extension, return the System.Type of the related document, or given a Type, return its extension. I could write a table of extensions and related types, but then how could I enforce every class that inherits from IDocument will register itself into this table? It should be mandatory for a document to have a extension, but I can not think of a way to enforce this rule. Sorry for the long question, but I hope I could explain what I'm trying to achieve. Thanks in advance, C

        J Offline
        J Offline
        Jonathan Davies
        wrote on last edited by
        #3

        Where should I specify which will be the default extension and icon for a particular document class I'm writing? I would consider that these defaults are the defaults of the context or system in which they are used. That is, the default is not of the document, but of the system its saved in. Moving a document from System A to System B may mean a different default icon, so information on defaults does not need to be part of the document.

        1 Reply Last reply
        0
        • P Pete OHanlon

          Well, you could always implement an abstract base class that your document classes must inherit from, and put rules inside here to ensure that a document has an extension and icon.

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          My blog | My articles | MoXAML PowerToys

          C Offline
          C Offline
          crs21
          wrote on last edited by
          #4

          Hi, thanks for replying. Its a nice sugestion, but then to retrieve this information I'd have to create an instance of the class, wouldn't I? If I have to look for a particular extension, I'd be instantiating several classes, one for each document, only to check the overriden methods. If there was a way to enforce a inherited class to have a particular static method, then it would be easy, but there isn't. At least none that I'm aware of. I think its possible to create a mechanism to register this information in a static structure somewhere based on overriden virtual methods, but I would have to instantiate the class at least once for this.

          P 1 Reply Last reply
          0
          • C crs21

            Hi, thanks for replying. Its a nice sugestion, but then to retrieve this information I'd have to create an instance of the class, wouldn't I? If I have to look for a particular extension, I'd be instantiating several classes, one for each document, only to check the overriden methods. If there was a way to enforce a inherited class to have a particular static method, then it would be easy, but there isn't. At least none that I'm aware of. I think its possible to create a mechanism to register this information in a static structure somewhere based on overriden virtual methods, but I would have to instantiate the class at least once for this.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            There's no easy way to do this internally. You could always store the extension and the type it relates to in a database/config file and then perform the instantiation based on that.

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            My blog | My articles | MoXAML PowerToys

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups