コード例 #1
0
        /// <summary>
        /// Creates an <see cref="IDictionary"/> and adds the
        /// specified key &amp; value to the collection.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <returns>an <see cref="IDictionary"/></returns>
        public static MonoRailDictionary CreateN(string key, object value)
        {
            var helper = new MonoRailDictionary();

            helper[key] = value.ToString();
            return(helper);
        }
コード例 #2
0
        /// <summary>
        /// Creates a dictionary froms a name value collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <returns></returns>
        public IDictionary FromNameValueCollection(NameValueCollection collection)
        {
            IDictionary dict = new MonoRailDictionary();

            foreach (var key in collection.AllKeys)
            {
                if (key != null)
                {
                    dict[key] = collection.GetValues(key);
                }
            }

            return(dict);
        }
コード例 #3
0
        /// <summary>
        /// Creates a dictionary from specified arguments.
        /// </summary>
        /// <remarks> Returns a MonoRailDictionary object,
        /// which is an IDictionary like previous versions of this method.
        /// </remarks>
        /// <example>
        /// <code>
        /// DictHelper.Create( "style=display: none;", "selected" )
        /// </code></example>
        /// <param name="args">The arguments.</param>
        /// <returns>an <see cref="IDictionary"/></returns>
        public static MonoRailDictionary Create(params String[] args)
        {
            var dict = new MonoRailDictionary();

            foreach (var arg in args)
            {
                var pos = arg.IndexOf('=');

                if (pos == -1)
                {
                    dict[arg] = "";
                }
                else
                {
                    dict[arg.Substring(0, pos)] = arg.Substring(pos + 1);
                }
            }
            return(dict);
        }
コード例 #4
0
ファイル: DictHelper.cs プロジェクト: ralescano/castle
		/// <summary>
		/// Creates a dictionary froms a name value collection.
		/// </summary>
		/// <param name="collection">The collection.</param>
		/// <returns></returns>
		public IDictionary FromNameValueCollection(NameValueCollection collection)
		{
			IDictionary dict = new MonoRailDictionary();

			foreach(string key in collection.AllKeys)
			{
				if (key != null)
				{
					dict[key] = collection.GetValues(key);
				}
			}
			
			return dict;
		}
コード例 #5
0
ファイル: DictHelper.cs プロジェクト: ralescano/castle
		/// <summary>
		/// Creates an <see cref="IDictionary"/> and adds the 
		/// specified key &amp; value to the collection.
		/// </summary>
		/// <param name="key">The key.</param>
		/// <param name="value">The value.</param>
		/// <returns>an <see cref="IDictionary"/></returns>
		public static MonoRailDictionary CreateN(string key, object value)
		{
			MonoRailDictionary helper = new MonoRailDictionary();
			helper[key] = value.ToString();
			return helper;
		}
コード例 #6
0
ファイル: DictHelper.cs プロジェクト: ralescano/castle
		/// <summary>
		/// Creates a dictionary from specified arguments.
		/// </summary>
		/// <remarks> Returns a MonoRailDictionary object, 
		/// which is an IDictionary like previous versions of this method.
		/// </remarks>
		/// <example>
		/// <code>
		/// DictHelper.Create( "style=display: none;", "selected" )
		/// </code></example>
		/// <param name="args">The arguments.</param>
		/// <returns>an <see cref="IDictionary"/></returns>
		public static MonoRailDictionary Create(params String[] args)
		{
			MonoRailDictionary dict = new MonoRailDictionary();
			foreach (String arg in args)
			{
				int pos = arg.IndexOf('=');

				if (pos == -1)
				{
					dict[arg] = "";
				}
				else
				{
					dict[arg.Substring(0, pos)] = arg.Substring(pos + 1);
				}
			}
			return dict;
		}