Reduce code duplication in Ads portal classes through improved inheritance#155
Draft
Copilot wants to merge 2 commits intodev/issue-123/code-duplicationsfrom
Draft
Reduce code duplication in Ads portal classes through improved inheritance#155Copilot wants to merge 2 commits intodev/issue-123/code-duplicationsfrom
Copilot wants to merge 2 commits intodev/issue-123/code-duplicationsfrom
Conversation
Co-authored-by: supermartzin <6864050+supermartzin@users.noreply.github.com>
|
Copilot
AI
changed the title
[WIP] Improve class inheritance of Ads portals to reduce code duplication
Reduce code duplication in Ads portal classes through improved inheritance
Oct 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Overview
This PR addresses issue #X by improving class inheritance in the Ads portal implementations to reduce code duplication. The refactoring centralizes common parsing patterns into the base class while maintaining portal-specific functionality.
Changes
Added Protected Helper Methods to
RealEstateAdsPortalBaseFour new protected helper methods were added to provide common parsing functionality:
ParsePriceFromNode(HtmlNode node, string xpath)- Extracts and parses decimal price values from HTML nodes by removing non-numeric charactersParseLayoutFromText(string text)- Parses layout information (e.g., "2+kk", "3+1") from text using regex pattern matchingParseFloorAreaFromText(string text)- Extracts floor area measurements from text using regex patternsGetPriceCommentWhenZero(decimal price, HtmlNode node, string xpath)- Returns price comment text when the price is zero (for "Price on request" scenarios)All methods include comprehensive XML documentation and follow consistent error handling patterns.
Refactored Portal Classes
The following 10 portal classes were refactored to use the new helper methods:
Example
Before:
After:
Impact
Benefits
Original prompt
Fixes #123
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.