Inheritance: System.Collections.Specialized.StringCollection
Exemplo n.º 1
0
		public AuthorizationRule (AuthorizationRuleAction action)
		{
			this.action = action;
			base[rolesProp] = new CommaDelimitedStringCollection ();
			base[usersProp] = new CommaDelimitedStringCollection ();
			base[verbsProp] = new CommaDelimitedStringCollection ();
		}
		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");
		}
		public void RO_Add ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();

			c.SetReadOnly ();
			c.Add ("hi");
		}
        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 ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data)
        {
            CommaDelimitedStringCollection strings = new CommaDelimitedStringCollection();

            strings.FromString((string)data);
            return(strings);
        }
Exemplo n.º 6
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;
        }
		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;
		}
        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);
        }
Exemplo n.º 9
0
        public CommaDelimitedStringCollection Clone()
        {
            CommaDelimitedStringCollection col = new CommaDelimitedStringCollection();

            string[] contents = new string[this.Count];
            CopyTo(contents, 0);

            col.AddRange(contents);

            return(col);
        }
Exemplo n.º 10
0
        public CommaDelimitedStringCollection Clone()
        {
            var col      = new CommaDelimitedStringCollection();
            var contents = new string[Count];

            CopyTo(contents, 0);

            col.AddRange(contents);
            col._originalStringHash = _originalStringHash;

            return(col);
        }
Exemplo n.º 11
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);
        }
        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);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Retrieves the industries associated with the network companies being bound to the page.
        /// </summary>
        /// <param name="companyID"></param>
        /// <returns></returns>
        protected string GetCompanyIndustries(string companyID)
        {
            string commandText = "SELECT IndustryDescr" + CareerCruisingWeb.CCLib.Common.Strings.SuffixCode() + " FROM Con_CompanyIndustries AS ci INNER JOIN Con_IndustriesLookup AS il ON ci.CompanyID=" + companyID + " and ci.IndustryID = il.IndustryID";
            DataTable industries = CareerCruisingWeb.CCLib.Common.DataAccess.GetDataTable(commandText);

            System.Configuration.CommaDelimitedStringCollection companyIndustriesCollection = new CommaDelimitedStringCollection();
            string companyIndustriesList = null;

            foreach (DataRow industry in industries.Rows)
            {
                companyIndustriesList = string.Join(",", new string[] { industry["IndustryDescr" + CareerCruisingWeb.CCLib.Common.Strings.SuffixCode()].ToString() });
            }

            return companyIndustriesList;
        }
Exemplo n.º 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);
        }
Exemplo n.º 15
0
        /// <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;
        }
Exemplo n.º 16
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.º 17
0
        /// <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;
        }
 public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data)
 {
     CommaDelimitedStringCollection strings = new CommaDelimitedStringCollection();
     strings.FromString((string) data);
     return strings;
 }
		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");
		}
Exemplo n.º 20
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();
        }
Exemplo n.º 21
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();
 }
		public CommaDelimitedStringCollection Clone ()
		{
			CommaDelimitedStringCollection col = new CommaDelimitedStringCollection();
			string[] contents = new string[this.Count];
			CopyTo (contents, 0);
			
			col.AddRange (contents);
			col.originalStringHash = originalStringHash;

			return col;
		}
		public void RO_AddRange ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();
			string[] foo = new string[2];

			foo[0] = "hi";
			foo[1] = "bye";

			c.SetReadOnly ();
			c.AddRange (foo);
		}
Exemplo n.º 24
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;
        }
		public void Defaults ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();
			Assert.IsFalse (c.IsModified, "A1");
			Assert.IsFalse (c.IsReadOnly, "A1");
		}
		public void RO_Insert ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();

			c.Add ("hi");
			c.SetReadOnly ();
			c.Insert (0, "bye");
		}
        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;
        }
Exemplo n.º 28
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.º 29
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;
		}
		public void RO_Remove ()
		{
			CommaDelimitedStringCollection c = new CommaDelimitedStringCollection ();

			c.SetReadOnly ();
			c.Clear ();
		}