private T GetConnectionInfo <T>([NotNull] DevOpsInfo devOpsInfo, [NotNull] IDevOpsConnector connector) where T : DevOpsConnectionInfo { return(devOpsInfo?.Infos? .FirstOrDefault(x => string.CompareOrdinal(x.ConnectorId, connector.FactoryId) == 0 && string.CompareOrdinal(x.Url, connector.Url) == 0 && string.CompareOrdinal(x.Project, connector.Project) == 0) as T); }
private DevOpsInfo GetInfo([NotNull] IPropertiesContainer container) { DevOpsInfo result = null; var propertyType = GetDevOpsInfoPropertyType(); if (propertyType != null) { result = (container.GetProperty(propertyType) as IPropertyJsonSerializableObject)?.Value as DevOpsInfo; } return(result); }
private void SetInfo([NotNull] IPropertiesContainer container, DevOpsConnectionInfo connectionInfo) { var info = GetInfo(container); if (info == null) { var propertyType = GetDevOpsInfoPropertyType(); if (propertyType != null) { var property = (container.GetProperty(propertyType) as IPropertyJsonSerializableObject) ?? container.AddProperty(propertyType, null) as IPropertyJsonSerializableObject; if (property != null) { info = new DevOpsInfo(); info.Infos = new List <DevOpsConnectionInfo>(); info.Infos.Add(connectionInfo); property.Value = info; } } } else { var existing = info.Infos? .FirstOrDefault(x => string.CompareOrdinal(x.ConnectorId, connectionInfo.ConnectorId) == 0 && string.CompareOrdinal(x.Url?.ToLower(), connectionInfo.Url?.ToLower()) == 0 && string.CompareOrdinal(x.Project, connectionInfo.Project) == 0); if (existing != null) { info.Infos.Remove(existing); } if (info.Infos == null) { info.Infos = new List <DevOpsConnectionInfo>(); } info.Infos.Add(connectionInfo); } }