/// <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;
            }
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        //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);
        }
Пример #4
0
    public static CloneBuilder GetInstance()
    {
        if (instance == null)
        {
            instance = new CloneBuilder();
        }

        return(instance);
    }
Пример #5
0
        /// <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);
        }
Пример #6
0
 /// <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;
         }
     }
 }
Пример #7
0
        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);
        }
Пример #8
0
    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);
    }
Пример #9
0
        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]);
            }
        }
Пример #10
0
        /// <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);
            }
        }
Пример #11
0
        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);
            }
        }
Пример #12
0
        /// <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);
            }
        }
Пример #13
0
        /// <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;
            }
        }
Пример #14
0
        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);
            }
        }
Пример #15
0
        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);
        }
Пример #16
0
 IDisplaySet IDisplaySet.Clone()
 {
     return((IDisplaySet)CloneBuilder.Clone(this));
 }
Пример #17
0
 public PatientInformation Clone()
 {
     return(CloneBuilder.Clone(this) as PatientInformation);
 }
Пример #18
0
 /// <summary>
 /// Creates a deep clone of this <see cref="AnnotationLayout"/>.
 /// </summary>
 public AnnotationLayout Clone()
 {
     return(CloneBuilder.Clone(this) as AnnotationLayout);
 }
Пример #19
0
 /// <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);
 }
Пример #20
0
 /// <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);
 }
Пример #21
0
 /// <summary>
 /// Creates a deep clone of this instance.
 /// </summary>
 public SeriesData Clone()
 {
     return(CloneBuilder.Clone(this) as SeriesData);
 }
Пример #22
0
 /// <summary>
 /// Clones a spatial transform.
 /// </summary>
 private static T CloneTransform <T>(T transform) where T : SpatialTransform
 {
     return((T)((IGraphic)CloneBuilder.Clone(transform.OwnerGraphic)).SpatialTransform);
 }
Пример #23
0
 /// <summary>
 /// Creates a deep clone of this instance.
 /// </summary>
 public StudyData Clone()
 {
     return(CloneBuilder.Clone(this) as StudyData);
 }
Пример #24
0
 public IDataLut Clone()
 {
     return(CloneBuilder.Clone(this) as IDataLut);
 }
Пример #25
0
 /// <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);
 }
Пример #26
0
 ///<summary>
 /// Creates a copy of this object.
 ///</summary>
 public DisplaySetDescriptor Clone()
 {
     return((DisplaySetDescriptor)CloneBuilder.Clone(this));
 }
Пример #27
0
 IDisplaySet IDisplaySet.CreateFreshCopy()
 {
     return((IDisplaySet)CloneBuilder.Clone(this));
 }
Пример #28
0
 public IAnnotationLayout Clone()
 {
     return((IAnnotationLayout)CloneBuilder.Clone(this));
 }