/// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool AlreadyMarshalled(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            return(_marshalledObjects.Contains(obj.GetHashCode(), obj) != -1);
        }
Exemple #2
0
        public void TestContains()
        {
            var multi = new MultiMap <string, int> {
                { "coso", 1 }, { "coso", 2 }, { "coso", 3 }
            };

            Assert.IsTrue(multi.Contains(new KeyValuePair <string, int>("coso", 1)));
            Assert.IsFalse(multi.Contains(new KeyValuePair <string, int>("coso", 5)));

            Assert.IsFalse(new MultiMap <string, int>().Contains(new KeyValuePair <string, int>("coso", 1)));
        }
            public bool AddValue(string value, MultiMap <Argument, object> argumentValues,
                                 CommandLineErrorReporter reporter)
            {
                if (!AllowMultiple && argumentValues.ContainsKey(this))
                {
                    reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgument, LongName));
                    return(false);
                }

                object newValue;

                if (!ParseValue(ValueType, value, out newValue))
                {
                    reporter(string.Format(Resources.CommandLineArgumentParser_Argument_InvalidArgumentValue, LongName, value));
                    return(false);
                }

                if (Unique && argumentValues.Contains(this, newValue))
                {
                    reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgumentValueExpectedUnique, LongName, value));
                    return(false);
                }

                argumentValues.Add(this, newValue);
                return(true);
            }
        private bool AlreadyVisited(Object obj)
        {
            if (_unmarshalledObjects == null)
            {
                InitializeMultiMaps();
            }

            return(_visitedElements.Contains(obj.GetHashCode(), obj) != -1);
        }
            public bool AddValue(string value, MultiMap<Argument, object> argumentValues,
                CommandLineErrorReporter reporter)
            {
                if (!AllowMultiple && argumentValues.ContainsKey(this))
                {
                    reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgument, LongName));
                    return false;
                }

                object newValue;
                if (!ParseValue(ValueType, value, out newValue))
                {
                    reporter(string.Format(Resources.CommandLineArgumentParser_Argument_InvalidArgumentValue, LongName, value));
                    return false;
                }

                if (Unique && argumentValues.Contains(this, newValue))
                {
                    reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgumentValueExpectedUnique, LongName, value));
                    return false;
                }

                argumentValues.Add(this, newValue);
                return true;
            }
 /// <summary>
 ///
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public bool NeedsHashCode(Object obj)
 {
     return(_needsAttributeHashCode.Contains(obj.GetHashCode(), obj) != -1);
 }