LEADTOOLS Barcode (Leadtools.Barcode assembly)
LEAD Technologies, Inc

Clone Method (BarcodeData)

Example 







Creates an exact copy of this barcode. .NET support Silverlight support
Syntax
public virtual object Clone()
'Declaration
 
Public Overridable Function Clone() As Object
'Usage
 
Dim instance As BarcodeData
Dim value As Object
 
value = instance.Clone()
public virtual object Clone()
ObjectiveC Syntax
 function Leadtools.Barcode.BarcodeData.Clone()
public:
virtual Object^ Clone(); 

Return Value

The BarcodeData method creates, and casts the barcode as an object.
Remarks

This methods clones (creates a new object) of the byte array that represents that data obtained from GetData. This data will not be shared between this BarcodeData and the object that is returned.

However, Tag is user defined value and BarcodeData does not have rules to dictate what action to perform when the object is cloned. Therefore, this method will simply set the Tag property of the returned object to the value in the source object. It is up to the user to change this behavior.

Example
Copy CodeCopy Code  
Public Sub BarcodeData_CloneExample()
   ' Create a BarcodeData object
   Dim data1 As New BarcodeData(BarcodeSymbology.UPCA, "01234567890")
   data1.Bounds = New LogicalRectangle(0, 0, 400, 200, LogicalUnit.Pixel)

   ' Clone it
   Dim data2 As BarcodeData = DirectCast(data1.Clone(), BarcodeData)

   ' Make sure they have the same value but not same reference
   Debug.Assert(Not data1 Is data2)
   Debug.Assert(data1.Symbology = data2.Symbology)
   Debug.Assert(data1.Value = data2.Value)
   Debug.Assert(data1.Bounds = data2.Bounds)

   Console.WriteLine("Cloned OK")
End Sub
public void BarcodeData_CloneExample()
{
   // Create a BarcodeData object
   BarcodeData data1 = new BarcodeData(BarcodeSymbology.UPCA, "01234567890");
   data1.Bounds = new LogicalRectangle(0, 0, 400, 200, LogicalUnit.Pixel);

   // Clone it
   BarcodeData data2 = data1.Clone() as BarcodeData;

   // Make sure they have the same value but not same reference
   Debug.Assert(data1 != data2);
   Debug.Assert(data1.Symbology == data2.Symbology);
   Debug.Assert(data1.Value == data2.Value);
   Debug.Assert(data1.Bounds == data2.Bounds);

   Console.WriteLine("Cloned OK");
}
[TestMethod]
public void BarcodeData_CloneExample()
{
   // Create a BarcodeData object
   BarcodeData data1 = new BarcodeData(BarcodeSymbology.UPCA, "01234567890");
   data1.Bounds = LeadRectHelper.Create(0, 0, 400, 200);
   // Clone it
   BarcodeData data2 = data1.Clone() as BarcodeData;

   // Make sure they have the same value but not same reference
   Debug.Assert(data1 != data2);
   Debug.Assert(data1.Symbology == data2.Symbology);
   Debug.Assert(data1.Value == data2.Value);
   Debug.Assert(LeadRectHelper.IsEqual(data1.Bounds, data2.Bounds));

   Debug.WriteLine("Cloned OK");
}
public void BarcodeData_CloneExample()
{
   // Create a BarcodeData object
   BarcodeData data1 = new BarcodeData(BarcodeSymbology.UPCA, "01234567890");
   data1.Bounds = new LogicalRectangle(0, 0, 400, 200, LogicalUnit.Pixel);
   // Clone it
   BarcodeData data2 = data1.Clone() as BarcodeData;

   // Make sure they have the same value but not same reference
   Debug.Assert(data1 != data2);
   Debug.Assert(data1.Symbology == data2.Symbology);
   Debug.Assert(data1.Value == data2.Value);
   Debug.Assert(data1.Bounds == data2.Bounds);

   Console.WriteLine("Cloned OK");
}
Public Sub BarcodeData_CloneExample()
  ' Create a BarcodeData object
  Dim data1 As BarcodeData = New BarcodeData(BarcodeSymbology.UPCA, "01234567890")
  data1.Bounds = New LogicalRectangle(0, 0, 400, 200, LogicalUnit.Pixel)
  ' Clone it
  Dim data2 As BarcodeData = TryCast(data1.Clone(), BarcodeData)

  ' Make sure they have the same value but not same reference
  Debug.Assert(Not data1 Is data2)
  Debug.Assert(data1.Symbology = data2.Symbology)
  Debug.Assert(data1.Value = data2.Value)
  Debug.Assert(data1.Bounds = data2.Bounds)

  Console.WriteLine("Cloned OK")
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

BarcodeData Class
BarcodeData Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features