Base on SoapBox code, I use an Import attribute to get these references, like so:

   [Import(SoapBox.Core.Services.Layout.LayoutManager, typeof(ILayoutManager))]
   private Lazy<ILayoutManager> layoutManager { get; set; }

   [Import(CompositionPoints.Workbench.Documents.MyDocument, typeof(MyDocument))] 
   private Lazy<MyDocument> myDocument { get; set; }

and show the Document:

   var newDoc = layoutManager.Value.ShowDocument(myDocument.Value, fileName);

I want to open multiple documents of the same type, but I don't know how to override the CreateDocument function ( since I learn c# language just for one month) to show multiple documents of the same type. Is anyone can teach me how to override the CreateDocument function and return a new instance (or an existing instance) base on "memento" ?

Thanks

asked 16 Jan '11, 23:44

lovablefish's gravatar image

lovablefish
56337
accept rate: 0%


You're almost there. When you implement the CreateDocument function, the parameter called memento will contain the value of the second parameter that you pass to ShowDocument (in your case, fileName). Use that value to either create a new document (using the new keyword) or return a cached value (by storing all the existing documents in a Dictionary where they key is your memento).

For an example, take a look at the CreateDocument method in this file.

link

answered 17 Jan '11, 06:41

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833
accept rate: 50%

Thanks for your help. I finished this work!

(17 Jan '11, 23:27) lovablefish
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×6

Asked: 16 Jan '11, 23:44

Seen: 2,673 times

Last updated: 17 Jan '11, 23:27

powered by OSQA