ToString() public method

public ToString ( ) : string
return string
        public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type)
        {
            ValidateType(value, typeof(CommaDelimitedStringCollection));
            CommaDelimitedStringCollection internalValue = value as CommaDelimitedStringCollection;

            return(internalValue?.ToString());
        }
        public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type)
        {
            base.ValidateType(value, typeof(CommaDelimitedStringCollection));
            CommaDelimitedStringCollection strings = value as CommaDelimitedStringCollection;

            if (strings != null)
            {
                return(strings.ToString());
            }
            return(null);
        }
		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");
		}
		/// <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;
		}
Exemplo n.º 5
0
        /// <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;
        }
Exemplo n.º 6
0
		/// <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();
		}
Exemplo n.º 7
0
 /// <summary>
 /// Translate a list of days of Month value to a string
 /// </summary>
 /// <param name="daysOfMonth">The list of values</param>
 /// <returns>A string representation of the values, in value1, value2, value3, ... format</returns>
 public static string GenerateDaysOfMonthString(IEnumerable<ushort> daysOfMonth)
 {
     var collection = new CommaDelimitedStringCollection();
     collection.AddRange(daysOfMonth.Select(day => day.ToString()).ToArray());
     return collection.ToString();
 }
Exemplo n.º 8
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();
        }
        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;
        }