当前位置: 首页>>代码示例>>C#>>正文


C# IShellContext.CreateChildContext方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:8,代码来源:DirectoryTabularDataSource.cs

示例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);
         }
     }
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:47,代码来源:ForEach.cs

示例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);
     }
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:31,代码来源:MapValue.cs


注:本文中的IShellContext.CreateChildContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。