public DropBoxStorageProviderSession(DropBoxToken token, DropBoxConfiguration config, OAuthConsumerContext consumerContext, IStorageProviderService service) { SessionToken = token; ServiceConfiguration = config; Service = service; Context = consumerContext; }
public GoogleDocsStorageProviderSession(IStorageProviderService service, ICloudStorageConfiguration configuration, OAuthConsumerContext context, ICloudStorageAccessToken token) { Service = service; ServiceConfiguration = configuration; Context = context; SessionToken = token; }
public CachedServiceWrapper(IStorageProviderService service) { if (service == null) throw new ArgumentNullException("service"); _service = service; }
public CachedServiceWrapper(IStorageProviderService service) { if (service == null) { throw new ArgumentNullException("service"); } _service = service; }
public BaseFileEntry(string name, long length, DateTime modified, IStorageProviderService service, IStorageProviderSession session) { Name = name; Length = length; Modified = modified; _service = new CachedServiceWrapper(service); //NOTE: Caching _session = session; IsDeleted = false; }
public BaseFileEntry(String Name, long Length, DateTime Modified, IStorageProviderService service, IStorageProviderSession session) { this.Name = Name; this.Length = Length; this.Modified = Modified; _service = new CachedServiceWrapper(service); //NOTE: Caching _session = session; IsDeleted = false; }
public BaseFileEntry(String Name, long Length, DateTime Modified, IStorageProviderService service, IStorageProviderSession session) { this.Name = Name; this.Length = Length; this.Modified = Modified; _service = service; _session = session; IsDeleted = false; }
public static BaseFileEntry UpdateObjectFromJsonString(String jsonMessage, BaseFileEntry objectToUpdate, IStorageProviderService service, IStorageProviderSession session) { // verify if we have a directory or a file var jc = new JsonHelper(); if (!jc.ParseJsonMessage(jsonMessage)) throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidFileOrDirectoryName); var isDir = jc.GetBooleanProperty("is_dir"); // create the entry BaseFileEntry dbentry; Boolean bEntryOk; if (isDir) { if (objectToUpdate == null) dbentry = new BaseDirectoryEntry("Name", 0, DateTime.Now, service, session); else dbentry = objectToUpdate as BaseDirectoryEntry; bEntryOk = BuildDirectyEntry(dbentry as BaseDirectoryEntry, jc, service, session); } else { if (objectToUpdate == null) dbentry = new BaseFileEntry("Name", 0, DateTime.Now, service, session); else dbentry = objectToUpdate; bEntryOk = BuildFileEntry(dbentry, jc); } // parse the childs and fill the entry as self if (!bEntryOk) throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotContactStorageService); // set the is deleted flag try { // try to read the is_deleted property dbentry.IsDeleted = jc.GetBooleanProperty("is_deleted"); } catch (Exception) { // the is_deleted proprty is missing (so it's not a deleted file or folder) dbentry.IsDeleted = false; } // return the child return dbentry; }
public static String RequestResourceByUrl(String url, Dictionary<String, String> parameters, IStorageProviderService service, IStorageProviderSession session, out int netErrorCode) { // cast the dropbox session var dropBoxSession = session as DropBoxStorageProviderSession; // instance the oAuthServer var svc = new OAuthService(); var urlhash = new KeyValuePair<string, string>(); if (!string.IsNullOrEmpty(url) && url.Contains("/metadata/")) { //Add the hash attr if any urlhash = SessionHashStorage.Get(session.SessionToken.ToString(), url, () => new KeyValuePair<string, string>()); } if (!string.IsNullOrEmpty(urlhash.Key) && !string.IsNullOrEmpty(urlhash.Value)) { //Add params if (parameters == null) parameters = new Dictionary<string, string>(); parameters.Add("hash", urlhash.Key); } // build the webrequest to protected resource var request = svc.CreateWebRequest(url, WebRequestMethodsEx.Http.Get, null, null, dropBoxSession.Context, (DropBoxToken) dropBoxSession.SessionToken, parameters); // get the error code WebException ex; // perform a simple webrequest using (Stream s = svc.PerformWebRequest(request, null, out netErrorCode, out ex, (code) => !string.IsNullOrEmpty(urlhash.Key) && !string.IsNullOrEmpty(urlhash.Value) && code == 304)/*to check code without downloading*/) { if (!string.IsNullOrEmpty(urlhash.Key) && !string.IsNullOrEmpty(urlhash.Value) && netErrorCode == 304) { return urlhash.Value; } if (s == null) return ""; // read the memory stream and convert to string var response = new StreamReader(s).ReadToEnd(); return response; } }
private static Boolean BuildDirectyEntry(BaseDirectoryEntry dirEntry, JsonHelper jh, IStorageProviderService service, IStorageProviderSession session) { // build the file entry part if (!BuildFileEntry(dirEntry, jh)) return false; // now take the content var content = jh.GetListProperty("contents"); if (content.Count == 0) return true; // remove all childs dirEntry.ClearChilds(); // add the childs foreach (var jsonContent in content) { // parse the item var jc = new JsonHelper(); if (!jc.ParseJsonMessage(jsonContent)) continue; // check if we have a directory var isDir = jc.GetBooleanProperty("is_dir"); BaseFileEntry fentry; if (isDir) { fentry = new BaseDirectoryEntry("Name", 0, DateTime.Now, service, session); } else { fentry = new BaseFileEntry("Name", 0, DateTime.Now, service, session); } // build the file attributes BuildFileEntry(fentry, jc); // establish parent child realtionship dirEntry.AddChild(fentry); } // set the length dirEntry.Length = dirEntry.Count; // go ahead return true; }
protected virtual String OnNameBase(String targetUrl, IStorageProviderService service, IStorageProviderSession session, String nameBase) { return(nameBase); }
protected override string OnNameBase(string targetUrl, IStorageProviderService service, IStorageProviderSession session, string nameBase) { return(nameBase.StartsWith("https") ? nameBase : nameBase.Replace("http", "https")); }
/// <summary> /// The constructure need a specific service implementation /// </summary> /// <param name="service"></param> public GenericStorageProvider(IStorageProviderService service) { _Service = service; }
public CIFSStorageProviderSession(ICloudStorageAccessToken token, CIFSConfiguration config, IStorageProviderService service) { SessionToken = token; ServiceConfiguration = config; Service = service; }
public static BaseFileEntry UpdateObjectFromJsonString(String jsonMessage, BaseFileEntry objectToUpdate, IStorageProviderService service, IStorageProviderSession session) { // verify if we have a directory or a file var jc = new JsonHelper(); if (!jc.ParseJsonMessage(jsonMessage)) { throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidFileOrDirectoryName); } var isDir = jc.GetBooleanProperty("is_dir"); // create the entry BaseFileEntry dbentry; Boolean bEntryOk; if (isDir) { if (objectToUpdate == null) { dbentry = new BaseDirectoryEntry("Name", 0, DateTime.Now, service, session); } else { dbentry = objectToUpdate as BaseDirectoryEntry; } bEntryOk = BuildDirectyEntry(dbentry as BaseDirectoryEntry, jc, service, session); } else { if (objectToUpdate == null) { dbentry = new BaseFileEntry("Name", 0, DateTime.Now, service, session); } else { dbentry = objectToUpdate; } bEntryOk = BuildFileEntry(dbentry, jc); } // parse the childs and fill the entry as self if (!bEntryOk) { throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotContactStorageService); } // set the is deleted flag try { // try to read the is_deleted property dbentry.IsDeleted = jc.GetBooleanProperty("is_deleted"); } catch (Exception) { // the is_deleted proprty is missing (so it's not a deleted file or folder) dbentry.IsDeleted = false; } // return the child return(dbentry); }
public static String RequestResourceByUrl(String url, Dictionary <String, String> parameters, IStorageProviderService service, IStorageProviderSession session, out int netErrorCode) { // cast the dropbox session var dropBoxSession = session as DropBoxStorageProviderSession; // instance the oAuthServer var svc = new OAuthService(); var urlhash = new KeyValuePair <string, string>(); if (!string.IsNullOrEmpty(url) && url.Contains("/metadata/")) { //Add the hash attr if any urlhash = SessionHashStorage.Get(session.SessionToken.ToString(), url, () => new KeyValuePair <string, string>()); } if (!string.IsNullOrEmpty(urlhash.Key) && !string.IsNullOrEmpty(urlhash.Value)) { //Add params if (parameters == null) { parameters = new Dictionary <string, string>(); } parameters.Add("hash", urlhash.Key); } // build the webrequest to protected resource var request = svc.CreateWebRequest(url, WebRequestMethodsEx.Http.Get, null, null, dropBoxSession.Context, (DropBoxToken)dropBoxSession.SessionToken, parameters); // get the error code WebException ex; // perform a simple webrequest using (Stream s = svc.PerformWebRequest(request, null, out netErrorCode, out ex, (code) => !string.IsNullOrEmpty(urlhash.Key) && !string.IsNullOrEmpty(urlhash.Value) && code == 304) /*to check code without downloading*/) { if (!string.IsNullOrEmpty(urlhash.Key) && !string.IsNullOrEmpty(urlhash.Value) && netErrorCode == 304) { return(urlhash.Value); } if (s == null) { return(""); } // read the memory stream and convert to string var response = new StreamReader(s).ReadToEnd(); return(response); } }
public static WebDavRequestResult CreateObjectsFromNetworkStream(Stream data, String targetUrl, IStorageProviderService service, IStorageProviderSession session) { return(CreateObjectsFromNetworkStream(data, targetUrl, service, session, null)); }
public static WebDavRequestResult CreateObjectsFromNetworkStream(Stream data, String targetUrl, IStorageProviderService service, IStorageProviderSession session, NameBaseFilterCallback callback) { return(null); }
protected override String OnNameBase(String targetUrl, IStorageProviderService service, IStorageProviderSession session, String NameBase) { return NameBase.Replace("http", "https"); }
public SkyDriveStorageProviderSession(ICloudStorageAccessToken token, IStorageProviderService service, ICloudStorageConfiguration configuration) { SessionToken = token; Service = service; ServiceConfiguration = configuration; }
public static WebDavRequestResult CreateObjectsFromNetworkStream(Stream data, String targetUrl, IStorageProviderService service, IStorageProviderSession session, NameBaseFilterCallback callback) { WebDavConfiguration config = session.ServiceConfiguration as WebDavConfiguration; WebDavRequestResult results = new WebDavRequestResult(); try { String resourceName = String.Empty; long resourceLength = 0; DateTime resourceModificationDate = DateTime.Now; DateTime resourceCreationDate = DateTime.Now; String resourceContentType = String.Empty; Boolean bIsHidden = false; Boolean bIsDirectory = false; Boolean bIsSelf = false; // build queryless uri String queryLessUri = HttpUtilityEx.GetPathAndQueryLessUri(config.ServiceLocator).ToString().TrimEnd('/'); // work with decoded target url String decodedTargetUrl = HttpUtility.UrlDecode(targetUrl); XmlTextReader reader = new XmlTextReader(data); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { // we are on an element and we have to handle this elements String currentElement = reader.Name; // we found a resource name if (currentElement.Contains(":href")) { // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(currentElement, reader)) { continue; } // go one more step reader.Read(); // get the name String nameBase = reader.Value; // call the filter if needed if (callback != null) { nameBase = callback(targetUrl, service, session, nameBase); } /* * Just for bug fixing * * Console.WriteLine(" SVC Locator: " + config.ServiceLocator.ToString()); * Console.WriteLine("SVC Locator QL: " + HttpUtilityEx.GetPathAndQueryLessUri(config.ServiceLocator)); * Console.WriteLine(" Target Url: " + targetUrl); * Console.WriteLine(" NameBase: " + nameBase); */ // generate namebase for self check String nameBaseForSelfCheck; // remove the base url and build for selfcheck if (nameBase.StartsWith(config.ServiceLocator.ToString())) { nameBaseForSelfCheck = HttpUtility.UrlDecode(nameBase); nameBase = nameBase.Remove(0, config.ServiceLocator.ToString().Length); } else { nameBaseForSelfCheck = queryLessUri + HttpUtilityEx.PathDecodeUTF8(nameBase); } // trim all trailing slashes nameBase = nameBase.TrimEnd('/'); // work with the trailing lsahed nameBaseForSelfCheck = nameBaseForSelfCheck.TrimEnd('/'); if (targetUrl.EndsWith("/")) { nameBaseForSelfCheck += "/"; } // check if we are self if (nameBaseForSelfCheck.Equals(decodedTargetUrl)) { bIsSelf = true; } else { bIsSelf = false; } // get the last file or directory name PathHelper ph = new PathHelper(nameBase); resourceName = ph.GetFileName(); // unquote name resourceName = HttpUtility.UrlDecode(resourceName); } else if (currentElement.Contains(":ishidden")) { // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(currentElement, reader)) { continue; } // go one more step reader.Read(); // try to parse int iIsHidden = 0; if (!int.TryParse(reader.Value, out iIsHidden)) { iIsHidden = 0; } // convert bIsHidden = Convert.ToBoolean(iIsHidden); } else if (currentElement.Contains(":getcontentlength")) { // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(currentElement, reader)) { continue; } // go one more step reader.Read(); // read value if (!long.TryParse(reader.Value, out resourceLength)) { resourceLength = -1; } } else if (currentElement.Contains(":creationdate")) { // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(currentElement, reader)) { continue; } // go one more step reader.Read(); // parse if (!DateTime.TryParse(reader.Value, out resourceCreationDate)) { resourceCreationDate = DateTime.Now; } } else if (currentElement.Contains(":getlastmodified")) { // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(currentElement, reader)) { continue; } // go one more step reader.Read(); // parse if (!DateTime.TryParse(reader.Value, out resourceModificationDate)) { resourceModificationDate = DateTime.Now; } } else if (currentElement.Contains(":getcontenttype")) { // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(currentElement, reader)) { continue; } // go one more step reader.Read(); // parse resourceContentType = reader.Value; } else if (currentElement.Contains(":collection")) { // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(currentElement, reader)) { continue; } // set as directory bIsDirectory = true; } // go ahead break; } case XmlNodeType.EndElement: { // handle the end of an response if (!reader.Name.ToLower().Contains(":response")) { break; } // check if it is an element with valud namespace prefix if (!CheckIfNameSpaceDAVSpace(reader.Name, reader)) { continue; } // handle the end of an response, this means // create entry BaseFileEntry entry = null; if (bIsDirectory) { entry = new BaseDirectoryEntry(resourceName, resourceLength, resourceModificationDate, service, session); } else { entry = new BaseFileEntry(resourceName, resourceLength, resourceModificationDate, service, session); } entry.SetPropertyValue("CreationDate", resourceCreationDate); entry.SetPropertyValue("ContentType", resourceContentType); if (!bIsHidden) { if (bIsSelf) { results.Self = entry; } else { results.Childs.Add(entry); } } // reset all state properties resourceName = String.Empty; resourceLength = 0; resourceModificationDate = DateTime.Now; resourceCreationDate = DateTime.Now; resourceContentType = String.Empty; bIsHidden = false; bIsDirectory = false; // go ahead break; } default: { break; } } } ; if (results.Self == null) { throw new Exception("Unknown error in webrequest parser"); } } catch (Exception) { } // go ahead return(results); }
public static WebDavRequestResult CreateObjectsFromNetworkStream(Stream data, String targetUrl, IStorageProviderService service, IStorageProviderSession session, NameBaseFilterCallback callback) { return null; }
public static WebDavRequestResult CreateObjectsFromNetworkStream(Stream data, String targetUrl, IStorageProviderService service, IStorageProviderSession session) { return CreateObjectsFromNetworkStream(data, targetUrl, service, session, null); }
public static BaseFileEntry CreateObjectsFromJsonString(String jsonMessage, IStorageProviderService service, IStorageProviderSession session) { return UpdateObjectFromJsonString(jsonMessage, null, service, session); }
public static String RequestResourceByUrl(String url, Dictionary <String, String> parameters, IStorageProviderService service, IStorageProviderSession session, out int netErrorCode) { // cast the dropbox session DropBoxStorageProviderSession dropBoxSession = session as DropBoxStorageProviderSession; // instance the oAuthServer OAuthService svc = new OAuthService(); // build the webrequest to protected resource WebRequest request = svc.CreateWebRequest(url, WebRequestMethodsEx.Http.Get, null, null, dropBoxSession.Context, (DropBoxToken)dropBoxSession.SessionToken, parameters); // get the error code WebException ex; // perform a simple webrequest Stream s = svc.PerformWebRequest(request, null, out netErrorCode, out ex); if (s == null) { return(""); } // read the memory stream and convert to string return(new StreamReader(s).ReadToEnd()); }
protected override String OnNameBase(String targetUrl, IStorageProviderService service, IStorageProviderSession session, String NameBase) { return(NameBase.Replace("http", "https")); }
public static BaseFileEntry CreateObjectsFromJsonString(String jsonMessage, IStorageProviderService service, IStorageProviderSession session) { return(UpdateObjectFromJsonString(jsonMessage, null, service, session)); }
public BaseDirectoryEntry(String Name, long Length, DateTime Modified, IStorageProviderService service, IStorageProviderSession session) : base(Name, Length, Modified, service, session) { }
public BaseFileEntryDataTransfer(ICloudFileSystemEntry fileSystemEntry, IStorageProviderService service, IStorageProviderSession session) { _fsEntry = fileSystemEntry; _session = session; _service = service; }
public WebDavStorageProvider(IStorageProviderService svc) : base(svc) { }
public static WebDavRequestResult CreateObjectsFromNetworkStream(Stream data, string targetUrl, IStorageProviderService service, IStorageProviderSession session, NameBaseFilterCallback callback) { var config = session.ServiceConfiguration as WebDavConfiguration; var results = new WebDavRequestResult(); var queryLessUri = HttpUtilityEx.GetPathAndQueryLessUri(config.ServiceLocator).ToString().TrimEnd('/'); var decodedTargetUrl = HttpUtility.UrlDecode(targetUrl); string s; using (var streamReader = new StreamReader(data)) { s = streamReader.ReadToEnd(); } //todo: var xDoc = XDocument.Load(new StringReader(s.Replace("d:d:", "d:"))); var responses = xDoc.Descendants(XName.Get("response", DavNamespace)); foreach (var response in responses) { var isHidden = false; var isDirectory = false; var lastModified = DateTime.Now; long contentLength = 0; var href = response.Element(XName.Get("href", DavNamespace)).ValueOrEmpty(); var propstats = response.Descendants(XName.Get("propstat", DavNamespace)); foreach (var propstat in propstats) { var prop = propstat.Element(XName.Get("prop", DavNamespace)); var status = propstat.Element(XName.Get("status", DavNamespace)).ValueOrEmpty(); if (!status.Equals(HttpOk) || prop == null) { continue; } var strLastModified = prop.Element(XName.Get("getlastmodified", DavNamespace)).ValueOrEmpty(); var strContentLength = prop.Element(XName.Get("getcontentlength", DavNamespace)).ValueOrEmpty(); var resourceType = prop.Element(XName.Get("resourcetype", DavNamespace)); var strIsHidden = prop.Element(XName.Get("ishidden", DavNamespace)).ValueOrEmpty(); if (!string.IsNullOrEmpty(strIsHidden)) { int code; if (!int.TryParse(strIsHidden, out code)) { code = 0; } isHidden = Convert.ToBoolean(code); } if (resourceType != null && resourceType.Element(XName.Get("collection", DavNamespace)) != null) { isDirectory = true; } if (!string.IsNullOrEmpty(strContentLength)) { contentLength = Convert.ToInt64(strContentLength); } if (!string.IsNullOrEmpty(strLastModified) && DateTime.TryParse(strLastModified, out lastModified)) { lastModified = lastModified.ToUniversalTime(); } } //entry not to be encluded if (isHidden) { continue; } var nameBase = href; if (callback != null) { nameBase = callback(targetUrl, service, session, nameBase); } string nameBaseForSelfCheck; if (nameBase.StartsWith(config.ServiceLocator.ToString())) { nameBaseForSelfCheck = HttpUtility.UrlDecode(nameBase); nameBase = nameBase.Remove(0, config.ServiceLocator.ToString().Length); } else { nameBaseForSelfCheck = queryLessUri + HttpUtilityEx.PathDecodeUTF8(nameBase); } nameBase = nameBase.TrimEnd('/'); nameBaseForSelfCheck = nameBaseForSelfCheck.TrimEnd('/'); if (targetUrl.EndsWith("/")) { nameBaseForSelfCheck += "/"; } var isSelf = nameBaseForSelfCheck.Equals(decodedTargetUrl); var ph = new PathHelper(nameBase); var resourceName = HttpUtility.UrlDecode(ph.GetFileName()); var entry = !isDirectory ? new BaseFileEntry(resourceName, contentLength, lastModified, service, session) : new BaseDirectoryEntry(resourceName, contentLength, lastModified, service, session); if (isSelf) { results.Self = entry; } else { results.Childs.Add(entry); } } return(results); }
private String WebDavNameBaseFilterCallback(String targetUrl, IStorageProviderService service, IStorageProviderSession session, String NameBase) { // call our virtual method return OnNameBase(targetUrl, service, session, NameBase); }
private String WebDavNameBaseFilterCallback(String targetUrl, IStorageProviderService service, IStorageProviderSession session, String NameBase) { // call our virtual method return(OnNameBase(targetUrl, service, session, NameBase)); }
protected virtual String OnNameBase(String targetUrl, IStorageProviderService service, IStorageProviderSession session, String NameBase) { return NameBase; }
public static String RequestResourceByUrl(String url, IStorageProviderService service, IStorageProviderSession session, out int netErrorCode) { return RequestResourceByUrl(url, null, service, session, out netErrorCode); }
public static String RequestResourceByUrl(String url, IStorageProviderService service, IStorageProviderSession session, out int netErrorCode) { return(RequestResourceByUrl(url, null, service, session, out netErrorCode)); }
private static Boolean BuildDirectyEntry(BaseDirectoryEntry dirEntry, JsonHelper jh, IStorageProviderService service, IStorageProviderSession session) { // build the file entry part if (!BuildFileEntry(dirEntry, jh)) { return(false); } // now take the content var content = jh.GetListProperty("contents"); if (content.Count == 0) { return(true); } // remove all childs dirEntry.ClearChilds(); // add the childs foreach (var jsonContent in content) { // parse the item var jc = new JsonHelper(); if (!jc.ParseJsonMessage(jsonContent)) { continue; } // check if we have a directory var isDir = jc.GetBooleanProperty("is_dir"); BaseFileEntry fentry; if (isDir) { fentry = new BaseDirectoryEntry("Name", 0, DateTime.Now, service, session); } else { fentry = new BaseFileEntry("Name", 0, DateTime.Now, service, session); } // build the file attributes BuildFileEntry(fentry, jc); // establish parent child realtionship dirEntry.AddChild(fentry); } // set the length dirEntry.Length = dirEntry.Count; // go ahead return(true); }
public BaseDirectoryEntry(String name, long Length, DateTime modified, IStorageProviderService service, IStorageProviderSession session) : base(name, Length, modified, service, session) { }
public static WebDavRequestResult CreateObjectsFromNetworkStream(Stream data, String targetUrl, IStorageProviderService service, IStorageProviderSession session, NameBaseFilterCallback callback) { var config = session.ServiceConfiguration as WebDavConfiguration; var results = new WebDavRequestResult(); var queryLessUri = HttpUtilityEx.GetPathAndQueryLessUri(config.ServiceLocator).ToString().TrimEnd('/'); var decodedTargetUrl = HttpUtility.UrlDecode(targetUrl); var s = new StreamReader(data).ReadToEnd(); //todo: var xDoc = XDocument.Load(new StringReader(s.Replace("d:d:", "d:"))); var responses = xDoc.Descendants(XName.Get("response", DavNamespace)); foreach (var response in responses) { bool isHidden = false; bool isDirectory = false; DateTime lastModified = DateTime.Now; long contentLength = 0; var href = response.Element(XName.Get("href", DavNamespace)).ValueOrEmpty(); var propstats = response.Descendants(XName.Get("propstat", DavNamespace)); foreach (var propstat in propstats) { var prop = propstat.Element(XName.Get("prop", DavNamespace)); var status = propstat.Element(XName.Get("status", DavNamespace)).ValueOrEmpty(); if (!status.Equals(HttpOk) || prop == null) continue; var strLastModified = prop.Element(XName.Get("getlastmodified", DavNamespace)).ValueOrEmpty(); var strContentLength = prop.Element(XName.Get("getcontentlength", DavNamespace)).ValueOrEmpty(); var resourceType = prop.Element(XName.Get("resourcetype", DavNamespace)); var strIsHidden = prop.Element(XName.Get("ishidden", DavNamespace)).ValueOrEmpty(); if (!String.IsNullOrEmpty(strIsHidden)) { int code; if (!int.TryParse(strIsHidden, out code)) code = 0; isHidden = Convert.ToBoolean(code); } if (resourceType.Element(XName.Get("collection", DavNamespace)) != null) isDirectory = true; if (!String.IsNullOrEmpty(strContentLength)) contentLength = Convert.ToInt64(strContentLength); if (!String.IsNullOrEmpty(strLastModified)) DateTime.TryParse(strLastModified, out lastModified); } //entry not to be encluded if (isHidden) continue; var nameBase = href; if (callback != null) nameBase = callback(targetUrl, service, session, nameBase); String nameBaseForSelfCheck; if (nameBase.StartsWith(config.ServiceLocator.ToString())) { nameBaseForSelfCheck = HttpUtility.UrlDecode(nameBase); nameBase = nameBase.Remove(0, config.ServiceLocator.ToString().Length); } else { nameBaseForSelfCheck = queryLessUri + HttpUtilityEx.PathDecodeUTF8(nameBase); } nameBase = nameBase.TrimEnd('/'); nameBaseForSelfCheck = nameBaseForSelfCheck.TrimEnd('/'); if (targetUrl.EndsWith("/")) nameBaseForSelfCheck += "/"; bool isSelf = nameBaseForSelfCheck.Equals(decodedTargetUrl); var ph = new PathHelper(nameBase); var resourceName = HttpUtility.UrlDecode(ph.GetFileName()); BaseFileEntry entry = !isDirectory ? new BaseFileEntry(resourceName, contentLength, lastModified, service, session) : new BaseDirectoryEntry(resourceName, contentLength, lastModified, service, session); if (isSelf) { results.Self = entry; } else { results.Childs.Add(entry); } } return results; }
public WebDavStorageProviderSession(ICloudStorageAccessToken token, WebDavConfiguration config, IStorageProviderService service) { SessionToken = token; ServiceConfiguration = config; Service = service; }
public WebDavStorageProvider(IStorageProviderService svc) : base(new CachedServiceWrapper(svc)) { }