Add() public method

public Add ( string value ) : void
value string
return void
コード例 #1
0
		public void Manipulations ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();

			c.Add ("1");
			Assert.AreEqual ("1", c.ToString(), "A1");

			c.Add ("2");
			c.Add ("3");
			Assert.AreEqual ("1,2,3", c.ToString(), "A2");

			c.Remove ("2");
			Assert.AreEqual ("1,3", c.ToString(), "A3");

			c.Insert (1, "2");
			Assert.AreEqual ("1,2,3", c.ToString(), "A4");

			c.Clear ();
			Assert.AreEqual (null, c.ToString(), "A5");

			string[] foo = new string[3];
			foo[0] = "1";
			foo[1] = "2";
			foo[2] = "3";
			c.AddRange (foo);
			Assert.AreEqual ("1,2,3", c.ToString(), "A6");
		}
コード例 #2
0
        private static StringCollection ValidateTable(DataTable table)
        {
            var problems = new CommaDelimitedStringCollection();

            if (!table.Columns.Contains("Principal"))
                problems.Add( "Missing Column: Principal" );

            if (!table.Columns.Contains("Operation"))
                problems.Add(  "Missing Column: Operation" );

            if (!table.Columns.Contains("Resource"))
                problems.Add(  "Missing Column: Resource" );

            for (var i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i].IsNull("Principal"))
                    problems.Add(string.Format("Missing Principal on Row {0:n0}", i + 1));

                if (table.Rows[i].IsNull("Operation"))
                    problems.Add(string.Format("Missing Operation on Row {0:n0}", i + 1));

                if (table.Rows[i].IsNull("Resource"))
                    problems.Add(string.Format("Missing Resource on Row {0:n0}", i + 1));
            }

            return problems;
        }
コード例 #3
0
		public void RO_Add ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();

			c.SetReadOnly ();
			c.Add ("hi");
		}
		public override object ConvertFrom (ITypeDescriptorContext ctx, CultureInfo ci, object data)
		{
			CommaDelimitedStringCollection col = new CommaDelimitedStringCollection ();
			string[] datums = ((string)data).Split(',');

			foreach (string datum in datums)
				col.Add (datum.Trim());

			return col;
		}
コード例 #5
0
        public CommaDelimitedStringCollection Clone()
        {
            CommaDelimitedStringCollection strings = new CommaDelimitedStringCollection();

            foreach (string str in this)
            {
                strings.Add(str);
            }
            strings._Modified       = false;
            strings._ReadOnly       = this._ReadOnly;
            strings._OriginalString = this._OriginalString;
            return(strings);
        }
コード例 #6
0
        public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data)
        {
            var col    = new CommaDelimitedStringCollection();
            var datums = ((string)data).Split(',');

            foreach (var datum in datums)
            {
                col.Add(datum.Trim());
            }

            col.UpdateStringHash();
            return(col);
        }
コード例 #7
0
        public CommaDelimitedStringCollection Clone()
        {
            CommaDelimitedStringCollection copy = new CommaDelimitedStringCollection();

            // Copy all values
            foreach (string str in this)
            {
                copy.Add(str);
            }

            // Copy Attributes
            copy._modified       = false;
            copy.IsReadOnly      = IsReadOnly;
            copy._originalString = _originalString;

            return(copy);
        }
コード例 #8
0
ファイル: BaseControlItem.cs プロジェクト: HydAu/DemoTBA
        /// <summary>
        /// Returns only those principals already added to an operation. Given a list of principals, you might want to
        /// know which one(s) have been included for a specific operation.
        /// </summary>
        public CommaDelimitedStringCollection FindIncludedPrincipals(string[] principals, string operation)
        {
            var includedPrincipals = new CommaDelimitedStringCollection();

            var key = StringHelper.Sanitize(operation);

            if (key == null || !_principals.ContainsKey(key))
                return includedPrincipals;

            var value = _principals[key];
            foreach (var principal in principals)
            {
                var p = StringHelper.Sanitize(principal);
                if (value.Contains(p))
                    includedPrincipals.Add(p);
            }

            return includedPrincipals;
        }
コード例 #9
0
		/// <summary>
		/// Gets the value of the property with the specified name.
		/// </summary>
		/// <param name="control">A <see cref="Control"/> object.</param>
		/// <param name="propertyName">The property name.</param>
		/// <returns>The property value.</returns>
		public static Object GetValue(Control control, String propertyName)
		{
			if ( control == null )
			{
				return null;
			}
			if ( String.IsNullOrEmpty(propertyName) )
			{
				propertyName = GetDefaultPropertyName(control);
			}

			Object value = null;

			if ( control is CheckBox )
			{
				value = ( control as CheckBox ).Checked ? 1 : 0;
			}
			else if ( control is ListControl )
			{
				CommaDelimitedStringCollection values = new CommaDelimitedStringCollection();
				ListControl list = control as ListControl;
				
				ListItem firstItem = null;
				foreach ( ListItem item in list.Items )
				{
					if ( item.Selected )
					{
						values.Add(item.Value);
					}
					
					if (firstItem == null)
               {
                  firstItem = item;
               }
				}
				
            if (firstItem != null && list is DropDownList && values.Count == 0)
            {
               //DropDownList must have one item selected
               values.Add(firstItem.Value);
            }

				value = values.ToString();
			}
			else
			{
				value = EntityUtil.GetPropertyValue(control, propertyName);
			}

			return value;
		}
コード例 #10
0
        private string SelectFieldNamesForEntity(int entityId)
        {
            string sqlText = @"SELECT name
                               FROM dbo.AdvancedFields
                               WHERE entity_id = @entity_id ";

            CommaDelimitedStringCollection commaStr = new CommaDelimitedStringCollection();
            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, conn))
            {
                cmd.AddParam("@entity_id", entityId);

                using (OpenCbsReader reader = cmd.ExecuteReader())
                {
                    if (reader.Empty)
                        return string.Empty;
                    while (reader.Read())
                    {
                        commaStr.Add(reader.GetString("name"));
                    }
                }
            }

            return commaStr.ToString();
        }
コード例 #11
0
ファイル: XmlMarkDown.cs プロジェクト: ankushraizada/Dynamo
        /// <summary>
        /// Converts the generic parameters.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="attribute">attribute = name / param / typeparam.</param>
        /// <returns>converted name</returns>
        public static string ConvertGenericParameters(XElement node, string methodName, string attribute)
        {
            //Seperate the method name and paramaeters (ex: Func(a,b) = [Func] + [a,b])
            var methodParams = methodName.Split('(', ')');
            var stringList = new CommaDelimitedStringCollection();
            if (methodParams.Count() > 1)
            {
                //Store the method name. the method name is Dynamo.Test.Test(int).
                //so splitting by . to get the method name as Test(int)
                methodName = methodParams[0].Split('.').Last();
                //Split the Parameters (ex: (a,b) = [a], [b]) 
                methodParams = methodParams[1].Split(',');
                int i = 0;
                foreach (var param in node.Elements(attribute))
                {
                    //when you add a parameter to a function, there is a possibility that comment is 
                    //not updated immediately. In that case add the param name to only those parameters 
                    //in the method name
                    if (methodParams.Count() > i)
                    {
                        //Extract only the classname , not the entire namespace
                        var className = string.Empty;
                        if (methodParams[i].Contains("Dynamo"))
                        {
                            className = methodParams[i].Split('.').Last();
                            className = className.ConstructUrl(methodParams[i]);
                        }
                        else
                        {
                            className = methodParams[i].Split('.').Last();
                        }

                        stringList.Add(className.MarkDownFormat("Italic") + " " + param.Attribute("name").Value);
                    }
                    i++;
                }
                //case 1: Param tag on the method.
                if (stringList.Count > 0)
                {
                    methodName = methodName + "(" + stringList + ")";
                }
                //case 1: No Param tag on the method.        
                else
                {
                    methodName = methodName + "(" + methodParams[0] + ")";
                }

                //add api_stability as super script. If there is no stability tag
                //then add a default value.
                methodName = "&nbsp;&nbsp;" + methodName;
                methodName = CheckAndAppendStability(node, methodName);
            }
            else
            {
                if (methodName.Contains("."))
                {
                    methodName = methodName.Split('.').Last();
                    methodName = methodName + "( )";
                }
                methodName = "&nbsp;&nbsp;" + methodName;
                methodName = CheckAndAppendStability(node, methodName);
            }

            return methodName;
        }
コード例 #12
0
ファイル: DataParameter.cs プロジェクト: mario-loza/School
        /// <summary>
        /// Updates and returns the value of the DataParameter object.
        /// </summary>
        /// <param name="context">The current System.Web.HttpContext of the request.</param>
        /// <param name="control">The System.Web.UI.Control that the parameter is bound to.</param>
        /// <returns>A System.Object that represents the updated and current value of the parameter.</returns>
        protected override Object Evaluate(HttpContext context, Control control)
        {
            String value = String.Empty;

            if ( _dataSource == null && control != null )
            {
                _dataSource = control.FindControl(DataSourceID) as IListDataSource;
            }
            if ( _dataSource != null )
            {
                IEnumerable entityList = _dataSource.GetEntityList();

                if ( entityList != null )
                {
                    CommaDelimitedStringCollection values = new CommaDelimitedStringCollection();
                    String propertyName = PropertyName ?? EntityKeyName;
                    IList list = EntityUtil.GetEntityList(entityList);
                    Object temp;

                    foreach ( Object item in list )
                    {
                        temp = EntityUtil.GetPropertyValue(item, EntityKeyName);

                        if ( temp != null )
                        {
                            values.Add(String.Format("'{0}'", temp));
                        }
                    }

                    if ( values.Count > 0 )
                    {
                        value = String.Format("{0} IN ({1})", propertyName, values.ToString());
                    }
                }
            }

            return value;
        }
コード例 #13
0
		public void ConvertTo ()
		{
			CommaDelimitedStringCollectionConverter cv = new CommaDelimitedStringCollectionConverter ();
			CommaDelimitedStringCollection col = new CommaDelimitedStringCollection();
			col.Add ("hi");
			col.Add ("bye");

			Assert.AreEqual ("hi,bye", cv.ConvertTo (null, null, col, typeof (string)), "A1");
		}
コード例 #14
0
        public CommaDelimitedStringCollection Clone()
        {
            CommaDelimitedStringCollection copy = new CommaDelimitedStringCollection();

            // Copy all values
            foreach (string str in this) copy.Add(str);

            // Copy Attributes
            copy._modified = false;
            copy.IsReadOnly = IsReadOnly;
            copy._originalString = _originalString;

            return copy;
        }
コード例 #15
0
		public void RO_Insert ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();

			c.Add ("hi");
			c.SetReadOnly ();
			c.Insert (0, "bye");
		}
コード例 #16
0
        protected void StartWorkflowButtonClick(object sender, EventArgs e)
        {
            var ids = Request["ids"].Split(',').ToList().ConvertAll(Convert.ToInt32);

            var workflowConfigId = Convert.ToInt32(AvailableCriteriaDropDownList.SelectedValue);
            var comment = string.IsNullOrEmpty(InstantiationCommentTextBox.Text) ? TheGlobalisationService.GetString("no_comment_supplied") : InstantiationCommentTextBox.Text;
            
            // TODO: custom workflow variables?

            Log.Info(string.Format("Instantiating workflow {0}: {1}", workflowConfigId, comment));

            var inst = TheWorkflowInstanceService.Instantiate(workflowConfigId, comment);

            var flags = new CommaDelimitedStringCollection();

            foreach (ListItem item in FlagsCheckBoxList.Items)
            {
                if (item.Selected)
                    flags.Add(TheGlobalisationService.GetString(item.Text));
            }
            
            inst.Flags = flags.ToString();

            foreach(var id in ids)
            {
                ((UmbracoWorkflowInstance) inst).CmsNodes.Add(id);
            }
            
            TheWorkflowInstanceService.Update(inst);
            TheWorkflowInstanceService.Start(inst.Id);

            TheWorkflowRuntime.RunWorkflows();
            SavedLiteral.Visible = true;
        }
コード例 #17
0
ファイル: SqlUtil.cs プロジェクト: chibuk/krooe
		/// <summary>
		/// Encodes the specified values for use in SQL expressions and
		/// optionally surrounds the value with single-quotes.
		/// </summary>
		/// <param name="values"></param>
		/// <param name="surround"></param>
		/// <returns></returns>
		public static String Encode(String[] values, bool surround)
		{
			if ( values == null || values.Length < 1 )
			{
				return SqlUtil.NULL;
			}

			CommaDelimitedStringCollection csv = new CommaDelimitedStringCollection();

			foreach ( String value in values )
			{
				if ( !String.IsNullOrEmpty(value) )
				{
					csv.Add(SqlUtil.Encode(value.Trim(), surround));
				}
			}

			return csv.ToString();
		}