• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IRuntimeContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRuntimeContext的典型用法代码示例。如果您正苦于以下问题:C# IRuntimeContext类的具体用法?C# IRuntimeContext怎么用?C# IRuntimeContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRuntimeContext类属于命名空间,在下文中一共展示了IRuntimeContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InsertAndUpdateRow

        private static void InsertAndUpdateRow(IDbCommand command, string tableName, IRuntimeContext context)
        {
            command.CommandText = string.Format(CultureInfo.InvariantCulture, "INSERT INTO \"{0}\" ( \"Content\" ) VALUES ( 'First' )", tableName);
            context.CommandExecutor.ExecuteNonQuery(command);

            byte[] firstRowVersion;
            if (IntegrationTestContext.IsScripting)
            {
                firstRowVersion = BitConverter.GetBytes(1L);
            }
            else
            {
                command.CommandText = string.Format(CultureInfo.InvariantCulture, "SELECT Version FROM \"{0}\"", tableName);
                firstRowVersion = (byte[])command.ExecuteScalar();
            }

            command.CommandText = string.Format(CultureInfo.InvariantCulture, "UPDATE \"{0}\" SET Content = 'Updated'", tableName);
            context.CommandExecutor.ExecuteNonQuery(command);

            byte[] updatedRowVersion;
            if (IntegrationTestContext.IsScripting)
            {
                updatedRowVersion = BitConverter.GetBytes(2L);
            }
            else
            {
                command.CommandText = string.Format(CultureInfo.InvariantCulture, "SELECT Version FROM \"{0}\"", tableName);
                updatedRowVersion = (byte[])command.ExecuteScalar();
            }
            CollectionAssert.AreNotEqual(firstRowVersion, updatedRowVersion, "The row version was not updated.");
        }
开发者ID:dradovic,项目名称:MigSharp,代码行数:31,代码来源:Migration21_RowVersion.cs


示例2: GetScriptType

		private JsExpression GetScriptType(IType type, TypeContext typeContext, IRuntimeContext context) {
			if (type.Kind == TypeKind.Delegate) {
				return CreateTypeReferenceExpression(KnownTypeReference.Delegate);
			}
			else if (type is ParameterizedType) {
				var pt = (ParameterizedType)type;
				var def = pt.GetDefinition();
				var sem = _metadataImporter.GetTypeSemantics(def);
				if (sem.Type == TypeScriptSemantics.ImplType.NormalType && !sem.IgnoreGenericArguments)
					return JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(_systemScript), "makeGenericType"), CreateTypeReferenceExpression(type.GetDefinition()), JsExpression.ArrayLiteral(pt.TypeArguments.Select(a => GetScriptType(a, TypeContext.GenericArgument, context))));
				else
					return GetTypeDefinitionScriptType(type.GetDefinition(), typeContext);
			}
			else if (type.TypeParameterCount > 0) {
				// This handles open generic types ( typeof(C<,>) )
				return CreateTypeReferenceExpression(type.GetDefinition());
			}
			else if (type.Kind == TypeKind.Array) {
				return CreateTypeReferenceExpression(KnownTypeReference.Array);
			}
			else if (type is ITypeParameter) {
				return context.ResolveTypeParameter((ITypeParameter)type);
			}
			else if (type is ITypeDefinition) {
				return GetTypeDefinitionScriptType((ITypeDefinition)type, typeContext);
			}
			else if (type.Kind == TypeKind.Anonymous || type.Kind == TypeKind.Null || type.Kind == TypeKind.Dynamic) {
				return CreateTypeReferenceExpression(KnownTypeReference.Object);
			}
			else {
				throw new InvalidOperationException("Could not determine the script type for " + type + ", context " + typeContext);
			}
		}
开发者ID:pdavis68,项目名称:SaltarelleCompiler,代码行数:33,代码来源:RuntimeLibrary.cs


示例3: InsertUsingParameters

 private static void InsertUsingParameters(IRuntimeContext ctx, string value)
 {
     IDbCommand command = ctx.CreateCommand();
     IDataParameter parameter = command.AddParameter("@value", DbType.String, value);
     command.CommandText = string.Format(CultureInfo.InvariantCulture, @"INSERT INTO ""Mig23b"" (""Data"") VALUES ({0})", ctx.ProviderMetadata.GetParameterSpecifier(parameter));
     ctx.CommandExecutor.ExecuteNonQuery(command);
 }
开发者ID:dradovic,项目名称:MigSharp,代码行数:7,代码来源:Migration23_Unicode.cs


示例4: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     return provider.AlterColumn(Parent.Parent.TableName, new Column(
         Parent.ColumnName,
         new DataType(_type, Size, Scale),
         _isNullable,
         DefaultValue));
 }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:8,代码来源:AlterColumnDefinitionCommand.cs


示例5: EventProcessor

        /// <summary>
        /// Initializes a new instance of the <see cref="EventProcessor"/> class.
        /// </summary>
        public EventProcessor(IWorkItemRepository workItemStore, IRuntimeContext runtime)
        {
            this.logger = runtime.Logger;
            this.store = workItemStore;
            this.settings = runtime.Settings;

            this.engine = runtime.GetEngine(workItemStore);
        }
开发者ID:DEllingsworth,项目名称:tfsaggregator,代码行数:11,代码来源:EventProcessor.cs


示例6: Trigger

        public bool Trigger(IRuntimeContext context)
        {
			// There is no control over how many times this will be called so 
			// there is no guarantee that rule will be triggered given Minimum times.
            bool trigger = triggerCount < minTriggers || random.Next(0, 2) == 0;
            if (trigger) triggerCount++;
            return (triggerCount <= maxTriggers) && trigger;
        }
开发者ID:krigans,项目名称:Mongo.Framework,代码行数:8,代码来源:TriggerRandomly.cs


示例7: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     if (_columnNames.Count == 0)
     {
         throw new InvalidCommandException("At least one column must be added to the AddPrimaryKey command.");
     }
     string effectiveConstraintName = GetEffectiveConstraintName();
     return provider.AddPrimaryKey(Parent.TableName, _columnNames, effectiveConstraintName);
 }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:9,代码来源:AddPrimaryKeyCommand.cs


示例8: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     if (context != null) // the context == null, when recording the changes to the RecordingProvider for validation
     {
         Log.Verbose(LogCategory.Sql, "Performing call-back");
         _action(context);
     }
     yield break;
 }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:9,代码来源:CallCommand.cs


示例9: RateLimiter

 public RateLimiter(IRuntimeContext context)
 {
     if (context.Settings?.RateLimit != null)
     {
         this.enabled = true;
         this.interval = context.Settings.RateLimit.Interval;
         this.changes = context.Settings.RateLimit.Changes;
     }
 }
开发者ID:veredflis,项目名称:tfsaggregator,代码行数:9,代码来源:RateLimiter.cs


示例10: EventProcessor

        /// <summary>
        /// Initializes a new instance of the <see cref="EventProcessor"/> class.
        /// </summary>
        public EventProcessor(IRuntimeContext runtime)
        {
            this.logger = runtime.Logger;
            this.settings = runtime.Settings;
            this.limiter = runtime.RateLimiter;

            this.store = runtime.GetWorkItemRepository();
            this.engine = runtime.GetEngine();
        }
开发者ID:veredflis,项目名称:tfsaggregator,代码行数:12,代码来源:EventProcessor.cs


示例11: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     if (_columnNames.Count == 0)
     {
         throw new InvalidCommandException("At least one column must be added to the AddForeignKeyTo command.");
     }
     string effectiveConstraintName = GetEffectiveConstraintName();
     return provider.AddForeignKey(Parent.TableName, _referencedTableName, _columnNames.Select(p => new ColumnReference(p.Key, p.Value)), effectiveConstraintName, CascadeOnDelete);
 }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:9,代码来源:AddForeignKeyToCommand.cs


示例12: Trigger

        public bool Trigger(IRuntimeContext context)
        {
            if (!string.IsNullOrEmpty(targetCaller) && targetCaller != context.Caller)
            {
                return false;
            }

	        Interlocked.Increment(ref calledTimes);

			return calledTimes <= n;
        }
开发者ID:krigans,项目名称:Mongo.Framework,代码行数:11,代码来源:TriggerOnFirstNCallBy.cs


示例13: OnInvoke

		protected override void OnInvoke(IRuntimeInvocation runtimeInvocation, IRuntimeContext runtimeContext)
		{
			this.LastOperationName = string.Format("{0}::{1}", (object)runtimeInvocation.TargetType == null ? "<null>" : runtimeInvocation.TargetType.Name, (object)runtimeInvocation.TargetMethod == null ? "<null>" : runtimeInvocation.TargetMethod.Name);

			if ((object)runtimeInvocation.TargetMethod != null)
			{
				if (runtimeInvocation.TargetMethod.DeclaringType == typeof(object) ||
					runtimeInvocation.TargetMethod.DeclaringType == typeof(IDisposable) ||
					runtimeInvocation.TargetMethod.DeclaringType == typeof(IMockCloneable))
					runtimeInvocation.InvocationReturnValue = runtimeInvocation.TargetMethod.Invoke(this, runtimeInvocation.InvocationArguments);
			}

			throw new InvalidOperationException(string.Format("Method '{0}' not supported on '{1}'.", (object)runtimeInvocation.TargetMethod == null ? "<null>" : runtimeInvocation.TargetMethod.Name, runtimeInvocation.TargetType.FullName));
		}
开发者ID:textmetal,项目名称:main,代码行数:14,代码来源:MockRuntimeInterception.cs


示例14: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     if (IsNullable && DefaultValue != null)
     {
         throw new InvalidCommandException("Adding nullable columns with default values is not supported: some database platforms (like SQL Server) leave missing values NULL and some update missing values to the default value. Consider adding the column first as not-nullable, and then altering it to nullable.");
     }
     string tableName = Parent.TableName;
     var dataType = new DataType(Type, Size, Scale);
     var column = new Column(ColumnName, dataType, IsNullable, DefaultValue, IsRowVersion);
     IEnumerable<string> commands = provider.AddColumn(tableName, column);
     if (DropThereafter)
     {
         commands = commands.Concat(provider.DropDefault(tableName, new Column(
             column.Name,
             column.DataType,
             column.IsNullable,
             null, false)));
     }
     return commands;
 }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:20,代码来源:AddColumnCommand.cs


示例15: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     string effectivePkConstraintName = GetEffectivePkConstraintName();
     List<CreateColumnCommand> createColumnCommands = GetCreateColumnCommands().ToList();
     if (createColumnCommands.Count == 0)
     {
         throw new InvalidCommandException("At least one column must be added to the CreateTable command.");
     }
     return provider.CreateTable(
         _tableName,
         createColumnCommands.Select(c => new CreatedColumn(
                                              c.ColumnName,
                                              new DataType(c.Type, c.Size, c.Scale),
                                              c.IsNullable,
                                              c.IsPrimaryKey,
                                              GetEffectiveUniqueConstraintName(c),
                                              c.IsIdentity,
                                              c.DefaultValue)),
         effectivePkConstraintName);
 }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:20,代码来源:CreateTableCommand.cs


示例16: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     AlterTableCommand parentAlterTableCommand;
     AlterColumnCommand parentAlterColumnCommand;
     AlterPrimaryKeyCommand parentAlterPrimaryKeyCommand;
     if ((parentAlterTableCommand = Parent as AlterTableCommand) != null)
     {
         return provider.RenameTable(parentAlterTableCommand.TableName, _newName);
     }
     else if ((parentAlterColumnCommand = Parent as AlterColumnCommand) != null)
     {
         return provider.RenameColumn(parentAlterColumnCommand.Parent.TableName, parentAlterColumnCommand.ColumnName, _newName);
     }
     else if ((parentAlterPrimaryKeyCommand = Parent as AlterPrimaryKeyCommand) != null)
     {
         return provider.RenamePrimaryKey(parentAlterPrimaryKeyCommand.Parent.TableName, parentAlterPrimaryKeyCommand.ConstraintName, _newName);
     }
     else
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unknown parent command of a RenameCommand: {0}.", Parent.GetType()));
     }
 }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:22,代码来源:RenameCommand.cs


示例17: ToSql

 public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
 {
     AlterTableCommand parentAlterTableCommand;
     AlterColumnCommand parentAlterColumnCommand;
     AlterPrimaryKeyCommand parentAlterPrimaryKeyCommand;
     AlterIndexCommand parentAlterIndexCommand;
     AlterUniqueConstraintCommand parentAlterUniqueConstraintCommand;
     AlterForeignKeyCommand parentAlterForeignKeyCommand;
     if ((parentAlterTableCommand = Parent as AlterTableCommand) != null)
     {
         return provider.DropTable(parentAlterTableCommand.TableName);
     }
     else if ((parentAlterColumnCommand = Parent as AlterColumnCommand) != null)
     {
         return provider.DropColumn(parentAlterColumnCommand.Parent.TableName, parentAlterColumnCommand.ColumnName);
     }
     else if ((parentAlterPrimaryKeyCommand = Parent as AlterPrimaryKeyCommand) != null)
     {
         string effectiveConstraintName = DefaultObjectNameProvider.GetPrimaryKeyConstraintName(parentAlterPrimaryKeyCommand.Parent.TableName, parentAlterPrimaryKeyCommand.ConstraintName);
         return provider.DropPrimaryKey(parentAlterPrimaryKeyCommand.Parent.TableName, effectiveConstraintName);
     }
     else if ((parentAlterIndexCommand = Parent as AlterIndexCommand) != null)
     {
         return provider.DropIndex(parentAlterIndexCommand.Parent.TableName, parentAlterIndexCommand.IndexName);
     }
     else if ((parentAlterUniqueConstraintCommand = Parent as AlterUniqueConstraintCommand) != null)
     {
         return provider.DropUniqueConstraint(parentAlterUniqueConstraintCommand.Parent.TableName, parentAlterUniqueConstraintCommand.ConstraintName);
     }
     else if ((parentAlterForeignKeyCommand = Parent as AlterForeignKeyCommand) != null)
     {
         return provider.DropForeignKey(parentAlterForeignKeyCommand.Parent.TableName, parentAlterForeignKeyCommand.ConstraintName);
     }
     else
     {
         throw new InvalidOperationException("Unsupported parent command of a DropCommand.");
     }
 }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:38,代码来源:DropCommand.cs


示例18: GetExpressionForLocal

		JsExpression IRuntimeLibrary.GetExpressionForLocal(string name, JsExpression accessor, IType type, IRuntimeContext context) {
			return GetExpressionForLocal(name, accessor, type, context);
		}
开发者ID:kumar0190,项目名称:SaltarelleCompiler,代码行数:3,代码来源:MockRuntimeLibrary.cs


示例19: GetMember

		JsExpression IRuntimeLibrary.GetMember(IMember member, IRuntimeContext context) {
			return GetMember(member, context);
		}
开发者ID:kumar0190,项目名称:SaltarelleCompiler,代码行数:3,代码来源:MockRuntimeLibrary.cs


示例20: ShallowCopy

		JsExpression IRuntimeLibrary.ShallowCopy(JsExpression source, JsExpression target, IRuntimeContext context) {
			return ShallowCopy(source, target, context);
		}
开发者ID:kumar0190,项目名称:SaltarelleCompiler,代码行数:3,代码来源:MockRuntimeLibrary.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRuntimeEnvironment类代码示例发布时间:2022-05-24
下一篇:
C# IRuntime类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap