本文整理汇总了C#中IScope.Set方法的典型用法代码示例。如果您正苦于以下问题:C# IScope.Set方法的具体用法?C# IScope.Set怎么用?C# IScope.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScope
的用法示例。
在下文中一共展示了IScope.Set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompoundMessage
public PostMessage CompoundMessage(IUser target, string template, string @from, string subject, IScope scope) {
var workingtemplate = ResolveTemplate(template);
scope = scope ?? new Scope();
scope.Set("user", target);
scope.Set("resource", AppInfo);
var resultmessage = workingtemplate.Interpolate(scope);
subject = (subject ?? "").Interpolate(scope);
var email = target.Email;
var pm = new PostMessage {
Addresses = new[] {email},
From = @from,
CanUseDefault = true,
Subject = subject,
Body = resultmessage.ToString(),
Tags = new Dictionary<string, object>()
};
foreach (var pair in scope) {
if (pair.Key == "user") {
pm.Tags["user"] = target.Login;
}
else {
pm.Tags[pair.Key] = pair.Value;
}
}
return pm;
}
示例2: OpenObject
public void OpenObject() {
if (InArray)
{
if (ArrayCount > 0)
{
_out.Write(",");
}
ArrayCount++;
}
this._out.Write("{");
scope = new Scope(scope);
scope.Set("pc",0);
scope.Set("state","inobj");
}
示例3: OpenProperty
public void OpenProperty(string name) {
if (!InObj) {
throw new Exception("invalid state");
}
if (PropCount > 0)
{
_out.Write(",");
}
PropCount++;
scope = new Scope(scope);
scope.Set("state", "inproperty");
_out.Write("\"" + name.Escape(EscapingType.JsonValue) + "\"");
_out.Write(":");
}
示例4: OpenArray
public void OpenArray() {
if (InArray)
{
if (ArrayCount > 0)
{
_out.Write(",");
}
ArrayCount++;
}
this._out.Write("[");
scope = new Scope(scope);
scope.Set("ac",0);
scope.Set("state", "inarray");
}
示例5: InterpolateDataToElement
private bool InterpolateDataToElement(XElement source, IScope datasource, out XElement result) {
result = source;
if (UseExtensions) {
if (!MatchCondition(source, datasource, "if")) {
return false;
}
#if !EMBEDQPT
XmlIncludeProvider = XmlIncludeProvider ?? new XmlIncludeProvider();
#endif
var globalreplace = source.Attr("xi-replace");
if (!string.IsNullOrWhiteSpace(globalreplace)) {
_stringInterpolation.Interpolate(globalreplace);
var xml = XmlIncludeProvider.GetXml(globalreplace, source, datasource);
if (null == xml) {
xml = XElement.Parse("<span class='no-ex replace'>no replace " + globalreplace + "</span>");
}
result = xml;
if (null != source.Parent) {
source.ReplaceWith(xml);
}
source = xml;
}
if (source.Attr("xi-repeat").ToBool()) {
XElement[] replace = ProcessRepeat(source, datasource);
if (null == replace) {
source.Remove();
}
else {
// ReSharper disable once CoVariantArrayConversion
source.ReplaceWith(replace);
}
return false;
}
var include = source.Attr("xi-include");
if (!string.IsNullOrWhiteSpace(include)) {
_stringInterpolation.Interpolate(include);
var xml = XmlIncludeProvider.GetXml(include, source, datasource);
if (null == xml) {
xml = XElement.Parse("<span class='no-ex include'>no replace " + include + "</span>");
}
source.ReplaceAll(xml);
}
}
var processchild = true;
if (!string.IsNullOrWhiteSpace(StopAttribute)) {
var stopper = source.Attribute(StopAttribute);
if (null != stopper) {
if (stopper.Value != "0") {
if (stopper.Value == "all") {
return false;
}
processchild = false;
}
}
}
if (CodeOnly) {
foreach (var a in source.Attributes()) {
if (a.Name.LocalName == "code" || a.Name.LocalName == "id") {
var val = a.Value;
if (val.Contains(_stringInterpolation.AncorSymbol) &&
val.Contains(_stringInterpolation.StartSymbol)) {
val = _stringInterpolation.Interpolate(val, datasource, SecondSource);
a.Value = val;
datasource.Set(a.Name.LocalName, val);
}
}
}
}
else {
var changed = true;
while (changed) {
changed = false;
foreach (var a in source.Attributes().OrderBy(_ => {
if (_.Value.Contains(AncorSymbol+"{") && _.Value.Contains("(")) {
return 1000;
}
return 0;
})) {
var val = a.Value;
if (val.Contains(_stringInterpolation.AncorSymbol) &&
val.Contains(_stringInterpolation.StartSymbol)) {
val = _stringInterpolation.Interpolate(val, datasource, SecondSource);
changed = changed || (val != a.Value);
a.Value = val;
datasource.Set(a.Name.LocalName, val);
}
}
}
changed = true;
while (changed) {
changed = false;
foreach (var t in source.Nodes().OfType<XText>()) {
var val = t.Value;
if (val.Contains(_stringInterpolation.AncorSymbol) &&
val.Contains(_stringInterpolation.StartSymbol)) {
val = _stringInterpolation.Interpolate(val, datasource, SecondSource);
//.........这里部分代码省略.........