This class is used to generate the token by atomic increase the token by 1.
Пример #1
0
            /// <summary>
            /// This method is used to build a root node object from a byte array.
            /// </summary>
            /// <param name="fileContent">Specify the byte array.</param>
            /// <returns>Return a root node object build from the byte array.</returns>
            public IntermediateNodeObject Build(byte[] fileContent)
            {
                IntermediateNodeObject rootNode = new IntermediateNodeObject();

                rootNode.Signature                  = new SignatureObject();
                rootNode.DataSize                   = new DataSizeObject();
                rootNode.DataSize.DataSize          = (ulong)fileContent.Length;
                rootNode.ExGuid                     = new ExGuid(SequenceNumberGenerator.GetCurrentSerialNumber(), Guid.NewGuid());
                rootNode.IntermediateNodeObjectList = ChunkingFactory.CreateChunkingInstance(fileContent).Chunking();
                return(rootNode);
            }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the DataElement class.
        /// </summary>
        /// <param name="type">data element type</param>
        /// <param name="data">Specifies the data of the element.</param>
        public DataElement(DataElementType type, DataElementData data)
            : base(StreamObjectTypeHeaderStart.DataElement)
        {
            if (!dataElementDataTypeMapping.Keys.Contains(type))
            {
                throw new InvalidOperationException("Invalid argument type value" + (int)type);
            }

            this.DataElementType         = type;
            this.Data                    = data;
            this.DataElementExtendedGUID = new ExGuid(SequenceNumberGenerator.GetCurrentSerialNumber(), Guid.NewGuid());
            this.SerialNumber            = new SerialNumber(Guid.NewGuid(), SequenceNumberGenerator.GetCurrentSerialNumber());
        }
Пример #3
0
            /// <summary>
            /// This method is used to build intermediate node object from a byte array with a signature.
            /// </summary>
            /// <param name="array">Specify the byte array.</param>
            /// <param name="signature">Specify the signature.</param>
            /// <returns>Return the intermediate node object.</returns>
            public LeafNodeObject Build(byte[] array, SignatureObject signature)
            {
                LeafNodeObject nodeObject = new LeafNodeObject();

                nodeObject.DataSize          = new DataSizeObject();
                nodeObject.DataSize.DataSize = (ulong)array.Length;

                nodeObject.Signature = signature;
                nodeObject.ExGuid    = new ExGuid(SequenceNumberGenerator.GetCurrentSerialNumber(), Guid.NewGuid());

                nodeObject.DataNodeObjectData         = new DataNodeObjectData(array, 0, array.Length);
                nodeObject.IntermediateNodeObjectList = null;

                // Now in the current implementation, one intermediate node only contain one single data object node.
                return(nodeObject);
            }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the DataNodeObjectData class.
 /// </summary>
 internal DataNodeObjectData()
 {
     this.ExGuid = new ExGuid(SequenceNumberGenerator.GetCurrentSerialNumber(), Guid.NewGuid());
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the CellKnowledgeEntry class.
 /// </summary>
 public CellKnowledgeEntry()
     : base(StreamObjectTypeHeaderStart.CellKnowledgeEntry)
 {
     this.SerialNumber = new SerialNumber(System.Guid.NewGuid(), SequenceNumberGenerator.GetCurrentSerialNumber());
 }
        /// <summary>
        /// This method is used to create the storage index data element.
        /// </summary>
        /// <param name="manifestExGuid">Specify the storage manifest data element extended GUID.</param>
        /// <param name="cellIDMappings">Specify the mapping of cell manifest.</param>
        /// <param name="revisionIDMappings">Specify the mapping of revision manifest.</param>
        /// <returns>Return the storage index data element.</returns>
        public static DataElement CreateStorageIndexDataElement(ExGuid manifestExGuid, Dictionary <CellID, ExGuid> cellIDMappings, Dictionary <ExGuid, ExGuid> revisionIDMappings)
        {
            StorageIndexDataElementData data = new StorageIndexDataElementData();

            data.StorageIndexManifestMapping = new StorageIndexManifestMapping();
            data.StorageIndexManifestMapping.ManifestMappingExtendedGUID = new ExGuid(manifestExGuid);
            data.StorageIndexManifestMapping.ManifestMappingSerialNumber = new SerialNumber(System.Guid.NewGuid(), SequenceNumberGenerator.GetCurrentSerialNumber());

            foreach (KeyValuePair <CellID, ExGuid> kv in cellIDMappings)
            {
                StorageIndexCellMapping cellMapping = new StorageIndexCellMapping();
                cellMapping.CellID = kv.Key;
                cellMapping.CellMappingExtendedGUID = kv.Value;
                cellMapping.CellMappingSerialNumber = new SerialNumber(System.Guid.NewGuid(), SequenceNumberGenerator.GetCurrentSerialNumber());
                data.StorageIndexCellMappingList.Add(cellMapping);
            }

            foreach (KeyValuePair <ExGuid, ExGuid> kv in revisionIDMappings)
            {
                StorageIndexRevisionMapping revisionMapping = new StorageIndexRevisionMapping();
                revisionMapping.RevisionExtendedGUID        = kv.Key;
                revisionMapping.RevisionMappingExtendedGUID = kv.Value;
                revisionMapping.RevisionMappingSerialNumber = new SerialNumber(Guid.NewGuid(), SequenceNumberGenerator.GetCurrentSerialNumber());
                data.StorageIndexRevisionMappingList.Add(revisionMapping);
            }

            return(new DataElement(DataElementType.StorageIndexDataElementData, data));
        }