Pendent
Inheritance: AbstractBindingScope
コード例 #1
0
		private object PerformDataBinding(string expression, BindingContext context, bool ignoreErrors)
		{
			object value;
			int index = expression.IndexOf('.');

			if (index > 0)
			{
				string symbolName = expression.Substring(0, index).Trim();

				value = context.ResolveSymbol(symbolName, !ignoreErrors);

				if (value != null)
				{
					expression = expression.Substring(index + 1).Trim();

					try
					{
						value = PerformDataBinding(value, expression, context);
					}
					catch
					{
						if (!ignoreErrors) throw;
						value = null;
					}
				}
			}
			else
			{
				value = context.ResolveSymbol(expression, !ignoreErrors);
			}

			return value;
		}
コード例 #2
0
		/// <summary>
		/// Evaluates the specified expression.
		/// </summary>
		/// <param name="expression">The expression.</param>
		/// <param name="context">The context.</param>
		/// <returns></returns>
		public object Evaluate(string expression, BindingContext context)
		{
			bool ignoreErrors;

			if (IsDataBindingExpression(ref expression, out ignoreErrors))
			{
				return PerformDataBinding(expression, context, ignoreErrors);
			}

			return expression;
		}
コード例 #3
0
		public Delegate CreateActionDelegate(Type genericEventHandlerType, EventDescriptor eventDescriptor,
		                                     BindingContext context)
		{
			Type eventArgsType = EventUtil.GetEventArgsType(eventDescriptor);
			EventHandlerInfo eventHandlerInfo =
				GetEventHandlerInfo(genericEventHandlerType, eventArgsType);

			if (eventHandlerInfo != null)
			{
				object eventHandler = Activator.CreateInstance(
					eventHandlerInfo.EventHandlerType, new object[] {context});

				return Delegate.CreateDelegate(eventDescriptor.EventType, eventHandler,
				                               eventHandlerInfo.EventMethod);
			}

			return null;
		}
コード例 #4
0
		private object PerformIndexDataBinding(object target, string expression,
		                                       BindingContext context, int start)
		{
			int end;

			string indexProperty = expression.Substring(0, start).Trim();

			if (!string.IsNullOrEmpty(indexProperty))
			{
				target = DataBinder.Eval(target, indexProperty);
			}

			string indexExpression = ExtractIndexerExpression(expression, start, out end);

			object indexer = Evaluate(indexExpression, context);

			indexExpression = string.Format("{0}{1}{2}", indexExprStartChars[0],
			                                indexer, indexExprEndChars[0]);

			target = DataBinder.Eval(target, indexExpression);

			expression = expression.Substring(end + 1).TrimStart('.');

			return PerformDataBinding(target, expression, context);
		}
コード例 #5
0
		private object PerformDataBinding(object target, string expression, BindingContext context)
		{
			if (string.IsNullOrEmpty(expression)) return target;

			int indexStart = expression.IndexOfAny(indexExprStartChars);

			if (indexStart < 0)
			{
				int formatIndex = expression.LastIndexOf(':');

				if (formatIndex < 0)
				{
					return DataBinder.Eval(target, expression);
				}
				else
				{
					string format = expression.Substring(formatIndex + 1);
					expression = expression.Substring(0, formatIndex);
					return DataBinder.Eval(target, expression, format);
				}
			}
			else
			{
				return PerformIndexDataBinding(target, expression, context, indexStart);
			}
		}
コード例 #6
0
		/// <summary>
		/// Initializes a new instance of the <see cref="AbstractEventScope"/> class.
		/// </summary>
		/// <param name="context">The context.</param>
		protected AbstractEventScope(BindingContext context)
		{
			this.context = context;
		}
コード例 #7
0
		/// <summary>
		/// Adds the action arguments.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="resolvedActionArgs">The resolved action args.</param>
		protected virtual void AddActionArguments(BindingContext context,
		                                          IDictionary resolvedActionArgs)
		{
		}
コード例 #8
0
		/// <summary>
		/// Adds the action arguments.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="resolvedActionArgs">The resolved action args.</param>
		void IBindingScope.AddActionArguments(BindingContext context,
		                                      IDictionary resolvedActionArgs)
		{
			AddActionArguments(context, resolvedActionArgs);
		}
コード例 #9
0
		/// <summary>
		/// Adds the action arguments.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="resolvedActionArgs">The resolved action args.</param>
		protected override void AddActionArguments(BindingContext context,
		                                           IDictionary resolvedActionArgs)
		{
			context.ResolveActionArguments(action.ActionArguments, resolvedActionArgs);
		}