CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ObjectCloner.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ObjectCloner.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>This class provides an implementation of a deep</summary>
7//-----------------------------------------------------------------------
9using System;
10using System.IO;
11
12namespace Csla.Core
13{
19 public class ObjectCloner
20 {
21 private ApplicationContext ApplicationContext { get; set; }
22
27 public ObjectCloner(ApplicationContext applicationContext)
28 {
29 ApplicationContext = applicationContext;
30 }
31
37 public static ObjectCloner GetInstance(ApplicationContext applicationContext)
38 {
39 return new ObjectCloner(applicationContext);
40 }
41
52 public object Clone(object obj)
53 {
54 using var buffer = new MemoryStream();
55 ISerializationFormatter formatter =
56 SerializationFormatterFactory.GetFormatter(ApplicationContext);
57 formatter.Serialize(buffer, obj);
58 buffer.Position = 0;
59 return formatter.Deserialize(buffer);
60 }
61 }
62}
Provides consistent context information between the client and server DataPortal objects.
This class provides an implementation of a deep clone of a complete object graph.
Definition: ObjectCloner.cs:20
ObjectCloner(ApplicationContext applicationContext)
Creates an instance of the type.
Definition: ObjectCloner.cs:27
static ObjectCloner GetInstance(ApplicationContext applicationContext)
Gets an instance of ObjectCloner.
Definition: ObjectCloner.cs:37
object Clone(object obj)
Clones an object.
Definition: ObjectCloner.cs:52
Defines an object that can serialize and deserialize object graphs.
void Serialize(System.IO.Stream serializationStream, object graph)
Converts an object graph into a byte stream.
object Deserialize(System.IO.Stream serializationStream)
Converts a serialization stream into an object graph.