ToSic.SexyContent.EAV.Implementation.ValueConverter.SexyContentValueConverter.ResolveFileLink C# (CSharp) Méthode

ResolveFileLink() private méthode

private ResolveFileLink ( int linkId, string defaultValue ) : string
linkId int
defaultValue string
Résultat string
        private string ResolveFileLink(int linkId, string defaultValue)
        {
            var fileInfo = FileManager.Instance.GetFile(linkId);
            if (fileInfo == null)
                return defaultValue;

            #region special handling of issues in case something in the background is broken
            // there are cases where the PortalSettings will be null or something, and in these cases the serializer would break down
            // so this is to just ensure that if it can't be converted, it'll just fall back to default
            try
            {
                return Path.Combine(new PortalSettings(fileInfo.PortalId)?.HomeDirectory ?? "", fileInfo?.RelativePath ?? "");
            }
            catch
            {
                return defaultValue;
            }
            #endregion
        }