public void CompareVersionsDiffLengths() { VersionPath v1 = new VersionPath(1, 0); VersionPath v2 = new VersionPath(1, 0, 0); Assert.IsTrue(v2 > v1, "Version v1.0.0 was not greater than v1.0."); }
public void CompareVersions() { VersionPath v1 = new VersionPath(1, 0, 0); VersionPath v2 = new VersionPath(1, 0, 1); Assert.IsTrue(v2 > v1, "Version v1.0.1 was not greater than v1.0.0"); }
public string BuildEndpoint(RestClient client) { var sb = new StringBuilder(); var path = Path.IsNullOrBlank() ? client.Path.IsNullOrBlank() ? "" : client.Path : Path; var versionPath = VersionPath.IsNullOrBlank() ? client.VersionPath.IsNullOrBlank() ? "" : client.VersionPath : VersionPath; var skipAuthority = client.Authority.IsNullOrBlank(); sb.Append(skipAuthority ? "" : client.Authority); sb.Append(skipAuthority ? "" : client.Authority.EndsWith("/") ? "" : "/"); sb.Append(skipAuthority ? "" : versionPath.IsNullOrBlank() ? "" : versionPath); if (!skipAuthority && !versionPath.IsNullOrBlank()) { sb.Append(versionPath.EndsWith("/") ? "" : "/"); } sb.Append(path.IsNullOrBlank() ? "" : path.StartsWith("/") ? path.Substring(1) : path); var queryStringHandling = QueryHandling ?? client.QueryHandling ?? Hammock.QueryHandling.None; switch (queryStringHandling) { case Hammock.QueryHandling.AppendToParameters: return(WebExtensions.UriMinusQuery(sb.ToString(), Parameters)); default: return(sb.ToString()); } }
public override Page GetVersion(Page o, int version) { VersionPath versionPath = new VersionPath(o, version); var versionDataFile = Path.Combine(versionPath.PhysicalPath, o.DataFileName); Page page = null; if (File.Exists(versionDataFile)) { PageProvider provider = new PageProvider(); page = provider.Deserialize(o, versionDataFile); ((IPersistable)page).Init(o); } return(page); }
public override Page GetVersion(Page o, int version) { VersionPath versionPath = new VersionPath(o, version); var versionDataFile = Path.Combine(versionPath.PhysicalPath, o.DataFileName); Page page = null; if (File.Exists(versionDataFile)) { PageProvider provider = new PageProvider(); page = (Page)Kooboo.Runtime.Serialization.DataContractSerializationHelper.Deserialize(typeof(Page), KnownTypes, versionDataFile); ((IPersistable)page).Init(o); } return(page); }
public override HtmlBlock GetVersion(HtmlBlock o, int version) { VersionPath versionPath = new VersionPath(o, version); var versionDataFile = Path.Combine(versionPath.PhysicalPath, o.DataFileName); HtmlBlock htmlBlock = null; if (File.Exists(versionDataFile)) { HtmlBlockProvider provider = new HtmlBlockProvider(); htmlBlock = provider.Deserialize(o, versionDataFile); ((IPersistable)htmlBlock).Init(o); } return(htmlBlock); }
public override HtmlBlock GetVersion(HtmlBlock o, int version) { VersionPath versionPath = new VersionPath(o, version); var versionDataFile = Path.Combine(versionPath.PhysicalPath, DataFileName); HtmlBlock versionItem = null; if (File.Exists(versionDataFile)) { HtmlBlockProvider provider = new HtmlBlockProvider(); versionItem = new HtmlBlock(o.Site, o.Name); versionItem.Body = IO.IOUtility.ReadAsString(versionDataFile); ((IPersistable)versionItem).Init(o); } return(versionItem); }
public override void LogVersion(HtmlBlock o) { locker.EnterWriteLock(); try { VersionPath versionPath = new VersionPath(o, NextVersionId(o)); IOUtility.EnsureDirectoryExists(versionPath.PhysicalPath); var versionDataFile = Path.Combine(versionPath.PhysicalPath, DataFileName); HtmlBlockProvider provider = new HtmlBlockProvider(); IO.IOUtility.SaveStringToFile(versionDataFile, o.Body); } finally { locker.ExitWriteLock(); } }
public override void LogVersion(Page o) { locker.EnterWriteLock(); try { VersionPath versionPath = new VersionPath(o, NextVersionId(o)); IOUtility.EnsureDirectoryExists(versionPath.PhysicalPath); var versionDataFile = Path.Combine(versionPath.PhysicalPath, o.DataFileName); PageProvider provider = new PageProvider(); provider.Serialize(o, versionDataFile); } finally { locker.ExitWriteLock(); } }
public override T GetVersion(T o, int version) { o = o.AsActual(); VersionPath versionPath = new VersionPath(o, version); var versionDataFile = Path.Combine(versionPath.PhysicalPath, Path.GetFileName(o.DataFile)); var versionTemplateFile = Path.Combine(versionPath.PhysicalPath, Path.GetFileName(o.TemplateFileName)); T template = null; if (File.Exists(versionDataFile)) { var provider = GetTemplateProvider(); template = (T)Kooboo.Runtime.Serialization.DataContractSerializationHelper.Deserialize(typeof(T), KnownTypes, versionDataFile); template.Body = IOUtility.ReadAsString(versionTemplateFile); template.Init(o); } return(template); }
public override T GetVersion(T o, int version) { o = o.AsActual(); VersionPath versionPath = new VersionPath(o, version); var versionDataFile = Path.Combine(versionPath.PhysicalPath, Path.GetFileName(o.DataFile)); var versionTemplateFile = Path.Combine(versionPath.PhysicalPath, Path.GetFileName(o.TemplateFileName)); T template = null; if (File.Exists(versionDataFile)) { var provider = GetTemplateProvider(); template = provider.Deserialize(o, versionDataFile); template.Body = IOUtility.ReadAsString(versionTemplateFile); template.Init(o); } return(template); }
public Uri BuildEndpoint(RestClient client) { var sb = new StringBuilder(); var path = Path.IsNullOrBlank() ? client.Path.IsNullOrBlank() ? "" : client.Path : Path; var versionPath = VersionPath.IsNullOrBlank() ? client.VersionPath.IsNullOrBlank() ? "" : client.VersionPath : VersionPath; var skipAuthority = client.Authority.IsNullOrBlank(); sb.Append(skipAuthority ? "" : client.Authority); sb.Append(skipAuthority ? "" : client.Authority.EndsWith("/") ? "" : "/"); sb.Append(skipAuthority ? "" : versionPath.IsNullOrBlank() ? "" : versionPath); if (!skipAuthority && !versionPath.IsNullOrBlank()) { sb.Append(versionPath.EndsWith("/") ? "" : "/"); } sb.Append(path.IsNullOrBlank() ? "" : path.StartsWith("/") ? path.Substring(1) : path); Uri uri; Uri.TryCreate(sb.ToString(), UriKind.RelativeOrAbsolute, out uri); var queryStringHandling = QueryHandling ?? client.QueryHandling ?? Hammock.QueryHandling.None; switch (queryStringHandling) { case Hammock.QueryHandling.AppendToParameters: WebParameterCollection parameters; uri = uri.UriMinusQuery(out parameters); foreach (var parameter in parameters) { Parameters.Add(parameter); } break; default: break; } return(uri); }
public override void LogVersion(T o) { var locker = GetLock(); locker.EnterWriteLock(); try { VersionPath versionPath = new VersionPath(o, NextVersionId(o)); IOUtility.EnsureDirectoryExists(versionPath.PhysicalPath); var versionDataFile = Path.Combine(versionPath.PhysicalPath, Path.GetFileName(o.DataFile)); var versionTemplateFile = Path.Combine(versionPath.PhysicalPath, Path.GetFileName(o.TemplateFileName)); File.Copy(o.DataFile, versionDataFile); File.Copy(o.PhysicalTemplateFileName, versionTemplateFile); } finally { locker.ExitWriteLock(); } }