本文整理汇总了C#中IShellContext.CreateChildContext方法的典型用法代码示例。如果您正苦于以下问题:C# IShellContext.CreateChildContext方法的具体用法?C# IShellContext.CreateChildContext怎么用?C# IShellContext.CreateChildContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellContext
的用法示例。
在下文中一共展示了IShellContext.CreateChildContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: using
DataFormatSettings ITabularDataSource.GetSourceFormat(IShellContext context)
{
using (var childCtx = context.CreateChildContext())
{
childCtx.SetVariable(context.Replace(PropertyName), context.Replace(PrimaryFile));
return SourceTemplate.GetSourceFormat(childCtx);
}
}
示例2: DoRun
protected override void DoRun(IShellContext context)
{
var childContext = context.CreateChildContext();
childContext.CreateScope();
foreach (var item in Source.GetList(context))
{
if (Property == null)
{
bool processed = false;
var dct = item as Dictionary<string, object>;
if (dct != null)
{
foreach (var tuple in dct)
{
childContext.SetVariable(tuple.Key, tuple.Value);
}
processed = true;
}
var record = item as ICdlRecord;
if (record != null)
{
for (int i = 0; i < record.FieldCount; i++)
{
childContext.SetVariable(record.GetName(i), record.GetValue(i));
}
processed = true;
}
if (!processed) throw new Exception("DBSH-00077 Property is not set and Items collection doesn't return property names");
}
else
{
childContext.SetVariable(Property, item);
}
try
{
foreach (var command in Commands)
{
command.Run(childContext);
}
}
catch (Exception err)
{
if (!ContinueOnErrors) throw;
context.OutputMessage(err.Message);
}
}
}
示例3: CdlValueHolder
void IColumnMapping.ProcessMapping(int column, int rowNumber, ICdlRecord record, ICdlValueWriter writer, IShellContext context)
{
if (_value == null)
{
_value = new CdlValueHolder();
}
if (Expression != null && Value != null)
{
throw new Exception("DBSH-00004 MapValue: Both Expression and Value is set");
}
var childContext = context.CreateChildContext();
if (Value != null)
{
CreateColumnValues(record, childContext);
string value = childContext.Replace(Value);
_value.ReadFrom(value);
_value.WriteTo(writer);
}
if (Expression != null)
{
CreateColumnValues(record, childContext);
object value = childContext.Evaluate(Expression);
_value.ReadFrom(value);
_value.WriteTo(writer);
}
if (Expression == null && Value == null)
{
_value.SetNull();
_value.WriteTo(writer);
}
}