Click or drag to resize

CopyForAnotherThread Class

Enables copying of IThreadAware objects for use in another thread.
Inheritance Hierarchy
System.Object
  AGI.Foundation.Infrastructure.CopyContext
    AGI.Foundation.Infrastructure.CopyForAnotherThread

Namespace:  AGI.Foundation.Infrastructure
Assembly:  AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 25.1.421.0 (25.1.421.0)
Syntax
public class CopyForAnotherThread : CopyContext

The CopyForAnotherThread type exposes the following members.

Constructors
  NameDescription
Public methodCopyForAnotherThread
Initializes a new instance of the CopyForAnotherThread class
Top
Methods
  NameDescription
Public methodAddObjectMapping<T>
Adds a mapping between an old object reference and a new one. The default implementation of UpdateReference<T> (T) will substitute newObject everywhere it encounters oldObject.
(Inherited from CopyContext.)
Public methodClearObjectMapping
Clears the list of mappings that has been created with calls to AddObjectMapping<T>(T, T). This is useful if you want to reuse a CopyContext instance for a separate copy operation.
(Inherited from CopyContext.)
Protected methodClone<T>
Copies the specified object using the ICloneWithContext interface or the ICloneable interface, with a preference on ICloneWithContext.
(Inherited from CopyContext.)
Public methodCloneIfNotMapped<T>
Looks for a mapping for this object that was added with AddObjectMapping<T>(T, T). If one is found, the object to which the specified one is mapped is returned. If one is not found, this method clones the given object by calling Clone<T>(T). Derived classes can override this default behavior.
(Inherited from CopyContext.)
Public methodStatic memberCode exampleCopy<T>
Copies an object for use in another thread.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetObjectMapping<T>
Gets the mapping for the specified object.
(Inherited from CopyContext.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUpdateReference<T>
Updates a given reference, returning a reference to use in its place.
(Overrides CopyContext.UpdateReference<T>(T).)
Top
Examples

The following example shows how to use this class to create a copy of an object that can be used simultaneously with the original from another thread:

C#
// An object that we need to copy for another thread. In this case, we are 
// copying an evaluator. 
AxesEvaluator axesEvaluator = GeometryTransformer.GetAxesTransformation(fromAxes, toAxes);

// Call the static Copy method.
AxesEvaluator copiedEvaluator = CopyForAnotherThread.Copy(axesEvaluator);
See Also