private void RefreshChildsOfDirectory(IStorageProviderSession session, BaseDirectoryEntry dir)
        {
            // get the location
            var reslocation = GetResourceUrl(session, dir, null);

            // ensure that we have a trailing slash
            reslocation = reslocation.TrimEnd('/');
            reslocation = reslocation + "/";

            // build the uri
            var resUri = new Uri(reslocation);

            // convert BaseDir to DirInfo
            var dInfo = new DirectoryInfo(resUri.LocalPath);

            // clear childs
            dir.ClearChilds();

            // get all childs
            foreach (var fInfo in dInfo.GetFileSystemInfos())
            {
                var f = CreateEntryByFileSystemInfo(fInfo, session);
                dir.AddChild(f);
            }
        }
        public override void RefreshResource(IStorageProviderSession session, ICloudFileSystemEntry resource)
        {
            // nothing to do for files
            if (!(resource is ICloudDirectoryEntry))
            {
                return;
            }

            // build url
            String uriString = GetResourceUrl(session, resource, null);

            // get the data
            List <BaseFileEntry> childs = null;

            RequestResourceFromWebDavShare(session, uriString, out childs);

            // set the new childs collection
            BaseDirectoryEntry dirEntry = resource as BaseDirectoryEntry;

            dirEntry.ClearChilds();

            // add the new childs
            if (childs != null)
            {
                dirEntry.AddChilds(childs);
            }
        }
예제 #3
0
        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);
        }