/// <summary> /// Cloning constructor. /// </summary> /// <param name="source">The source object from which to clone.</param> /// <param name="context">The cloning context object.</param> protected MammogramAnnotationLayoutProxy(MammogramAnnotationLayoutProxy source, ICloningContext context) { context.CloneFields(source, this); // clone the annotation boxes with their state! if (source._annotationBoxes != null) { var annotationBoxes = new Dictionary <object, AnnotationBox>(); foreach (var sourceBox in source._annotationBoxes.Values) { var cloneBox = (AnnotationBox)CloneBuilder.Clone(sourceBox); // if the box has an item, use the item's identifier as the key object key = cloneBox; if (cloneBox.AnnotationItem != null) { key = cloneBox.AnnotationItem.GetIdentifier(); // if for some reason the key is a duplicate, use the box as the key (but keep it as part of the layout!) if (annotationBoxes.ContainsKey(key)) { key = cloneBox; } } annotationBoxes.Add(key, cloneBox); } _annotationBoxes = annotationBoxes; } }
public void Test() { try { SimpleCloneableObject simple = new SimpleCloneableObject(); TestDerivedClass.Cloning = false; TestDerivedClass test = new TestDerivedClass(); TestDerivedClass.Cloning = true; test.IgnoredValue = simple; test.Value = 4; test.TestField = 5; test.CloneableObject = simple; test.CopyReferenceObject = simple; TestDerivedClass clone = (TestDerivedClass)CloneBuilder.Clone(test); Assert.AreEqual(clone.IgnoredValue, null); Assert.AreEqual(test.Value, clone.Value); Assert.AreEqual(test.TestField, clone.TestField); Assert.AreEqual(clone.CloneInitializeCalled, true); Assert.AreEqual(clone.CloneCompleteCalled, true); Assert.AreSame(clone.CopyReferenceObject, simple); Assert.AreNotSame(clone.CloneableObject, simple); } finally { TestDerivedClass.Cloning = false; } }
//pixel data is not cloned. public PixelDataInfo Clone() { PixelDataInfo clone = (PixelDataInfo)CloneBuilder.Clone(this); clone.AspectRatio = new PixelAspectRatio(AspectRatio.Row, AspectRatio.Column); clone.PixelSpacing = new PixelSpacing(PixelSpacing.Row, PixelSpacing.Column); clone.ImagerPixelSpacing = new PixelSpacing(ImagerPixelSpacing.Row, ImagerPixelSpacing.Column); return(clone); }
public static CloneBuilder GetInstance() { if (instance == null) { instance = new CloneBuilder(); } return(instance); }
/// <summary> /// Creates a deep copy of the graphic. /// </summary> /// <remarks> /// Graphic3D objects that are not cloneable may return null. /// </remarks> public IGraphic3D Clone() { var clone = CloneBuilder.Clone(this) as IGraphic3D; if (clone != null && ImageViewer != null) { ImageViewer.EventBroker.OnCloneCreated(new CloneCreatedEventArgs(this, clone)); } return(clone); }
/// <summary> /// Cloning constructor. /// </summary> private ExtensionData(ExtensionData source, ICloningContext context) { _data = new Dictionary <Type, object>(); foreach (var sourceData in source._data) { var valueClone = CloneBuilder.Clone(sourceData.Value); if (valueClone != null) { _data[sourceData.Key] = valueClone; } } }
public void SubClassArray() { FieldCloneSubNodeModel model = new FieldCloneSubNodeModel(); model.Node = new FieldCloneNormalModel() { Age = 1, Name = "111" }; CloneBuilder <FieldCloneSubNodeModel> .CreateCloneDelegate(); var newModel = DeepClone <FieldCloneSubNodeModel> .Clone(model); Assert.Equal(model.Node.Name, newModel.Node.Name); Assert.Equal(model.Node.Age, newModel.Node.Age); }
public void clone(int sliceCount) { // pauseController.PauseGame(); GameController_v7.Instance.GetPauseController().Pause(); cloneObject = CloneBuilder.GetInstance().SpawnClone(this.gameObject, clonePosition, highlightColor, disabledColor, this.scaleReduction); // cloneObject.GetComponent<PartitionedClone> ().highlightColor = highlightColor; // cloneObject.GetComponent<PartitionedClone> ().disabledColor = disabledColor; Destroy(cloneObject.GetComponent <Rigidbody2D> ()); cloneObject.transform.position = new Vector3(0, gameObject.transform.localScale.y, cloneObject.transform.position.z); cloneObject.transform.SetPositionAndRotation(new Vector3(0, gameObject.transform.localScale.y, cloneObject.transform.position.z), Quaternion.identity); cloneObject.transform.localPosition = new Vector3(0, gameObject.transform.localScale.y, cloneObject.transform.position.z); partitionController.Partition(this, cloneObject, sliceCount); this.MatchScale(cloneObject); }
public void NotClassArray() { FieldCloneArrayModel model = new FieldCloneArrayModel(); model.Name = new string[10]; for (int i = 0; i < 10; i++) { model.Name[i] = i.ToString(); } CloneBuilder <FieldCloneArrayModel> .CreateCloneDelegate(); var newModel = DeepClone <FieldCloneArrayModel> .Clone(model); for (int i = 0; i < 10; i++) { Assert.Equal(model.Name[i], newModel.Name[i]); } }
/// <summary> /// Creates a deep copy of the <see cref="IPresentationImage"/>. /// </summary> /// <remarks> /// <see cref="IPresentationImage"/>s should never return null from this method. /// </remarks> public IPresentationImage Clone() { try { PresentationImage clone = CloneBuilder.Clone(this) as PresentationImage; if (clone != null) { clone.SceneGraph.SetParentPresentationImage(clone); if (ImageViewer != null) { ImageViewer.EventBroker.OnCloneCreated(new CloneCreatedEventArgs(this, clone)); } } return(clone); } catch (Exception e) { throw new PresentationImageCloningException(this, e); } }
public void PropClassCollectionArray() { PropCloneClassCollectionModel model = new PropCloneClassCollectionModel(); model.Nodes = new List <PropCloneNormalModel>(); for (int i = 0; i < 10; i++) { model.Nodes.Add(new PropCloneNormalModel() { Age = i, Name = i.ToString() }); } CloneBuilder <PropCloneClassCollectionModel> .CreateCloneDelegate(); var newModel = DeepClone <PropCloneClassCollectionModel> .Clone(model); for (int i = 0; i < 10; i++) { Assert.Equal(model.Nodes[i].Name, newModel.Nodes[i].Name); Assert.Equal(model.Nodes[i].Age, newModel.Nodes[i].Age); } }
/// <summary> /// Creates a deep copy of the <see cref="IDisplaySet"/>. /// </summary> /// <remarks> /// <see cref="IDisplaySet"/>s may not return null from this method. /// </remarks> public IDisplaySet Clone() { try { DisplaySet clone = CloneBuilder.Clone(this) as DisplaySet; //if (ParentImageSet != null) // ((ImageSet)ParentImageSet).AddCopy(clone); if (clone != null) { if (ImageViewer != null) { ImageViewer.EventBroker.OnCloneCreated(new CloneCreatedEventArgs(this, clone)); } } return(clone); } catch (Exception e) { throw new DisplaySetCloningException(this, e); } }
/// <summary> /// Cloning constructor. /// </summary> /// <param name="source">The source object from which to clone.</param> /// <param name="context">The cloning context object.</param> protected MammogramAnnotationLayoutProxy(MammogramAnnotationLayoutProxy source, ICloningContext context) { context.CloneFields(source, this); // clone the annotation boxes with their state! if (source._annotationBoxes != null) { var annotationBoxes = new Dictionary <object, AnnotationBox>(); foreach (var sourceBox in source._annotationBoxes.Values) { var cloneBox = (AnnotationBox)CloneBuilder.Clone(sourceBox); if (cloneBox.AnnotationItem != null) { annotationBoxes.Add(cloneBox.AnnotationItem.GetIdentifier(), cloneBox); } else { annotationBoxes.Add(cloneBox, cloneBox); } } _annotationBoxes = annotationBoxes; } }
public void ClassArray() { FieldCloneClassArrayModel model = new FieldCloneClassArrayModel(); model.Models = new FieldCloneNormalModel[10]; for (int i = 0; i < 10; i++) { model.Models[i] = new FieldCloneNormalModel() { Age = i, Name = i.ToString() }; } CloneBuilder <FieldCloneClassArrayModel> .CreateCloneDelegate(); var newModel = DeepClone <FieldCloneClassArrayModel> .Clone(model); for (int i = 0; i < 10; i++) { Assert.Equal(model.Models[i].Name, newModel.Models[i].Name); Assert.Equal(model.Models[i].Age, newModel.Models[i].Age); } }
public void PropNormal() { PropCloneNormalModel model = new PropCloneNormalModel(); model.Age = 1000; model.Name = "ababab"; model.Timer = DateTime.Now; model.money = 100000; model.Title = false; model.Id = 100000; CloneBuilder <PropCloneNormalModel> .CreateCloneDelegate(); var newModel = DeepClone <PropCloneNormalModel> .Clone(model); Assert.Equal(model.Id, newModel.Id); Assert.Equal(model.Title, newModel.Title); Assert.Equal(model.money, newModel.money); Assert.Equal(model.Timer, newModel.Timer); Assert.Equal(model.Age, newModel.Age); Assert.Equal(model.Name, newModel.Name); }
IDisplaySet IDisplaySet.Clone() { return((IDisplaySet)CloneBuilder.Clone(this)); }
public PatientInformation Clone() { return(CloneBuilder.Clone(this) as PatientInformation); }
/// <summary> /// Creates a deep clone of this <see cref="AnnotationLayout"/>. /// </summary> public AnnotationLayout Clone() { return(CloneBuilder.Clone(this) as AnnotationLayout); }
/// <summary> /// Creates a deep-copy of the <see cref="IColorMap"/>. /// </summary> /// <remarks> /// <see cref="IColorMap"/> implementations may return NULL from this method when appropriate. /// </remarks> public IColorMap Clone() { return(CloneBuilder.Clone(this) as IColorMap); }
/// <summary> /// Creates a deep-copy of the <see cref="IComposableLut"/>. /// </summary> /// <remarks> /// Implementations may return null from this method when appropriate. /// </remarks> public IComposableLut Clone() { return(CloneBuilder.Clone(this) as IComposableLut); }
/// <summary> /// Creates a deep clone of this instance. /// </summary> public SeriesData Clone() { return(CloneBuilder.Clone(this) as SeriesData); }
/// <summary> /// Clones a spatial transform. /// </summary> private static T CloneTransform <T>(T transform) where T : SpatialTransform { return((T)((IGraphic)CloneBuilder.Clone(transform.OwnerGraphic)).SpatialTransform); }
/// <summary> /// Creates a deep clone of this instance. /// </summary> public StudyData Clone() { return(CloneBuilder.Clone(this) as StudyData); }
public IDataLut Clone() { return(CloneBuilder.Clone(this) as IDataLut); }
/// <summary> /// Creates a deep copy of this strategy object. /// </summary> /// <remarks> /// Implementations should never return null from this method. /// </remarks> public IAnnotationCalloutLocationStrategy Clone() { return(CloneBuilder.Clone(this) as IAnnotationCalloutLocationStrategy); }
///<summary> /// Creates a copy of this object. ///</summary> public DisplaySetDescriptor Clone() { return((DisplaySetDescriptor)CloneBuilder.Clone(this)); }
IDisplaySet IDisplaySet.CreateFreshCopy() { return((IDisplaySet)CloneBuilder.Clone(this)); }
public IAnnotationLayout Clone() { return((IAnnotationLayout)CloneBuilder.Clone(this)); }