本文整理汇总了C#中Sprocket.Web.CMS.Script.ExecutionState类的典型用法代码示例。如果您正苦于以下问题:C# ExecutionState类的具体用法?C# ExecutionState怎么用?C# ExecutionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionState类属于Sprocket.Web.CMS.Script命名空间,在下文中一共展示了ExecutionState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EvaluateProperty
public object EvaluateProperty(string propertyName, Token token, ExecutionState state)
{
switch (propertyName)
{
case "action":
return PayPal.PayPalPostURL;
case "subscribetest":
PaypalSubscription pps = new PaypalSubscription();
pps.CustomValue = Guid.NewGuid().ToString();
pps.ItemName = "Test Subscription";
pps.ItemNumber = 400;
pps.NotifyURL = "http://snowdevil78.dyndns.org/prospector/public/paypal-ipn-process/";
pps.SubscriptionPeriodSize = 3;
pps.SubscriptionPeriodUnit = PayPalSubscriptionPeriodUnit.Day;
pps.SubscriptionPrice = 10;
pps.TrialPeriodSize = 0;
pps.EditMode = PayPalSubscriptionEditMode.ModifyOnly;
return pps.GetFormFields();
default:
throw new InstructionExecutionException("\"" + propertyName + "\" is not a valid property of this object", token);
}
}
示例2: Evaluate
protected override object Evaluate(IExpression left, IExpression right, ExecutionState state)
{
object b = TokenParser.VerifyUnderlyingType(right.Evaluate(state, token));
object a = TokenParser.VerifyUnderlyingType(left.Evaluate(state, token));
decimal x, y;
//typeof(decimal).IsAssignableFrom(typeof(a))
if (a is decimal)
x = (decimal)a;
else
{
//if(a is int || a is long || a is double || a is float || a is short
TypeConverter tc = TypeDescriptor.GetConverter(a);
if (!tc.CanConvertTo(typeof(decimal)))
return string.Concat(a, b);
x = (decimal)tc.ConvertTo(a, typeof(decimal));
}
if (b is decimal)
y = (decimal)b;
else
{
TypeConverter tc = TypeDescriptor.GetConverter(b);
if (!tc.CanConvertTo(typeof(decimal)))
return string.Concat(a, b);
y = (decimal)tc.ConvertTo(b, typeof(decimal));
}
return x + y;
}
示例3: Evaluate
public object Evaluate(ExecutionState state, Token contextToken)
{
if (expr is IArgumentListEvaluatorExpression)
return ((IArgumentListEvaluatorExpression)expr).Evaluate(token, args, state);
object o = expr.Evaluate(state, token);
return SystemTypeEvaluator.EvaluateArguments(state, o, args, token);
}
示例4: GetList
public IList GetList(ExecutionState state)
{
List<QSComponent> list = new List<QSComponent>();
foreach (string s in HttpContext.Current.Request.QueryString.Keys)
list.Add(new QSComponent(s, HttpContext.Current.Request.QueryString[s]));
return list;
}
示例5: Render
internal override void Render(ExecutionState state, Dictionary<string, SprocketScript> overrides)
{
script.SetOverrides(overrides);
if (!script.Execute(state))
state.Output.Write(state.ErrorHTML);
script.RestoreOverrides();
}
示例6: EvaluateArguments
public static object EvaluateArguments(ExecutionState state, object o, List<ExpressionArgument> args, Token contextToken)
{
if (o == null)
{
if(contextToken.Previous != null)
throw new InstructionExecutionException("\"" + contextToken.Previous.Value + "\" is not a keyword and has not been assigned a value as a variable. As such, it cannot evaluate the specified argument list.", contextToken.Previous);
throw new InstructionExecutionException("The value here is null, which isn't able to process an argument list.", contextToken);
}
if (o is IList)
{
if (args.Count > 1)
throw new InstructionExecutionException("I can't evaluate the arguments for this list because you've specified more than one argument. The only argument you can specify for a list is a numeric expression indicating which list item you're referring to.", contextToken);
object n = TokenParser.VerifyUnderlyingType(args[0].Expression.Evaluate(state, args[0].Token));
if (!(n is decimal))
return ((IList)o).Contains(n);
int index = Convert.ToInt32(n);
if(index >= ((IList)o).Count)
throw new InstructionExecutionException("The index specified here is higher than the highest index in the list. Remember, the lowest index is 0 and the highest is one less than the total number of items in the list.", args[0].Token);
return ((IList)o)[index];
}
if (o is IDictionary)
{
if(args.Count > 1)
throw new InstructionExecutionException("I can't evaluate the arguments for this collection because you've specified more than one argument. The only argument you can specify for a list is an expression indicating the name or key of the item you're referring to.", contextToken);
object n = TokenParser.VerifyUnderlyingType(args[0].Expression.Evaluate(state, args[0].Token));
if (!((IDictionary)o).Contains(n))
return null;
return ((IDictionary)o)[n];
}
throw new InstructionExecutionException("This type of object isn't able to process an argument list. (Underlying type: " + o.GetType().Name, contextToken);
}
示例7: Evaluate
public object Evaluate(Token contextToken, List<ExpressionArgument> args, ExecutionState state)
{
string catset = (args[0].Expression.Evaluate(state, args[0].Token) ?? "").ToString();
string catname = (args[1].Expression.Evaluate(state, args[1].Token) ?? "").ToString();
int pageSize = Convert.ToInt32(TokenParser.VerifyUnderlyingType(args[2].Expression.Evaluate(state, args[2].Token)) ?? 0);
int pageNumber = Convert.ToInt32(TokenParser.VerifyUnderlyingType(args[3].Expression.Evaluate(state, args[3].Token)) ?? 0);
string sort = (args[4].Expression.Evaluate(state, args[4].Token) ?? "").ToString();
PageResultSetOrder pageOrder;
switch (sort)
{
case "random": pageOrder = PageResultSetOrder.Random; break;
case "publishdate ascending": pageOrder = PageResultSetOrder.PublishDateAscending; break;
default: pageOrder = PageResultSetOrder.PublishDateDescending; break;
}
PageSearchOptions options = new PageSearchOptions();
options.Draft = false;
options.Deleted = false;
options.Hidden = false;
options.PageSize = pageSize;
options.PageNumber = pageNumber;
options.PageOrder = pageOrder;
options.SetCategory(catset, catname);
PageResultSet pages = ContentManager.Instance.DataProvider.ListPages(options);
pages.LoadContentForPages();
return pages;
}
示例8: Evaluate
public object Evaluate(ExecutionState state)
{
// attempt to load the specified ForumCategory
object value = TokenParser.VerifyUnderlyingType(args[0].Expression.Evaluate(state));
if (value is decimal)
forumCategory = ForumHandler.DataLayer.SelectForumCategory((long)value);
else if (value is string)
forumCategory = ForumHandler.DataLayer.SelectForumCategoryByCode((string)value);
else
throw new InstructionExecutionException("Could not load an instance of \"forumcategory\" because the argument did not equate to the right kind of value.", args[0].Token);
// return the relevant value
switch (propertyType)
{
case PropertyType.ForumCategoryID: return forumCategory.ForumCategoryID;
case PropertyType.ClientSpaceID: return forumCategory.ClientSpaceID;
case PropertyType.CategoryCode: return forumCategory.CategoryCode;
case PropertyType.Name: return forumCategory.Name;
case PropertyType.URLToken: return forumCategory.URLToken;
case PropertyType.DateCreated: return forumCategory.DateCreated;
case PropertyType.Rank: return forumCategory.Rank;
case PropertyType.InternalUseOnly: return forumCategory.InternalUseOnly;
case PropertyType.ForumList: return GetForums();
case PropertyType.None:
if (forumCategory == null)
return null;
return this;
default: return "[ForumCategory]";
}
}
示例9: Evaluate
public object Evaluate(Token contextToken, List<ExpressionArgument> args, ExecutionState state)
{
string descendentPath;
string[] sections;
GetDescendentPath(out descendentPath, out sections);
switch (args.Count)
{
case 0:
return descendentPath;
case 1:
{
object o = TokenParser.VerifyUnderlyingType(args[0].Expression.Evaluate(state, args[0].Token));
if (o is decimal)
{
int n = Convert.ToInt32(o);
if (n >= sections.Length)
throw new InstructionExecutionException("The argument you specified for the \"descendentpath\" expression equates to the number " + n + ", which is too high. Remember, the first component in the path is index zero (0). The second is one (1), and so forth.", args[0].Token);
return sections[n];
}
throw new InstructionExecutionException("You specified an argument for the \"descendentpath\" expression, but it isn't equating to a number. I need a number to know which bit of the path you are referring to.", args[0].Token);
}
default:
throw new TokenParserException("the \"descendentpath\" expression must contain no more than one argument, and it should be a number specifying which querystring element you want, or a string (word) specifying the name of the querystring parameter you want.", args[1].Token);
}
}
示例10: Evaluate
public object Evaluate(ExecutionState state, Token contextToken)
{
// ensure that the variable has been set to some value first
if(!state.HasVariable(variableToken.Value))
throw new InstructionExecutionException("I can't evaluate the word \"" + variableToken.Value + "\". Either it doesn't mean anything or you forgot to assign it a value.", variableToken);
return state.GetVariable(variableToken.Value);
}
示例11: Evaluate
protected override object Evaluate(IExpression left, IExpression right, ExecutionState state)
{
if (!(left is BooleanExpression))
left = new BooleanExpression(left);
if (!(right is BooleanExpression))
right = new BooleanExpression(right);
return left.Evaluate(state, token).Equals(true) && right.Evaluate(state, token).Equals(true);
}
示例12: EvaluateProperty
public object EvaluateProperty(string propertyName, Token token, ExecutionState state)
{
switch (propertyName)
{
case "length": return text.Length;
default: return VariableExpression.InvalidProperty;
}
}
示例13: Evaluate
public object Evaluate(ExecutionState state, Token contextToken)
{
TimeSpan ts = SprocketDate.Now.Subtract((DateTime)CurrentRequest.Value["RequestSpeedExpression.Start"]);
string s = ts.TotalSeconds.ToString("0.####") + "s";
if (s == "0s")
return "instant";
return s;
}
示例14: Evaluate
public object Evaluate(ExecutionState state, Token contextToken)
{
if (expr != null)
o = expr.Evaluate(state, contextToken);
if (o == null)
return new SoftBoolean(false);
return new SoftBoolean(!(o.Equals(0m) || o.Equals("") || o.Equals(false)));
}
示例15: Evaluate
public object Evaluate(Token contextToken, List<ExpressionArgument> args, ExecutionState state)
{
if(args.Count == 0)
throw new InstructionExecutionException("The \"editfield\" expression requires an argument specifying the name of an edit field to retrieve", contextToken);
if(args.Count > 1)
throw new InstructionExecutionException("The \"editfield\" expression takes a single argument specifying the name of an edit field to retrieve. You've specified more than one argument.", contextToken);
return "[todo: render content node output]";
}