Esempio n. 1
0
        public static OpenBond.PipBuildRequest ToOpenBond(this PipBuildRequest message)
        {
            var hashes = new List <OpenBond.FileArtifactKeyedHash>();

            foreach (var i in message.Hashes)
            {
                var directories = new List <OpenBond.BondDirectoryArtifact>();

                if (i.AssociatedDirectories != null)
                {
                    foreach (var j in i.AssociatedDirectories)
                    {
                        directories.Add(new OpenBond.BondDirectoryArtifact()
                        {
                            DirectoryPathValue      = j.DirectoryPathValue,
                            DirectorySealId         = j.DirectorySealId,
                            IsDirectorySharedOpaque = j.IsDirectorySharedOpaque
                        });
                    }
                }

                hashes.Add(new OpenBond.FileArtifactKeyedHash()
                {
                    AssociatedDirectories = directories,
                    ContentHash           = i.ContentHash.ToBondContentHash(),
                    FileName           = i.FileName,
                    Length             = i.Length,
                    PathString         = i.PathString,
                    PathValue          = i.PathValue,
                    ReparsePointTarget = i.ReparsePointTarget,
                    ReparsePointType   = (Cache.Fingerprints.BondReparsePointType)((int)i.ReparsePointType),
                    RewriteCount       = i.RewriteCount
                });
            }

            var pips = new List <OpenBond.SinglePipBuildRequest>();

            foreach (var i in message.Pips)
            {
                pips.Add(new OpenBond.SinglePipBuildRequest()
                {
                    ActivityId         = i.ActivityId,
                    ExpectedRamUsageMb = i.ExpectedRamUsageMb,
                    Fingerprint        = i.Fingerprint.ToCacheFingerprint(),
                    PipIdValue         = i.PipIdValue,
                    Priority           = i.Priority,
                    SequenceNumber     = i.SequenceNumber,
                    Step = i.Step,
                });
            }

            return(new OpenBond.PipBuildRequest()
            {
                BuildId = message.BuildId,
                SenderId = message.SenderId,
                SenderName = message.SenderName,
                Hashes = hashes,
                Pips = pips
            });
        }
Esempio n. 2
0
        public static PipBuildRequest ToInternalBond(this OpenBond.PipBuildRequest message)
        {
            var pipBuildRequest = new PipBuildRequest();

            pipBuildRequest.Hashes = new List <FileArtifactKeyedHash>();

            foreach (var hash in message.Hashes)
            {
                var fileArtifactKeyedHash = new FileArtifactKeyedHash()
                {
                    ContentHash        = hash.ContentHash.ToDistributedContentHash(),
                    FileName           = hash.FileName,
                    Length             = hash.Length,
                    PathString         = hash.PathString,
                    PathValue          = hash.PathValue,
                    ReparsePointType   = (BondReparsePointType)hash.ReparsePointType,
                    RewriteCount       = hash.RewriteCount,
                    ReparsePointTarget = hash.ReparsePointTarget,
                };

                if (hash.AssociatedDirectories != null)
                {
                    fileArtifactKeyedHash.AssociatedDirectories = new List <BondDirectoryArtifact>();

                    foreach (var dir in hash.AssociatedDirectories)
                    {
                        fileArtifactKeyedHash.AssociatedDirectories.Add(new BondDirectoryArtifact()
                        {
                            DirectoryPathValue      = dir.DirectoryPathValue,
                            DirectorySealId         = dir.DirectorySealId,
                            IsDirectorySharedOpaque = dir.IsDirectorySharedOpaque,
                        });
                    }
                }

                pipBuildRequest.Hashes.Add(fileArtifactKeyedHash);
            }

            pipBuildRequest.Pips = new List <SinglePipBuildRequest>();

            foreach (var pip in message.Pips)
            {
                var singlePipBuildRequest = new SinglePipBuildRequest()
                {
                    ActivityId         = pip.ActivityId,
                    ExpectedRamUsageMb = pip.ExpectedRamUsageMb,
                    Fingerprint        = pip.Fingerprint.ToDistributionCacheFingerprint(),
                    PipIdValue         = pip.PipIdValue,
                    Priority           = pip.Priority,
                    SequenceNumber     = pip.SequenceNumber,
                    Step = pip.Step
                };

                pipBuildRequest.Pips.Add(singlePipBuildRequest);
            }

            return(pipBuildRequest);
        }