public bool CheckForNewFile() { var filename = GetFilename(); var updFile = this.GetUPDFilename(); if (m_fileHandler.Exists(updFile)) { return(m_fileHandler.Exists(filename)); } return(false); }
List <Cookie> ReadFromFile() { if (!fileHandler.Exists(filePath)) { return(new List <Cookie>()); } try { using (Stream stream = fileHandler.OpenReadStream(filePath)) { BinaryReader reader = new BinaryReader(stream); int size = reader.ReadInt32(); List <Cookie> readCookies = new List <Cookie>(size); for (int i = 0; i < size; i++) { readCookies.Add(new Cookie { name = reader.ReadString(), value = reader.ReadString(), domain = reader.ReadBoolean() ? reader.ReadString() : null, path = reader.ReadString(), expires = reader.ReadBoolean() ? (DateTime?)DateTime.FromBinary(reader.ReadInt64()) : null, secure = reader.ReadBoolean(), httpOnly = reader.ReadBoolean(), size = reader.ReadInt32(), }); } return(readCookies); } } catch (IOException exception) { Debug.LogWarning(exception); return(new List <Cookie>()); } }
internal CacheMetadata FindMetadata(HttpRequest request) { string filePath = GetFilePath(request.Uri); CacheMetadata data = null; Mutex mutex = new Mutex(false, filePath); mutex.WaitOne(); try { if (fileHandler.Exists(filePath)) { data = ReadMetaData(filePath); } } finally { mutex.ReleaseMutex(); } return(data); }
public override SubmitResult Create(PageCategory obj) { if (string.IsNullOrEmpty(obj.Name)) { obj.Name = obj.ViewPath?.GetAfterLast("/"); } var domain = Unit.DomainRepository.GetOrCreatePath(obj.ViewPath.GetBeforeLast("/")); string template = Path.Combine(Shell.AppRootPath, "Views", obj.ViewPath + ".cshtml"); if (!fileHandler.Exists(template)) { throw new Exception("No such template : " + template); } domain.PageCategories.Add(obj); obj.DomainId = domain.Id; if (obj.ResourceName != null) { string[] sp = obj.ResourceName.Split('/'); string res = obj.ResourceName; string service = null; if (sp.Length > 1) { res = sp[1]; service = sp[0]; } Resource r = Unit.ResourceRepository.GetResource(res, service); string[] bases = new[] { "Edit", "List", "Tree" }; if (bases.Contains(obj.BaseComponent) && r == null) { throw new Exception("This " + obj.BaseComponent + " base component requires a Resource"); } r.PageCategories.Add(obj); return(Unit.SaveChanges()); } return(base.Create(obj)); }