当前位置: 首页>>代码示例>>C#>>正文


C# IPropertyBag类代码示例

本文整理汇总了C#中IPropertyBag的典型用法代码示例。如果您正苦于以下问题:C# IPropertyBag类的具体用法?C# IPropertyBag怎么用?C# IPropertyBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IPropertyBag类属于命名空间,在下文中一共展示了IPropertyBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public override object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup)
        {
            if (parameters == null || (parameters.Length < 2 || parameters.Length > 3))
                throw new ImpressionInterpretException("Filter " + Keyword + " expects 2 or 3 parameters.", markup);

            // text field to bind to
            // selected value

            // text field to bind to
            // value field to bind to
            // selected value

            if (obj == null)
                return null;

            if (obj.GetType().GetInterface("IEnumerable") != null) {

                IReflector reflector = new Reflector();

                bool textOnly = parameters.Length == 2;
                string textField = parameters[0];
                string selectedField = textOnly ? parameters[1] : parameters[2];

                StringBuilder optionBuilder = new StringBuilder();
                IEnumerator en = ((IEnumerable) obj).GetEnumerator();

                // &#34; for quotes
                // &#39; for apostrophes

                // lookup the selected value
                object selectedObject = bag == null ? null : reflector.Eval(bag, selectedField);
                string selectedValue = selectedObject != null ? selectedObject.ToString() : null;

                if (textOnly) {
                    while (en.MoveNext()) {
                        object current = en.Current;
                        object textObject = reflector.Eval(current, textField);
                        string textString = textObject != null ? textObject.ToString() : null;
                        string selected = (textString == selectedValue) ? " selected=\"true\"" : "";
                        optionBuilder.AppendFormat("<option{1}>{0}</option>", textString, selected);
                    }
                } else {
                    string valueField = parameters[1];

                    while(en.MoveNext()) {
                        object current = en.Current;
                        object textObject = reflector.Eval(current, textField);
                        string textString = textObject != null ? textObject.ToString() : null;
                        object valueObject = reflector.Eval(current, valueField);
                        string valueString = valueObject != null ? valueObject.ToString() : null;

                        string selected = (valueString == selectedValue) ? " selected=\"true\"" : "";
                        optionBuilder.AppendFormat("<option value=\"{0}\"{2}>{1}</option>", valueString, textString, selected);
                    }
                }
                return optionBuilder.ToString();
            }

            return null;
        }
开发者ID:codesoda,项目名称:Impression,代码行数:60,代码来源:HtmlOptionsFilter.cs

示例2: Get

		/// <summary>
		/// Gets the dataset.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			// create the dataset
			var dataset = new Dataset();

			// loop over all the CMS plugin types
			foreach (var plugin in typeService.Load(context, "CmsPlugin").GetInheritingTypes(context).Select(type =>
			                                                                                                 {
			                                                                                                 	// get the plugin descriptor
			                                                                                                 	CmsPluginDescriptor descriptor;
			                                                                                                 	if (!type.TryGetDescriptor(out descriptor))
			                                                                                                 		throw new InvalidOperationException(string.Format("Type '{0}' does not contain a CMS-plugin", type.Name));

			                                                                                                 	// return the model
			                                                                                                 	return new
			                                                                                                 	       {
			                                                                                                 	       	Type = type,
			                                                                                                 	       	Descriptor = descriptor
			                                                                                                 	       };
			                                                                                                 }).OrderBy(plugin => plugin.Descriptor.GetOrder(context)))
			{
				// create the plugin row
				var row = new PropertyBag
				          {
				          	{"type", plugin.Type.Name}
				          };

				// add the row to the dataset
				dataset.AddRow(row);
			}

			return dataset;
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:39,代码来源:GetPluginDatasetTag.cs

示例3: IsVisible

		public bool IsVisible(IPropertyBag properties)
		{
			if (base.CompareFromContext(properties, "UserMode", "1") != 0)          // Runtime
				return true;
			else                                                                    // DesignTime            
				return properties.GetPropertyValue<bool>("EnableCheckbox");
		}
开发者ID:genexuslabs,项目名称:gxui,代码行数:7,代码来源:UncheckedNodesResolver.cs

示例4: DoCreateNode

		/// <summary>
		/// Creates a new node in this repository.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parent">The parent node.</param>
		/// <param name="newProperties">The properties of the node which to create.</param>
		/// <returns>Returns the created nodes.</returns>
		protected override Node DoCreateNode(IMansionContext context, Node parent, IPropertyBag newProperties)
		{
			// build the query
			int nodeId;
			using (var connection = CreateConnection())
			using (var transaction = connection.BeginTransaction())
			using (var command = context.Nucleus.CreateInstance<InsertNodeCommand>())
			{
				// init the command
				command.Prepare(context, connection, transaction, parent.Pointer, newProperties);

				// execute the command
				try
				{
					// execute the query
					nodeId = command.Execute();

					// woohoo it worked!
					transaction.Commit();
				}
				catch (Exception)
				{
					// something terrible happened, revert everything
					transaction.Rollback();
					throw;
				}
			}

			// retrieve the created node
			return RetrieveSingleNode(context, new Query().Add(new IsPropertyEqualSpecification("id", nodeId)));
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:38,代码来源:SqlServerRepository.cs

示例5: DoToUpdateStatement

		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="queryBuilder"></param>
		/// <param name="record"> </param>
		/// <param name="modifiedProperties"></param>
		protected override void DoToUpdateStatement(IMansionContext context, ModificationQueryBuilder queryBuilder, Record record, IPropertyBag modifiedProperties)
		{
			// check if the property is not modified
			int newOrder;
			if (!modifiedProperties.TryGet(context, PropertyName, out newOrder))
				return;

			// check if the record contains a pointer
			NodePointer pointer;
			if (!record.TryGet(context, "pointer", out pointer))
				throw new InvalidOperationException("Could not update this record because it did not contain a pointer");

			// don't update order for root  nodes
			if (pointer.Depth == 1)
				return;

			// do not allow values smaller than 1
			if (newOrder < 1)
				throw new InvalidOperationException("Can not set orders smaller than 1");

			// assemble parameter
			var newOrderParameterName = queryBuilder.AddParameter("newOrder", newOrder, DbType.Int32);
			var oldOrderParameterName = queryBuilder.AddParameter("oldOrder", record.Get<int>(context, PropertyName), DbType.Int32);
			var parentIdParameterName = queryBuilder.AddParameter("parentId", pointer.Parent.Id, DbType.Int32);

			// update the orders before updating the order of the current node
			queryBuilder.PrependQuery(string.Format("UPDATE [Nodes] SET [order] = [order] + 1 WHERE (parentId = {0}) AND ([order] < {1} AND [order] >= {2})", parentIdParameterName, oldOrderParameterName, newOrderParameterName));
			queryBuilder.PrependQuery(string.Format("UPDATE [Nodes] SET [order] = [order] - 1 WHERE (parentId = {0}) AND ([order] > {1} AND [order] <= {2})", parentIdParameterName, oldOrderParameterName, newOrderParameterName));

			// update the column
			queryBuilder.AddColumnValue(PropertyName, newOrderParameterName);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:39,代码来源:OrderColumn.cs

示例6: Initialize

		/// <summary>
		/// Initializes the given <paramref name="column"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="column">The <see cref="PropertyColumn"/> which to initialze.</param>
		/// <param name="properties">The properties.</param>
		/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
		protected static void Initialize(IMansionContext context, PropertyColumn column, IPropertyBag properties)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (column == null)
				throw new ArgumentNullException("column");
			if (properties == null)
				throw new ArgumentNullException("properties");

			// get the allow null flag
			column.AllowNullValue = properties.Get(context, "allowNullValue", false);

			// check if there is an expression
			string expressionString;
			if (properties.TryGet(context, "expression", out expressionString))
			{
				var expressionService = context.Nucleus.ResolveSingle<IExpressionScriptService>();
				column.HasExpression = true;
				column.Expression = expressionService.Parse(context, new LiteralResource(expressionString));
			}

			// get the default value
			string defaultValue;
			if (properties.TryGet(context, "defaultValue", out defaultValue))
			{
				var expressionService = context.Nucleus.ResolveSingle<IExpressionScriptService>();
				var defaultValueExpression = expressionService.Parse(context, new LiteralResource(defaultValue));
				column.DefaultValue = defaultValueExpression.Execute<object>(context);
				column.HasDefaultValue = true;
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:39,代码来源:PropertyColumn.cs

示例7: Write

		/// <summary>
		/// Writes <paramref name="values"/> to the output.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="values">The <see cref="IPropertyBag"/> containing the values which to write.</param>
		public void Write(IMansionContext context, IPropertyBag values)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (values == null)
				throw new ArgumentNullException("values");
			CheckDisposed();

			// write out the values
			for (var index = 0; index < format.ColumnProperties.Length; index++)
			{
				// write out the current value when there is one
				string value;
				if (values.TryGet(context, format.ColumnProperties[index], out value))
				{
					outputPipe.Writer.Write(format.TextQualifier);
					outputPipe.Writer.Write(value);
					outputPipe.Writer.Write(format.TextQualifier);
				}

				// write out the column or row delimitor
				outputPipe.Writer.Write(index == (format.ColumnProperties.Length - 1) ? format.RowDelimitor : format.ColumnDelimitor);
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:30,代码来源:CsvOutputPipe.cs

示例8: Populate

		/// <summary>
		/// Populates the fullText property.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="modifiedProperties">The modified <see cref="IPropertyBag"/>.</param>
		/// <param name="originalProperties">The original <see cref="IPropertyBag"/>.</param>
		/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
		public void Populate(IMansionContext context, IPropertyBag modifiedProperties, IPropertyBag originalProperties)
		{
			//validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (modifiedProperties == null)
				throw new ArgumentNullException("modifiedProperties");
			if (originalProperties == null)
				throw new ArgumentNullException("originalProperties");

			// get all the properties over which to loop
			var properties = Properties.Get<string>(context, "properties").Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(property => property.Trim());

			// assemble the content
			var buffer = new StringBuilder();
			foreach (var property in properties)
			{
				//  get the content for the given property
				String content;
				if (!modifiedProperties.TryGet(context, property, out content))
				{
					if (!originalProperties.TryGet(context, property, out content))
						continue;
				}

				// strip the HTML
				content = content.StripHtml();

				// add it to the buffer
				buffer.AppendLine(content);
			}

			// if there is full-text content, add it to the full-text property, otherwise set it to null
			modifiedProperties.Set("fullText", buffer.Length > 0 ? buffer.ToString() : null);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:42,代码来源:FullTextDescriptor.cs

示例9: Section

		/// <summary>
		/// Constructs an section.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="properties">The descriptor of this section.</param>
		/// <param name="expression">The expressio of this section.</param>
		public Section(IMansionContext context, IPropertyBag properties, IExpressionScript expression)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (properties == null)
				throw new ArgumentNullException("properties");
			if (expression == null)
				throw new ArgumentNullException("expression");

			// set values
			Properties = properties;
			Expression = expression;
			Id = Guid.NewGuid().ToString();
			Name = Properties.Get<string>(context, "name");
			ShouldBeRenderedOnce = !Properties.Get(context, "repeatable", true);
			TargetField = Properties.Get(context, "field", Name);

			// check if there is a requires property
			string requiresExpressionString;
			if (Properties.TryGet(context, "requires", out requiresExpressionString))
			{
				// assemble the expression
				var expressionService = context.Nucleus.ResolveSingle<IExpressionScriptService>();
				var requiresExpression = expressionService.Parse(context, new LiteralResource(requiresExpressionString));

				// execute the expression
				areRequirementsSatisfied = requiresExpression.Execute<bool>;
			}
			else
				areRequirementsSatisfied = mansionContext => true;
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:38,代码来源:Section.cs

示例10: Run

        public object Run(object obj, string[] parameters, IPropertyBag bag, IMarkupBase markup)
        {
            if (parameters != null && parameters.Length > 1)
                throw new ImpressionInterpretException("Filter " + Keyword + " does not accept parameters.");

            if (obj == null)
            {
                obj = 0.0;
            }

            double val = 0;
            string valString = obj.ToString();
            if (Double.TryParse(valString, out val))
            {
                int pointIndex = valString.IndexOf('.');
                if (pointIndex >= 0)
                {
                    string subs = valString.Substring(pointIndex + 1, valString.Length - (pointIndex + 1));
                    if (subs.Length > 2)
                    {
                        obj = subs.Substring(0, 2);
                    } else
                    {
                        obj = subs.PadRight(2, '0');
                    }
                } else
                {
                    obj = "00";
                }
            }

            return obj;
        }
开发者ID:codesoda,项目名称:Impression,代码行数:33,代码来源:MoneyFilter.cs

示例11: ReviveUser

        /// <summary>
        /// Tries to revive the user based on the revival properties.
        /// </summary>
        /// <param name="context">The security context.</param>
        /// <param name="revivalProperties">The revival properties.</param>
        /// <returns>Returns the revived <see cref="UserState"/> or null.</returns>
        public override UserState ReviveUser(IMansionContext context, IPropertyBag revivalProperties)
        {
            // validate arguments
            if (context == null)
                throw new ArgumentNullException("context");
            if (revivalProperties == null)
                throw new ArgumentNullException("revivalProperties");

            // get the id of the from the revival properties
            Guid id;
            if (!revivalProperties.TryGet(context, "id", out id))
                return null;

            // retrieve the user by guid
            var userNode = context.Repository.RetrieveSingleNode(context, new PropertyBag {
                {"baseType", "User"},
                {"guid", id},
                {"status", "any"},
                {"bypassAuthorization", true},
                {"cache", false},
                {StorageOnlyQueryComponent.PropertyKey, true}
            });
            if (userNode == null)
                return null;

            // create and return the user state
            return CreateUserState(context, userNode);
        }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:34,代码来源:RepositoryAuthenticationProvider.cs

示例12: DoProcess

		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// check for search
			string where;
			if (parameters.TryGetAndRemove(context, "sqlWhere", out where) && !string.IsNullOrEmpty(where))
				query.Add(new SqlWhereSpecification(where));
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:13,代码来源:SqlWhereQueryArgumentProcessor.cs

示例13: DoProcess

		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// check for the cache flag
			object tmp;
			if (parameters.TryGetAndRemove(context, StorageOnlyQueryComponent.PropertyKey, out tmp))
				query.Add(new StorageOnlyQueryComponent());
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:13,代码来源:StorageOnlyArgumentProcessor.cs

示例14: RecordSet

		/// <summary>
		/// Creates a filled nodeset.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="properties"></param>
		/// <param name="records"></param>
		public RecordSet(IMansionContext context, IPropertyBag properties, IEnumerable<Record> records) : base(properties)
		{
			// validate arguments
			if (records == null)
				throw new ArgumentNullException("records");
			if (properties == null)
				throw new ArgumentNullException("properties");

			// set values
			foreach (var node in records)
				RowCollection.Add(node);
			Set("count", RowCollection.Count);

			// check for paging
			var totalRowCount = properties.Get(context, "totalCount", -1);
			var pageNumber = properties.Get(context, "pageNumber", -1);
			var rowsPerPage = properties.Get(context, "pageSize", -1);
			if (totalRowCount != -1 && pageNumber != -1 && rowsPerPage != -1)
				SetPaging(totalRowCount, pageNumber, rowsPerPage);

			// check for sort
			string sortString;
			if (properties.TryGet(context, "sort", out sortString))
			{
				foreach (var sort in Collections.Sort.Parse(sortString))
					AddSort(sort);
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:34,代码来源:RecordSet.cs

示例15: DoAfterUpdate

        /// <summary>
        /// This method is called just after a node is updated by the repository.
        /// </summary>
        /// <param name="context">The <see cref="IMansionContext"/>.</param>
        /// <param name="record"> </param>
        /// <param name="properties">The properties which were set to the updated <paramref name="record"/>.</param>
        protected override void DoAfterUpdate(IMansionContext context, Record record, IPropertyBag properties)
        {
            // get the propagate property names
            var propagatePropertyNames = properties.Names.Where(x => x.StartsWith(PropagatePrefix, StringComparison.OrdinalIgnoreCase));

            // get the property names who's value is true
            var propagatedNowProperties = propagatePropertyNames.Where(x => properties.Get(context, x, false));

            // loop over all the updated properties and propagated properties
            foreach (var propagatePropertyName in propagatedNowProperties)
            {
                // get the name of the property being propagated
                var propagatedPropertyName = propagatePropertyName.Substring(PropagatePrefix.Length);

                // get the propagated property value
                var propagatedPropertyValue = properties.Get<object>(context, propagatedPropertyName);

                // retrieve all the children nodes and update them all
                foreach (var childNode in context.Repository.RetrieveNodeset(context, new PropertyBag
                                                                                      {
                                                                                      	{"parentSource", record},
                                                                                      	{"depth", "any"}
                                                                                      }).Nodes)
                {
                    context.Repository.UpdateNode(context, childNode, new PropertyBag
                                                                      {
                                                                      	{propagatedPropertyName, propagatedPropertyValue}
                                                                      });
                }
            }
        }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:37,代码来源:PropagateListener.cs


注:本文中的IPropertyBag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。