/// <summary>Create a new subspace from a binary prefix</summary>
 /// <param name="prefix">Prefix of the new subspace</param>
 /// <param name="encoding">Type System used to encode keys in this subspace</param>
 internal DynamicKeySubspace(Slice prefix, [NotNull] IKeyEncoding encoding)
     : base(prefix)
 {
     Contract.Requires(encoding != null);
     this.Encoding   = encoding;
     this.KeyEncoder = encoding.GetDynamicKeyEncoder();
     this.Keys       = new DynamicKeys(this, this.KeyEncoder);
     this.Partition  = new DynamicPartition(this);
 }
 internal FdbDirectoryPartition([NotNull] ITuple location, [NotNull] ITuple relativeLocation, Slice prefix, [NotNull] FdbDirectoryLayer directoryLayer, [NotNull] IKeyEncoding keyEncoding)
     : base(location, relativeLocation, prefix, new FdbDirectoryLayer(FromKey(prefix + FdbKey.Directory).AsDynamic(keyEncoding), FromKey(prefix).AsDynamic(keyEncoding), location), LayerId, keyEncoding)
 {
     this.ParentDirectoryLayer = directoryLayer;
 }
        internal FdbDirectorySubspace([NotNull] ITuple location, [NotNull] ITuple relativeLocation, Slice prefix, [NotNull] FdbDirectoryLayer directoryLayer, Slice layer, [NotNull] IKeyEncoding encoding)
            : base(prefix, encoding)
        {
            Contract.Requires(location != null && relativeLocation != null && prefix != null && directoryLayer != null);
            if (layer.IsNull)
            {
                layer = Slice.Empty;
            }

            this.DirectoryLayer   = directoryLayer;
            this.Location         = location;
            this.RelativeLocation = relativeLocation;
            this.Layer            = layer;
            this.Path             = location.ToArray <string>();

            Contract.Ensures(this.DirectoryLayer != null && this.Location != null && this.RelativeLocation != null && this.Path != null);
            Contract.Ensures(this.RelativeLocation.Count <= this.Location.Count && this.Location.EndsWith(this.RelativeLocation));
        }
 public static ITypedKeySubspace <T1, T2, T3, T4> AsTyped <T1, T2, T3, T4>([NotNull] this IKeySubspace subspace, [CanBeNull] IKeyEncoding encoding = null)
 {
     Contract.NotNull(subspace, nameof(subspace));
     return(new TypedKeySubspace <T1, T2, T3, T4>(subspace.GetPrefix(), (encoding ?? TuPack.Encoding).GetKeyEncoder <T1, T2, T3, T4>()));
 }
 public static IDynamicKeySubspace AsDynamic([NotNull] this IKeySubspace subspace, IKeyEncoding encoding = null)
 {
     Contract.NotNull(subspace, nameof(subspace));
     return(new DynamicKeySubspace(subspace.GetPrefix(), encoding ?? TuPack.Encoding));
 }
 public static DynamicKeySubspace Copy([NotNull] this IKeySubspace subspace, IKeyEncoding encoding)
 {
     Contract.NotNull(subspace, nameof(subspace));
     Contract.NotNull(encoding, nameof(encoding));
     return(new DynamicKeySubspace(StealPrefix(subspace), encoding));
 }
 /// <summary>Initializes a new subspace with the given binary <paramref name="prefix"/>, that uses a typed key <paramref name="encoding"/>.</summary>
 /// <returns>A subspace that can handle composite keys of type (<typeparamref name="T1"/>, <typeparamref name="T2"/>).</returns>
 public static TypedKeySubspace <T1, T2> CreateTyped <T1, T2>(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
 {
     return(new TypedKeySubspace <T1, T2>(prefix, (encoding ?? TuPack.Encoding).GetKeyEncoder <T1, T2>()));
 }
 public static DynamicKeySubspace CreateDynamic(Slice prefix, [CanBeNull] IKeyEncoding encoding = null)
 {
     return(new DynamicKeySubspace(prefix, (encoding ?? TuPack.Encoding).GetDynamicKeyEncoder()));
 }