/// <summary>
        /// Expands the template tree into the templating context current output.
        /// </summary>
        /// <param name="templatingContext"> The templating context. </param>
        public void ExpandTemplate(ITemplatingContext templatingContext)
        {
            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            templatingContext.LaunchDebugger();
        }
        /// <summary>
        /// Gets the value of the current associative object instance.
        /// </summary>
        /// <param name="templatingContext"> The templating context. </param>
        /// <returns> A value or null. </returns>
        public object GetAssociativeObjectValue(ITemplatingContext templatingContext)
        {
            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            templatingContext.LaunchDebugger();

            return(this);
        }
        /// <summary>
        /// Gets the enumerator (tick one) for the current associative object instance.
        /// </summary>
        /// <param name="templatingContext"> The templating context. </param>
        /// <returns> An instance of IEnumerator`1 or null. </returns>
        public IEnumerator <KeyValuePair <string, object> > GetAssociativeObjectEnumeratorTickOne(ITemplatingContext templatingContext)
        {
            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            templatingContext.LaunchDebugger();

            return(null);
        }
        /// <summary>
        /// Gets the dictionary enumerator for the current associative object instance.
        /// </summary>
        /// <param name="templatingContext"> The templating context. </param>
        /// <returns> An instance of IDictionaryEnumerator or null. </returns>
        public IDictionaryEnumerator GetAssociativeObjectEnumeratorDict(ITemplatingContext templatingContext)
        {
            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            templatingContext.LaunchDebugger();

            return(null);
        }
        /// <summary>
        /// Re-orders an enumerable of values, yielding a re-ordered enumerable.
        /// </summary>
        /// <param name="templatingContext"> The templating context. </param>
        /// <param name="values"> </param>
        /// <returns> </returns>
        public IEnumerable EvaluateSort(ITemplatingContext templatingContext, IEnumerable values)
        {
            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            templatingContext.LaunchDebugger();

            return(values);
        }
        /// <summary>
        /// Evaluates at run-time, an expression tree yielding an object value result.
        /// </summary>
        /// <param name="templatingContext"> The templating context. </param>
        /// <returns> An expression return value or null. </returns>
        public object EvaluateExpression(ITemplatingContext templatingContext)
        {
            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            templatingContext.LaunchDebugger();

            return(null);
        }
Example #7
0
		protected override void CoreExpandTemplate(ITemplatingContext templatingContext)
		{
			DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy;

			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			if (this.Debug)
				templatingContext.LaunchDebugger();

			dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy();

			if ((object)this.Items != null)
			{
				foreach (ITemplateMechanism templateMechanism in this.Items)
					templateMechanism.ExpandTemplate(templatingContext);
			}
		}
Example #8
0
        protected override void CoreExpandTemplate(ITemplatingContext templatingContext)
        {
            DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy;

            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            if (this.Debug)
            {
                templatingContext.LaunchDebugger();
            }

            dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy();

            if ((object)this.Items != null)
            {
                foreach (ITemplateMechanism templateMechanism in this.Items)
                {
                    templateMechanism.ExpandTemplate(templatingContext);
                }
            }
        }
        protected override object CoreEvaluateExpression(ITemplatingContext templatingContext)
        {
            JavaScriptHost javaScriptHost;
            DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy;
            string scriptContent;
            IDictionary <string, object> scriptVariables;

            object result;
            Func <string, object> func;
            Action action;
            IDictionary <string, object> textMetal;

            if ((object)templatingContext == null)
            {
                throw new ArgumentNullException(nameof(templatingContext));
            }

            dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy();

            switch (this.Src)
            {
            case JavaScriptSource.Script:
                scriptContent = this.Script;
                break;

            case JavaScriptSource.Expr:
                scriptContent = this.Expr;
                break;

            case JavaScriptSource.File:
                string file;
                file          = templatingContext.Tokenizer.ExpandTokens(this.File, dynamicWildcardTokenReplacementStrategy);
                scriptContent = templatingContext.Input.LoadContent(file);
                break;

            default:
                scriptContent = "";
                break;
            }

            javaScriptHost = JavaScriptHost.Instance;

            if (!javaScriptHost.Compile(scriptContent.GetHashCode(), scriptContent))
            {
                new object();                 // in cache already
            }
            textMetal = new Dictionary <string, object>();

            func = (token) =>
            {
                object value;
                value = dynamicWildcardTokenReplacementStrategy.Evaluate(token, null);
                templatingContext.Output.LogTextWriter.WriteLine("[{0}]={1}", token, value);
                return(value);
            };

            action = () => templatingContext.LaunchDebugger();

            textMetal.Add("EvaluateToken", func);
            textMetal.Add("DebuggerBreakpoint", action);

            scriptVariables = new Dictionary <string, object>();
            scriptVariables.Add("textMetal", textMetal);

            // natives
            scriptVariables.Add("print", new Action <object>(Console.WriteLine));
            scriptVariables.Add("prompt", new Func <object>(Console.ReadLine));

            foreach (KeyValuePair <string, object> variableEntry in templatingContext.CurrentVariableTable)
            {
                if (scriptVariables.ContainsKey(variableEntry.Key))
                {
                    throw new InvalidOperationException(string.Format("Cannot set variable '{0}' in JavaScript script scope; the specified variable name already exists.", variableEntry.Key));
                }

                scriptVariables.Add(variableEntry.Key, variableEntry.Value);
            }

            result = javaScriptHost.Execute(scriptContent.GetHashCode(), scriptVariables);
            return(result);
        }
		/// <summary>
		/// Gets the value of the current associative object instance.
		/// </summary>
		/// <param name="templatingContext"> The templating context. </param>
		/// <returns> A value or null. </returns>
		public object GetAssociativeObjectValue(ITemplatingContext templatingContext)
		{
			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			templatingContext.LaunchDebugger();

			return this;
		}
		/// <summary>
		/// Gets the enumerator (tick one) for the current associative object instance.
		/// </summary>
		/// <param name="templatingContext"> The templating context. </param>
		/// <returns> An instance of IEnumerator`1 or null. </returns>
		public IEnumerator<KeyValuePair<string, object>> GetAssociativeObjectEnumeratorTickOne(ITemplatingContext templatingContext)
		{
			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			templatingContext.LaunchDebugger();

			return null;
		}
		/// <summary>
		/// Gets the dictionary enumerator for the current associative object instance.
		/// </summary>
		/// <param name="templatingContext"> The templating context. </param>
		/// <returns> An instance of IDictionaryEnumerator or null. </returns>
		public IDictionaryEnumerator GetAssociativeObjectEnumeratorDict(ITemplatingContext templatingContext)
		{
			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			templatingContext.LaunchDebugger();

			return null;
		}
		/// <summary>
		/// Expands the template tree into the templating context current output.
		/// </summary>
		/// <param name="templatingContext"> The templating context. </param>
		public void ExpandTemplate(ITemplatingContext templatingContext)
		{
			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			templatingContext.LaunchDebugger();
		}
		/// <summary>
		/// Re-orders an enumerable of values, yielding a re-ordered enumerable.
		/// </summary>
		/// <param name="templatingContext"> The templating context. </param>
		/// <param name="values"> </param>
		/// <returns> </returns>
		public IEnumerable EvaluateSort(ITemplatingContext templatingContext, IEnumerable values)
		{
			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			templatingContext.LaunchDebugger();

			return values;
		}
		/// <summary>
		/// Evaluates at run-time, an expression tree yielding an object value result.
		/// </summary>
		/// <param name="templatingContext"> The templating context. </param>
		/// <returns> An expression return value or null. </returns>
		public object EvaluateExpression(ITemplatingContext templatingContext)
		{
			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			templatingContext.LaunchDebugger();

			return null;
		}
Example #16
0
		protected override object CoreEvaluateExpression(ITemplatingContext templatingContext)
		{
			JavaScriptHost javaScriptHost;
			DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy;
			string scriptContent;
			IDictionary<string, object> scriptVariables;

			object result;
			Func<string, object> func;
			Action action;
			IDictionary<string, object> textMetal;

			if ((object)templatingContext == null)
				throw new ArgumentNullException(nameof(templatingContext));

			dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy();

			switch (this.Src)
			{
				case JavaScriptSource.Script:
					scriptContent = this.Script;
					break;
				case JavaScriptSource.Expr:
					scriptContent = this.Expr;
					break;
				case JavaScriptSource.File:
					string file;
					file = templatingContext.Tokenizer.ExpandTokens(this.File, dynamicWildcardTokenReplacementStrategy);
					scriptContent = templatingContext.Input.LoadContent(file);
					break;
				default:
					scriptContent = "";
					break;
			}

			javaScriptHost = JavaScriptHost.Instance;

			if (!javaScriptHost.Compile(scriptContent.GetHashCode(), scriptContent))
				new object(); // in cache already

			textMetal = new Dictionary<string, object>();

			func = (token) =>
					{
						object value;
						value = dynamicWildcardTokenReplacementStrategy.Evaluate(token, null);
						templatingContext.Output.LogTextWriter.WriteLine("[{0}]={1}", token, value);
						return value;
					};

			action = () => templatingContext.LaunchDebugger();

			textMetal.Add("EvaluateToken", func);
			textMetal.Add("DebuggerBreakpoint", action);

			scriptVariables = new Dictionary<string, object>();
			scriptVariables.Add("textMetal", textMetal);

			// natives
			scriptVariables.Add("print", new Action<object>(Console.WriteLine));
			scriptVariables.Add("prompt", new Func<object>(Console.ReadLine));

			foreach (KeyValuePair<string, object> variableEntry in templatingContext.CurrentVariableTable)
			{
				if (scriptVariables.ContainsKey(variableEntry.Key))
					throw new InvalidOperationException(string.Format("Cannot set variable '{0}' in JavaScript script scope; the specified variable name already exists.", variableEntry.Key));

				scriptVariables.Add(variableEntry.Key, variableEntry.Value);
			}

			result = javaScriptHost.Execute(scriptContent.GetHashCode(), scriptVariables);
			return result;
		}