Exemplo n.º 1
0
 public void AddToList(string fileName)
 {
     if (FileName.Equals(fileName))
     {
         return;
     }
     if (!FilesToInclude.Contains(fileName))
     {
         FilesToInclude.Add(fileName);
     }
 }
Exemplo n.º 2
0
 //for the tostring thing
 public override string ToString()
 {
     return(string.Format("NativeProcessingFile: {0}\nActualPatchName: {1}\nPkg: {2}\nDirectoryInArchive: {3}\nFileName: {4}\nExtractDirectory: {5}\nNewFileName: {6}",
                          NativeProcessingFile.Equals("") ? "(empty)" : NativeProcessingFile,
                          ActualPatchName.Equals("") ? "(empty)" : ActualPatchName,
                          Pkg.Equals("") ? "(empty)" : Pkg,
                          DirectoryInArchive.Equals("") ? "(empty)" : DirectoryInArchive,
                          FileName.Equals("") ? "(empty)" : FileName,
                          ExtractDirectory.Equals("") ? "(empty)" : ExtractDirectory,
                          NewFileName.Equals("") ? "(empty)" : NewFileName));
 }
Exemplo n.º 3
0
 public override bool Equals(object obj)
 {
     if (obj is Photo)
     {
         Photo p = (Photo)obj;
         return(FileName.Equals(p.FileName,
                                StringComparison.
                                InvariantCultureIgnoreCase));
     }
     return(false);
 }
Exemplo n.º 4
0
        public string GetFileName(string extension)
        {
            if (FileName.Equals(""))
            {
                return(Index + extension);
            }

            string fileName = FileName.Replace("/", "_");

            fileName = Index + "_" + fileName + extension;

            return(fileName);
        }
Exemplo n.º 5
0
        /// <inheritdoc/>
        public override bool Equals(BaseEntity other)
        {
            DataFile file2 = other as DataFile;

            if (file2 == null)
            {
                return(base.Equals(other));
            }
            else
            {
                return(FileName.Equals(file2.FileName) && FilePath.Equals(file2.FilePath));
            }
        }
Exemplo n.º 6
0
        public bool Equals(ResultInfo p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(DateTime.Equals(p.DateTime) &&
                   FileName.Equals(p.FileName) &&
                   EventType.Equals(p.EventType) &&
                   UploadStatus.Equals(p.UploadStatus) &&
                   Link.Equals(p.Link));
        }
Exemplo n.º 7
0
 public bool Equals(FileItem other)
 {
     if (Object.ReferenceEquals(other, null))
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     return(FileName.Equals(other.FileName) &&
            RootPath.Equals(other.RootPath) &&
            SHAHash.Equals(other.SHAHash) &&
            FileSize.Equals(other.FileSize));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Returns a value indicating whether this instance is equal to the specified <see cref="NzbFile"/> value.
 /// </summary>
 /// <param name="other">A <see cref="NzbFile"/> object to compare to this instance.</param>
 /// <returns>true if <paramref name="other" /> has the same value as this instance; otherwise, false.</returns>
 public bool Equals(NzbFile other)
 {
     if ((object)other == null)
     {
         return(false);
     }
     return
         (Poster.Equals(other.Poster) &&
          Subject.Equals(other.Subject) &&
          FileName.Equals(other.FileName) &&
          Date.Equals(other.Date) &&
          Groups.Equals(other.Groups) &&
          Size.Equals(other.Size) &&
          Segments.SequenceEqual(other.Segments));
 }
 public bool Equals(FileMetadataList.FileMetadataRow row)
 {
     if (row.FileExtension == null)
     {
         row.FileExtension = "NULL";
     }
     return(FileName.Equals(row.FileName) &&
            FilePath.Equals(row.FilePath) &&
            CreatedDate.Equals(row.CreatedDate) &&
            LastAccessedDate.Equals(row.LastAccessedDate) &&
            LastModifiedDate.Equals(row.LastModifiedDate) &&
            FileTypeId.Equals(row.FileTypeId) &&
            FileExtension.Equals(row.FileExtension) &&
            FileSize.Equals(row.FileSize));
 }
Exemplo n.º 10
0
        public override bool Equals(object obj)
        {
            if (obj is IFileData file && file.IsUrl == IsUrl)
            {
                if (FileID.HasValue)
                {
                    return(FileID.Value == file.FileID);
                }
                else
                {
                    return(FileName.Equals(file.FileName));
                }
            }

            return(false);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Compare if files are equal.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(FileItem other)
        {
            if (ReferenceEquals(other, null))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(FileName.Equals(other.FileName) &&
                   FilePathFromRoot.Equals(other.FilePathFromRoot) &&
                   FileHash.Equals(other.FileHash) &&
                   FileSize.Equals(other.FileSize));
        }
Exemplo n.º 12
0
        public bool Equals(BackblazeB2UploadFileResult other)
        {
            if (EqualsPreamble(other) == false)
            {
                return(false);
            }

            return
                (AccountID.Equals(other.AccountID, StringComparison.Ordinal) &&
                 BucketID.Equals(other.BucketID, StringComparison.Ordinal) &&
                 ContentLength == other.ContentLength &&
                 ContentSHA1.Equals(other.ContentSHA1, StringComparison.Ordinal) &&
                 FileID.Equals(other.FileID, StringComparison.Ordinal) &&
                 FileName.Equals(other.FileName, StringComparison.Ordinal) &&
                 UploadTimeStamp == other.UploadTimeStamp);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Returns true if AttachmentViewModel instances are equal
        /// </summary>
        /// <param name="other">Instance of AttachmentViewModel to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AttachmentViewModel other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     FileName == other.FileName ||
                     FileName != null &&
                     FileName.Equals(other.FileName)
                 ) &&
                 (
                     FileSize == other.FileSize ||
                     FileSize != null &&
                     FileSize.Equals(other.FileSize)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     LastUpdateUserid == other.LastUpdateUserid ||
                     LastUpdateUserid != null &&
                     LastUpdateUserid.Equals(other.LastUpdateUserid)
                 ) &&
                 (
                     LastUpdateTimestamp == other.LastUpdateTimestamp ||
                     LastUpdateTimestamp != null &&
                     LastUpdateTimestamp.Equals(other.LastUpdateTimestamp)
                 ));
        }
Exemplo n.º 14
0
        public bool Equals(FeatureBox other)
        {
            //Check whether the compared object is null.
            if (Object.ReferenceEquals(other, null))
            {
                return(false);
            }

            //Check whether the compared object references the same data.
            if (Object.ReferenceEquals(this, other))
            {
                return(true);
            }

            //Check whether the products' properties are equal.
            return(FileName.Equals(other.FileName));
        }
Exemplo n.º 15
0
        public bool IsMatchingCodeSegment(CodeSegDefinition aCodeSegment)
        {
            bool ret = false;

            //
            if (iCodeSegmentResolver != null)
            {
                ret = iCodeSegmentResolver.IsMatchingCodeSegment(this, aCodeSegment);
            }
            else
            {
                PlatformFileName codeSegName = PlatformFileName.NewByDeviceName(aCodeSegment.FileName);
                ret = FileName.Equals(codeSegName);
            }
            //
            return(ret);
        }
Exemplo n.º 16
0
        /* From:
         * - https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type
         * - https://intellitect.com/overidingobjectusingtuple/
         * - https://montemagno.com/optimizing-c-struct-equality-with-iequatable/
         */

        public bool Equals(ObservableTransfer other)
        {
            // If parameter is null, return false.
            if (other is null)
            {
                return(false);
            }

            // Optimization for a common success case.
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(HostId == other.HostId &&
                   Project.Equals(other.Project, StringComparison.Ordinal) &&
                   FileName.Equals(other.FileName, StringComparison.Ordinal));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Returns true if LoadImageFromByteArrayParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of LoadImageFromByteArrayParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(LoadImageFromByteArrayParameters input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Content == input.Content ||
                     (Content != null &&
                      Content.Equals(input.Content))
                     ) &&
                 (
                     FileName == input.FileName ||
                     (FileName != null &&
                      FileName.Equals(input.FileName))
                 ) &&
                 (
                     ContentEncoding == input.ContentEncoding ||
                     ContentEncoding.Equals(input.ContentEncoding)
                 ) &&
                 (
                     GetPreview == input.GetPreview ||
                     GetPreview.Equals(input.GetPreview)
                 ) &&
                 (
                     ThumbnailWidth == input.ThumbnailWidth ||
                     ThumbnailWidth.Equals(input.ThumbnailWidth)
                 ) &&
                 (
                     ThumbnailHeight == input.ThumbnailHeight ||
                     ThumbnailHeight.Equals(input.ThumbnailHeight)
                 ) &&
                 (
                     ThumbnailBackgroundColor == input.ThumbnailBackgroundColor ||
                     (ThumbnailBackgroundColor != null &&
                      ThumbnailBackgroundColor.Equals(input.ThumbnailBackgroundColor))
                 ) &&
                 (
                     ThumbnailFitToPageSize == input.ThumbnailFitToPageSize ||
                     ThumbnailFitToPageSize.Equals(input.ThumbnailFitToPageSize)
                 ));
        }
Exemplo n.º 18
0
        public bool Equals(PluginFileInfos other)
        {
            if (other is null)
            {
                return(false);
            }

            if (this == other)
            {
                return(true);
            }

            if (other == null)
            {
                return(false);
            }

            return(FileName.Equals(other.FileName) && CheckSum.Equals(other.CheckSum));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Returns true if Attachment instances are equal
        /// </summary>
        /// <param name="other">Instance of Attachment to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Attachment other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     FileName == other.FileName ||
                     FileName != null &&
                     FileName.Equals(other.FileName)
                 ) &&
                 (
                     FileContents == other.FileContents ||
                     FileContents != null &&
                     FileContents.Equals(other.FileContents)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     MimeType == other.MimeType ||
                     MimeType != null &&
                     MimeType.Equals(other.MimeType)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ));
        }
Exemplo n.º 20
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            var os2           = (OpenSlide)obj;
            var quickhash1    = Properties[OpenSlide.PROPERTY_NAME_QUICKHASH1];
            var os2Quickhash1 = os2.Properties[OpenSlide.PROPERTY_NAME_QUICKHASH1];

            if (quickhash1 != null && os2Quickhash1 != null)
            {
                return(quickhash1.Equals(os2Quickhash1));
            }
            if (quickhash1 == null && os2Quickhash1 == null)
            {
                return(FileName.Equals(os2.FileName));
            }
            return(false);
        }
Exemplo n.º 21
0
    public override string ToString()
    {
        if (FileName.Equals(""))
        {
            return("No json file has been provided.");
        }
        //print
        StringBuilder jsonPrinter = new StringBuilder(64);

        jsonPrinter.AppendLine("Json File Device Description:")
        .Append("filename = ").AppendLine(FileName)
        .Append("HMD\n")
        .Append("vendor = ").AppendLine(Vendor)
        .Append("model = ").AppendLine(Model)
        .Append("version = ").AppendLine(Version)
        .Append("num_displays = ").AppendLine(NumDisplays.ToString())
        .Append("notes = ").AppendLine(Note)
        .Append("\nFIELD OF VIEW\n")
        .Append("monocular_horizontal = ").AppendLine(MonocularHorizontal.ToString())
        .Append("monocular_vertical = ").AppendLine(MonocularVertical.ToString())
        .Append("overlap_percent = ").AppendLine(OverlapPercent.ToString())
        .Append("pitch_tilt = ").AppendLine(PitchTilt.ToString())
        .Append("\nRESOLUTION\n")
        .Append("width = ").AppendLine(Width.ToString())
        .Append("height = ").AppendLine(Height.ToString())
        .Append("video_inputs = ").AppendLine(VideoInputs.ToString())
        .Append("display_mode = ").AppendLine(DisplayMode)
        .Append("\nDISTORTION\n")
        .Append("k1_red = ").AppendLine(K1Red.ToString())
        .Append("k1_green = ").AppendLine(K1Green.ToString())
        .Append("k1_blue = ").AppendLine(K1Blue.ToString())
        .Append("\nRENDERING\n")
        .Append("left_roll = ").AppendLine(LeftRoll.ToString())
        .Append("right_roll = ").AppendLine(RightRoll.ToString())
        .Append("\nEYES\n")
        .Append("center_proj_x = ").AppendLine(CenterProjX.ToString())
        .Append("center_proj_y = ").AppendLine(CenterProjY.ToString())
        .Append("rotate_180 = ").AppendLine(Rotate180.ToString());
        return(jsonPrinter.ToString());
    }
Exemplo n.º 22
0
        public override bool Equals(object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            ResultInfo p = obj as ResultInfo;

            if (p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(DateTime.Equals(p.DateTime) &&
                   FileName.Equals(p.FileName) &&
                   EventType.Equals(p.EventType) &&
                   UploadStatus.Equals(p.UploadStatus) &&
                   Link.Equals(p.Link));
        }
        public static void ShowAsSearchResults(string title, List <Reference> list)
        {
            if (list == null)
            {
                return;
            }
            List <SearchResultMatch> results  = new List <SearchResultMatch>(list.Count);
            TextDocument             document = null;
            FileName     fileName             = null;
            IHighlighter highlighter          = null;

            foreach (Reference r in list)
            {
                var f = new FileName(r.FileName);
                if (document == null || !f.Equals(fileName))
                {
                    document = new TextDocument(DocumentUtilitites.GetTextSource(ParserService.GetParseableFileContent(r.FileName)));
                    fileName = new FileName(r.FileName);
                    var def = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(r.FileName));
                    if (def != null)
                    {
                        highlighter = new DocumentHighlighter(document, def.MainRuleSet);
                    }
                    else
                    {
                        highlighter = null;
                    }
                }
                var start             = document.GetLocation(r.Offset).ToLocation();
                var end               = document.GetLocation(r.Offset + r.Length).ToLocation();
                var builder           = SearchResultsPad.CreateInlineBuilder(start, end, document, highlighter);
                SearchResultMatch res = new SearchResultMatch(fileName, start, end, r.Offset, r.Length, builder);
                results.Add(res);
            }
            SearchResultsPad.Instance.ShowSearchResults(title, results);
            SearchResultsPad.Instance.BringToFront();
        }
Exemplo n.º 24
0
        private void Load()
        {
            if (File.Exists(FullPathFileName) && !FileName.Equals("Memory.json"))
            {
                try
                {
                    string contents = null;
                    using (var stream = File.Open(FullPathFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        using (var reader = new StreamReader(stream, System.Text.Encoding.UTF8))
                        {
                            contents = reader.ReadToEnd();
                        }

                    var customLanguage            = typeof(T).Equals(typeof(LocalizationConfig)) && !FileName.Equals("en-US.json");
                    var fileContentsEqualsAutoGen = contents == GetAutoGenerateedJson();
                    if (!fileContentsEqualsAutoGen && FileName != "Config.json" && !customLanguage)
                    {
                        Log.WriteWarning($"Warning: {FileName} differs from autogenerated version.");
                    }

                    var settings = new JsonSerializerSettings
                    {
                        Formatting       = Formatting.Indented,
                        ContractResolver = new ContractResolver(),
                        Error            = HandleDeserializationError,
                    };

                    // Solves dictionary/lists being added to instead of overwritten but causes problems elsewhere
                    // https://stackoverflow.com/questions/29113063/json-net-why-does-it-add-to-list-instead-of-overwriting
                    // https://stackoverflow.com/questions/27848547/explanation-for-objectcreationhandling-using-newtonsoft-json
                    // This has been moved to ContractResolver to target Dictionaries specifically
                    // settings.ObjectCreationHandling = ObjectCreationHandling.Replace;
                    settings.Converters.Add(new StringEnumConverter());
                    settings.Converters.Add(new StringFloatConverter());

                    if (FileName.Equals("Config.json") || fileContentsEqualsAutoGen || ConfigHelper.Main.Values.UseCustomData || customLanguage)
                    {
                        JsonConvert.PopulateObject(contents, Values, settings);
                        Log.WriteLine($"{FileName} loaded");
                    }
                    else
                    {
                        Log.WriteLine($"{FileName} will be renamed to custom_{FileName} and recreated...");
                        Log.WriteLine("This can be disabled by setting [\"UseCustomData\": true,] in Config.json.");

                        File.Delete($"custom_{FileName}");
                        File.Move(FileName, $"custom_{FileName}");
                        Save();
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteException(ex);
                }
            }
            else
            {
                Save();
            }

            Loaded?.Invoke(this, null);
        }
Exemplo n.º 25
0
        internal void RemapFilePath(string originalPath, string remappedPath)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            DetachFromDocument(_documentCookie);

            var uri = new Uri(remappedPath, UriKind.Absolute);
            FileRegionsCache regionsCache = CodeAnalysisResultManager.Instance.RunDataCaches[_runId].FileRegionsCache;

            if (FileName.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
            {
                FileName = remappedPath;
            }

            foreach (LocationModel location in Locations)
            {
                if (location.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                {
                    location.FilePath = remappedPath;
                    location.Region   = regionsCache.PopulateTextRegionProperties(location.Region, uri, true);
                }
            }

            foreach (LocationModel location in RelatedLocations)
            {
                if (location.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                {
                    location.FilePath = remappedPath;
                    location.Region   = regionsCache.PopulateTextRegionProperties(location.Region, uri, true);
                }
            }

            foreach (CallTree callTree in CallTrees)
            {
                Stack <CallTreeNode> nodesToProcess = new Stack <CallTreeNode>();

                foreach (CallTreeNode topLevelNode in callTree.TopLevelNodes)
                {
                    nodesToProcess.Push(topLevelNode);
                }

                while (nodesToProcess.Count > 0)
                {
                    CallTreeNode current = nodesToProcess.Pop();
                    try
                    {
                        if (current.FilePath != null &&
                            current.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                        {
                            current.FilePath = remappedPath;
                            current.Region   = regionsCache.PopulateTextRegionProperties(current.Region, uri, true);
                        }
                    }
                    catch (ArgumentException)
                    {
                        // An argument exception is thrown if the node does not have a region.
                        // Since there's no region, there's no document to attach to.
                        // Just move on with processing the child nodes.
                    }

                    foreach (CallTreeNode childNode in current.Children)
                    {
                        nodesToProcess.Push(childNode);
                    }
                }
            }

            foreach (StackCollection stackCollection in Stacks)
            {
                foreach (StackFrameModel stackFrame in stackCollection)
                {
                    if (stackFrame.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                    {
                        stackFrame.FilePath = remappedPath;
                        stackFrame.Region   = regionsCache.PopulateTextRegionProperties(stackFrame.Region, uri, true);
                    }
                }
            }

            foreach (FixModel fixModel in Fixes)
            {
                foreach (ArtifactChangeModel fileChangeModel in fixModel.ArtifactChanges)
                {
                    if (fileChangeModel.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                    {
                        fileChangeModel.FilePath = remappedPath;
                    }
                }
            }

            AttachToDocument();
        }
Exemplo n.º 26
0
 private static void AssertEqualityNotEquals(FileName left, object right)
 {
     Assert.That(left.Equals(right), Is.False, string.Format("! '{0}'.Equals('{1}')", left, right));
     Assert.That(left.GetHashCode(), Is.Not.EqualTo(right.GetHashCode()), string.Format("'{0}'.GetHashCode() != '{1}'.GetHashCode()", left, right));
 }
Exemplo n.º 27
0
 public override bool Equals(object obj)
 {
     return(FileName.Equals(((SafeFile)obj).FileName));
 }
Exemplo n.º 28
0
 protected bool Equals(Mesh other)
 {
     return(FileName.Equals(other.FileName) && Scale.Equals(other.Scale) &&
            (Size != null ? Size.Equals(other.Size) : other.Size == null));
 }
Exemplo n.º 29
0
        public override bool Equals(object obj)
        {
            InputFile site = obj as InputFile;

            return(site == null ? false : FileName.Equals(site.FileName));
        }
		public static void ShowAsSearchResults(string title, List<Reference> list)
		{
			if (list == null) return;
			List<SearchResultMatch> results = new List<SearchResultMatch>(list.Count);
			TextDocument document = null;
			FileName fileName = null;
			IHighlighter highlighter = null;
			foreach (Reference r in list) {
				var f = new FileName(r.FileName);
				if (document == null || !f.Equals(fileName)) {
					document = new TextDocument(DocumentUtilitites.GetTextSource(ParserService.GetParseableFileContent(r.FileName)));
					fileName = new FileName(r.FileName);
					var def = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(r.FileName));
					if (def != null)
						highlighter = new DocumentHighlighter(document, def.MainRuleSet);
					else
						highlighter = null;
				}
				var start = document.GetLocation(r.Offset).ToLocation();
				var end = document.GetLocation(r.Offset + r.Length).ToLocation();
				var builder = SearchResultsPad.CreateInlineBuilder(start, end, document, highlighter);
				SearchResultMatch res = new SearchResultMatch(fileName, start, end, r.Offset, r.Length, builder);
				results.Add(res);
			}
			SearchResultsPad.Instance.ShowSearchResults(title, results);
			SearchResultsPad.Instance.BringToFront();
		}
		public static void ShowAsSearchResults(string title, List<Reference> list)
		{
			if (list == null) return;
			List<SearchResultMatch> results = new List<SearchResultMatch>(list.Count);
			TextDocument document = null;
			ITextBuffer buffer = null;
			FileName fileName = null;
			ISyntaxHighlighter highlighter = null;
			foreach (Reference r in list) {
				var f = new FileName(r.FileName);
				if (document == null || !f.Equals(fileName)) {
					buffer = ParserService.GetParseableFileContent(r.FileName);
					document = new TextDocument(DocumentUtilitites.GetTextSource(buffer));
					fileName = new FileName(r.FileName);
					highlighter = EditorControlService.Instance.CreateHighlighter(new AvalonEditDocumentAdapter(document, null), fileName);
				}
				var start = document.GetLocation(r.Offset).ToLocation();
				var end = document.GetLocation(r.Offset + r.Length).ToLocation();
				var builder = SearchResultsPad.CreateInlineBuilder(start, end, document, highlighter);
				SearchResultMatch res = new SearchResultMatch(fileName, start, end, r.Offset, r.Length, builder, highlighter.DefaultTextColor);
				results.Add(res);
			}
			SearchResultsPad.Instance.ShowSearchResults(title, results);
			SearchResultsPad.Instance.BringToFront();
		}
Exemplo n.º 32
0
        internal void RemapFilePath(string originalPath, string remappedPath)
        {
            if (FileName.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
            {
                FileName = remappedPath;
            }

            foreach (AnnotatedCodeLocationModel location in Locations)
            {
                if (location.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                {
                    location.FilePath = remappedPath;
                }
            }

            foreach (AnnotatedCodeLocationModel location in RelatedLocations)
            {
                if (location.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                {
                    location.FilePath = remappedPath;
                }
            }

            foreach (CallTree callTree in CallTrees)
            {
                Stack <CallTreeNode> nodesToProcess = new Stack <CallTreeNode>();

                foreach (CallTreeNode topLevelNode in callTree.TopLevelNodes)
                {
                    nodesToProcess.Push(topLevelNode);
                }

                while (nodesToProcess.Count > 0)
                {
                    CallTreeNode current = nodesToProcess.Pop();
                    try
                    {
                        if (current.FilePath != null &&
                            current.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                        {
                            current.FilePath = remappedPath;
                        }
                    }
                    catch (ArgumentException)
                    {
                        // An argument exception is thrown if the node does not have a region.
                        // Since there's no region, there's no document to attach to.
                        // Just move on with processing the child nodes.
                    }

                    foreach (CallTreeNode childNode in current.Children)
                    {
                        nodesToProcess.Push(childNode);
                    }
                }
            }

            foreach (StackCollection stackCollection in Stacks)
            {
                foreach (StackFrameModel stackFrame in stackCollection)
                {
                    if (stackFrame.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                    {
                        stackFrame.FilePath = remappedPath;
                    }
                }
            }

            foreach (FixModel fixModel in Fixes)
            {
                foreach (FileChangeModel fileChangeModel in fixModel.FileChanges)
                {
                    if (fileChangeModel.FilePath.Equals(originalPath, StringComparison.OrdinalIgnoreCase))
                    {
                        fileChangeModel.FilePath = remappedPath;
                    }
                }
            }
        }
Exemplo n.º 33
0
        //Attempts to Locate Steam Executables Using Patterns Noticed in My Steam Folders
        public static bool AttemptLocateGameExe(String filename, String directory)
        {
            Regex firstLetters = new Regex(@"(\b[a-zA-Z])[a-zA-Z]* ?");

            //bool isDemo;

            String file              = filename.Substring(filename.LastIndexOf("\\") + 1);
            String direc             = directory.Substring(directory.LastIndexOf("\\") + 1);
            String direcNoSpace      = Regex.Replace(direc, @"\s+", String.Empty);
            String directfirstLetter = firstLetters.Replace(direc, "$1");
            String directNoThe       = "______________";
            String directNoSQuote    = "___________";
            String directNoDemo      = "________";

            if (direcNoSpace.Contains("The"))
            {
                directNoThe = direcNoSpace.Remove(direcNoSpace.IndexOf("The"), "The".Length);
            }
            if (direcNoSpace.Contains("'"))
            {
                directNoSQuote = direcNoSpace.Remove(direcNoSpace.IndexOf("'"), "'".Length);
            }
            if (direcNoSpace.Contains("Demo"))
            {
                directNoDemo = direcNoSpace.Remove(direcNoSpace.IndexOf("Demo"), "Demo".Length);
            }

            //Console.WriteLine(file);
            //Console.WriteLine(direc);
            //Console.WriteLine(direcNoSpace);
            //Console.WriteLine(directfirstLetter+"Tag");
            //Console.WriteLine(string.Equals(file, direc + ".exe"));
            //Console.WriteLine(directNoThe);

            //Compares File's Name to Certain Cases.  Will Probably Be Replaced By CompareTo Later
            switch (file)
            {
            case string FileName when FileName.Equals(direc + ".exe", StringComparison.OrdinalIgnoreCase):
                return(true);

            case string FileName when FileName.Equals("launcher.exe", StringComparison.OrdinalIgnoreCase):
                return(true);

            case string FileName when FileName.Equals("game.exe", StringComparison.OrdinalIgnoreCase):
                return(true);

            case string FileName when FileName.Equals(direcNoSpace + ".exe", StringComparison.OrdinalIgnoreCase):
                return(true);

            case string FileName when FileName.Equals(directfirstLetter + ".exe", StringComparison.OrdinalIgnoreCase):
                return(true);

            case string FileName when FileName.Contains(direcNoSpace):
                if (file.Contains("Unity"))
                {
                    return(false);
                }
                return(true);

            case string FileName when FileName.Contains(directNoThe):
                if (file.Contains("Unity"))
                {
                    return(false);
                }
                return(true);

            case string FileName when FileName.Contains(directfirstLetter):
                if (file.Contains("Unity"))
                {
                    return(false);
                }
                return(true);

            case string FileName when FileName.Contains(directNoSQuote):
                if (file.Contains("Unity"))
                {
                    return(false);
                }
                return(true);

            case string FileName when FileName.Contains(directNoDemo):
                return(true);

            case string FileName when FileName.Contains("RPG_RT.exe"):
                return(true);

            case string FileName when FileName.Contains("Dagon64.exe"):
                return(true);

            case string FileName when FileName.Contains("SEGAGenesisClassics.exe"):
                return(true);

            default:
                return(false);
            }
        }