Beispiel #1
0
        private void Serialize(ref SerializationWriter mySerializationWriter, DirectoryEntry myDirectoryEntry)
        {
            try
            {

                #region Write the InlineData

                mySerializationWriter.Write(myDirectoryEntry._InlineData);

                #endregion

                #region Write the INodePositions

                mySerializationWriter.WriteUInt32((UInt32)myDirectoryEntry.INodePositions.Count);

                foreach (var _ExtendedPosition in myDirectoryEntry.INodePositions)
                {
                    _ExtendedPosition.StorageUUID.Serialize(ref mySerializationWriter);
                    mySerializationWriter.WriteUInt64(_ExtendedPosition.Position);
                }

                #endregion

                #region Write the ObjectStreamsList

                mySerializationWriter.WriteUInt32((UInt32)myDirectoryEntry.ObjectStreamsList.Count);

                foreach (var _ObjectStreamType in myDirectoryEntry.ObjectStreamsList)
                    mySerializationWriter.WriteString(_ObjectStreamType);

                #endregion

                myDirectoryEntry.isDirty = false;

            }

            catch (SerializationException e)
            {
                throw new SerializationException(e.Message);
            }
        }
Beispiel #2
0
        public DirectoryEntry Clone()
        {
            var newEntry = new DirectoryEntry();

            if (_InlineData != null)
            {
                newEntry._InlineData = new Byte[_InlineData.Length];
                _InlineData.CopyTo(newEntry._InlineData, 0);
            }

            if (_INodePositions != null)
            {

                newEntry._INodePositions = new HashSet<ExtendedPosition>();

                foreach (var _ExtendedPosition in _INodePositions)
                    newEntry._INodePositions.Add(new ExtendedPosition(_ExtendedPosition.StorageUUID, _ExtendedPosition.Position));

            }

            newEntry._isDirty   = _isDirty;

            if (_ObjectStreamsList != null)
            {

                newEntry._ObjectStreamsList = new HashSet<String>();

                foreach (var _ObjectStream in _ObjectStreamsList)
                    newEntry._ObjectStreamsList.Add(_ObjectStream);

            }

            return newEntry;
        }
Beispiel #3
0
        private object Deserialize(ref SerializationReader mySerializationReader, DirectoryEntry myDirectoryEntry)
        {
            try
            {

                #region Read the Inlinedata

                myDirectoryEntry._InlineData = mySerializationReader.ReadByteArray();

                #endregion

                #region Read the INodePositions

                var _NumOfINodePositions = mySerializationReader.ReadUInt32();

                if (_NumOfINodePositions > 0)
                {
                    for (var j = 0UL; j < _NumOfINodePositions; j++)
                    {
                        StorageUUID ID = new StorageUUID();
                        ID.Deserialize(ref mySerializationReader);
                        myDirectoryEntry._INodePositions.Add(new ExtendedPosition(ID, mySerializationReader.ReadUInt64()));
                    }
                }

                #endregion

                #region Read the ObjectStreamsList

                var _NumberOfObjectStreamTypes = mySerializationReader.ReadUInt32();

                if (_NumberOfObjectStreamTypes > 0)
                {
                    for (var j = 0UL; j < _NumberOfObjectStreamTypes; j++)
                        myDirectoryEntry._ObjectStreamsList.Add(mySerializationReader.ReadString());
                }

                #endregion

            }

            catch (GraphFSException e)
            {
                throw new GraphFSException("DirectoryEntry could not be deserialized!\n\n" + e);
            }

            myDirectoryEntry.isDirty = true;

            return myDirectoryEntry;
        }
Beispiel #4
0
        private object Deserialize(ref SerializationReader mySerializationReader, DirectoryEntry myDirectoryEntry)
        {
            try
            {

                #region Read the Inlinedata

                myDirectoryEntry._InlineData = mySerializationReader.ReadByteArray();

                #region Estimated Size

                if (myDirectoryEntry._InlineData != null)
                {
                    myDirectoryEntry._estimatedSize += Convert.ToUInt64(myDirectoryEntry._InlineData.Length) * EstimatedSizeConstants.Byte;
                }

                #endregion

                #endregion

                #region Read the INodePositions

                #region Estimated Size

                myDirectoryEntry._estimatedSize += EstimatedSizeConstants.HashSet;

                #endregion

                var _NumOfINodePositions = mySerializationReader.ReadUInt32();

                if (_NumOfINodePositions > 0)
                {
                    for (var j = 0UL; j < _NumOfINodePositions; j++)
                    {
                        StorageUUID ID = new StorageUUID();
                        ID.Deserialize(ref mySerializationReader);
                        myDirectoryEntry._INodePositions.Add(new ExtendedPosition(ID, mySerializationReader.ReadUInt64()));

                        #region Estimated Size

                        myDirectoryEntry._estimatedSize += EstimatedSizeConstants.ExtendedPosition;

                        #endregion

                    }
                }

                #endregion

                #region Read the ObjectStreamsList

                #region Estimated Size

                myDirectoryEntry._estimatedSize += EstimatedSizeConstants.HashSet;

                #endregion

                var _NumberOfObjectStreamTypes = mySerializationReader.ReadUInt32();

                if (_NumberOfObjectStreamTypes > 0)
                {
                    for (var j = 0UL; j < _NumberOfObjectStreamTypes; j++)
                    {
                        myDirectoryEntry._ObjectStreamsList.Add(mySerializationReader.ReadString());

                        #region Estimated Size

                        myDirectoryEntry._estimatedSize += EstimatedSizeConstants.Char * EstimatedSizeConstants.EstimatedObjectStreamNameLength;

                        #endregion

                    }
                }

                #endregion

            }

            catch (GraphFSException e)
            {
                throw new GraphFSException("DirectoryEntry could not be deserialized!\n\n" + e);
            }

            myDirectoryEntry.isDirty = true;

            return myDirectoryEntry;
        }