public Builder(
     string pName
     , BlobID pBlobID
     )
 {
     this.Name   = pName;
     this.BlobID = pBlobID;
 }
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string strValue = value as string;

            if (strValue != null)
            {
                return(BlobID.TryParse(strValue).Value);
            }

            return(base.ConvertFrom(context, culture, value));
        }
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (typeof(string) == destinationType)
            {
                return(((BlobID)value).ToString());
            }
            else if (typeof(Errorable <BlobID>) == destinationType)
            {
                string strValue = value as string;
                if (strValue != null)
                {
                    return(BlobID.TryParse(strValue));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
        public static BlobID ComputeID(Stream m)
        {
            // SHA1 instances are NOT thread-safe.
            SHA1 sh = SHA1.Create();

            const int bufsize = 8040 * 8 * 4;

            byte[] dum   = new byte[bufsize];
            int    count = bufsize;

            while ((count = m.Read(dum, 0, bufsize)) > 0)
            {
                sh.TransformBlock(dum, 0, count, null, 0);
            }
            sh.TransformFinalBlock(dum, 0, 0);

            byte[] hash = sh.Hash;

            BlobID id = new BlobID(hash);

            return(id);
        }
 public Builder(TreeBlobReference imm)
 {
     this.Name   = imm.Name;
     this.BlobID = imm.BlobID;
 }
 public TreeBlobReference(Builder b)
 {
     this.Name   = b.Name;
     this.BlobID = b.BlobID;
 }
Exemplo n.º 7
0
 public CanonicalBlobIDPath(CanonicalBlobPath path, BlobID blobID)
 {
     this.Path   = path;
     this.BlobID = blobID;
 }