public RelativeRoute GetRoute(TValue fieldValue, bool searchSignificant)
        {
            if (!typeof(TValue).IsValueType && fieldValue == null)
            {
                return(null);
            }

            string stringValue;

            if (IsGuidField)
            {
                stringValue = UrlUtils.CompressGuid((fieldValue as Guid?).Value);
            }
            else if (IsStringField)
            {
                stringValue = searchSignificant ? UrlUtils.EncodeUrlInvalidCharacters(fieldValue as string)
                                                : StringToUrlPart(fieldValue as string);
            }
            else
            {
                stringValue = ValueTypeConverter.Convert <string>(fieldValue);
            }


            return(new RelativeRoute {
                PathSegments = new[] { stringValue }
            });
        }
Esempio n. 2
0
        internal static string GetEntityTokenHash(EntityToken entityToken)
        {
            var entityTokenString = EntityTokenSerializer.Serialize(entityToken);
            var bytes             = Encoding.UTF8.GetBytes(entityTokenString);

            return(UrlUtils.CompressGuid(new Guid(HashingAlgorithm.ComputeHash(bytes))));
        }
Esempio n. 3
0
        /// <exclude />
        public static string CreateTempDirectory()
        {
            string directory = Path.Combine(TempDirectoryPath, UrlUtils.CompressGuid(Guid.NewGuid()));

            C1Directory.CreateDirectory(directory);

            return(directory);
        }
        internal static string GetTempFileName(string extension)
        {
            if (!extension.StartsWith("."))
            {
                extension = "." + extension;
            }

            return(Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory),
                                UrlUtils.CompressGuid(Guid.NewGuid()).Substring(0, 8)) + (extension ?? ""));
        }
        private string GetDocumentId(IPage page)
        {
            bool isUnpublished = page.DataSourceId.PublicationScope == PublicationScope.Unpublished;

            string versionId = "";

            if (page.VersionId != Guid.Empty)
            {
                versionId = UrlUtils.CompressGuid(page.VersionId);
            }
            return($"{UrlUtils.CompressGuid(page.Id)}{versionId}" + (isUnpublished ? "u" : ""));
        }
Esempio n. 6
0
        private string GetDocumentId(IData data)
        {
            var uniqueKey = data.GetUniqueKey();

            if (uniqueKey is Guid)
            {
                uniqueKey = UrlUtils.CompressGuid((Guid)uniqueKey);
            }

            string scopeSuffix = _isPublishable && data.DataSourceId.PublicationScope == PublicationScope.Unpublished
                ? "u" : string.Empty;

            return(uniqueKey + scopeSuffix);
        }
Esempio n. 7
0
        private static string GetUrlKey(IData data)
        {
            object keyValue = _keyPropertyInfo.GetValue(data);

            if (keyValue == null)
            {
                return(null);
            }

            if (keyValue is Guid)
            {
                return(UrlUtils.CompressGuid((Guid)keyValue));
            }

            string urlKey = keyValue.ToString();

            return(string.IsNullOrEmpty(urlKey) ? null : urlKey);
        }
Esempio n. 8
0
 internal static string GetTempFileName(string extension)
 {
     return(Path.Combine(TempDirectoryPath, UrlUtils.CompressGuid(Guid.NewGuid()).Substring(0, 8)) + (extension ?? ""));
 }
 private static string GenerateRandomString(int length)
 {
     return(UrlUtils.CompressGuid(Guid.NewGuid()).Substring(0, length));
 }