- /*
- * P4.Net *
- Copyright (c) 2007 Shawn Hladky
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- and associated documentation files (the "Software"), to deal in the Software without
- restriction, including without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all copies or
- substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- using System;
- using System.Collections;
- using System.Text;
- namespace P4API
- {
- /// <summary>
- /// Strongly typed dictionary to represent fields returned from Perforce commands.
- /// </summary>
- /// <remarks>
- /// The FieldDictionary only contains fields that contain a single string value. Fields that return array
- /// values are stored in <paramref name="ArrayFieldDictionary"/>.
- /// </remarks>
- public class FieldDictionary
- {
- private Hashtable _ht;
- internal FieldDictionary()
- {
- _ht = new Hashtable();
- }
- internal void Add(string key, string value)
- {
- _ht.Add(key, value);
- }
- /// <summary>
- /// Clears all elements of the dictionary.
- /// </summary>
- public void Clear()
- {
- _ht.Clear();
- }
- /// <summary>
- /// Tests if the key exists in the dictionary.
- /// </summary>
- /// <param name="key">The key to test</param>
- /// <returns>True if the key is defined in the dictionary.</returns>
- public bool ContainsKey(string key)
- {
- return _ht.Contains(key);
- }
- /// <summary>
- /// Gets all keys contained in the dictionary.
- /// </summary>
- /// <value>Keys in the FieldDictionary</value>
- public string[] Keys
- {
- get
- {
- string[] ret = new string[_ht.Count];
- int i = 0;
- foreach (string s in _ht.Keys)
- {
- ret[i] = s;
- i++;
- }
- return ret;
- }
- }
- /// <summary>
- /// Removes elements from the dictionary.
- /// </summary>
- /// <param name="key">The key of the element to remove.</param>
- public void Remove(string key)
- {
- _ht.Remove(key);
- }
- /// <summary>
- /// Gets the number of elements in the dictionary
- /// </summary>
- /// <value>Count of items.</value>
- public int Count
- {
- get
- {
- return _ht.Count;
- }
- }
- /// <summary>
- /// Returns the value assocatied to the key.
- /// </summary>
- /// <param name="key">The key to search on.</param>
- /// <returns>String value associated to the key.</returns>
- public string this[string key]
- {
- get
- {
- return (string) _ht[key];
- }
- set
- {
- //Many p4 form commands do not have all the fields by default.
- //this will auto-add that key when you try to set a value.
- if (_ht.ContainsKey(key))
- {
- _ht[key] = value;
- }
- else
- {
- _ht.Add(key, value);
- }
- }
- }
- }
- }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 6335 | Jim Gomes | Branch P4.Net. | 17 years ago | |
//guest/shawn_hladky/P4.Net/main/src/P4API/Record/FieldDictionary.cs | |||||
#4 | 6102 | Shawn Hladky | P4.Net: Documentation. Fixed SetTicketFile bug. Added form processing with Sp...ecDef. Stubbed-out code for launching external merge tool, but is disabled since it's too difficult to use. « |
17 years ago | |
#3 | 5915 | Shawn Hladky | p4.net Fixed diff2 bug. Re-worked array field logic More unit tests Organized P4Connecti...on w/ #region blocks, and moved methods around « |
18 years ago | |
#2 | 5878 | Shawn Hladky | P4.Net: 1.0, support for raw spec processing. Update copyright. Fix bu...ild script. Bugs found along the way. « |
18 years ago | |
#1 | 5830 | Shawn Hladky | P4.Net: reorg to support release branches | 18 years ago | |
//guest/shawn_hladky/P4.Net/src/P4API/Record/FieldDictionary.cs | |||||
#1 | 5798 | Shawn Hladky | P4.Net... still not ready for beta Added license to all files Added several doc fi...les Misc bugs « |
18 years ago | |
//guest/shawn_hladky/P4.Net/src/P4API/Record/FieldCollection.cs | |||||
#3 | 5774 | Shawn Hladky |
P4.Net. A few bug fixes. Addes first draft of MSBuild custom tasks. |
18 years ago | |
#2 | 5436 | Shawn Hladky | P4.Net -- Added some high-level functionality | 19 years ago | |
#1 | 5433 | Shawn Hladky | P4.Net More refactoring | 19 years ago |