本文整理汇总了C#中IStorageProviderSession类的典型用法代码示例。如果您正苦于以下问题:C# IStorageProviderSession类的具体用法?C# IStorageProviderSession怎么用?C# IStorageProviderSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStorageProviderSession类属于命名空间,在下文中一共展示了IStorageProviderSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RefreshDirectoryContent
public void RefreshDirectoryContent(IStorageProviderSession session, BaseDirectoryEntry entry)
{
if (entry == null)
return;
var url = String.Format(GoogleDocsConstants.GoogleDocsContentsUrlFormat, entry.Id.ReplaceFirst("_", "%3a"));
var parameters = new Dictionary<string, string> { { "max-results", "1000" } };
try
{
while (!String.IsNullOrEmpty(url))
{
var request = CreateWebRequest(session, url, "GET", parameters);
var response = (HttpWebResponse)request.GetResponse();
var rs = response.GetResponseStream();
var feedXml = new StreamReader(rs).ReadToEnd();
var childs = GoogleDocsXmlParser.ParseEntriesXml(session, feedXml);
entry.AddChilds(childs);
url = GoogleDocsXmlParser.ParseNext(feedXml);
}
}
catch (WebException)
{
}
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:27,代码来源:GoogleDocsStorageProviderService.cs
示例2: RefreshDirectoryContent
public void RefreshDirectoryContent(IStorageProviderSession session, ICloudDirectoryEntry directory)
{
String uri = String.Format(SkyDriveConstants.FilesAccessUrlFormat, directory.Id);
uri = SignUri(session, uri);
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
using (var rs = response.GetResponseStream())
{
if (rs == null)
throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotRetrieveDirectoryList);
String json = new StreamReader(rs).ReadToEnd();
var childs = SkyDriveJsonParser.ParseListOfEntries(session, json)
.Select(x => x as BaseFileEntry).Where(x => x != null).ToArray();
if (childs.Length == 0 || !(directory is BaseDirectoryEntry))
throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotRetrieveDirectoryList);
var directoryBase = directory as BaseDirectoryEntry;
directoryBase.AddChilds(childs);
}
}
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:25,代码来源:SkyDriveStorageProviderService.cs
示例3: RemoveResource
public bool RemoveResource(IStorageProviderSession session, ICloudFileSystemEntry resource, RemoveMode mode)
{
String url;
Dictionary<String, String> parameters = null;
if (mode == RemoveMode.FromParentCollection)
{
var pId = (resource.Parent != null ? resource.Parent.Id : GoogleDocsConstants.RootFolderId).ReplaceFirst("_", "%3a");
url = String.Format("{0}/{1}/contents/{2}", GoogleDocsConstants.GoogleDocsFeedUrl, pId, resource.Id.ReplaceFirst("_", "%3a"));
}
else
{
url = String.Format(GoogleDocsConstants.GoogleDocsResourceUrlFormat, resource.Id.ReplaceFirst("_", "%3a"));
parameters = new Dictionary<string, string> {{"delete", "true"}};
}
var request = CreateWebRequest(session, url, "DELETE", parameters);
request.Headers.Add("If-Match", "*");
try
{
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
return true;
}
catch (WebException)
{
}
return false;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:31,代码来源:GoogleDocsStorageProviderService.cs
示例4: RequestResource
public override ICloudFileSystemEntry RequestResource(IStorageProviderSession session, string Name, ICloudDirectoryEntry parent)
{
//declare the requested entry
ICloudFileSystemEntry fsEntry = null;
// lets have a look if we are on the root node
if (parent == null)
{
// just create the root entry
fsEntry = GenericStorageProviderFactory.CreateDirectoryEntry(session, Name, parent);
}
else
{
// ok we have a parent, let's retrieve the resource
// from his child list
fsEntry = parent.GetChild(Name, false);
}
// now that we create the entry just update the chuld
if (fsEntry != null && fsEntry is ICloudDirectoryEntry)
RefreshResource(session, fsEntry as ICloudDirectoryEntry);
// go ahead
return fsEntry;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:25,代码来源:FtpStorageProviderService.cs
示例5: DeleteResource
public override bool DeleteResource(IStorageProviderSession session, ICloudFileSystemEntry entry)
{
// get the creds
ICredentials creds = ((GenericNetworkCredentials) session.SessionToken).GetCredential(null, null);
// generate the loca path
String uriPath = GetResourceUrl(session, entry, null);
// removed the file
if (entry is ICloudDirectoryEntry)
{
// we need an empty directory
foreach (ICloudFileSystemEntry child in (ICloudDirectoryEntry) entry)
{
DeleteResource(session, child);
}
// remove the directory
return _ftpService.FtpDeleteEmptyDirectory(uriPath, creds);
}
else
{
// remove the file
return _ftpService.FtpDeleteFile(uriPath, creds);
}
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:26,代码来源:FtpStorageProviderService.cs
示例6: RefreshResource
public override void RefreshResource(IStorageProviderSession session, ICloudFileSystemEntry resource)
{
// nothing to do for files
if (!(resource is ICloudDirectoryEntry))
return;
// Refresh schild
RefreshChildsOfDirectory(session, resource as ICloudDirectoryEntry);
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:9,代码来源:FtpStorageProviderService.cs
示例7: GetAccountInfo
public DropBoxAccountInfo GetAccountInfo(IStorageProviderSession session)
{
// request the json object via oauth
int code;
var res = DropBoxRequestParser.RequestResourceByUrl(GetUrlString(DropBoxGetAccountInfo, session.ServiceConfiguration), this, session, out code);
// parse the jason stuff
return new DropBoxAccountInfo(res);
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:9,代码来源:DropBoxStorageProviderService.cs
示例8: RefreshResource
public void RefreshResource(IStorageProviderSession session, ICloudFileSystemEntry resource)
{
var cached = FsCache.Get(GetSessionKey(session), GetCacheKey(session, null, resource), null) as ICloudDirectoryEntry;
if (cached == null || cached.HasChildrens == nChildState.HasNotEvaluated)
{
_service.RefreshResource(session, resource);
FsCache.Add(GetSessionKey(session), GetCacheKey(session, null, resource), resource);
}
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:10,代码来源:CachedServiceWrapper.cs
示例9: BaseFileEntry
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;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:10,代码来源:BaseFileEntry.cs
示例10: PerformRequest
public static String PerformRequest(IStorageProviderSession session, String uri, String method, String data, bool signUri, int countAttempts)
{
if (String.IsNullOrEmpty(method))
method = "GET";
if (!String.IsNullOrEmpty(data) && method == "GET")
return null;
if (signUri)
uri = SignUri(session, uri);
int attemptsToComplete = countAttempts;
while (attemptsToComplete > 0)
{
WebRequest request = WebRequest.Create(uri);
request.Method = method;
request.Timeout = 5000;
if (!signUri)
request.Headers.Add("Authorization", "Bearer " + GetValidToken(session).AccessToken);
if (!String.IsNullOrEmpty(data))
{
byte[] bytes = Encoding.UTF8.GetBytes(data);
request.ContentType = "application/json";
request.ContentLength = bytes.Length;
using (var rs = request.GetRequestStream())
{
rs.Write(bytes, 0, bytes.Length);
}
}
try
{
WebResponse response = request.GetResponse();
using (var rs = response.GetResponseStream())
{
if (rs != null)
{
return new StreamReader(rs).ReadToEnd();
}
}
return null;
}
catch (WebException exception)
{
attemptsToComplete--;
if (exception.Response != null && ((HttpWebResponse)exception.Response).StatusCode == HttpStatusCode.NotFound)
return null;
}
}
return null;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:55,代码来源:SkyDriveRequestHelper.cs
示例11: RequestResource
public override ICloudFileSystemEntry RequestResource(IStorageProviderSession session, String nameOrID, ICloudDirectoryEntry parent)
{
/* In this method name could be either requested resource name or it's ID.
* In first case just refresh the parent and then search child with an appropriate.
* In second case it does not matter if parent is null or not a parent because we use only resource ID. */
if (SkyDriveHelpers.IsResourceID(nameOrID) || nameOrID.Equals("/") && parent == null)
//If request by ID or root folder requested
{
String uri =
SkyDriveHelpers.IsResourceID(nameOrID)
? String.Format("{0}/{1}", SkyDriveConstants.BaseAccessUrl, nameOrID)
: SkyDriveConstants.RootAccessUrl;
uri = SignUri(session, uri);
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
using (var rs = response.GetResponseStream())
{
if (rs != null)
{
String json = new StreamReader(rs).ReadToEnd();
ICloudFileSystemEntry entry = SkyDriveJsonParser.ParseSingleEntry(session, json);
return entry;
}
}
}
else
{
String uri =
parent != null
? String.Format(SkyDriveConstants.FilesAccessUrlFormat, parent.Id)
: SkyDriveConstants.RootAccessUrl + "/files";
uri = SignUri(session, uri);
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
using (var rs = response.GetResponseStream())
{
if (rs != null)
{
String json = new StreamReader(rs).ReadToEnd();
var entry = SkyDriveJsonParser.ParseListOfEntries(session, json).FirstOrDefault(x => x.Name.Equals(nameOrID));
if (entry != null && parent != null && parent is BaseDirectoryEntry)
(parent as BaseDirectoryEntry).AddChild(entry as BaseFileEntry);
return entry;
}
}
}
return null;
}
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:53,代码来源:SkyDriveStorageProviderService.cs
示例12: RequestResource
public override ICloudFileSystemEntry RequestResource(IStorageProviderSession session, string Name, ICloudDirectoryEntry parent)
{
// build path
String path;
if (Name.Equals("/"))
path = session.ServiceConfiguration.ServiceLocator.LocalPath;
else if (parent == null)
path = Path.Combine(path = session.ServiceConfiguration.ServiceLocator.LocalPath, Name);
else
path = new Uri(GetResourceUrl(session, parent, Name)).LocalPath;
// check if file exists
if (File.Exists(path))
{
// create the fileinfo
FileInfo fInfo = new FileInfo(path);
BaseFileEntry bf = new BaseFileEntry(fInfo.Name, fInfo.Length, fInfo.LastWriteTimeUtc, this, session) {Parent = parent};
// add to parent
if (parent != null)
(parent as BaseDirectoryEntry).AddChild(bf);
// go ahead
return bf;
}
// check if directory exists
else if (Directory.Exists(path))
{
// build directory info
DirectoryInfo dInfo = new DirectoryInfo(path);
// build bas dir
BaseDirectoryEntry dir = CreateEntryByFileSystemInfo(dInfo, session, parent) as BaseDirectoryEntry;
if (Name.Equals("/"))
dir.Name = "/";
// add to parent
if (parent != null)
(parent as BaseDirectoryEntry).AddChild(dir);
// refresh the childs
RefreshChildsOfDirectory(session, dir);
// go ahead
return dir;
}
else
return null;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:51,代码来源:CIFSStorageProviderService.cs
示例13: UpdateObjectFromJsonString
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;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:51,代码来源:DropBoxRequestParser.cs
示例14: ParseSingleEntry
private static ICloudFileSystemEntry ParseSingleEntry(IStorageProviderSession session, String json, JsonHelper parser)
{
if (json == null)
return null;
if (parser == null)
parser = CreateParser(json);
if (ContainsError(json, false, parser))
return null;
BaseFileEntry entry;
var type = parser.GetProperty("type");
if (!IsFolderType(type) && !IsFileType(type))
return null;
var id = parser.GetProperty("id");
var name = parser.GetProperty("name");
var parentID = parser.GetProperty("parent_id");
var uploadLocation = parser.GetProperty("upload_location");
var updatedTime = Convert.ToDateTime(parser.GetProperty("updated_time")).ToUniversalTime();
if (IsFolderType(type))
{
int count = parser.GetPropertyInt("count");
entry = new BaseDirectoryEntry(name, count, updatedTime, session.Service, session) {Id = id};
}
else
{
var size = Convert.ToInt64(parser.GetProperty("size"));
entry = new BaseFileEntry(name, size, updatedTime, session.Service, session) {Id = id};
}
entry[SkyDriveConstants.UploadLocationKey] = uploadLocation;
if (!String.IsNullOrEmpty(parentID))
{
entry.ParentID = SkyDriveConstants.RootIDRegex.IsMatch(parentID) ? "/" : parentID;
}
else
{
entry.Name = "/";
entry.Id = "/";
}
entry[SkyDriveConstants.InnerIDKey] = id;
entry[SkyDriveConstants.TimestampKey] = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture);
return entry;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:51,代码来源:SkyDriveJsonParser.cs
示例15: CreateDirectoryEntry
/// <summary>
///
/// </summary>
/// <param name="session"></param>
/// <param name="Name"></param>
/// <param name="modifiedDate"></param>
/// <param name="parent"></param>
/// <returns></returns>
public static ICloudDirectoryEntry CreateDirectoryEntry(IStorageProviderSession session, string Name, DateTime modifiedDate, ICloudDirectoryEntry parent)
{
// build up query url
var newObj = new BaseDirectoryEntry(Name, 0, modifiedDate, session.Service, session);
// case the parent if possible
if (parent != null)
{
var objparent = parent as BaseDirectoryEntry;
objparent.AddChild(newObj);
}
return newObj;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:22,代码来源:GenericStorageProviderFactory.cs
示例16: GetValidToken
private static OAuth20Token GetValidToken(IStorageProviderSession session)
{
var token = session.SessionToken as OAuth20Token;
if (token == null) throw new ArgumentException("Can not retrieve valid oAuth 2.0 token from given session", "session");
if (token.IsExpired)
{
token = (OAuth20Token)SkyDriveAuthorizationHelper.RefreshToken(token);
var sdSession = session as SkyDriveStorageProviderSession;
if (sdSession != null)
{
sdSession.SessionToken = token;
}
}
return token;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:15,代码来源:SkyDriveRequestHelper.cs
示例17: RequestResourceByUrl
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;
}
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:45,代码来源:DropBoxRequestParser.cs
示例18: RequestResource
/// <summary>
/// This method request information about a resource
/// </summary>
/// <param name="session"></param>
/// <param name="Name"></param>
/// <param name="parent"></param>
/// <returns></returns>
public override ICloudFileSystemEntry RequestResource(IStorageProviderSession session, string Name, ICloudDirectoryEntry parent)
{
// build url
String uriString = GetResourceUrl(session, parent, null);
uriString = PathHelper.Combine(uriString, Name);
// get the data
List<BaseFileEntry> childs = null;
BaseFileEntry requestResource = RequestResourceFromWebDavShare(session, uriString, out childs);
// check errors
if (requestResource == null)
return null;
// rename the root
if (Name.Equals("/"))
requestResource.Name = "/";
// init parent child relation
if (parent != null)
{
BaseDirectoryEntry parentDir = parent as BaseDirectoryEntry;
parentDir.AddChild(requestResource);
}
// check if we have to add childs
if (!(requestResource is BaseDirectoryEntry))
return requestResource;
else
{
BaseDirectoryEntry requestedDir = requestResource as BaseDirectoryEntry;
// add the childs
foreach (BaseFileEntry child in childs)
{
requestedDir.AddChild(child);
}
}
// go ahead
return requestResource;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:49,代码来源:WebDavStorageProviderService.cs
示例19: CreateObjectsFromJsonString
public static BaseFileEntry CreateObjectsFromJsonString(String jsonMessage, IStorageProviderService service, IStorageProviderSession session)
{
return UpdateObjectFromJsonString(jsonMessage, null, service, session);
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:4,代码来源:DropBoxRequestParser.cs
示例20: Addhash
public static void Addhash(string url, string hash, string response, IStorageProviderSession session)
{
SessionHashStorage.Add(session.SessionToken.ToString(), url, new KeyValuePair<string, string>(hash, response));
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:4,代码来源:DropBoxRequestParser.cs
注:本文中的IStorageProviderSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论