Ejemplo n.º 1
0
        public void CacheDictionary_Null()
        {
            var cd = new CacheDictionary<string, int>(EqualityComparer<string>.Default);
            Assert.AreEqual(0, cd.Count);

            var values = cd.Values;

            Assert.AreEqual(4, cd.GetOrAdd(key: null, x => (x ?? "null").Length));
            Assert.AreEqual(1, cd.Count);
            Assert.AreEqual(1, values.Count());
            Assert.IsTrue(values.Contains(4));

            Assert.AreEqual(4, cd.GetOrAdd(key: null, x => (x ?? "null").Length));
            Assert.AreEqual(1, cd.Count);
            Assert.AreEqual(1, values.Count());
            Assert.IsTrue(values.Contains(4));

            Assert.IsTrue(cd.Remove(key: null));
            Assert.AreEqual(0, cd.Count);
            Assert.AreEqual(0, values.Count());

            cd.Clear();
            Assert.AreEqual(0, cd.Count);
            Assert.AreEqual(0, values.Count());
        }
Ejemplo n.º 2
0
        protected virtual void OnDestroy()
        {
            Instance = null;
            _usedServiceCallbackIds.Clear();
            foreach (var item in _pendingServiceCallbacks.CacheItems.Values)
            {
                item.Value.State = ServiceCallbackStateEnum.ERROR_TIMEOUT;
                item.Value.RaiseTimeout();
            }

            _pendingServiceCallbacks.Clear();
        }
Ejemplo n.º 3
0
        public DependencyProperty AddOwner(Type ownerType, PropertyMetadata metadata = null)
        {
            AddRegisteredProperty(new DependencyPropertyHashKey(ownerType, Name), this);

            if (metadata != null)
            {
                OverrideMetadata(ownerType, metadata);
            }

            typeContainsCache.Clear();

            return(this);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// delete all files and structure related to search process
 /// </summary>
 internal void SearchReset()
 {
     try
     {
         if (File.Exists($@"{SavingQueryResultPath}\{SavingFileName}"))
         {
             File.Delete($@"{SavingQueryResultPath}\{SavingFileName}");
         }
         InvertedIndex.Clear();
         CacheDictionary.Clear();
         DocumentsDataList.Clear();
         queryFilesNameResults = new List <string>();
         queryFilesNameResults.Clear();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 5
0
        public virtual bool Init(UInt32 mapId, UInt32 sceneId)
        {
            m_MapScenePlayer.Clear();
            m_MapSceneOtherCreature.Clear();
            m_Grid9Manager.Clear();

            Map = MapMgr.Inst().GetMap(mapId);
            if (Map == null)
            {
                return(false);
            }

            Grid9Manager.InitGridSize(Map.Width, Map.Height);

            MapId   = mapId;
            SceneId = sceneId;

            return(true);
        }
Ejemplo n.º 6
0
        public void CacheDictionary_Simple()
        {
            var cd = new CacheDictionary<int, int>(EqualityComparer<int>.Default);
            Assert.AreEqual(0, cd.Count);

            var values = cd.Values;

            Assert.AreEqual(42, cd.GetOrAdd(21, x => x * 2));
            Assert.AreEqual(1, cd.Count);
            Assert.AreEqual(1, values.Count());
            Assert.IsTrue(values.Contains(42));

            Assert.AreEqual(42, cd.GetOrAdd(21, x => x * 2));
            Assert.AreEqual(1, cd.Count);
            Assert.AreEqual(1, values.Count());
            Assert.IsTrue(values.Contains(42));

            Assert.AreEqual(44, cd.GetOrAdd(22, x => x * 2));
            Assert.AreEqual(2, cd.Count);
            Assert.AreEqual(2, values.Count());
            Assert.IsTrue(values.Contains(42) && values.Contains(44));

            Assert.IsTrue(cd.Remove(21));
            Assert.AreEqual(1, cd.Count);
            Assert.AreEqual(1, values.Count());
            Assert.IsTrue(values.Contains(44));

            Assert.IsFalse(cd.Remove(21));
            Assert.AreEqual(1, cd.Count);
            Assert.AreEqual(1, values.Count());
            Assert.IsTrue(values.Contains(44));

            Assert.IsFalse(cd.Remove(-1));
            Assert.AreEqual(1, cd.Count);
            Assert.AreEqual(1, values.Count());
            Assert.IsTrue(values.Contains(44));

            cd.Clear();
            Assert.AreEqual(0, cd.Count);
            Assert.AreEqual(0, values.Count());
        }
Ejemplo n.º 7
0
 /// <summary>
 /// delete all files created
 /// </summary>
 internal void Reset()
 {
     if (Directory.Exists($@"{ResultPath}\Posting With Stemming"))
     {
         Directory.Delete($@"{ResultPath}\Posting With Stemming", true);
     }
     if (Directory.Exists($@"{ResultPath}\Posting"))
     {
         Directory.Delete($@"{ResultPath}\Posting", true);
     }
     if (File.Exists($@"{LoadingAndSavingPath}\Dictionary"))
     {
         File.Delete($@"{LoadingAndSavingPath}\Dictionary");
     }
     if (File.Exists($@"{LoadingAndSavingPath}\Cache"))
     {
         File.Delete($@"{LoadingAndSavingPath}\Cache");
     }
     InvertedIndex.Clear();
     CacheDictionary.Clear();
     DocumentsDataList.Clear();
 }
Ejemplo n.º 8
0
        public void OverrideMetadata(Type forType, PropertyMetadata metadata)
        {
            if (typeMetadata.ContainsKey(forType))
            {
                throw new Granular.Exception("DependencyProperty \"{0}\" already contains metadata for type \"{1}\"", this, forType.Name);
            }

            if (metadata.DefaultValue == null)
            {
                metadata.DefaultValue = ownerMetadata.DefaultValue;
            }

            if (metadata.CoerceValueCallback == null)
            {
                metadata.CoerceValueCallback = ownerMetadata.CoerceValueCallback;
            }

            if (Inherits != metadata.Inherits)
            {
                throw new Granular.Exception("Overriding inheritance behavior is not supported, Overrides of \"{0}\" must declare \"inherits: {1}\"", this, Inherits);
            }

            if (Inherits)
            {
                if (metadata.DefaultValue != null && metadata.DefaultValue != ownerMetadata.DefaultValue)
                {
                    throw new Granular.Exception("Overriding inherited properties metadata with different default value is not supported, Overrides of \"{0}\" cannot set a different default value other than \"{1}\"", this, ownerMetadata.DefaultValue);
                }

                metadata.DefaultValue = ownerMetadata.DefaultValue;
            }

            typeMetadata.Add(forType, metadata);

            typeMetadataCache.Clear();
            orderedTypeMetadataCache = null;

            isMetadataOverridden = true;
        }
Ejemplo n.º 9
0
 protected virtual void OnResourcesChanged(ResourcesChangedEventArgs e)
 {
     resourcesCache.Clear();
     SetValue(StyleProperty, GetDefaultStyle(), BaseValueSource.Default);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 刷新清空
 /// </summary>
 public static void Refresh()
 {
     _contextSet.Clear();
 }