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


C# IPropertyBag.TryGetAndRemove方法代码示例

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


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

示例1: 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)
		{
			var counter = 0;

			// check for id, guid or pointer
			int id;
			if (parameters.TryGetAndRemove(context, "id", out id))
			{
				query.Add(new IsPropertyEqualSpecification("id", id));
				counter++;
			}
			string guids;
			if (parameters.TryGetAndRemove(context, "guid", out guids) && !string.IsNullOrEmpty(guids))
			{
				// split the value
				var values = guids.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();
				query.Add(new IsPropertyInSpecification("guid", values));
				counter++;
			}
			NodePointer pointer;
			if (parameters.TryGetAndRemove(context, "pointer", out pointer))
			{
				query.Add(new IsPropertyEqualSpecification("id", pointer.Id));
				counter++;
			}

			// check for ambigous parameters
			if (counter > 1)
				throw new InvalidOperationException("Detected an ambigious id parmeters. Remove either id, guid or pointer.");
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:36,代码来源:IdArgumentProcessor.cs

示例2: 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 the input
			int pageNumber;
			var hasPageNumber = parameters.TryGetAndRemove(context, "pageNumber", out pageNumber);
			int pageSize;
			var hasPageSize = parameters.TryGetAndRemove(context, "pageSize", out pageSize);

			// add the paging query component
			if ((hasPageNumber && hasPageSize))
				query.Add(new PagingQueryComponent(pageNumber, pageSize));
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:18,代码来源:PagingArgumentProcessor.cs

示例3: 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)
		{
			// get the component and method names
			string componentName;
			if (!attributes.TryGetAndRemove(context, "componentName", out componentName))
				throw new AttributeNullException("componentName", this);
			string methodName;
			if (!attributes.TryGetAndRemove(context, "methodName", out methodName))
				throw new AttributeNullException("methodName", this);

			// invoke the method
			return context.InvokeMethodOnComponent<Dataset>(componentName, methodName, attributes);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:19,代码来源:RetrieveDatasetFromComponentTag.cs

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

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

示例6: 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)
		{
			var clauseCounter = 0;

			// get the depth
			var depthValue = new Lazy<int?>(() =>
			                                {
			                                	int? depth = 1;
			                                	string depthString;
			                                	if (parameters.TryGetAndRemove(context, "depth", out depthString))
			                                	{
			                                		// check for any
			                                		if ("any".Equals(depthString, StringComparison.OrdinalIgnoreCase))
			                                			depth = null;
			                                		else
			                                		{
			                                			// parse the depth
			                                			depth = conversionService.Convert(context, depthString, 1);
			                                		}
			                                	}
			                                	return depth;
			                                });

			// check for parentPointer
			NodePointer parentPointer;
			if (parameters.TryGetAndRemove(context, "childPointer", out parentPointer))
			{
				query.Add(ParentOfSpecification.Child(parentPointer, depthValue.Value));
				clauseCounter++;
			}

			// check for pointer
			Node parentNode;
			if (parameters.TryGetAndRemove(context, "childSource", out parentNode))
			{
				query.Add(ParentOfSpecification.Child(parentNode.Pointer, depthValue.Value));
				clauseCounter++;
			}

			// sort on depth if no explicit sort has been set
			if (clauseCounter > 0 && !parameters.Contains("sort"))
				query.Add(new SortQueryComponent(DefaultSort));

			// check for ambigous parameters
			if (clauseCounter > 1)
				throw new InvalidOperationException("Detected an ambigious parent of clause. Remove either childPointer or childSource.");
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:53,代码来源:ParentOfQueryArgumentProcessor.cs

示例7: 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)
		{
			// parse the sorts and add them to the query
			string sortString;
			if (parameters.TryGetAndRemove(context, "sort", out sortString) && !string.IsNullOrEmpty(sortString))
				query.Add(Sort.Parse(sortString));
			else
				query.Add(Sort.DefaultSort);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:15,代码来源:SortArgumentProcessor.cs

示例8: 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)
		{
			int limit;
			if (!parameters.TryGetAndRemove(context, "limit", out limit))
				return;

			// parse the sorts and add them to the query
			query.Add(new LimitQueryComponent(limit));
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:15,代码来源:LimitArgumentProcessor.cs

示例9: 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)
		{
			Specification where;
			if (!parameters.TryGetAndRemove(context, "where", out where))
				return;

			// parse the sorts and add them to the query
			query.Add(where);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:15,代码来源:WhereArgumentProcessor.cs

示例10: 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
			bool isCachable;
			if (!parameters.TryGetAndRemove(context, "cache", out isCachable))
				isCachable = true;

			// add the query component
			query.Add(new CacheQueryComponent(isCachable));
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:16,代码来源:CacheArgumentProcessor.cs

示例11: 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)
		{
			// if the authorization is bypassed do not add the security check
			// TODO: add validator logic to make sure the type supports authorization
			bool bypassAuthorization;
			if (parameters.TryGetAndRemove(context, "bypassAuthorization", out bypassAuthorization) && bypassAuthorization)
				query.Add(AllowedRolesSpecification.Any());
			else
				query.Add(AllowedRolesSpecification.UserRoles(context));
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:16,代码来源:AllowedRolesQueryArgumentProcessor.cs

示例12: Get

		/// <summary>
		/// Gets the row.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override IPropertyBag Get(IMansionContext context, IPropertyBag attributes)
		{
			// check if query source is specified
			IPropertyBag queryProperties;
			if (attributes.TryGetAndRemove(context, "querySource", out queryProperties))
				attributes = queryProperties.Copy().Merge(attributes);

			// invoke template method
			return Retrieve(context, attributes, context.Repository, parser);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:16,代码来源:RetrieveRecordBaseTag.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)
		{
			// loop over all the facet properties
			var facetPropertyNames = parameters.Names.Where(candidate => candidate.StartsWith("facet")).ToList();
			foreach (var facetPropertyName in facetPropertyNames)
			{
				// retrieve the facet from the property
				FacetDefinition facet;
				if (!parameters.TryGetAndRemove(context, facetPropertyName, out facet))
					throw new InvalidOperationException(string.Format("Property {0} did not contain a valid facet", facetPropertyName));

				// add the query component
				query.Add(new FacetQueryComponent(facet));
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:21,代码来源:FacetArgumentProcessor.cs

示例14: DoMap

		/// <summary>
		/// Maps the given <paramref name="dbRecord"/> to <paramref name="properties"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="dbRecord">The <see cref="DbRecord"/> which to map.</param>
		/// <param name="properties">The <see cref="IPropertyBag"/> in which to store the mapped result.</param>
		protected override void DoMap(IMansionContext context, DbRecord dbRecord, IPropertyBag properties)
		{
			// set all the column values as properties
			foreach (var ordinals in dbRecord.GetUnreadOrdinals())
			{
				// if the column is empty remove the value from the properties, otherwise set the value from the column
				if (dbRecord.IsDBNull(ordinals))
				{
					object obj;
					properties.TryGetAndRemove(context, dbRecord.GetName(ordinals), out obj);
				}
				else
					properties.Set(dbRecord.GetName(ordinals), dbRecord.GetValue(ordinals));
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:21,代码来源:RemainderRecordMapper.cs

示例15: 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)
		{
			// get the type name is any
			string typeNames;
			if (!parameters.TryGetAndRemove(context, "type", out typeNames) && string.IsNullOrEmpty(typeNames))
				return;

			// parse the type names
			var types = typeNames.Split(',').Select(x => typeService.Load(context, x)).ToArray();
			if (types.Length == 0)
				return;

			// add the type hints to the query
			query.Add(types);
			query.Add(new IsPropertyInSpecification("type", types.Select(type => type.Name)));
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:22,代码来源:TypeArgumentProcessor.cs


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