Ejemplo n.º 1
0
        /// <summary>
        /// Returns true if the IPropertyBag contains the key
        /// </summary>
        /// <param name="key">The key to check</param>
        /// <param name="propertyBag">The property bag to check</param>
        /// <returns>true if the key is in the property bag</returns>
        public bool ContainsKeyInPropertyBag(string key, IPropertyBag propertyBag)
        {
            Validation.ArgumentNotNullOrEmpty(key, "key");
            Validation.ArgumentNotNull(propertyBag, "propertyBag");
            string fullKey = GetNamespacedKey(key);

            return(propertyBag.Contains(fullKey));
        }
		/// <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.");
		}
Ejemplo n.º 3
0
		/// <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>
		public Node CreateNode(IMansionContext context, Node parent, IPropertyBag newProperties)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (parent == null)
				throw new ArgumentNullException("parent");
			if (newProperties == null)
				throw new ArgumentNullException("newProperties");
			CheckDisposed();

			// if no allowedRoleGuids are specified, copy the parens
			if (!newProperties.Contains("allowedRoleGuids"))
				newProperties.Set("allowedRoleGuids", parent.Get(context, "allowedRoleGuids", string.Empty));

			// invoke template method
			return DoCreateNode(context, parent, newProperties);
		}
        private TValue GetValueFromPropertyBagOrParents <TValue>(string key, IPropertyBag propertyBag)
        {
            if (propertyBag.Contains(key))
            {
                return(GetFromPropertyBag <TValue>(key, propertyBag));
            }

            IPropertyBag parent = propertyBag.GetParent();

            if (parent == null)
            {
                string exceptionMessage = string.Format(CultureInfo.CurrentCulture,
                                                        "There was no value configured for key '{0}' in a propertyBag with level '{1}' or above.",
                                                        key, propertyBag.Level);
                throw new ConfigurationException(exceptionMessage);
            }

            return(GetValueFromPropertyBagOrParents <TValue>(key, parent));
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Check whether a <paramref name="bag"/> contains <paramref name="propertyName"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="bag">The haystack in which to look.</param>
		/// <param name="propertyName">The name of the property which to check.</param>
		/// <returns>Returns true when <paramref name="bag"/> contains <paramref name="propertyName"/>, otherwise false.</returns>
		public bool Evaluate(IMansionContext context, IPropertyBag bag, string propertyName)
		{
			return bag.Contains(propertyName);
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Add the job to the scheduler
		/// </summary>
		/// <param name="context"></param>
		/// <param name="record"></param>
		/// <param name="properties"></param>
		protected override void DoAfterUpdate(IMansionContext context, Record record, IPropertyBag properties)
		{
			if (!properties.Contains("_scheduleStatusUpdate"))
				ScheduleJob(context, record as Node);
			base.DoAfterUpdate(context, record, properties);
		}
 /// <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)
 {
     return parameters.Contains("userId") ? AuthenticateWithId(context, parameters) : AuthenticateWithUsernamePassword(context, parameters);
 }
 private bool ContainsKeyInPropertyBag(string key, IPropertyBag propertyBag)
 {
     return(propertyBag.Contains(key));
 }
Ejemplo n.º 9
0
 bool ContainsKeyInPropertyBagImpl(string key, IPropertyBag propertyBag)
 {
     return propertyBag.Contains(key);
 }
Ejemplo n.º 10
0
 public static void AddContains(IPropertyBag target, string key, string value)
 {
     target[key] = value;
     Assert.IsTrue(target.Contains(key));
     Assert.IsTrue(value == target[key]);
 }