Example #1
0
        public static ShardKey <TRecord> FromExternalString(string value)
        {
            var     aValues  = StringExtensions.SerializeFromExternalString(value);
            short   shardId  = 0;
            TRecord recordId = default(TRecord);

            int orgnLen = aValues[0] & 3;
            var orgn    = System.Text.Encoding.UTF8.GetString(aValues, 1, orgnLen)[0];
            var pos     = orgnLen + 1;

            shardId  = ConvertFromBytes(aValues, ref pos, typeof(short));
            recordId = ConvertFromBytes(aValues, ref pos, typeof(TRecord));
            return(new ShardKey <TRecord>(orgn, shardId, recordId));
        }
Example #2
0
        public static ShardKey <TRecord, TChild, TGrandChild, TGreatGrandChild> FromExternalString(string value)
        {
            var aValues = StringExtensions.SerializeFromExternalString(value);

            int orgnLen = aValues[0] & 3;
            var orgn    = System.Text.Encoding.UTF8.GetString(aValues, 1, orgnLen)[0];
            var pos     = orgnLen + 1;

            short shardId = ShardKey <TRecord> .ConvertFromBytes(aValues, ref pos, typeof(short));

            TRecord recordId = ShardKey <TRecord> .ConvertFromBytes(aValues, ref pos, typeof(TRecord));

            TChild childId = ShardKey <TRecord> .ConvertFromBytes(aValues, ref pos, typeof(TChild));

            TGrandChild grandChildId = ShardKey <TRecord> .ConvertFromBytes(aValues, ref pos, typeof(TGrandChild));

            TGreatGrandChild greatGrandChildId = ShardKey <TRecord> .ConvertFromBytes(aValues, ref pos, typeof(TGreatGrandChild));

            return(new ShardKey <TRecord, TChild, TGrandChild, TGreatGrandChild>(orgn, shardId, recordId, childId, grandChildId, greatGrandChildId));
        }