Beispiel #1
0
        public static bool Exists(string dictName)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(dictName))
            {
                throw new ArgumentException("dictName cannot be null or empty");
            }
            #endregion

            return(DictionaryManager.DictionaryExists(dictName));
        }
Beispiel #2
0
        public static int Count(string dictName)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(dictName))
            {
                throw new ArgumentException("dictName cannot be null or empty");
            }
            #endregion

            return(DictionaryManager.GetDictionary(dictName).Count);
        }
Beispiel #3
0
        public static string GetValue(string dictName, string key)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(dictName))
            {
                throw new ArgumentException("dictName cannot be null or empty");
            }
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentException("key cannot be null or empty");
            }
            #endregion

            return(DictionaryManager.GetDictionary(dictName)[key]);
        }
Beispiel #4
0
        public static bool IsEmpty(string dictName)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(dictName))
            {
                throw new ArgumentException("dictName cannot be null or empty");
            }
            #endregion

            if (!DictionaryManager.DictionaryExists(dictName))
            {
                return(true);
            }
            return(DictionaryManager.GetDictionary(dictName).Count == 0);
        }
        /// <summary>
        /// Execute the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            base.ExecuteTask();

            if (DictionaryManager.DictionaryExists(NewDictionaryName))
            {
                throw new BuildException(string.Format("Dictionary with name [{0}] already exists.", NewDictionaryName));
            }

            IDictionary <string, string> newDictionary = DictionaryManager.GetDictionary(NewDictionaryName);

            foreach (string key in Dictionary.Keys)
            {
                newDictionary[key] = Dictionary[key];
            }
        }
        /// <summary>
        /// Execute the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            IDictionary <string, string> dict = DictionaryManager.GetDictionary(DictionaryName);

            foreach (string key in dict.Keys)
            {
                if (KeyProperty != null)
                {
                    NAntUtility.AddOrOverwriteProperty(Project, KeyProperty, key);
                }
                if (ValueProperty != null)
                {
                    NAntUtility.AddOrOverwriteProperty(Project, ValueProperty, dict[key]);
                }

                // Base execute handles executing all child tasks.
                base.ExecuteTask();
            }
        }
 /// <summary>
 /// Execute the task.
 /// </summary>
 protected override void ExecuteTask()
 {
     _dictionary = DictionaryManager.GetDictionary(DictionaryName);
 }