Exemple #1
0
        public override bool Execute()
        {
            if (!ValidateInputs())
            {
                return(false);
            }

            if (String.IsNullOrEmpty(Version))
            {
                OutputVersion = "1.0.0.0";
            }
            else if (Version.EndsWith("*", StringComparison.Ordinal))
            {
                OutputVersion = Version.Substring(0, Version.Length - 1) + Revision.ToString("G", CultureInfo.InvariantCulture);
            }
            else
            {
                OutputVersion = Version;
            }

            if (_formatType == _FormatType.Path)
            {
                OutputVersion = OutputVersion.Replace('.', '_');
            }
            return(true);
        }
Exemple #2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (FileId != null)
         {
             hashCode = hashCode * 59 + FileId.GetHashCode();
         }
         hashCode = hashCode * 59 + OutputVersion.GetHashCode();
         hashCode = hashCode * 59 + ImageQuality.GetHashCode();
         hashCode = hashCode * 59 + RecompressImages.GetHashCode();
         hashCode = hashCode * 59 + EnableColorDetection.GetHashCode();
         hashCode = hashCode * 59 + PackDocument.GetHashCode();
         hashCode = hashCode * 59 + PackFonts.GetHashCode();
         hashCode = hashCode * 59 + DownscaleImages.GetHashCode();
         hashCode = hashCode * 59 + DownscaleResolution.GetHashCode();
         hashCode = hashCode * 59 + FastWebView.GetHashCode();
         hashCode = hashCode * 59 + RemoveFormFields.GetHashCode();
         hashCode = hashCode * 59 + RemoveAnnotations.GetHashCode();
         hashCode = hashCode * 59 + RemoveBookmarks.GetHashCode();
         hashCode = hashCode * 59 + RemoveHyperlinks.GetHashCode();
         hashCode = hashCode * 59 + RemoveEmbeddedFiles.GetHashCode();
         hashCode = hashCode * 59 + RemoveBlankPages.GetHashCode();
         hashCode = hashCode * 59 + RemoveJavaScript.GetHashCode();
         hashCode = hashCode * 59 + EnableJPEG2000.GetHashCode();
         hashCode = hashCode * 59 + EnableJBIG2.GetHashCode();
         hashCode = hashCode * 59 + EnableCharRepair.GetHashCode();
         hashCode = hashCode * 59 + EnableMRC.GetHashCode();
         hashCode = hashCode * 59 + PreserveSmoothing.GetHashCode();
         hashCode = hashCode * 59 + DownscaleResolutionMRC.GetHashCode();
         hashCode = hashCode * 59 + RemoveMetadata.GetHashCode();
         hashCode = hashCode * 59 + RemovePageThumbnails.GetHashCode();
         hashCode = hashCode * 59 + RemovePagePieceInfo.GetHashCode();
         hashCode = hashCode * 59 + JBIG2PMSThreshold.GetHashCode();
         return(hashCode);
     }
 }
Exemple #3
0
        public FindBestVersionMatchOutput FindBestVersionMatch(FindBestVersionMatchInput input)
        {
            var outputVersions = new List <OutputVersion>();
            var invalid        = new List <string>();
            var output         = new FindBestVersionMatchOutput
            {
                InputStatus          = InputStatus.Missing,
                Versions             = outputVersions,
                Invalid              = invalid,
                Input                = input,
                IsOperationSupported = _versionRangeLogic.FindBestMatchAvailable,
            };

            if (input == null)
            {
                return(output);
            }

            var versionRangeMissing = string.IsNullOrWhiteSpace(input.VersionRange);
            var versionsMissing     = string.IsNullOrWhiteSpace(input.Versions);

            var versionRange = default(TVersionRange);

            if (!versionRangeMissing)
            {
                try
                {
                    versionRange               = _versionRangeLogic.Parse(input.VersionRange);
                    output.VersionRange        = versionRange;
                    output.IsVersionRangeValid = true;
                }
                catch (Exception)
                {
                    output.IsVersionRangeValid = false;
                }
            }

            if (!versionsMissing)
            {
                using (var reader = new StringReader(input.Versions))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (string.IsNullOrEmpty(line))
                        {
                            continue;
                        }

                        try
                        {
                            var version = _versionLogic.Parse(line);
                            var pair    = new OutputVersion
                            {
                                Input   = line,
                                Version = version
                            };

                            if (output.VersionRange != null)
                            {
                                pair.Satisfies = _versionRangeLogic.Satisfies(versionRange, version);
                            }

                            outputVersions.Add(pair);
                        }
                        catch (Exception)
                        {
                            invalid.Add(line);
                        }
                    }
                }

                output.IsVersionValid = output.Versions.Any();
            }

            if (!versionRangeMissing && !versionsMissing)
            {
                if (output.IsVersionRangeValid && output.IsVersionValid)
                {
                    output.InputStatus = InputStatus.Valid;

                    if (output.IsOperationSupported)
                    {
                        var versions  = output.Versions.Select(x => (TVersion)x.Version).ToArray();
                        var bestMatch = _versionRangeLogic.FindBestMatch(versionRange, versions);
                        if (bestMatch != null)
                        {
                            output.BestMatch = output.Versions.First(x => x.Version.Equals(bestMatch));
                        }
                    }
                }
                else
                {
                    output.InputStatus = InputStatus.Invalid;
                }
            }

            return(output);
        }
Exemple #4
0
        /// <summary>
        /// Returns true if PdfReduceParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of PdfReduceParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PdfReduceParameters input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     FileId == input.FileId ||
                     (FileId != null &&
                      FileId.Equals(input.FileId))
                     ) &&
                 (
                     OutputVersion == input.OutputVersion ||
                     OutputVersion.Equals(input.OutputVersion)
                 ) &&
                 (
                     ImageQuality == input.ImageQuality ||
                     ImageQuality.Equals(input.ImageQuality)
                 ) &&
                 (
                     RecompressImages == input.RecompressImages ||
                     RecompressImages.Equals(input.RecompressImages)
                 ) &&
                 (
                     EnableColorDetection == input.EnableColorDetection ||
                     EnableColorDetection.Equals(input.EnableColorDetection)
                 ) &&
                 (
                     PackDocument == input.PackDocument ||
                     PackDocument.Equals(input.PackDocument)
                 ) &&
                 (
                     PackFonts == input.PackFonts ||
                     PackFonts.Equals(input.PackFonts)
                 ) &&
                 (
                     DownscaleImages == input.DownscaleImages ||
                     DownscaleImages.Equals(input.DownscaleImages)
                 ) &&
                 (
                     DownscaleResolution == input.DownscaleResolution ||
                     DownscaleResolution.Equals(input.DownscaleResolution)
                 ) &&
                 (
                     FastWebView == input.FastWebView ||
                     FastWebView.Equals(input.FastWebView)
                 ) &&
                 (
                     RemoveFormFields == input.RemoveFormFields ||
                     RemoveFormFields.Equals(input.RemoveFormFields)
                 ) &&
                 (
                     RemoveAnnotations == input.RemoveAnnotations ||
                     RemoveAnnotations.Equals(input.RemoveAnnotations)
                 ) &&
                 (
                     RemoveBookmarks == input.RemoveBookmarks ||
                     RemoveBookmarks.Equals(input.RemoveBookmarks)
                 ) &&
                 (
                     RemoveHyperlinks == input.RemoveHyperlinks ||
                     RemoveHyperlinks.Equals(input.RemoveHyperlinks)
                 ) &&
                 (
                     RemoveEmbeddedFiles == input.RemoveEmbeddedFiles ||
                     RemoveEmbeddedFiles.Equals(input.RemoveEmbeddedFiles)
                 ) &&
                 (
                     RemoveBlankPages == input.RemoveBlankPages ||
                     RemoveBlankPages.Equals(input.RemoveBlankPages)
                 ) &&
                 (
                     RemoveJavaScript == input.RemoveJavaScript ||
                     RemoveJavaScript.Equals(input.RemoveJavaScript)
                 ) &&
                 (
                     EnableJPEG2000 == input.EnableJPEG2000 ||
                     EnableJPEG2000.Equals(input.EnableJPEG2000)
                 ) &&
                 (
                     EnableJBIG2 == input.EnableJBIG2 ||
                     EnableJBIG2.Equals(input.EnableJBIG2)
                 ) &&
                 (
                     EnableCharRepair == input.EnableCharRepair ||
                     EnableCharRepair.Equals(input.EnableCharRepair)
                 ) &&
                 (
                     EnableMRC == input.EnableMRC ||
                     EnableMRC.Equals(input.EnableMRC)
                 ) &&
                 (
                     PreserveSmoothing == input.PreserveSmoothing ||
                     PreserveSmoothing.Equals(input.PreserveSmoothing)
                 ) &&
                 (
                     DownscaleResolutionMRC == input.DownscaleResolutionMRC ||
                     DownscaleResolutionMRC.Equals(input.DownscaleResolutionMRC)
                 ) &&
                 (
                     RemoveMetadata == input.RemoveMetadata ||
                     RemoveMetadata.Equals(input.RemoveMetadata)
                 ) &&
                 (
                     RemovePageThumbnails == input.RemovePageThumbnails ||
                     RemovePageThumbnails.Equals(input.RemovePageThumbnails)
                 ) &&
                 (
                     RemovePagePieceInfo == input.RemovePagePieceInfo ||
                     RemovePagePieceInfo.Equals(input.RemovePagePieceInfo)
                 ) &&
                 (
                     JBIG2PMSThreshold == input.JBIG2PMSThreshold ||
                     JBIG2PMSThreshold.Equals(input.JBIG2PMSThreshold)
                 ));
        }