Пример #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="client">The client to use for checkouts.</param>
        internal CheckoutSystem(SalesForceClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            _client = client;
        }
Пример #2
0
        /// <summary>
        /// Save the package to file.
        /// </summary>
        /// <param name="client">The client to download files from.</param>
        public void Save(SalesForceClient client)
        {
            if (FileName == null)
            {
                throw new Exception("Can't save to file.  FileName is null.");
            }

            if (File.Exists(FileName))
            {
                File.Delete(FileName);
            }

            if (Manifest.Groups.Count == 0)
            {
                using (FileStream fs = new FileStream(FileName, FileMode.Create))
                {
                    using (ZipArchive zip = new ZipArchive(fs, ZipArchiveMode.Create))
                    {
                        ZipArchiveEntry zipEntry = zip.CreateEntry(IsDestructive ? "destructiveChanges.xml" : "package.xml");
                        using (Stream output = zipEntry.Open())
                            Manifest.Save(output);
                    }
                }
            }
            else if (IsDestructive)
            {
                using (FileStream fs = new FileStream(FileName, FileMode.Create))
                {
                    using (ZipArchive zip = new ZipArchive(fs, ZipArchiveMode.Create))
                    {
                        ZipArchiveEntry zipEntry = zip.CreateEntry("destructiveChanges.xml");
                        using (Stream output = zipEntry.Open())
                        {
                            Manifest.Save(output);
                        }

                        Manifest        empty        = new Manifest("package");
                        ZipArchiveEntry packageEntry = zip.CreateEntry("package.xml");
                        using (Stream packageOutput = packageEntry.Open())
                            empty.Save(packageOutput);
                    }
                }
            }
            else
            {
                if (client == null)
                {
                    throw new ArgumentNullException("client");
                }

                using (FileStream fs = new FileStream(FileName, FileMode.Create))
                {
                    byte[] bits = client.Meta.GetSourceFileContentAsPackage(Manifest);
                    fs.Write(bits, 0, bits.Length);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="client">The client to use.</param>
        internal DiagnosticSystem(SalesForceClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            _client = client;
        }