public void Clear() { var target = new FieldSelector<FieldSelectorTests>(); var result = target.Add("hello").Add("world").Clear(); Assert.AreEqual(0, target.Items.Length); Assert.AreSame(target, result); }
public void Add1() { var target = new FieldSelector<FieldSelectorTests>(); var result = target.Add("hello"); Assert.AreEqual(1, target.Items.Length); Assert.AreEqual("hello", target.Items[0]); Assert.AreSame(target, result); }
public Document Doc(int n, FieldSelector fieldSelector) { indexStream.Seek(n * 8L); long position = indexStream.ReadLong(); fieldsStream.Seek(position); Document doc = new Document(); int numFields = fieldsStream.ReadVInt(); for (int i = 0; i < numFields; i++) { int fieldNumber = fieldsStream.ReadVInt(); FieldInfo fi = fieldInfos.FieldInfo(fieldNumber); FieldSelectorResult acceptField = fieldSelector == null ? FieldSelectorResult.LOAD : fieldSelector.Accept(fi.name); byte bits = fieldsStream.ReadByte(); bool compressed = (bits & FieldsWriter.FIELD_IS_COMPRESSED) != 0; bool tokenize = (bits & FieldsWriter.FIELD_IS_TOKENIZED) != 0; bool binary = (bits & FieldsWriter.FIELD_IS_BINARY) != 0; //TODO: Find an alternative approach here if this list continues to grow beyond the //list of 5 or 6 currently here. See Lucene 762 for discussion if (acceptField.Equals(FieldSelectorResult.LOAD)) { AddField(doc, fi, binary, compressed, tokenize); } else if (acceptField.Equals(FieldSelectorResult.LOAD_FOR_MERGE)) { AddFieldForMerge(doc, fi, binary, compressed, tokenize); } else if (acceptField.Equals(FieldSelectorResult.LOAD_AND_BREAK)) { AddField(doc, fi, binary, compressed, tokenize); break; //Get out of this loop } else if (acceptField.Equals(FieldSelectorResult.LAZY_LOAD)) { AddFieldLazy(doc, fi, binary, compressed, tokenize); } else if (acceptField.Equals(FieldSelectorResult.SIZE)) { SkipField(binary, compressed, AddFieldSize(doc, fi, binary, compressed)); } else if (acceptField.Equals(FieldSelectorResult.SIZE_AND_BREAK)) { AddFieldSize(doc, fi, binary, compressed); break; } else { SkipField(binary, compressed); } } return doc; }
/// <summary> /// retrieve a company by using the company ID /// </summary> public Companies.Company GetById( UserAuthorization user , string companyId , FieldSelector<Companies.Company> fields = null ) { const string urlFormat = "/v1/companies/{CompanyId}{FieldSelector}"; var url = FormatUrl(urlFormat, fields, "CompanyId", companyId); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Companies.Company>(context); return result; }
public override Document.Document Document(int n, FieldSelector fieldSelector) { EnsureOpen(); return in_Renamed.Document(n, fieldSelector); }
// inherit javadoc public override Document.Document Doc(int i, FieldSelector fieldSelector) { return reader.Document(i, fieldSelector); }
public void ToString1() { var target = new FieldSelector<FieldSelectorTests>().Add("hello"); var result = target.ToString(); Assert.AreEqual(":(hello)", result); }
public void Merge2Levels1() { var selector = new FieldSelector<object>().Add("a:(m)").Add("a:(n:(z))"); Assert.AreEqual(2, selector.Items.Length); Assert.AreEqual(":(a:(m,n:(z)))", selector.ToString()); }
public EmbededValidatorRule(FieldSelector selector, JsonValidator validator) { Selector = selector; this.Validator = validator; }
/// <summary> /// returns a list of 1st degree connections for a user /// </summary> public Profiles.Connections GetUpdatedConnectionsByPublicProfile( UserAuthorization user , string publicProfileUrl , int start , int count , long modifiedSince , FieldSelector<Profiles.Connections> fields = null ) { const string urlFormat = "/v1/people/url={PublicProfileUrl}/connections{FieldSelector}?start={int start}&count={int count}&modified=updated&modified-since={long modifiedSince}"; var url = FormatUrl(urlFormat, fields, "PublicProfileUrl", publicProfileUrl, "int start", start, "int count", count, "long modifiedSince", modifiedSince); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Profiles.Connections>(context); return result; }
public async Task <ActionResult> Index(string culture = "en-US") { // step 1: configuration this.ViewBag.Configuration = this.apiConfig; // step 2: authorize url var scope = AuthorizationScope.ReadEmailAddress | AuthorizationScope.ReadWriteCompanyPage | AuthorizationScope.WriteShare; var state = Guid.NewGuid().ToString(); var redirectUrl = this.Request.Compose() + this.Url.Action("OAuth2"); this.ViewBag.LocalRedirectUrl = redirectUrl; if (this.apiConfig != null && !string.IsNullOrEmpty(this.apiConfig.ApiKey)) { var authorizeUrl = this.api.OAuth2.GetAuthorizationUrl(scope, state, redirectUrl); this.ViewBag.Url = authorizeUrl; } else { this.ViewBag.Url = null; } // step 3 if (this.data.HasAccessToken) { var token = this.data.GetAccessToken(); this.ViewBag.Token = token; var user = new UserAuthorization(token); var watch = new Stopwatch(); watch.Start(); try { ////var profile = this.api.Profiles.GetMyProfile(user); var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", }; var fields = FieldSelector.For <Person>() .WithId() .WithFirstName() .WithLastName() .WithFormattedName() .WithEmailAddress() .WithHeadline() .WithLocationName() .WithLocationCountryCode() .WithPictureUrl() .WithPublicProfileUrl() .WithSummary() .WithIndustry() .WithPositions() .WithPositionsSummary() .WithThreeCurrentPositions() .WithThreePastPositions() .WithProposalComments() .WithAssociations() .WithInterests() .WithLanguageId() .WithLanguageName() .WithLanguageProficiency() .WithCertifications() .WithEducations() .WithFullVolunteer() .WithPatents() ////.WithRecommendationsReceived() // may not use that .WithRecommendationsReceivedWithAdditionalRecommenderInfo() .WithDateOfBirth() .WithPhoneNumbers() .WithImAccounts() .WithPrimaryTwitterAccount() .WithTwitterAccounts() .WithSkills(); var profile = await this.api.Profiles.GetMyProfileAsync(user, acceptLanguages, fields); var originalPicture = await this.api.Profiles.GetOriginalProfilePictureAsync(user); this.ViewBag.Picture = originalPicture; this.ViewBag.Profile = profile; } catch (LinkedInApiException ex) { this.ViewBag.ProfileError = ex.ToString(); } catch (Exception ex) { this.ViewBag.ProfileError = ex.ToString(); } watch.Stop(); this.ViewBag.ProfileDuration = watch.Elapsed; } return(this.View()); }
public ActionResult FullProfile(string id, string culture = "en-US") { var token = this.data.GetAccessToken(); this.ViewBag.Token = token; var user = new UserAuthorization(token); Person profile = null; var watch = new Stopwatch(); watch.Start(); try { ////var profile = this.api.Profiles.GetMyProfile(user); var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", }; var fields = FieldSelector.For <Person>() .WithFirstName().WithFormattedName().WithLastName() .WithHeadline() .WithId() .WithEmailAddress() //.WithLocation() .WithLocationName() // subfields issue //.WithLocationCountryCode() // subfields issue .WithPictureUrl() .WithPublicProfileUrl() .WithSummary() .WithIndustry() .WithPositions() .WithThreeCurrentPositions() .WithThreePastPositions() .WithProposalComments() .WithAssociations() .WithInterests() .WithLanguageId() .WithLanguageName() .WithLanguageProficiency() .WithCertifications() .WithEducations() .WithFullVolunteer() //.WithRecommendationsReceived() // may not use that .WithRecommendationsReceivedWithAdditionalRecommenderInfo() .WithDateOfBirth() .WithPhoneNumbers() .WithImAccounts() .WithPrimaryTwitterAccount() .WithTwitterAccounts() .WithAllFields() ; profile = this.api.Profiles.GetProfileById(user, id, acceptLanguages, fields); this.ViewBag.Profile = profile; } catch (LinkedInApiException ex) { this.ViewBag.ProfileError = ex.ToString(); this.ViewBag.RawResponse = ex.Data["ResponseText"]; } catch (LinkedInNetException ex) { this.ViewBag.ProfileError = ex.ToString(); this.ViewBag.RawResponse = ex.Data["ResponseText"]; } catch (Exception ex) { this.ViewBag.ProfileError = ex.ToString(); } watch.Stop(); this.ViewBag.ProfileDuration = watch.Elapsed; return(this.View(profile)); }
public IFieldValidatorConfig Then(FieldSelector selector, string alias, CapturedConstraint constraint) => Then(new AliasedFieldSelector(alias, selector), constraint);
public IFieldValidatorConfig Then(FieldSelector selector, CapturedConstraint constraint) => Then(new BasicRule(selector, constraint));
public void ForEachIn(FieldSelector selector, string alias = null) { selector = new ForEachInFieldSelector(selector); selector = alias != null ? new AliasedFieldSelector(alias, selector) : selector; factory.Then(new EmbededValidatorRule(selector, validator)); }
/// <summary> /// Retrieve the company's updates /// </summary> public Companies.CompanyUpdates GetShares( UserAuthorization user , int id , FieldSelector<Companies.CompanyUpdates> fields = null ) { const string urlFormat = "/v1/companies/{int id}/updates"; var url = FormatUrl(urlFormat, fields, "int id", id); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Companies.CompanyUpdates>(context); return result; }
/// <summary> /// Formats the URL. /// </summary> /// <param name="format">The format.</param> /// <param name="fieldSelector">The field selectors.</param> /// <param name="values">The values.</param> /// <returns></returns> protected string FormatUrl(string format, FieldSelector fieldSelector, params object[] values) { var result = format; var dic = new Dictionary <string, string>(values.Length / 2); for (int i = 0; i < values.Length; i++) { if (i % 2 == 1) { var key = values[i - 1].ToString(); object valueObject = values[i] != null ? values[i] : null; var value = valueObject != null?valueObject.ToString() : null; if (valueObject != null) { var type = valueObject.GetType(); DateTime?ndt = null; if (type == typeof(DateTime?)) { ndt = (DateTime?)valueObject; } if (type == typeof(DateTime)) { ndt = (DateTime)valueObject; } if (ndt != null) { value = ndt.Value.ToUnixTime().ToString(); } } dic.Add(key, value); } } if (fieldSelector != null) { result = result.Replace("{FieldSelector}", fieldSelector.ToString()); } else { result = result.Replace("{FieldSelector}", string.Empty); } foreach (var key in dic.Keys) { var value = dic[key]; if (value != null) { result = result.Replace("{" + key + "}", value); } else { result = result.Replace("{" + key + "}", string.Empty); } } return(result); }
/// <summary> /// returns a list of 1st degree connections for a user /// </summary> public Profiles.Connections GetMyConnections( UserAuthorization user , int start , int count , FieldSelector<Profiles.Connections> fields = null ) { const string urlFormat = "/v1/people/~/connections{FieldSelector}?start={int start}&count={int count}"; var url = FormatUrl(urlFormat, fields, "int start", start, "int count", count); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Profiles.Connections>(context); return result; }
public async Task <ActionResult> Index(string culture = "en-US") { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // step 1: configuration this.ViewBag.Configuration = this.apiConfig; // step 2: authorize url var scope = AuthorizationScope.ReadEmailAddress | AuthorizationScope.ReadWriteCompanyPage | AuthorizationScope.WriteShare; var state = Guid.NewGuid().ToString(); var redirectUrl = this.Request.Compose() + this.Url.Action("OAuth2"); this.ViewBag.LocalRedirectUrl = redirectUrl; if (this.apiConfig != null && !string.IsNullOrEmpty(this.apiConfig.ApiKey)) { var authorizeUrl = this.api.OAuth2.GetAuthorizationUrl(scope, state, redirectUrl); this.ViewBag.Url = authorizeUrl; } else { this.ViewBag.Url = null; } var accessToken = ""; this.data.SaveAccessToken(accessToken); // step 3 if (this.data.HasAccessToken) { var token = this.data.GetAccessToken(); this.ViewBag.Token = token; var user = new UserAuthorization(token); var watch = new Stopwatch(); watch.Start(); try { ////var profile = this.api.Profiles.GetMyProfile(user); var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", }; var fields = FieldSelector.For <Person>().WithAllFields(); var profile = await this.api.Profiles.GetMyProfileAsync(user, acceptLanguages, fields); //await CreateLike(user); //await GetProfile(user); //await GetPosts(user); //await GetComemnt(user); // await GetPost(user); // await GetPosts(user); //await GetVideo(user); //await PublishImage(user); await PublishTest(user); // var originalPicture = await this.api.Profiles.GetOriginalProfilePictureAsync(user); // this.ViewBag.Picture = originalPicture; //this.ViewBag.Profile = profile; } catch (LinkedInApiException ex) { this.ViewBag.ProfileError = ex.ToString(); } catch (Exception ex) { this.ViewBag.ProfileError = ex.ToString(); } watch.Stop(); this.ViewBag.ProfileDuration = watch.Elapsed; } return(this.View()); }
/// <summary> /// Formats the URL. /// </summary> /// <param name="format">The format.</param> /// <param name="fieldSelector">The field selectors.</param> /// <param name="skipUrlParamsEscape">list lit comma separated values. e.g.: urn,id,postId</param> /// <param name="values">The values.</param> /// <returns></returns> protected string FormatUrl(string format, FieldSelector fieldSelector, string skipUrlParamsEscape, params object[] values) { var result = format; var dic = new Dictionary <string, string>(values.Length / 2); for (int i = 0; i < values.Length; i++) { if (i % 2 == 1) { var key = values[i - 1].ToString(); object valueObject = values[i] != null ? values[i] : null; var value = valueObject != null?valueObject.ToString() : null; if (valueObject != null) { var type = valueObject.GetType(); DateTime?ndt = null; if (type == typeof(DateTime?)) { ndt = (DateTime?)valueObject; } if (type == typeof(DateTime)) { ndt = (DateTime)valueObject; } if (ndt != null) { value = ndt.Value.ToUnixTime().ToString(); } } dic.Add(key, value); } } if (fieldSelector != null) { var selector = fieldSelector.ToString(); selector = selector.Replace("~~~", "~:"); result = result.Replace("{FieldSelector}", selector); } else { result = result.Replace("{FieldSelector}", string.Empty); } var skipParamsEscape = !string.IsNullOrEmpty(skipUrlParamsEscape) ? skipUrlParamsEscape.Split(',').ToList() : new List <string>(); foreach (var key in dic.Keys) { var value = dic[key]; if (value != null) { var skipEscape = skipParamsEscape.Contains(key); result = result.Replace("{" + key + "}", skipEscape ? value : Uri.EscapeDataString(value)); } else { result = result.Replace("{" + key + "}", string.Empty); } } return(result); }
public async Task <ActionResult> Company(int id, string culture = "en-US", int start = 0, int count = 10, string eventType = null) { this.ViewBag.Id = id; this.ViewBag.EventType = eventType; var token = this.data.GetAccessToken(); this.ViewBag.Token = token; var user = new UserAuthorization(token); var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", }; Exception error = null; Company company; { var fields = FieldSelector.For <Company>() .WithAllFields(); try { company = await this.api.Companies.GetByIdAsync(user, id.ToString(), fields); } catch (LinkedInApiException ex) { if (ex.StatusCode == 403) { company = new Company(); company.Id = id; company.Name = "Company " + id + " - Permission error"; error = ex; } else { throw; } } } this.ViewBag.SharesStart = start; this.ViewBag.SharesCount = count; this.ViewBag.SharesTotal = 0; if (error != null) { var fields = FieldSelector.For <CompanyUpdates>(); Companies.CompanyUpdates shares; try { if (string.IsNullOrEmpty(eventType)) { shares = await this.api.Companies.GetSharesAsync(user, id, start, count); } else { shares = await this.api.Companies.GetSharesAsync(user, id, start, count, eventType); } this.ViewBag.SharesTotal = shares.Total; this.ViewBag.Shares = shares; } catch (LinkedInApiException ex) { if (ex.StatusCode == 403) { error = ex; } else { throw; } } } this.ViewBag.Error = error; return(this.View(company)); }
public void DeDuplicate() { var selector = new FieldSelector<object>().Add("location").Add("location:()"); Assert.AreEqual(2, selector.Items.Length); Assert.AreEqual(":(location)", selector.ToString()); }
static TestLazyBug() { SELECTOR = new AnonymousClassFieldSelector(); }
public void MergeSimple() { var selector = new FieldSelector<object>().Add("location:(name)").Add("location:(code)"); Assert.AreEqual(2, selector.Items.Length); Assert.AreEqual(":(location:(name,code))", selector.ToString()); }
/// <summary> /// Retrieve the company's updates /// </summary> public async Task<Companies.CompanyUpdates> GetSharesAsync( UserAuthorization user , int id , int start , int count , string type , FieldSelector<Companies.CompanyUpdates> fields = null ) { const string urlFormat = "/v1/companies/{int id}/updates?start={int start}&count={int count}&event-type={type}"; var url = FormatUrl(urlFormat, fields, "int id", id, "int start", start, "int count", count, "type", type); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; var exec = await this.ExecuteQueryAsync(context); if (!exec) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Companies.CompanyUpdates>(context); return result; }
public string FormatUrlInvoke(string format, FieldSelector fields, params object[] values) { return FormatUrl(format, fields, values); }
// inherit javadoc public override Document.Document Document(int n, FieldSelector fieldSelector) { EnsureOpen(); int i = ReaderIndex(n); // find segment num return subReaders[i].Document(n - starts[i], fieldSelector); // dispatch to segment reader }
/// <summary> Get the <see cref="Net.Document.Document" /> at the <c>n</c> /// <sup>th</sup> position. The <see cref="FieldSelector" /> may be used to determine /// what <see cref="Field" />s to load and how they should /// be loaded. <b>NOTE:</b> If this Reader (more specifically, the underlying /// <c>FieldsReader</c>) is closed before the lazy /// <see cref="Field" /> is loaded an exception may be /// thrown. If you want the value of a lazy /// <see cref="Field" /> to be available after closing you /// must explicitly load it or fetch the Document again with a new loader. /// <p/> /// <b>NOTE:</b> for performance reasons, this method does not check if the /// requested document is deleted, and therefore asking for a deleted document /// may yield unspecified results. Usually this is not required, however you /// can call <see cref="IsDeleted(int)" /> with the requested document ID to verify /// the document is not deleted. /// /// </summary> /// <param name="n">Get the document at the <c>n</c><sup>th</sup> position /// </param> /// <param name="fieldSelector">The <see cref="FieldSelector" /> to use to determine what /// Fields should be loaded on the Document. May be null, in which case /// all Fields will be loaded. /// </param> /// <returns> The stored fields of the /// <see cref="Net.Document.Document" /> at the nth position /// </returns> /// <throws> CorruptIndexException if the index is corrupt </throws> /// <exception cref="System.IO.IOException">If there is a low-level IO error</exception> /// <seealso cref="IFieldable"> /// </seealso> /// <seealso cref="FieldSelector"> /// </seealso> /// <seealso cref="SetBasedFieldSelector"> /// </seealso> /// <seealso cref="LoadFirstFieldSelector"> /// </seealso> // TODO (1.5): When we convert to JDK 1.5 make this Set<String> public abstract Document.Document Document(int n, FieldSelector fieldSelector);
public void ToString2SlashColon() { var target = new FieldSelector<FieldSelectorTests>().Add("hello:(name)").Add("world/wtf"); var result = target.ToString(); Assert.AreEqual(":(hello:(name),world/wtf)", result); }
private static Hit CreateHit ( Document primary_doc, IndexReader secondary_reader, TermDocs term_docs, FieldSelector fields) { Hit hit = DocumentToHit (primary_doc); if (secondary_reader == null) return hit; // Get the stringified version of the URI // exactly as it comes out of the index. Term term = new Term ("Uri", primary_doc.Get ("Uri")); term_docs.Seek (term); // Move to the first (and only) matching term doc term_docs.Next (); Document secondary_doc = (fields == null) ? secondary_reader.Document (term_docs.Doc ()) : secondary_reader.Document (term_docs.Doc (), fields); // If we are using the secondary index, now we need to // merge the properties from the secondary index AddPropertiesToHit (hit, secondary_doc, false); return hit; }
public void ToString3() { var target = new FieldSelector<FieldSelectorTests>().Add("hello").Add("location:(name,country)").Add("world"); var result = target.ToString(); Assert.AreEqual(":(hello,location:(name,country),world)", result); }
/// <summary> /// This returns an array of companies that match to the specified email domain. /// </summary> public Companies.Company GetListByEmailDomain( UserAuthorization user , string universalName , FieldSelector<Companies.Company> fields = null ) { const string urlFormat = "/v1/companies/universal-name={UniversalName}{FieldSelector}"; var url = FormatUrl(urlFormat, fields, "UniversalName", universalName); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Companies.Company>(context); return result; }
public void ToStringEmpty() { var target = new FieldSelector<FieldSelectorTests>(); var result = target.ToString(); Assert.AreEqual(string.Empty, result); }
/// <summary> /// /// </summary> public Companies.CompanySearch Search( UserAuthorization user , int start , int count , string keywords , FieldSelector<Companies.CompanySearch> fields = null ) { const string urlFormat = "/v1/company-search{FieldSelector}?start={int start}&count={int count}&keywords={keywords}"; var url = FormatUrl(urlFormat, fields, "int start", start, "int count", count, "keywords", keywords); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Companies.CompanySearch>(context); return result; }
public ICollection GetHitsForUris (ICollection uris, FieldSelector fields) { Hashtable hits_by_uri = UriFu.NewHashtable (); LNS.IndexSearcher primary_searcher = GetSearcher (PrimaryStore); LNS.IndexSearcher secondary_searcher = GetSearcher (SecondaryStore); LNS.Query uri_query = UriQuery ("Uri", uris); LNS.Hits primary_hits = primary_searcher.Search (uri_query); for (int i = 0; i < primary_hits.Length (); i++) { Document doc = ((fields == null) ? primary_hits.Doc (i) : primary_hits.Doc (i, fields)); Uri u = GetUriFromDocument (doc); Hit hit = DocumentToHit (doc); hits_by_uri [hit.Uri] = hit; } if (secondary_searcher != null) { LNS.Hits secondary_hits = secondary_searcher.Search (uri_query); for (int i = 0; i < secondary_hits.Length (); i++) { Document doc = ((fields == null) ? secondary_hits.Doc (i) : secondary_hits.Doc (i, fields)); Uri uri = GetUriFromDocument (doc); Hit hit = (Hit) hits_by_uri [uri]; if (hit != null) AddPropertiesToHit (hit, doc, false); } } ReleaseSearcher (primary_searcher); ReleaseSearcher (secondary_searcher); return hits_by_uri.Values; }
/// <summary> /// the public profile of a user /// </summary> /// <remarks> /// See https://developer.linkedin.com/documents/profile-api /// </remarks> public Profiles.Person GetPublicProfile( UserAuthorization user , string publicProfileUrl , string[] acceptLanguages , FieldSelector<Profiles.Person> fields = null ) { const string urlFormat = "/v1/people/url={PublicProfileUrl}{FieldSelector}"; var url = FormatUrl(urlFormat, fields, "PublicProfileUrl", publicProfileUrl); var context = new RequestContext(); context.UserAuthorization = user; context.AcceptLanguages = acceptLanguages; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Profiles.Person>(context); return result; }
/// <summary> /// retrieve the member's updates /// </summary> public Social.UserUpdates GetMyUpdates( UserAuthorization user , int start = 0 , int count = 50 , DateTime? before = null , DateTime? after = null , bool showHiddenMembers = false , FieldSelector<Social.UserUpdates> fields = null ) { const string urlFormat = "/v1/people/~/network/updates?scope=self&start={int start = 0}&count={int count = 50}&before={DateTime? before = null}&after={DateTime? after = null}&show-hidden-members={bool showHiddenMembers = false}"; var url = FormatUrl(urlFormat, fields, "int start = 0", start, "int count = 50", count, "DateTime? before = null", before, "DateTime? after = null", after, "bool showHiddenMembers = false", showHiddenMembers); var context = new RequestContext(); context.UserAuthorization = user; context.Method = "GET"; context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url; if (!this.ExecuteQuery(context)) this.HandleJsonErrorResponse(context); var result = this.HandleJsonResponse<Social.UserUpdates>(context); return result; }
internal LuceneSearchResults(Query query, IEnumerable <SortField> sortField, Searcher searcher, int maxResults, FieldSelector fieldSelector) { LuceneQuery = query; FieldSelector = fieldSelector; LuceneSearcher = searcher; _maxResults = maxResults; _sortField = sortField; }
public abstract Document Doc(int docid, FieldSelector fieldSelector);
public void CreatesWithEmptyList() { var target = new FieldSelector<FieldSelectorTests>(); Assert.AreEqual(0, target.Items.Length); }
/*internal*/ public Document Doc(int n, FieldSelector fieldSelector) { SeekIndex(n); long position = indexStream.ReadLong(); fieldsStream.Seek(position); var doc = new Document(); int numFields = fieldsStream.ReadVInt(); for (int i = 0; i < numFields; i++) { int fieldNumber = fieldsStream.ReadVInt(); FieldInfo fi = fieldInfos.FieldInfo(fieldNumber); FieldSelectorResult acceptField = fieldSelector == null?FieldSelectorResult.LOAD:fieldSelector.Accept(fi.name); byte bits = fieldsStream.ReadByte(); System.Diagnostics.Debug.Assert(bits <= FieldsWriter.FIELD_IS_COMPRESSED + FieldsWriter.FIELD_IS_TOKENIZED + FieldsWriter.FIELD_IS_BINARY); bool compressed = (bits & FieldsWriter.FIELD_IS_COMPRESSED) != 0; System.Diagnostics.Debug.Assert( (!compressed || (format < FieldsWriter.FORMAT_LUCENE_3_0_NO_COMPRESSED_FIELDS)), "compressed fields are only allowed in indexes of version <= 2.9"); bool tokenize = (bits & FieldsWriter.FIELD_IS_TOKENIZED) != 0; bool binary = (bits & FieldsWriter.FIELD_IS_BINARY) != 0; //TODO: Find an alternative approach here if this list continues to grow beyond the //list of 5 or 6 currently here. See Lucene 762 for discussion if (acceptField.Equals(FieldSelectorResult.LOAD)) { AddField(doc, fi, binary, compressed, tokenize); } else if (acceptField.Equals(FieldSelectorResult.LOAD_AND_BREAK)) { AddField(doc, fi, binary, compressed, tokenize); break; //Get out of this loop } else if (acceptField.Equals(FieldSelectorResult.LAZY_LOAD)) { AddFieldLazy(doc, fi, binary, compressed, tokenize); } else if (acceptField.Equals(FieldSelectorResult.SIZE)) { SkipField(binary, compressed, AddFieldSize(doc, fi, binary, compressed)); } else if (acceptField.Equals(FieldSelectorResult.SIZE_AND_BREAK)) { AddFieldSize(doc, fi, binary, compressed); break; } else { SkipField(binary, compressed); } } return doc; }
public BasicRule(FieldSelector selector, CapturedConstraint constraint) { this.Selector = selector; this.Constraint = constraint.Constraint.Optimize(); }