/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ExternalId != null) { hashCode = hashCode * 59 + ExternalId.GetHashCode(); } if (Metadata != null) { hashCode = hashCode * 59 + Metadata.GetHashCode(); } if (SensorType != null) { hashCode = hashCode * 59 + SensorType.GetHashCode(); } if (UnitOfMeasurement != null) { hashCode = hashCode * 59 + UnitOfMeasurement.GetHashCode(); } if (fixedLatitude != null) { hashCode = hashCode * 59 + fixedLatitude.GetHashCode(); } if (fixedLongitude != null) { hashCode = hashCode * 59 + fixedLongitude.GetHashCode(); } return(hashCode); } }
public async Task AddEffectiveAuthorizationAsync_Event_Stored_With_Invalid_Authorization_No_Owner_Throws_NullReferenceException() { //Arrange var eaEventsStorate = new RawEventInMemoryStorage(); var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory(); eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler()); var eatimelineFactory = new EffectiveAuthorizationTimelineFactory(eaEventsStorate, eaHandlerFactory); var prService = new PersonalInfoEnrichmentService(new MockPersonalLocalStorage(), new MockPersonalInfoExternalServiceFactory(), new MockInMemoryLogger()); var rpStorage = new ReportingInMemoryStorage(); var owner = new ExternalId() { Id = _defaultId, Context = _defaultContext }; var effectiveAuthorization = new EffectiveAuthorization() { TenantId = _tenantId, User = owner }; var eaEvent = new EffectiveAuthorizationGrantedEvent() { From = new DateTime(2018, 1, 1), EffectiveAuthorization = effectiveAuthorization }; await eaEventsStorate.WriteRawEventAsync(eaEvent); //event needs to be previously writteng to storage. var dataEnrichmentService = new DataEnrichmentService(eatimelineFactory, prService, rpStorage); //Act & Assert await Assert.ThrowsExceptionAsync <NullReferenceException>(() => dataEnrichmentService.AddEffectiveAuthorizationAsync(eaEvent)); }
public Task <Person> FindPersonAsync(ExternalId externalId) { var person = persons.Find(x => x.Key.Context == externalId.Context && x.Key.Id == externalId.Id); return(Task.FromResult(person)); }
public async Task ResolvePerson_EmptyId_ThrowsException() { MockInMemoryLogger logger = new MockInMemoryLogger(); try { var personalInfoEnrichmentService = new PersonalInfoEnrichmentService( new Mock <IPersonLocalStorage>().Object, new Mock <IPersonalInfoExternalServiceFactory>().Object, logger); var externalId = new ExternalId() { Context = "Youforce" }; await personalInfoEnrichmentService.ResolvePerson(externalId); } catch (Exception e) { Assert.AreEqual(typeof(ArgumentException), e.GetType()); } finally { var log = logger.Logs.Dequeue(); Assert.AreEqual(LogLevel.Error, log.LogLevel); Assert.AreEqual("PersonalInfoEnrichmentService: Invalid External ID", log.Message); } }
public async Task ResolvePerson_ExternalIdNotFoundInLocalStorage_UnknownContext_ReturnsPersonWithoutEnrichmentInfo() { var externalId = new ExternalId() { Context = "Other", Id = "0001" }; Mock <IPersonLocalStorage> localStorage = new Mock <IPersonLocalStorage>(); localStorage.Setup(x => x.FindPersonAsync(externalId)).ReturnsAsync(() => null); Mock <IPersonalInfoExternalServiceFactory> extServiceFactory = new Mock <IPersonalInfoExternalServiceFactory>(); extServiceFactory.Setup(x => x.Resolve("Other")).Returns(() => null); var logger = new MockInMemoryLogger(); var personalInfoEnrichmentService = new PersonalInfoEnrichmentService(localStorage.Object, extServiceFactory.Object, logger); var person = await personalInfoEnrichmentService.ResolvePerson(externalId); Assert.IsNotNull(person); Assert.AreEqual(externalId.Context, person.Key.Context); Assert.AreEqual(externalId.Id, person.Key.Id); Assert.IsNull(person.PersonalInfo); var log = logger.Logs.Dequeue(); Assert.AreEqual(LogLevel.Warning, log.LogLevel); Assert.AreEqual( $"PersonalInfoEnrichmentService: Error on getting Personal Info for ExternalId [Context: {externalId.Context}, Id: {externalId.Id}]. Can't find a valid resolver api for given context. Person will be created based on Technical Keys only.", log.Message); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (IdStr != null) { hashCode = hashCode * 59 + IdStr.GetHashCode(); } if (ExternalId != null) { hashCode = hashCode * 59 + ExternalId.GetHashCode(); } if (Error != null) { hashCode = hashCode * 59 + Error.GetHashCode(); } if (Status != null) { hashCode = hashCode * 59 + Status.GetHashCode(); } if (ActivityId != null) { hashCode = hashCode * 59 + ActivityId.GetHashCode(); } return(hashCode); } }
public async Task ResolvePerson_ExternalIdFoundInLocalStorage_ReturnsPersonFromLocalStorage() { var externalId = new ExternalId() { Context = "Youforce", Id = "0001" }; Mock <IPersonLocalStorage> localStorage = new Mock <IPersonLocalStorage>(); localStorage.Setup(x => x.FindPersonAsync(externalId)) .ReturnsAsync(new Person(externalId, new PersonalInfo() { LastNameAtBirth = "Van der Test", Initials = "VT", BirthDate = new DateTime(1970, 1, 15) })); var personalInfoEnrichmentService = new PersonalInfoEnrichmentService( localStorage.Object, new Mock <IPersonalInfoExternalServiceFactory>().Object, new Mock <ILogger>().Object); var person = await personalInfoEnrichmentService.ResolvePerson(externalId); Assert.IsNotNull(person); Assert.AreEqual(externalId.Context, person.Key.Context); Assert.AreEqual(externalId.Id, person.Key.Id); Assert.AreEqual("Van der Test", person.PersonalInfo.LastNameAtBirth); Assert.AreEqual("VT", person.PersonalInfo.Initials); Assert.AreEqual(1970, person.PersonalInfo.BirthDate.Year); Assert.AreEqual(1, person.PersonalInfo.BirthDate.Month); Assert.AreEqual(15, person.PersonalInfo.BirthDate.Day); }
/** Writes out an entity declaration for this entity */ public void Write(StreamWriter writer) { writer.Write("<!ENTITY "); if (IsParsed) { writer.Write(" % "); } writer.Write(Name); if (Value != null) { char quoteChar = '"'; if (Value.IndexOf(quoteChar) >= 0) { quoteChar = '\''; } writer.Write(quoteChar); writer.Write(Value); writer.Write(quoteChar); } else { ExternalId.Write(writer); if (Ndata != null) { writer.Write(" NDATA "); writer.Write(Ndata); } } writer.WriteLine(">"); }
/// <summary> /// Computes and retrieves a hash code for an object. /// </summary> /// <remarks> /// This method implements the <see cref="Object">Object</see> method. /// </remarks> /// <returns>A hash code for an object.</returns> public override int GetHashCode() { return(Culture.GetHashCode() + Id.GetHashCode() + UserId.GetValueOrDefault().GetHashCode() + ExternalId.GetHashCode()); }
public void ParseWorks() { foreach (var identifier in ExpectedOrder) { Assert.Equal(identifier, ExternalId.Parse(identifier.ToString())); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is V1Employee other && ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) && ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) && ((FirstName == null && other.FirstName == null) || (FirstName?.Equals(other.FirstName) == true)) && ((LastName == null && other.LastName == null) || (LastName?.Equals(other.LastName) == true)) && ((RoleIds == null && other.RoleIds == null) || (RoleIds?.Equals(other.RoleIds) == true)) && ((AuthorizedLocationIds == null && other.AuthorizedLocationIds == null) || (AuthorizedLocationIds?.Equals(other.AuthorizedLocationIds) == true)) && ((Email == null && other.Email == null) || (Email?.Equals(other.Email) == true)) && ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) && ((ExternalId == null && other.ExternalId == null) || (ExternalId?.Equals(other.ExternalId) == true)) && ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) && ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true))); }
public async Task RawEventStorageRepository_GetRawEventsAsync_ExistingRevokedEvent_Returns_EffectiveAuthorizationRevokedEvent_With_Right_EffectiveAuthorization() { //Arrange: create event data to be stored var owner = new ExternalId() { Context = _ownerContext, Id = _ownerId }; var permission = new HAS.Core.Domain.Permission() { Application = _applicationName, Id = _Identifier, Description = _Identifier }; var effectiveAuthorization = new EffectiveAuthorization() { TenantId = _tenantId, Permission = permission, User = owner }; var eaEvent = new EffectiveAuthorizationRevokedEvent() { Until = _until, EffectiveAuthorization = effectiveAuthorization, DateCreated = DateTime.Now }; //Act: Attempt to write event to repository _eventIdList.Add(await _repository.WriteRawEventAsync(eaEvent)); //Act: Attempt to get nonexisting event var rawEventList = await _repository.GetRawEventsAsync(effectiveAuthorization); var revokedRawEventList = rawEventList.Where(e => e.GetType() == typeof(EffectiveAuthorizationRevokedEvent)); //Assert: check that there is a returned Id with some data Assert.IsNotNull(rawEventList); Assert.IsTrue(rawEventList.Count > 0); Assert.IsNotNull(revokedRawEventList); Assert.AreEqual(rawEventList[0].EffectiveAuthorization, effectiveAuthorization); }
public async Task RawEventStorageRepository_WriteRawEventAsync_OnSuccessfulWritingRevokedEvent_Returns_Event_Id() { //Arrange: create event data to be stored var owner = new ExternalId() { Context = _ownerContext, Id = _ownerId }; var permission = new HAS.Core.Domain.Permission() { Application = _applicationName, Id = _Identifier, Description = _Identifier }; var effectiveAuthorization = new EffectiveAuthorization() { TenantId = _tenantId, Permission = permission, User = owner }; var eaEvent = new EffectiveAuthorizationRevokedEvent() { Until = _until, EffectiveAuthorization = effectiveAuthorization, DateCreated = DateTime.Now }; //Act: Attempt to write event to repository _eventIdList.Add(await _repository.WriteRawEventAsync(eaEvent)); //Assert: check that there is a returned Id with some data Assert.IsNotNull(_eventIdList[0]); Assert.IsTrue(_eventIdList[0].Length > 0); }
public async Task ReportingStorageRepository_GetIntervals_NonExistingEffectiveAuthorization_Returns_EmptyList() { //Arrange: create Non-existing EffectiveAuthorization var owner = new ExternalId() { Context = "NonExisting", Id = "NonExisting" }; var permission = new HAS.Core.Domain.Permission() { Application = "NonExisting", Id = "NonExisting", Description = "NonExisting" }; var target = new ExternalId() { Id = "NonExisting", Context = "NonExisting" }; var effectiveAuthorization = new EffectiveAuthorization() { TenantId = "NonExisting" + DateTime.Now.Ticks, Permission = permission, User = owner, Target = target }; //Act: Attempt to get EffectiveAuthorization intervals var intervals = await _repository.GetIntervals(effectiveAuthorization); //Assert: check that there is no returned data Assert.IsNotNull(intervals); Assert.AreEqual(0, intervals.Count); }
public async Task ReportingStorageRepository_SaveAsync_OnSuccessfulWritingEffectiveAuthorizationInterval_Without_TargetPerson_Returns_EffectiveAuthorizationInterval_Id() { //Arrange: create EffectiveAuthorizationInterval data to be stored var owner = new ExternalId() { Context = _ownerContext, Id = _ownerId }; var user = new Person(owner, new PersonalInfo() { BirthDate = _birthDate1, Initials = _initials1, LastNameAtBirth = _lastNameAtBirth1, LastNameAtBirthPrefix = _lastNameAtBirthPrefix1 }); var permission = new HAS.Core.Domain.Permission() { Application = _applicationName, Id = _Identifier, Description = _Identifier }; var interval = new Interval(_dateTimeStart1, null); var effectiveAuthorizationInterval = new EffectiveAuthorizationInterval(interval, user, null, permission, _tenantId); var intervalList = new List <EffectiveAuthorizationInterval>(); intervalList.Add(effectiveAuthorizationInterval); //Act: Attempt to write effectiveAuthorizationInterval to repository _idToDeleteList.AddRange((await _repository.SaveAsync(intervalList)).Split(",")); //Assert: check that there is a returned Id with some data Assert.IsNotNull(_idToDeleteList[0]); Assert.IsTrue(_idToDeleteList[0].Length > 0); }
public async Task ReportingStorageRepository_GetIntervals_ExistingEffectiveAuthorizationInterval_With_TargetPerson_Returns_EffectiveAuthorizationGrantedEvent_With_Right_EffectiveAuthorization() { //Arrange: create EffectiveAuthorizationInterval data to be stored var owner = new ExternalId() { Context = _ownerContext, Id = _ownerId }; var user = new Person(owner, new PersonalInfo() { BirthDate = _birthDate1, Initials = _initials1, LastNameAtBirth = _lastNameAtBirth1, LastNameAtBirthPrefix = _lastNameAtBirthPrefix1 }); var target = new ExternalId() { Context = _ownerContext, Id = _targetId }; var targetPerson = new Person(target, new PersonalInfo() { BirthDate = _birthDate2, Initials = _initials2, LastNameAtBirth = _lastNameAtBirth2, LastNameAtBirthPrefix = _lastNameAtBirthPrefix2 }); var permission = new HAS.Core.Domain.Permission() { Application = _applicationName, Id = _Identifier, Description = _Identifier }; var interval = new Interval(_dateTimeStart1, null); var effectiveAuthorizationInterval = new EffectiveAuthorizationInterval(interval, user, targetPerson, permission, _tenantId); var effectiveAuthorization = new EffectiveAuthorization() { TenantId = _tenantId, Permission = permission, User = owner, Target = target }; var intervalList = new List <EffectiveAuthorizationInterval>(); intervalList.Add(effectiveAuthorizationInterval); //Act: Attempt to write effectiveAuthorizationInterval to repository and getting it back _idToDeleteList.AddRange((await _repository.SaveAsync(intervalList)).Split(",")); var effectiveAuthorizationIntervals = await _repository.GetIntervals(effectiveAuthorization); //Assert: check that there is a returned Id with some data Assert.IsNotNull(effectiveAuthorizationIntervals); Assert.IsTrue(effectiveAuthorizationIntervals.Count > 0); Assert.IsInstanceOfType(effectiveAuthorizationIntervals[0], typeof(EffectiveAuthorizationInterval)); Assert.AreEqual(effectiveAuthorizationIntervals[0].TenantId, effectiveAuthorization.TenantId); Assert.AreEqual(effectiveAuthorizationIntervals[0].User.Key, effectiveAuthorization.User); Assert.AreEqual(effectiveAuthorizationIntervals[0].TargetPerson.Key, effectiveAuthorization.Target); Assert.AreEqual(effectiveAuthorizationIntervals[0].Permission, effectiveAuthorization.Permission); }
public static Core.Domain.ExternalId MapExternalId(ExternalId dtoExternalId) { return(new Core.Domain.ExternalId() { Id = dtoExternalId.Id.Trim(), Context = dtoExternalId.Context.Trim() }); }
public override int GetHashCode() { unchecked { return(((ExternalId != null ? ExternalId.GetHashCode() : 0) * 397) ^ (LinkInstanceName != null ? LinkInstanceName.GetHashCode() : 0)); } }
public void Create_EffectiveAuthorization_Without_EffectiveAuthorizationEvent_InStorage_Returns_Timeline_With_EffectiveAuthorization() { //Arrange var eaEventsStorate = new RawEventInMemoryStorage(); var eaHandlerFactory = new EffectiveAuthorizationHandlerFactory(); eaHandlerFactory.RegisterHandler(typeof(EffectiveAuthorizationGrantedEvent), new PermissionGrantedHandler()); var owner = new ExternalId() { Id = _defaultId, Context = _defaultContext }; var permission = new Permission() { Application = _defaultApplication, Id = _defaultPermissionId, Description = _defaultDescription }; var effectiveAuthorization = new EffectiveAuthorization() { TenantId = _tenantId, Permission = permission, User = owner }; var eaTimelineFactory = new EffectiveAuthorizationTimelineFactory(eaEventsStorate, eaHandlerFactory); //Act var eaTimeline = eaTimelineFactory.Create(effectiveAuthorization).Result; //Assert Assert.IsNotNull(eaTimeline); Assert.AreEqual(effectiveAuthorization, eaTimeline.EffectiveAuthorization); }
/// <summary> /// Creates a Person object based on provided ExternalId /// </summary> /// <param name="externalId">Person context identifier</param> /// <exception cref="System.ArgumentException">Thrown when ExternalId is not valid (Empty properties)</exception> /// <returns>Person enriched with resolved personal information</returns> public async Task <Person> ResolvePerson(ExternalId externalId) { ValidateExternalId(externalId); var person = await personLocalStorage.FindPersonAsync(externalId); if (person != null) { return(person); } var persInfoExternalService = persInfoExternalServiceFactory.Resolve(externalId.Context); if (persInfoExternalService == null) { LogResolverApiNotFound(externalId); return(new Person(externalId, null)); } var personalInfo = await persInfoExternalService.FindPersonalInfoAsync(externalId.Id); if (personalInfo == null) { LogPersonalInfoNotFound(externalId); return(new Person(externalId, null)); } return(await personLocalStorage.CreatePersonAsync(new Person(externalId, personalInfo))); }
public override int GetHashCode() { int hash = 1; if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (DisplayName.Length != 0) { hash ^= DisplayName.GetHashCode(); } if (ExternalId.Length != 0) { hash ^= ExternalId.GetHashCode(); } if (Size != 0) { hash ^= Size.GetHashCode(); } if (HeadquartersAddress.Length != 0) { hash ^= HeadquartersAddress.GetHashCode(); } if (HiringAgency != false) { hash ^= HiringAgency.GetHashCode(); } if (EeoText.Length != 0) { hash ^= EeoText.GetHashCode(); } if (WebsiteUri.Length != 0) { hash ^= WebsiteUri.GetHashCode(); } if (CareerSiteUri.Length != 0) { hash ^= CareerSiteUri.GetHashCode(); } if (ImageUri.Length != 0) { hash ^= ImageUri.GetHashCode(); } hash ^= keywordSearchableJobCustomAttributes_.GetHashCode(); if (derivedInfo_ != null) { hash ^= DerivedInfo.GetHashCode(); } if (Suspended != false) { hash ^= Suspended.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private FixedIncomeStripWithSecurity(FixedIncomeStrip originalStrip, Tenor resolvedTenor, DateTimeOffset maturity, ExternalId securityIdentifier, ISecurity security) { _resolvedTenor = resolvedTenor; _originalStrip = originalStrip; _maturity = maturity; _securityIdentifier = securityIdentifier; _security = security; }
private static void EqualsCodeBehavesAsExpected(Func <ExternalId, ExternalId, bool> equals) { foreach (var id in ExpectedOrder) { Assert.Equal(1, ExpectedOrder.Where(e => equals(e, id)).Count()); Assert.True(equals(id, ExternalId.Create(id.Scheme, id.Value))); } }
public void HashCodeBehavesAsExpected() { foreach (var identifier in ExpectedOrder) { Assert.Equal(1, ExpectedOrder.Where(e => e.GetHashCode() == identifier.GetHashCode()).Count()); Assert.Equal(identifier.GetHashCode(), ExternalId.Create(identifier.Scheme, identifier.Value).GetHashCode()); } }
public void AddValue(ExternalId identifier, string valueName, object value) { ArgumentChecker.NotNull(identifier, "identifier"); ArgumentChecker.NotEmpty(valueName, "valueName"); AddValue(new AddValueRequest { Identifier = identifier, ValueName = valueName, Value = value }); }
public void RemoveValue(ExternalId identifier, string valueName) { ArgumentChecker.NotNull(identifier, "identifier"); ArgumentChecker.NotEmpty(valueName, "valueName"); RemoveValue(new RemoveValueRequest { Identifier = identifier, ValueName = valueName }); }
private void LogPersonalInfoNotFound(ExternalId externalId) { string message = $"PersonalInfoEnrichmentService: Error on getting Personal Info for ExternalId [Context: {externalId.Context}, Id: {externalId.Id}]. "; message += "Personal Info not found by provided resolver api for given context. "; message += "Person will be created based on Technical Keys only."; logger.LogWarning(message); }
/// <summary> /// Returns true if OgcDataStreamInfo instances are equal /// </summary> /// <param name="other">Instance of OgcDataStreamInfo to be compared</param> /// <returns>Boolean</returns> public bool Equals(OgcDataStreamInfo other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( DataStreamId == other.DataStreamId || DataStreamId != null && DataStreamId.Equals(other.DataStreamId) ) && ( MqttTopic == other.MqttTopic || MqttTopic != null && MqttTopic.Equals(other.MqttTopic) ) && ( MqttServer == other.MqttServer || MqttServer != null && MqttServer.Equals(other.MqttServer) ) && ( ExternalId == other.ExternalId || ExternalId != null && ExternalId.Equals(other.ExternalId) ) && ( Metadata == other.Metadata || Metadata != null && Metadata.Equals(other.Metadata) ) && ( SensorType == other.SensorType || SensorType != null && SensorType.Equals(other.SensorType) ) && ( UnitOfMeasurement == other.UnitOfMeasurement || UnitOfMeasurement != null && UnitOfMeasurement.Equals(other.UnitOfMeasurement) ) && ( fixedLatitude == other.fixedLatitude || fixedLatitude != null && fixedLatitude.Equals(other.fixedLatitude) ) && ( fixedLongitude == other.fixedLongitude || fixedLongitude != null && fixedLongitude.Equals(other.fixedLongitude) )); }
public InterpolatedYieldCurveSpecification(DateTimeOffset curveDate, string name, Currency currency, List <FixedIncomeStripWithIdentifier> resolvedStrips, ExternalId region) { _curveDate = curveDate; _name = name; _currency = currency; _resolvedStrips = resolvedStrips; _region = region; }
public InterpolatedYieldCurveSpecification(DateTimeOffset curveDate, string name, Currency currency, List<FixedIncomeStripWithIdentifier> resolvedStrips, ExternalId region) { _curveDate = curveDate; _name = name; _currency = currency; _resolvedStrips = resolvedStrips; _region = region; }
public override string ToString() { if (!string.IsNullOrEmpty(Description)) { return(Description); } return(ExternalId.ToString()); }
/// <summary> /// Creates a link to retrieve a series by external id (currently only imdb id supported) /// /// http://forums.thetvdb.com/viewtopic.php?f=8&t=3724&start=0 /// </summary> /// <param name="apiKey">api key</param> /// <param name="site">type of external site</param> /// <param name="id">id on the site</param> /// <returns></returns> internal static String CreateGetSeriesByIdLink(String apiKey, ExternalId site, String id) { String siteString; switch (site) { case ExternalId.ImdbId: siteString = "imdbid"; break; default: return "";//unknown site } String link = String.Format("{0}/api/GetSeriesByRemoteID.php?{1}={2}", BASE_SERVER, siteString, id); return link; //http://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=tt0411008 }
/// <summary> /// Searches for a series by the id of an external provider /// </summary> /// <param name="externalSite">external provider</param> /// <param name="id">id of the series</param> /// <returns>The tvdb series that corresponds to the external id</returns> public TvdbSearchResult GetSeriesByRemoteId(ExternalId externalSite, String id) { TvdbSearchResult retSeries = _downloader.DownloadSeriesSearchByExternalId(externalSite, id); return retSeries; }
public FixedIncomeStripWithIdentifier(ExternalId security, FixedIncomeStrip strip) { _security = security; _strip = strip; }
/// <summary> /// Download a series search for the id of an external site /// </summary> /// <param name="site">The site that provides the external id</param> /// <param name="id">The id that identifies the series on the external site</param> /// <exception cref="TvdbInvalidXmlException"><para>Exception is thrown when there was an error parsing the xml files. </para> /// <para>Feel free to post a detailed description of this issue on http://code.google.com/p/tvdblib /// or http://forums.thetvdb.com/</para></exception> /// <exception cref="TvdbInvalidApiKeyException">The stored api key is invalid</exception> /// <exception cref="TvdbNotAvailableException">The tvdb database is unavailable</exception> /// <returns>the series object that corresponds to the given site and id</returns> public TvdbSearchResult DownloadSeriesSearchByExternalId(ExternalId site, String id) { //download the xml data from this request String xml = string.Empty; String link = string.Empty; try { link = TvdbLinkCreator.CreateGetSeriesByIdLink(_apiKey, site, id); xml = DownloadString(link); //extract all series the xml file contains List<TvdbSearchResult> seriesList = _xmlHandler.ExtractSeriesSearchResults(xml); //if a request is made on a series id, one and only one result //should be returned, otherwise there obviously was an error if (seriesList != null && seriesList.Count == 1) { TvdbSearchResult series = seriesList[0]; return series; } Log.Warn("More than one series returned when trying to retrieve series by id " + id); return null; } catch (XmlException ex) { Log.Error("Error parsing the xml file " + link + "\n\n" + xml, ex); throw new TvdbInvalidXmlException("Error parsing the xml file " + link + "\n\n" + xml); } catch (WebException ex) { throw HandleWebException("retrieve " + id, ex); } }
public CounterpartyImpl(ExternalId counterpartyId) { ArgumentChecker.NotNull(counterpartyId, "counterpartyId"); _counterpartyId = counterpartyId; }
public EquityOptionSecurity(string name, string securityType, UniqueId uniqueId, ExternalIdBundle identifiers, ExternalId underlyingIdentifier) : base(name, securityType, uniqueId, identifiers) { _underlyingIdentifier = underlyingIdentifier; }
/// <summary> /// Download a series search for the id of an external site /// </summary> /// <param name="_site">The site that provides the external id</param> /// <param name="_id">The id that identifies the series on the external site</param> /// <exception cref="TvdbInvalidXmlException"><para>Exception is thrown when there was an error parsing the xml files. </para> /// <para>Feel free to post a detailed description of this issue on http://code.google.com/p/tvdblib /// or http://forums.thetvdb.com/</para></exception> /// <exception cref="TvdbInvalidApiKeyException">The stored api key is invalid</exception> /// <exception cref="TvdbNotAvailableException">The tvdb database is unavailable</exception> /// <returns>the series object that corresponds to the given site and id</returns> public TvdbSearchResult DownloadSeriesSearchByExternalId(ExternalId _site, String _id) { //download the xml data from this request String xml = ""; String link = ""; try { link = TvdbLinkCreator.CreateGetSeriesByIdLink(m_apiKey, _site, _id); xml = m_webClient.DownloadString(link); //extract all series the xml file contains List<TvdbSearchResult> seriesList = m_xmlHandler.ExtractSeriesSearchResults(xml); //if a request is made on a series id, one and only one result //should be returned, otherwise there obviously was an error if (seriesList != null && seriesList.Count == 1) { TvdbSearchResult series = seriesList[0]; return series; } else { Log.Warn("More than one series returned when trying to retrieve series by id " + _id); return null; } } catch (XmlException ex) { Log.Error("Error parsing the xml file " + link + "\n\n" + xml, ex); throw new TvdbInvalidXmlException("Error parsing the xml file " + link + "\n\n" + xml); } catch (WebException ex) { Log.Warn("Request not successfull", ex); if (ex.Message.Equals("The remote server returned an error: (404) Not Found.")) { throw new TvdbInvalidApiKeyException("Couldn't connect to Thetvdb.com to retrieve " + _id + ", you may use an invalid api key or the series doesn't exists"); } else { throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve " + _id + ", check your internet connection and the status of http://thetvdb.com"); } } }
public void AddValue(ExternalId identifier, string valueName, object value) { ArgumentChecker.NotNull(identifier, "identifier"); ArgumentChecker.NotEmpty(valueName, "valueName"); AddValue(new AddValueRequest { Identifier = identifier, ValueName = valueName, Value = value}); }
public void RemoveValue(ExternalId identifier, string valueName) { ArgumentChecker.NotNull(identifier, "identifier"); ArgumentChecker.NotEmpty(valueName, "valueName"); RemoveValue(new RemoveValueRequest {Identifier = identifier, ValueName = valueName}); }