Repository navigation
Use the host search function - #7912
Conversation
…o LibraryReorg # Conflicts: # src/LibraryViewExtension/Handlers/NodeItemDataProvider.cs # src/LibraryViewExtension/LibraryViewController.cs
| { | ||
| supportedSchemes.Add(provider.Scheme); | ||
| resourceProviders.Add(baseurl, provider); | ||
| if (!resourceProviders.ContainsKey(baseurl)) |
There was a problem hiding this comment.
I think we should not be changing resource provider for the same url. Url should have additional data to differentiate the different scenarios.
There was a problem hiding this comment.
Again, I don't think we should allow updating the old provider.
| /// Provides json resource data for all the loaded nodes | ||
| /// </summary> | ||
| class NodeItemDataProvider : ResourceProviderBase | ||
| { |
There was a problem hiding this comment.
I would rather subclass this class to implement node search data provider.
| refreshLibraryView(libController); | ||
|
|
||
| libController.searchLibraryItemsHandler = function (text, callback) { | ||
| let url = csharpController.searchLibraryItems(text); |
There was a problem hiding this comment.
We can directly have a url to provide a search service as http://localhost/nodesearch/{searchText} and register a provider for http://localhost/nodesearch/
…o LibraryReorg # Conflicts: # src/LibraryViewExtension/Handlers/NodeItemDataProvider.cs
| @@ -86,7 +100,6 @@ public static string GetFullyQualifiedName(NodeSearchElement element) | |||
| /// <returns></returns> | |||
| internal LoadedTypeItem CreateLoadedTypeItem(NodeSearchElement element) | |||
There was a problem hiding this comment.
You can use Generics to implement this method so that you don't have to use the same code again for LoadedTypeItemExtended class.
internal T CreateLoadedTypeItem<T>(NodeSearchElement element) where T : LoadedTypeItem, new()
There was a problem hiding this comment.
You mean the constructor of LoadedTypeItem?
| /// </summary> | ||
| /// <param name="element"></param> | ||
| /// <param name="item"></param> | ||
| protected void InitializeLoadedTypeItem(NodeSearchElement element, LoadedTypeItem item) |
There was a problem hiding this comment.
Not sure why do we need this method?
There was a problem hiding this comment.
This is the one that after an instance of LoadedTypeItem or its derived class is created, the data need to be initialized to set iconUrl or update fully qualified name. This will be the same in the base and the derived classes.
| { | ||
| supportedSchemes.Add(provider.Scheme); | ||
| resourceProviders.Add(baseurl, provider); | ||
| if (!resourceProviders.ContainsKey(baseurl)) |
There was a problem hiding this comment.
Again, I don't think we should allow updating the old provider.
| var uri = new Uri(url); | ||
| var pathAndQuery = uri.PathAndQuery; | ||
| var index = url.IndexOf(serviceIdentifier); | ||
| var text = url.Substring(index + serviceIdentifier.Length + 1); |
There was a problem hiding this comment.
what if the passed url is /search/point/bycoordinates, the text becomes point/bycoordinates?
There was a problem hiding this comment.
you might consider having a method IEnumerable<LoadedTypeItem> GetLoadedTypeDataForRequest(Uri requestUri) then the base class implementation doesn't need to be overridden. Here is how the base class implementation would look like.
public override Stream GetResource(IRequest request, out string extension)
{
var uri = new Uri(request.Url);
var items = GetLoadedTypeDataForRequest(uri);
extension = "json";
return GetLoadedTypeDataStream(items);
}
There was a problem hiding this comment.
The old search behavior allows input text like "point/bycoordinates".
There was a problem hiding this comment.
For the second point, then you need to override GetLoadedTypeDataForRequest. But as GetResource is only a function with few lines, why not override it directly?
| /// <param name="element"></param> | ||
| /// <param name="w"></param> | ||
| /// <returns></returns> | ||
| private LoadedTypeItem CreateLoadedTypeItemExtended(NodeSearchElement element, int w = 0) |
There was a problem hiding this comment.
why is this method not returning LoadedTypeItemExtended instead of LoadedTypeItem?
| var sw = new StreamWriter(ms); | ||
| var serializer = new JsonSerializer(); | ||
|
|
||
| var data = CreateObjectForSerialization(searchEntries); |
There was a problem hiding this comment.
What if this method accepts list of LoadedTypeItem instead of searchEntities, then you won't need an additional method CreateObjectForSerialization?
protected Stream GetLoadedTypeDataStream(IEnumerable<LoadedTypeItem> items) {...}
There was a problem hiding this comment.
CreateObjectForSerialization basically creates different instance of LoadedTypeData in the base class and the derived class.
| } | ||
|
|
||
| class LoadedTypeData | ||
| class LoadedTypeData<T> |
There was a problem hiding this comment.
you might want to put a condition for T to be derived from LoadedTypeItem
There was a problem hiding this comment.
I am wondering if it would have worked as it is when loadedTypes internally contains the list of LoadedTypeItemExtended?
There was a problem hiding this comment.
That is how template means? If it does not work, I doubt the reason why this language feature exists.
There was a problem hiding this comment.
But if you mean LoadedTypeData<A> can not be casted to LoadedTypeData<B> directly, then you are right. But this is not the intention here.
78664b0 to
c18d69d
Compare
c18d69d to
73eb9e0
Compare
|
@sharadkjaiswal |
Purpose
This is to implement to use the old search function.
Here is the old search result when "list.s" is input in the search box:

Here is the search result now:

The order and content(only part of the result is in the view) are the same.
Declarations
Check these if you believe they are true
*.resxfilesReviewers
@sharadkjaiswal
FYIs
@benglin @riteshchandawar @Racel