Ejemplo n.º 1
0
        public static PartitionMap CreateFrom(byte[] buffer, int offset)
        {
            PartitionMap result = null;

            byte type = buffer[offset];
            if (type == 1)
            {
                result = new Type1PartitionMap();
            }
            else if (type == 2)
            {
                EntityIdentifier id = Utilities.ToStruct<UdfEntityIdentifier>(buffer, offset + 4);
                switch (id.Identifier)
                {
                    case "*UDF Virtual Partition":
                        result = new VirtualPartitionMap();
                        break;
                    case "*UDF Sparable Partition":
                        result = new SparablePartitionMap();
                        break;
                    case "*UDF Metadata Partition":
                        result = new MetadataPartitionMap();
                        break;
                    default:
                        throw new InvalidDataException("Unrecognized partition map entity id: " + id);
                }
            }

            if (result != null)
            {
                result.ReadFrom(buffer, offset);
            }

            return result;
        }
Ejemplo n.º 2
0
        public static PartitionMap CreateFrom(byte[] buffer, int offset)
        {
            PartitionMap result = null;

            byte type = buffer[offset];

            if (type == 1)
            {
                result = new Type1PartitionMap();
            }
            else if (type == 2)
            {
                EntityIdentifier id = Utilities.ToStruct <UdfEntityIdentifier>(buffer, offset + 4);
                switch (id.Identifier)
                {
                case "*UDF Virtual Partition":
                    result = new VirtualPartitionMap();
                    break;

                case "*UDF Sparable Partition":
                    result = new SparablePartitionMap();
                    break;

                case "*UDF Metadata Partition":
                    result = new MetadataPartitionMap();
                    break;

                default:
                    throw new InvalidDataException("Unrecognized partition map entity id: " + id);
                }
            }

            if (result != null)
            {
                result.ReadFrom(buffer, offset);
            }

            return(result);
        }