示例#1
0
        public bool TryGetValue(out ReadOnlyCollection <AGraphElement> result, Object keyObject)
        {
            IComparable key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                result = null;

                return(false);
            }

            if (ReadResource())
            {
                AGraphElement element;
                var           foundSth = _idx.TryGetValue(key, out element);

                result = foundSth ? new ReadOnlyCollection <AGraphElement>(new List <AGraphElement> {
                    element
                }) : null;

                FinishReadResource();

                return(foundSth);
            }

            throw new CollisionException(this);
        }
示例#2
0
        public void AddOrUpdate(Object keyObject, AGraphElement graphElement)
        {
            IComparable key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                List <AGraphElement> values;
                if (_idx.TryGetValue(key, out values))
                {
                    values.Add(graphElement);
                }
                else
                {
                    values = new List <AGraphElement> {
                        graphElement
                    };
                    _idx.Add(key, values);
                }

                FinishWriteResource();

                return;
            }

            throw new CollisionException();
        }
示例#3
0
        public bool TryGetValue(out ReadOnlyCollection <AGraphElement> result, object keyObject)
        {
            String key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                result = null;
                return(false);
            }

            if (ReadResource())
            {
                try
                {
                    List <AGraphElement> graphElements;
                    var foundSth = _idx.TryGetValue(key, out graphElements);

                    result = foundSth ? new ReadOnlyCollection <AGraphElement>(graphElements) : null;
                    return(foundSth);
                }
                finally
                {
                    FinishReadResource();
                }
            }

            throw new CollisionException(this);
        }
示例#4
0
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for CheckObject
        ///</summary>
        public void CheckObjectUnitTestHelper <T>()
            where T : class
        {
            T      result         = null;  // TODO: Initialize to an appropriate value
            T      resultExpected = null;  // TODO: Initialize to an appropriate value
            object obj            = null;  // TODO: Initialize to an appropriate value
            bool   expected       = false; // TODO: Initialize to an appropriate value
            bool   actual;

            actual = IndexHelper.CheckObject <T>(out result, obj);
            Assert.AreEqual(resultExpected, result);
            Assert.AreEqual(expected, actual);
        }
示例#5
0
        public bool TryRemoveKey(Object keyObject)
        {
            IComparable key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return(false);
            }

            if (WriteResource())
            {
                var foundSth = _idx.Remove(key);

                FinishWriteResource();

                return(foundSth);
            }

            throw new CollisionException();
        }
示例#6
0
        public void AddOrUpdate(Object keyObject, AGraphElement graphElement)
        {
            IComparable key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                _idx[key] = graphElement;

                FinishWriteResource();

                return;
            }

            throw new CollisionException(this);
        }
示例#7
0
        public bool TryRemoveKey(object keyObject)
        {
            String key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return(false);
            }

            if (WriteResource())
            {
                try
                {
                    var foundSth = _idx.Remove(key);
                    return(foundSth);
                }
                finally
                {
                    FinishWriteResource();
                }
            }

            throw new CollisionException(this);
        }
示例#8
0
        public void AddOrUpdate(object keyObject, AGraphElement graphElement)
        {
            String key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                try
                {
                    List <AGraphElement> values;
                    if (_idx.TryGetValue(key, out values))
                    {
                        values.Add(graphElement);
                    }
                    else
                    {
                        values = new List <AGraphElement> {
                            graphElement
                        };
                        _idx.Add(key, values);
                    }
                }
                finally
                {
                    FinishWriteResource();
                }

                return;
            }

            throw new CollisionException(this);
        }