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


C# IShellContext.Replace方法代码示例

本文整理汇总了C#中IShellContext.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# IShellContext.Replace方法的具体用法?C# IShellContext.Replace怎么用?C# IShellContext.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IShellContext的用法示例。


在下文中一共展示了IShellContext.Replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoRun

 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);
     if (Expression != null && Value != null) throw new Exception("DBSH-00078 SaveToFile: both Expression and Value is set");
     if (Expression == null && Value == null) throw new Exception("DBSH-00079 SaveToFile: none of Expression and Value is set");
     if (Expression != null)
     {
         object obj = context.Evaluate(Expression);
         if (obj is byte[])
         {
             var bytes = (byte[]) obj;
             using (var fw = System.IO.File.OpenWrite(file))
             {
                 fw.Write(bytes, 0, bytes.Length);
             }
         }
         else
         {
             using (var fw = new StreamWriter(file, false, Encoding))
             {
                 fw.Write(obj.ToString());
             }
         }
     }
     if (Value!=null)
     {
         string val = context.Replace(Value);
         using (var fw = new StreamWriter(file, false, Encoding))
         {
             fw.Write(val);
         }
     }
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:33,代码来源:SaveToFile.cs

示例2: DoRun

 protected override void DoRun(IShellContext context)
 {
     GetModel(context).LoadReference(
         new NameWithSchema(context.Replace(Schema), context.Replace(Table)),
         context.Replace(Column), 
         new NameWithSchema(context.Replace(RefSchema), context.Replace(RefTable)));
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:7,代码来源:LoadReference.cs

示例3: 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

示例4: TargetEntitySqlModel

        public TargetEntitySqlModel(DataSyncSqlModel dataSyncSqlModel, Target dbsh, IShellContext context)
        {
            this._dataSyncSqlModel = dataSyncSqlModel;
            this._dbsh = dbsh;
            TargetTable = new NameWithSchema(context.Replace(dbsh.TableSchema), context.Replace(dbsh.TableName));
            string findSchema = dbsh.TableSchema;
            if (findSchema != null && findSchema.StartsWith(NameWithSchema.NoQuotePrefix)) findSchema = null;
            Structure = dataSyncSqlModel.TargetStructure.FindTableLike(findSchema, TargetTable.Name);
            SqlAlias = _dbsh.Alias ?? "dst_" + _dataSyncSqlModel.Entities.Count;

            foreach (var col in dbsh.Columns)
            {
                var targetCol = new TargetNoRefColumnSqlModel(col, FindColumnInfo(col.Name));
                TargetColumns.Add(targetCol);

                foreach (string alias in ExtractColumnSources(col))
                {
                    SourceColumnSqlModel source = null;
                    if (dataSyncSqlModel.SourceGraphModel == null)
                    {
                        // flat sync
                        if (!String.IsNullOrEmpty(dbsh.PrimarySource))
                        {
                            var tableSource = DataSync.FlatSources.FirstOrDefault(x => x.Match(Dbsh.PrimarySource));
                            if (tableSource != null)
                            {
                                source = tableSource.Columns.FirstOrDefault(x => x.Alias == alias);
                            }
                        }
                    }
                    else
                    {
                        source = dataSyncSqlModel.SourceGraphModel[alias];
                        //targetCol.Sources.Add(source);
                    }
                    RequiredSourceColumns.Add(source);
                    if (col.IsKey) KeySourceColumns.Add(source);
                }
            }

            if (!String.IsNullOrEmpty(_dbsh.Connection))
            {
                var ctxConn = new NormalizedDatabaseConnectionInfo(new DatabaseConnectionInfoHolder { ProviderString = context.GetDefaultConnection() });
                var tableConn = new NormalizedDatabaseConnectionInfo(new DatabaseConnectionInfoHolder { ProviderString = context.Replace(_dbsh.Connection), LinkedInfo = _dbsh.LinkedInfo });

                if (ctxConn != tableConn)
                {
                    if (ctxConn.ServerConnectionString == tableConn.ServerConnectionString)
                    {
                        TargetLinkedInfo = tableConn.GetLinkedInfo();
                    }
                    else
                    {
                        throw new IncorrectRdsDefinitionException($"DBSH-00000 RDS target must be reachable by database or linked server: ({TargetTable})");
                    }
                }
            }
        }
开发者ID:dbshell,项目名称:dbshell,代码行数:58,代码来源:TargetEntitySqlModel.cs

示例5: GetParameterValues

 private Dictionary<string, string> GetParameterValues(IShellContext context)
 {
     var res = new Dictionary<string, string>();
     foreach(var par in Parameters)
     {
         res[context.Replace(par.Name)] = context.Replace(par.Value);
     }
     return res;
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:9,代码来源:Run.cs

示例6: DoRun

 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);
     string url = context.Replace(Url);
     context.OutputMessage("Downloading from URL " + url);
     using (var client = new WebClient())
     {
         client.DownloadFile(url, file);
     }
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:10,代码来源:Download.cs

示例7: DoRun

 protected override void DoRun(IShellContext context)
 {
     using (var conn = GetConnectionProvider(context).Connect())
     {
         var cmd = conn.CreateCommand();
         cmd.CommandText = context.Replace(Text);
         object value = cmd.ExecuteScalar();
         context.SetVariable(context.Replace(Name), value);
     }
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:10,代码来源:QueryValue.cs

示例8: DoRun

        protected override void DoRun(IShellContext context)
        {
            var model = GetModel(context);
            var sqlModel = new DataSyncSqlModel(model, context, false, context.Replace(GetProviderString(context)));

            var connection = GetConnectionProvider(context);
            using (var conn = connection.Connect())
            {
                sqlModel.CreateProcedure(conn, connection.Factory, new NameWithSchema(context.Replace(ProcSchema), context.Replace(ProcName)), context, UseTransaction, OverwriteExisting, sqlModel.Parameters);
            }
        }
开发者ID:dbshell,项目名称:dbshell,代码行数:11,代码来源:CreateProcedure.cs

示例9: DoRun

        protected override void DoRun(IShellContext context)
        {
            var db = GetDatabaseStructure(context);
            if (Table != null && Tables != null) throw new Exception("DBSH-00085 SetTableProperty: both of Table and tables attribute is set");
            if (Table == null && Tables == null) throw new Exception("DBSH-00086 SetTableProperty: none of Table and tables attribute is set");

            string value = context.Replace(Value);
            if (Table != null)
            {
                var table = db.FindTableLike(Table);
                if (table != null)
                {
                    table.Properties[Name] = value;
                }
            }
            if (Tables != null)
            {
                foreach (var table in db.Tables)
                {
                    if (Regex.Match(table.Name, Tables).Success)
                    {
                        table.Properties[Name] = value;
                    }
                }
            }
        }
开发者ID:dbshell,项目名称:dbshell,代码行数:26,代码来源:SetTableProperty.cs

示例10: DoRun

 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Input);
     var model = ExcelModel.OpenFile(file);
     model.DataFormat = DataFormat;
     context.SetVariable(GetExcelVariableName(context), model);
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:7,代码来源:Open.cs

示例11: CreateWriter

 public ICdlWriter CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);
     var fw = new StreamWriter(file);
     var provider = GetConnectionProvider(context);
     return new SqlFileWriter(fw, provider.Factory);
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:7,代码来源:SqlDataWriter.cs

示例12: DirectoryTabularDataReader

        ICdlReader ITabularDataSource.CreateReader(IShellContext context)
        {
            string filter = context.Replace(Filter);
            if (filter == null)
            {
                string path = context.Replace(PrimaryFile);
                filter = context.Replace(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), "*" + System.IO.Path.GetExtension(path)));
            }

            string pathPart = System.IO.Path.GetDirectoryName(filter);
            string filterPart = System.IO.Path.GetFileName(filter);

            string[] files = System.IO.Directory.GetFiles(pathPart, filterPart);

            return new DirectoryTabularDataReader(context, SourceTemplate, PropertyName, files);
        }
开发者ID:dbshell,项目名称:dbshell,代码行数:16,代码来源:DirectoryTabularDataSource.cs

示例13: OpenDbfRead

 private SocialExplorer.IO.FastDBF.DbfFile OpenDbfRead(IShellContext context)
 {
     var dbf = new SocialExplorer.IO.FastDBF.DbfFile(Encoding);
     var name = context.ResolveFile(context.Replace(Name), ResolveFileMode.Input);
     dbf.Open(name, System.IO.FileMode.Open);
     return dbf;
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:7,代码来源:DbfFile.cs

示例14: DoRun

 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Input);
     var model = ShapeFileModel.OpenFile(file, SpatialTool.GetProjection(Projection, context));
     model.DataFormat = DataFormat;
     model.AddFileIdentifier = AddFileIdentifier;
     context.SetVariable(GetShpVariableName(context), model);
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:8,代码来源:ShpOpen.cs

示例15: DoRun

 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);
     context.OutputMessage("Writing file " + Path.GetFullPath(file));
     var model = ExcelModel.CreateFile(file);
     model.DataFormat = DataFormat;
     context.SetVariable(GetExcelVariableName(context), model);
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:8,代码来源:Create.cs


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