ClonableObject.ClonableObjClass.Assign C# (CSharp) Méthode

Assign() public méthode

Assigns the properties of src to the receiver.
public Assign ( IClone src ) : void
src IClone
Résultat void
    public void Assign(IClone src)
    {
      //1. make sure that src is pointing to a valid object
      if (null == src)
      {
        throw new COMException("Invalid objact.");
      }

      //2. make sure that the type of src is of type 'ClonableObjClass'
      if (!(src is ClonableObjClass))
      {
        throw new COMException("Bad object type.");
      }

      //3. assign the properties of src to the current instance
      ClonableObjClass srcClonable = (ClonableObjClass)src;
      m_name = srcClonable.Name;
      m_version = srcClonable.Version;
      m_ID = new Guid(srcClonable.ID.ToString());

      //don't clone the spatial reference, since in this case we want both object to 
      //reference the same spatial reference (for example like features in a featureclass 
      //which share the same spatial reference)
      m_spatialRef = srcClonable.SpatialReference;

      //clone the point. Use deep cloning 
      if (null == srcClonable.Point)
        m_point = null;
      else
      {
        IObjectCopy objectCopy = new ObjectCopyClass();
        object obj = objectCopy.Copy((object)srcClonable.Point);
        m_point = (IPoint)obj;
      }

      m_arr = (ArrayList)srcClonable.ManagedArray.Clone();
    }

Usage Example

Exemple #1
0
        /// <summary>
        /// Clones the receiver and assigns the result to clonee.
        /// <returns></returns>
        public IClone Clone()
        {
            //create a new instance of the object
            ClonableObjClass obj = new ClonableObjClass();

            //assign the properties of the new object with the current object's properties.
            //according to each 'Ref' property, the user need to decide whether to use deep cloning
            //or shallow cloning.
            obj.Assign(this);

            return((IClone)obj);
        }
All Usage Examples Of ClonableObject.ClonableObjClass::Assign