No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

BytePtr.cs

Description du code

BytePtr.cs est un fichier du projet BiblioBrol.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/src/.

Projet BiblioBrol :

Gestion de media en CSharp.

Pour plus d'infos, vous pouvez consulter la brève analyse.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5.  
  6. namespace be.gaudry.bibliobrol.model.eid
  7. {
  8. public struct BytePtr
  9. {
  10. private IntPtr data;
  11.  
  12. public BytePtr(byte[] data)
  13. : this((data != null) ? data : null, 0, (data != null) ? data.Length : 0)
  14. {
  15.  
  16. }
  17. public BytePtr(byte[] data, int offset, int count)
  18. {
  19. // allocate
  20. this.data = (data == null) ? IntPtr.Zero : Memory.ByteToHLocal(data, offset, count);
  21. }
  22.  
  23.  
  24. public BytePtr(int size)
  25. {
  26. // allocate
  27. this.data = Memory.AllocHLocal(size);
  28. }
  29.  
  30. public override string ToString()
  31. {
  32. // return
  33. return data.ToString();
  34. }
  35.  
  36. public IntPtr Handle
  37. {
  38. get
  39. {
  40. // return value
  41. return this.data;
  42. }
  43. }
  44. public void Free()
  45. {
  46. // free
  47. Memory.FreeHLocal(this.data);
  48. }
  49.  
  50. public static BytePtr Zero
  51. {
  52. get
  53. {
  54. // return empty version
  55. return new BytePtr(null);
  56. }
  57. }
  58. public static bool operator ==(BytePtr v1, BytePtr v2)
  59. {
  60. // check
  61. return v1.Equals(v2);
  62. }
  63. public static bool operator !=(BytePtr v1, BytePtr v2)
  64. {
  65. // check
  66. return !v1.Equals(v2);
  67. }
  68. public override bool Equals(object obj)
  69. {
  70. // check if it is an instance
  71. return ((obj is BytePtr) && ((BytePtr)obj).data.Equals(this.data));
  72. }
  73. public override int GetHashCode()
  74. {
  75. // return hash code of data block
  76. return data.GetHashCode();
  77. }
  78. public static void Free(BytePtr ptr)
  79. {
  80. // check if zero
  81. if (BytePtr.Zero != ptr)
  82. {
  83. // free it
  84. ptr.Free();
  85. }
  86. }
  87.  
  88.  
  89.  
  90.  
  91. public static byte[] Free(BytePtr ptr, int length)
  92. {
  93. // declare
  94. byte[] result = null;
  95. // check if zero
  96. if (BytePtr.Zero != ptr)
  97. {
  98. // convert to array
  99. result = ptr.ToArray(length);
  100. // free it
  101. ptr.Free();
  102. }
  103. // return result
  104. return result;
  105. }
  106.  
  107. public byte[] ToArray(int length)
  108. {
  109. // declare result
  110. byte[] result = null;
  111. // check if zer
  112. if (this.data != IntPtr.Zero)
  113. {
  114. // allocate
  115. result = new byte[length];
  116. // copy
  117. Marshal.Copy(this.data, result, 0, Convert.ToInt32(length));
  118. }
  119. // return result
  120. return result;
  121. }
  122. public void Dispose()
  123. {
  124. // just free
  125. Free();
  126. }
  127. }
  128. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/src/model/eid/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1716068740 18/05/2024 23:45:40
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/src/model/eid/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csEidAdapter.cs27.46 Ko31/10/2018 18:32:54-refusé-
Afficher le fichier .cs|.csMemory.cs4.31 Ko31/10/2018 18:32:54-refusé-
Afficher le fichier .cs|.csBytePtr.cs3.12 Ko31/10/2018 18:32:54-refusé-
Afficher le fichier .cs|.csStringPtr.cs1.81 Ko31/10/2018 18:32:55-refusé-
Afficher le fichier .cs|.csEidPerson.cs171 octets31/10/2018 18:32:54-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-bibliobrol-source-rf-model/eid/BytePtr.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.