コード例 #1
0
        public void TestCreate()
        {
            ElementFactory ef = new ElementFactory();

            ef.AddType(new global::Jabber.protocol.iq.Factory());

            string g = new Guid().ToString();
            FileMap <DiscoInfo> fm = new FileMap <DiscoInfo>("test.xml", ef);

            fm.Clear();
            Assert.AreEqual(0, fm.Count);

            fm[g] = Element;
            Assert.IsTrue(fm.Contains(g));
            Assert.IsFalse(fm.Contains("foo"));
            Assert.IsInstanceOf <DiscoInfo>(fm[g]);
            Assert.AreEqual(1, fm.Count);

            // re-read, to reparse
            fm = new FileMap <DiscoInfo>("test.xml", ef);
            Assert.IsTrue(fm.Contains(g));
            Assert.IsInstanceOf <DiscoInfo>(fm[g]);

            fm[g] = null;
            Assert.AreEqual(1, fm.Count);

            fm.Remove(g);
            Assert.AreEqual(0, fm.Count);
        }
コード例 #2
0
ファイル: FileMap.cs プロジェクト: rankida/HangoutPhone
        public void TestCreate()
        {
            ElementFactory ef = new ElementFactory();
            ef.AddType(new global::jabber.protocol.iq.Factory());

            string g = new Guid().ToString();
            FileMap<DiscoInfo> fm = new FileMap<DiscoInfo>("test.xml", ef);
            fm.Clear();
            Assert.AreEqual(0, fm.Count);

            fm[g] = Element;
            Assert.IsTrue(fm.Contains(g));
            Assert.IsFalse(fm.Contains("foo"));
            Assert.IsInstanceOfType(typeof(DiscoInfo), fm[g]);
            Assert.AreEqual(1, fm.Count);

            // re-read, to reparse
            fm = new FileMap<DiscoInfo>("test.xml", ef);
            Assert.IsTrue(fm.Contains(g));
            Assert.IsInstanceOfType(typeof(DiscoInfo), fm[g]);

            fm[g] = null;
            Assert.AreEqual(1, fm.Count);

            fm.Remove(g);
            Assert.AreEqual(0, fm.Count);
        }
コード例 #3
0
        //
        // Outer funcs
        //

        /// <summary>
        /// This functions asks the AAS REST repository on given location, which AasIds would be availble.
        /// Using the AasIds, details are retrieved for each inidivudal AAS and synchronized with the
        /// repository.
        /// Note: for the time being, the list of file items is recreated, but not synchronized
        /// Note: due to the nature of long-lasting actions, this is by design async!
        /// </summary>
        /// <returns>If a successfull retrieval could be made</returns>
        public async Task <bool> SyncronizeFromServerAsync()
        {
            // access
            if (true != _connector?.IsValid())
            {
                return(false);
            }

            // try get a list of items from the connector
            var items = await _connector.GenerateRepositoryFromEndpointAsync();

            // just re-set
            FileMap.Clear();
            foreach (var fi in items)
            {
                if (fi != null)
                {
                    FileMap.Add(fi);
                    fi.ContainerList = this;
                }
            }

            // ok
            return(true);
        }
コード例 #4
0
        /// <summary>
        ///     GC safe dispose wrapper
        /// </summary>
        /// <param name="disposing">truth check</param>
        protected virtual void Dispose(bool disposing)
        {
            if (Disposed)
            {
                return;
            }

            Hasher?.Dispose();

            Prefetch.Dispose();

            foreach (var(_, cache) in CacheFiles)
            {
                cache?.Dispose();
            }

            if (disposing)
            {
                CacheFiles.Clear();
                CacheFiles = default;
                FileMap.Clear();
                FileMap  = default;
                Prefetch = default;
            }

            Disposed = true;
        }
コード例 #5
0
        IDictionary <UInt32, UInt32> CorrectOffsets()
        {
            var changes = new SortedDictionary <UInt32, UInt32>();

            var list = FileMap.ToList();
            var firstinstructioindex = list.FindIndex(x => x.Value is Bytecode.Instruction);

            var itemoffset = list[firstinstructioindex].Key;

            for (var i = firstinstructioindex; i >= 0 && i < list.Count; ++i)
            {
                var item = list[i];

                if (itemoffset != item.Key)
                {
                    var diff = itemoffset - item.Key;

                    list[i]           = new KeyValuePair <UInt32, Object>(itemoffset, item.Value);
                    changes[item.Key] = itemoffset;
                }

                var size = (UInt32)GetObjectSize(item.Value);
                itemoffset += size;
            }

            FileMap.Clear();

            foreach (var item in list)
            {
                FileMap.Add(item.Key, item.Value);
            }

            return(changes);
        }
コード例 #6
0
        public virtual void Clear()
        {
            if (Directory.Exists(CachePath))
            {
                try
                {
                    Directory.Delete(CachePath, true);
                }
                catch (IOException)
                {
                }
            }

            FileMap.Clear();
        }
コード例 #7
0
ファイル: HostService.cs プロジェクト: timpatt/docfx
        private void LoadCore(IEnumerable <FileModel> models)
        {
            EventHandler fileOrBaseDirChangedHandler = HandleFileOrBaseDirChanged;
            EventHandler <PropertyChangedEventArgs <ImmutableArray <UidDefinition> > > uidsChangedHandler = HandleUidsChanged;
            EventHandler contentAccessedHandler = null;

            if (!Environment.Is64BitProcess)
            {
                contentAccessedHandler = ContentAccessedHandler;
            }
            if (Models != null)
            {
                foreach (var m in Models)
                {
                    m.FileOrBaseDirChanged -= fileOrBaseDirChangedHandler;
                    m.UidsChanged          -= uidsChangedHandler;
                    m.ContentAccessed      -= contentAccessedHandler;
                }
            }
            Models = models.ToImmutableList();
            _uidIndex.Clear();
            FileMap.Clear();
            foreach (var m in Models)
            {
                m.FileOrBaseDirChanged += fileOrBaseDirChangedHandler;
                m.UidsChanged          += uidsChangedHandler;
                m.ContentAccessed      += contentAccessedHandler;
                foreach (var uid in m.Uids)
                {
                    List <FileModel> list;
                    if (!_uidIndex.TryGetValue(uid.Name, out list))
                    {
                        list = new List <FileModel>();
                        _uidIndex.Add(uid.Name, list);
                    }
                    list.Add(m);
                }
                if (m.Type != DocumentType.Overwrite)
                {
                    FileMap[m.FileAndType] = m.FileAndType;
                }
            }
        }
コード例 #8
0
ファイル: ClientData.cs プロジェクト: vaginessa/Code
        // Interface
        public override void Clear()
        {
            base.Clear();

            Name = Default.Name;

            Group.Clear();
            Router.Clear();
            DownloadFolder = FileUtil.GetDownloadFolder();

            lock (SharedFolders)
                SharedFolders.Clear();

            lock (FileMap)
                FileMap.Clear();

            lock (FolderMap)
                FolderMap.Clear();
        }