1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Collections;
6
using System.ComponentModel.Design.Serialization;
7
using System.ComponentModel.Design;
9
namespace ICSharpCode.Reports.Addin
12
/// This class implements the IDesignerSerializationService interface.
13
/// A designer loader that does not derive from the CodeDOMDesignerLoader class
14
/// (e.g. the XmlDesignerLoader) need to create an instance of this class
15
/// and it to the available services otherwise cut/copy and paste will not work.
17
public class DesignerSerializationService : IDesignerSerializationService
19
IServiceProvider serviceProvider;
20
public DesignerSerializationService(IServiceProvider serviceProvider)
22
if (serviceProvider == null) {
23
throw new ArgumentNullException("serviceProvider");
25
this.serviceProvider = serviceProvider;
29
/// Deserializes the serialization data object and returns a
30
/// collection of objects represented by that data.
32
public ICollection Deserialize(object serializationData)
34
IDesignerHost host = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost));
36
ComponentSerializationService serializationService = (ComponentSerializationService)serviceProvider.GetService(typeof(ComponentSerializationService));
37
return serializationService.Deserialize((SerializationStore)serializationData,host.Container);
43
/// Serializes a collection of objects and stores them in a
44
/// serialization data object.
46
public object Serialize(ICollection objects)
48
if (objects == null) {
49
throw new ArgumentNullException("objects");
51
ComponentSerializationService serializationService = (ComponentSerializationService)serviceProvider.GetService(typeof(ComponentSerializationService));
52
SerializationStore store = serializationService.CreateStore();
53
foreach (object value in objects) {
54
serializationService.Serialize(store, value);