Changes in Xamarin Client to fox image erro with local Docker
This commit is contained in:
parent
484a7d0d14
commit
67bfe7ddf9
@ -0,0 +1,36 @@
|
|||||||
|
using eShopOnContainers.Core.Models.Catalog;
|
||||||
|
using eShopOnContainers.ViewModels.Base;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace eShopOnContainers.Core.Helpers
|
||||||
|
{
|
||||||
|
public static class ServicesHelper
|
||||||
|
{
|
||||||
|
public static void FixCatalogItemPictureUri(IEnumerable<CatalogItem> catalogItems)
|
||||||
|
{
|
||||||
|
if(catalogItems == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ViewModelLocator.Instance.UseMockService
|
||||||
|
&& Settings.UrlBase != GlobalSetting.DefaultEndpoint)
|
||||||
|
{
|
||||||
|
foreach (var catalogItem in catalogItems)
|
||||||
|
{
|
||||||
|
Regex ip = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
|
||||||
|
MatchCollection serverResult = ip.Matches(catalogItem.PictureUri);
|
||||||
|
MatchCollection localResult = ip.Matches(Settings.UrlBase);
|
||||||
|
|
||||||
|
if (serverResult.Count != -1 && localResult.Count != -1)
|
||||||
|
{
|
||||||
|
var serviceIp = serverResult[0].Value;
|
||||||
|
var localIp = localResult[0].Value;
|
||||||
|
catalogItem.PictureUri = catalogItem.PictureUri.Replace(serviceIp, localIp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,11 +5,7 @@ using eShopOnContainers.Core.Models.Catalog;
|
|||||||
using eShopOnContainers.Core.Services.RequestProvider;
|
using eShopOnContainers.Core.Services.RequestProvider;
|
||||||
using eShopOnContainers.Core.Extensions;
|
using eShopOnContainers.Core.Extensions;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using eShopOnContainers.ViewModels.Base;
|
|
||||||
using eShopOnContainers.Core.Helpers;
|
using eShopOnContainers.Core.Helpers;
|
||||||
using Xamarin.Forms;
|
|
||||||
using eShopOnContainers.Core.Services.IPAddress;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace eShopOnContainers.Core.Services.Catalog
|
namespace eShopOnContainers.Core.Services.Catalog
|
||||||
{
|
{
|
||||||
@ -61,22 +57,7 @@ namespace eShopOnContainers.Core.Services.Catalog
|
|||||||
|
|
||||||
if (catalog?.Data != null)
|
if (catalog?.Data != null)
|
||||||
{
|
{
|
||||||
// TODO: Experimental
|
ServicesHelper.FixCatalogItemPictureUri(catalog?.Data);
|
||||||
if (!ViewModelLocator.Instance.UseMockService && Settings.UrlBase != GlobalSetting.DefaultEndpoint)
|
|
||||||
{
|
|
||||||
foreach (var catalogItem in catalog?.Data)
|
|
||||||
{
|
|
||||||
//string ipaddress = DependencyService.Get<IIPAddressService>().GetIPAddress();
|
|
||||||
Regex ip = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
|
|
||||||
MatchCollection result = ip.Matches(catalogItem.PictureUri);
|
|
||||||
|
|
||||||
if (result.Count != -1)
|
|
||||||
{
|
|
||||||
var serviceIp = result[0].Value;
|
|
||||||
catalogItem.PictureUri = catalogItem.PictureUri.Replace(serviceIp, Settings.UrlBase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return catalog?.Data.ToObservableCollection();
|
return catalog?.Data.ToObservableCollection();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
namespace eShopOnContainers.Core.Services.IPAddress
|
|
||||||
{
|
|
||||||
public interface IIPAddressService
|
|
||||||
{
|
|
||||||
string GetIPAddress();
|
|
||||||
}
|
|
||||||
}
|
|
@ -66,6 +66,7 @@
|
|||||||
<Compile Include="Extensions\ObservableExtension.cs" />
|
<Compile Include="Extensions\ObservableExtension.cs" />
|
||||||
<Compile Include="GlobalSettings.cs" />
|
<Compile Include="GlobalSettings.cs" />
|
||||||
<Compile Include="Helpers\EasingHelper.cs" />
|
<Compile Include="Helpers\EasingHelper.cs" />
|
||||||
|
<Compile Include="Helpers\ServicesHelper.cs" />
|
||||||
<Compile Include="Helpers\Settings.cs" />
|
<Compile Include="Helpers\Settings.cs" />
|
||||||
<Compile Include="Models\Basket\BasketItem.cs" />
|
<Compile Include="Models\Basket\BasketItem.cs" />
|
||||||
<Compile Include="Models\Basket\CustomerBasket.cs" />
|
<Compile Include="Models\Basket\CustomerBasket.cs" />
|
||||||
@ -94,7 +95,6 @@
|
|||||||
<Compile Include="Services\Dialog\IDialogService.cs" />
|
<Compile Include="Services\Dialog\IDialogService.cs" />
|
||||||
<Compile Include="Services\Identity\IdentityService.cs" />
|
<Compile Include="Services\Identity\IdentityService.cs" />
|
||||||
<Compile Include="Services\Identity\IIdentityService.cs" />
|
<Compile Include="Services\Identity\IIdentityService.cs" />
|
||||||
<Compile Include="Services\IPAddress\IIPAddressService.cs" />
|
|
||||||
<Compile Include="Services\Navigation\INavigationService.cs" />
|
<Compile Include="Services\Navigation\INavigationService.cs" />
|
||||||
<Compile Include="Services\Navigation\NavigationService.cs" />
|
<Compile Include="Services\Navigation\NavigationService.cs" />
|
||||||
<Compile Include="Services\OpenUrl\IOpenUrlService.cs" />
|
<Compile Include="Services\OpenUrl\IOpenUrlService.cs" />
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
using eShopOnContainers.Core.Services.IPAddress;
|
|
||||||
using eShopOnContainers.Droid.Services.IPAddress;
|
|
||||||
using System.Net;
|
|
||||||
using Xamarin.Forms;
|
|
||||||
|
|
||||||
[assembly: Dependency(typeof(IPAddressService))]
|
|
||||||
namespace eShopOnContainers.Droid.Services.IPAddress
|
|
||||||
{
|
|
||||||
public class IPAddressService : IIPAddressService
|
|
||||||
{
|
|
||||||
public string GetIPAddress()
|
|
||||||
{
|
|
||||||
System.Net.IPAddress[] adresses = Dns.GetHostAddresses(Dns.GetHostName());
|
|
||||||
|
|
||||||
if (adresses != null && adresses[0] != null)
|
|
||||||
{
|
|
||||||
return adresses[0].ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -231,7 +231,6 @@
|
|||||||
<Compile Include="Renderers\SlideDownMenuPageRenderer.cs" />
|
<Compile Include="Renderers\SlideDownMenuPageRenderer.cs" />
|
||||||
<Compile Include="Resources\Resource.Designer.cs" />
|
<Compile Include="Resources\Resource.Designer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\IPAddress\IPAddressService.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidAsset Include="..\CommonResources\Fonts\Montserrat-Bold.ttf">
|
<AndroidAsset Include="..\CommonResources\Fonts\Montserrat-Bold.ttf">
|
||||||
|
@ -178,9 +178,7 @@
|
|||||||
<Name>eShopOnContainers.Core</Name>
|
<Name>eShopOnContainers.Core</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="Services\IPAddress\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -429,9 +429,7 @@
|
|||||||
<Name>eShopOnContainers.Core</Name>
|
<Name>eShopOnContainers.Core</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="Services\IPAddress\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user