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


C# IPropertyBag.Get方法代码示例

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


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

示例1: DoAuthenticate

		/// <summary>
		/// Authenticates the user.
		/// </summary>
		/// <param name="context">The security context.</param>
		/// <param name="parameters">The parameters used for authentication.</param>
		/// <returns>Returns the <see cref="AuthenticationResult"/>.</returns>
		protected override AuthenticationResult DoAuthenticate(IMansionContext context, IPropertyBag parameters)
		{
			// get the credentials
			var username = parameters.Get<string>(context, "username");
			if (string.IsNullOrEmpty(username))
			{
				return AuthenticationResult.Failed(new PropertyBag
				                                   {
				                                   	{AuthenticationResult.ReasonPropertyName, AuthenticationResult.NoUsernameSpecifiedReason}
				                                   });
			}
			var password = parameters.Get<string>(context, "password");
			if (string.IsNullOrEmpty(password))
			{
				return AuthenticationResult.Failed(new PropertyBag
				                                   {
				                                   	{AuthenticationResult.ReasonPropertyName, AuthenticationResult.NoPasswordSpecifiedReason}
				                                   });
			}

			// check for incorrect credentials
			if (!username.Equals("System") || !password.Equals("Premotion"))
			{
				return AuthenticationResult.Failed(new PropertyBag
				                                   {
				                                   	{AuthenticationResult.ReasonPropertyName, AuthenticationResult.InvalidCredentialsReason}
				                                   });
			}

			// return the user
			return AuthenticationResult.Success(new UserState(Guid.NewGuid(), this), new PropertyBag());
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:38,代码来源:ConfigurationFileAuthenticationProvider.cs

示例2: 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

示例3: 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

示例4: 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

示例5: DoMapRowProperties

		/// <summary>
		/// Maps the properties of the row.
		/// </summary>
		/// <param name="context">The <see cref="IMansionWebContext"/>.</param>
		/// <param name="row">The row which to map.</param>
		/// <returns>Returns the mapped result.</returns>
		protected override IPropertyBag DoMapRowProperties(IMansionWebContext context, IPropertyBag row)
		{
			return new PropertyBag
			       {
			       	{"value", row.Get(context, valueProperty, string.Empty)},
			       	{"label", row.Get(context, labelProperty, string.Empty)}
			       };
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:14,代码来源:PropertyRowMappingStrategy.cs

示例6: DoInterpret

		/// <summary>
		/// Interprets the input..
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="input">The input which to interpret.</param>
		/// <returns>Returns the interpreted result.</returns>
		protected override IResourcePath DoInterpret(IMansionContext context, IPropertyBag input)
		{
			// get the path
			var path = input.Get<string>(context, "path");
			if (string.IsNullOrEmpty(path))
				throw new InvalidOperationException("The path should not be empty");
			var overridable = input.Get(context, "overridable", true);

			// return the resource path
			return new RelativeResourcePath(path, overridable);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:17,代码来源:RelativeResourcePathInterpreter.cs

示例7: DoBeforeCreate

		/// <summary>
		/// This method is called just before a node is created by the repository.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="properties">The new properties of the node.</param>
		protected override void DoBeforeCreate(IMansionContext context, IPropertyBag properties)
		{
			base.DoBeforeCreate(context, properties);

			// make sure the idenitifier is lowwercase
			var identifier = properties.Get<string>(context, "identifier").Trim().ToLower();
			properties.Set("identifier", identifier);

			// make sure there is a name
			var name = properties.Get(context, "name", identifier).Trim().ToLower();
			properties.Set("name", name);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:17,代码来源:ThesaurusTermIdentifierChangeListener.cs

示例8: Prepare

		/// <summary>
		/// Prepares an insert query.
		/// </summary>
		/// <param name="context"></param>
		/// <param name="connection">The connection.</param>
		/// <param name="transaction">The transaction.</param>
		/// <param name="parent"></param>
		/// <param name="properties"></param>
		/// <returns></returns>
		public void Prepare(IMansionContext context, SqlConnection connection, SqlTransaction transaction, NodePointer parent, IPropertyBag properties)
		{
			// validate arguments
			if (connection == null)
				throw new ArgumentNullException("connection");
			if (transaction == null)
				throw new ArgumentNullException("transaction");
			if (parent == null)
				throw new ArgumentNullException("parent");
			if (properties == null)
				throw new ArgumentNullException("properties");

			// get the values
			var name = properties.Get<string>(context, "name", null);
			if (string.IsNullOrWhiteSpace(name))
				throw new InvalidOperationException("The node must have a name");
			var typeName = properties.Get<string>(context, "type", null);
			if (string.IsNullOrWhiteSpace(typeName))
				throw new InvalidOperationException("The node must have a type");

			// retrieve the type
			var type = typeService.Load(context, typeName);

			// get the schema of the root type
			var schema = Resolver.Resolve(context, type);

			// set the full text property
			SqlServerUtilities.PopulateFullTextColumn(context, type, properties, properties);

			// create the new pointer
			name = NodePointer.MakeSafeName(name);
			var newPointer = NodePointer.Parse(string.Join(NodePointer.PointerSeparator, new[] {parent.PointerString, 0.ToString(CultureInfo.InvariantCulture)}), string.Join(NodePointer.StructureSeparator, new[] {parent.StructureString, type.Name}), string.Join(NodePointer.PathSeparator, new[] {parent.PathString, name}));
			properties.Set("_newPointer", newPointer);

			// create the commands
			command = connection.CreateCommand();
			command.CommandType = CommandType.Text;
			command.Transaction = transaction;

			// prepare the query
			var queryBuilder = new ModificationQueryBuilder(command);

			// loop through all the tables in the schema and let them prepare for insert
			foreach (var table in schema.Tables)
				table.ToInsertStatement(context, queryBuilder, properties);

			// finish the complete insert statement
			queryBuilder.AppendQuery("SELECT @ScopeIdentity");

			// set the command text
			command.CommandText = queryBuilder.ToStatement();
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:61,代码来源:InsertNodeCommand.cs

示例9: 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

示例10: DoToInsertStatement

		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="queryBuilder"></param>
		/// <param name="properties"></param>
		protected override void DoToInsertStatement(IMansionContext context, ModificationQueryBuilder queryBuilder, IPropertyBag properties)
		{
			// allow identity insert on special cases, most likely used when fixing the repository integrity
			if (!properties.Get(context, "_allowIdenityInsert", false))
				return;

			queryBuilder.PrependQuery("SET IDENTITY_INSERT [dbo].[Nodes] ON;");
			// get the value of the column
			var value = properties.Get<object>(context, PropertyName);

			// add the parameter
			var parameterName = queryBuilder.AddParameter(ColumnName, value);

			// set the column value
			queryBuilder.AddColumnValue(ColumnName, parameterName);
			queryBuilder.AppendQuery("SET IDENTITY_INSERT [dbo].[Nodes] OFF;");
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:23,代码来源:IdentityColumn.cs

示例11: DoToInsertStatement

		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="queryBuilder"></param>
		/// <param name="properties"></param>
		protected override void DoToInsertStatement(IMansionContext context, ModificationQueryBuilder queryBuilder, IPropertyBag properties)
		{
			// build the select max order + 1 query only for none root nodes
			var newPointer = properties.Get<NodePointer>(context, "_newPointer");
			queryBuilder.PrependQuery("DECLARE @order int = 1");
			if (newPointer.Depth > 1)
				queryBuilder.PrependQuery(string.Format("SET @order = (SELECT ISNULL(MAX([order]) + 1, 1) FROM [Nodes] WHERE [parentId] = {0})", queryBuilder.AddParameter("parentId", newPointer.Parent.Id, DbType.Int32)));

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

示例12: DoTransform

		/// <summary>
		/// Transforms the given <paramref name="source"/> into an ElasticSearch document.
		/// </summary>
		/// <param name="context">the <see cref="IMansionContext"/>.</param>
		/// <param name="source">The <see cref="IPropertyBag"/> which to transform.</param>
		/// <param name="document">The document to which to write the mapped value.</param>
		/// <returns>Returns the resulting document.</returns>
		/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
		protected override void DoTransform(IMansionContext context, IPropertyBag source, Dictionary<string, object> document)
		{
			// get the property value
			var raw = source.Get(context, Field, string.Empty) ?? string.Empty;

			// split on comma, trim all values, remove empty entries
			var values = raw.Split(new[] {','}).Select(x => Normalize(context, x.Trim()).ToString()).Where(x => !string.IsNullOrEmpty(x)).ToArray();

			// write the values to the document
			document.Add(Field, values);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:19,代码来源:MultiValuedPropertyMapping.cs

示例13: DoRenderCell

		/// <summary>
		/// Renders a cell of this column.
		/// </summary>
		/// <param name="context">The <see cref="IMansionWebContext"/>.</param>
		/// <param name="templateService">The <see cref="ITemplateService"/>.</param>
		/// <param name="dataset">The <see cref="Dataset"/> rendered in this column.</param>
		/// <param name="row">The being rendered.</param>
		protected override void DoRenderCell(IMansionWebContext context, ITemplateService templateService, Dataset dataset, IPropertyBag row)
		{
			// create the cell properties
			var cellProperties = new PropertyBag
			                     {
			                     	{"value", row.Get<object>(context, propertyName, null)}
			                     };

			// render the cell
			using (context.Stack.Push("CellProperties", cellProperties))
				templateService.Render(context, "GridControlPropertyColumnContent").Dispose();
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:19,代码来源:PropertyColumn.cs

示例14: DoToInsertStatement

		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="queryBuilder"></param>
		/// <param name="properties"></param>
		protected override void DoToInsertStatement(IMansionContext context, ModificationQueryBuilder queryBuilder, IPropertyBag properties)
		{
			var newPointer = properties.Get<NodePointer>(context, "_newPointer");
			queryBuilder.AddColumnValue("name", newPointer.Name.Trim(), DbType.String);
			queryBuilder.AddColumnValue("type", newPointer.Type.Trim(), DbType.String);
			queryBuilder.AddColumnValue("depth", newPointer.Depth, DbType.Int32);

			queryBuilder.AddColumnValue("parentId", newPointer.HasParent ? (object) newPointer.Parent.Id : null, DbType.Int32);
			queryBuilder.AddColumnValue("parentPointer", newPointer.HasParent ? newPointer.Parent.PointerString + NodePointer.PointerSeparator : null, DbType.String);
			queryBuilder.AddColumnValue("parentPath", newPointer.HasParent ? newPointer.Parent.PathString + NodePointer.PathSeparator : null, DbType.String);
			queryBuilder.AddColumnValue("parentStructure", newPointer.HasParent ? newPointer.Parent.StructureString + NodePointer.StructureSeparator : null, DbType.String);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:18,代码来源:NodePointerPropertyColumn.cs

示例15: DoBeforeUpdate

		/// <summary>
		/// This method is called just before a node is updated by the repository.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="record"> </param>
		/// <param name="properties">The updated properties of the node.</param>
		protected override void DoBeforeUpdate(IMansionContext context, Record record, IPropertyBag properties)
		{
			base.DoBeforeUpdate(context, record, properties);

			// check if the identifier was updated
			string identifier;
			if (!properties.TryGet(context, "identifier", out identifier))
				return;
			identifier = identifier.Trim().ToLower();
			properties.Set("identifier", identifier);

			// only update the name with the identifier if the previous name was also derived from the identifier
			if (record.Get(context, "name", string.Empty).Equals(record.Get(context, "identifier", string.Empty)))
			{
				var name = properties.Get(context, "name", identifier).Trim().ToLower();
				properties.Set("name", name);
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:24,代码来源:ThesaurusTermIdentifierChangeListener.cs


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