コード例 #1
0
        /// <summary>
        /// Checks whether a clone is successful and returns the cloned object.
        /// </summary>
        /// <param name="the_cloneable">the object to clone.</param>
        /// <returns>the new cloned object.</returns>
        public static Cloneable cloneCheck(Cloneable the_cloneable)
        {
            Cloneable clone = (Cloneable)the_cloneable.clone();

            //this check removes the chance of a programmer building a cloneable that
            //returns a reference to itself
            //this check ensures that after object.clone() is called, only a disconnected
            //object is returned
            if (the_cloneable == clone)
            {
                throw new ArgumentException("Clone method returns reference to the same object.");
            }

            return(clone);
        }
コード例 #2
0
        static void sheep()
        {
            Cloneable sheep = new Sheep();

            Console.Write("\nCounting Sheep...\n\n");

            CountUtil.count(sheep, 2);

            Console.Write("\n");

            Cloneable sheepClone = sheep.cloneAnimal(sheep);

            CountUtil.count(sheepClone, 3);

            Console.Write("\n");

            sheep.resetCount();
            CountUtil.count(sheep, 1);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Countable objAlligator = new Alligator();

            Console.WriteLine("Counting Alligator...");
            CountUtil.count(objAlligator, 4);
            Console.WriteLine("\n");
            Cloneable objSheep = new Sheep();

            Console.WriteLine("Counting Sheep...");


            CountUtil.count(objSheep, 3);
            Console.WriteLine("\n");
            Cloneable sheepDuplicate = objSheep.cloneAnimal(objSheep);

            CountUtil.count(sheepDuplicate, 3);
            Console.WriteLine("\n");
            objSheep.resetCount();

            CountUtil.count(objSheep, 1);
        }
 protected override void CloneOverride(Cloneable source)
 {
     // Copy all properties from source to 'this' description.
 }
コード例 #5
0
 protected override void CloneCore(Cloneable source)
 {
 }
        protected override void CloneOverride(Cloneable source)
        {

        }
コード例 #7
0
 protected override void CloneOverride(Cloneable source)
 {
     // Copy all properties from source to 'this' description is applicable.
 }
コード例 #8
0
        protected override void CloneCore(Cloneable source)
        {
            var delegateGroupFilter = source as DelegateGroupFilter;

            this.FilterImpl = delegateGroupFilter.FilterImpl;
        }
コード例 #9
0
ファイル: SortDescription.cs プロジェクト: zyhong/UI-For-UWP
 /// <summary>
 /// Makes the instance a clone (deep copy) of the specified <see cref="Telerik.Data.Core.Cloneable"/>.
 /// </summary>
 /// <param name="source">The object to clone.</param>
 /// <remarks>Notes to Inheritors
 /// If you derive from <see cref="Telerik.Data.Core.Cloneable"/>, you need to override this method to copy all properties.
 /// It is essential that all implementations call the base implementation of this method (if you don't call base you should manually copy all needed properties including base properties).
 /// </remarks>
 protected abstract void CloneOverride(Cloneable source);
コード例 #10
0
 protected override void CloneOverride(Cloneable source)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
 Cloneable Cloneable.cloneAnimal(Cloneable animal)
 {
     animal = new Sheep();
     animal.setCloneName("Dolly");
     return(animal);
 }