本文整理汇总了C#中IStatement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IStatement.GetType方法的具体用法?C# IStatement.GetType怎么用?C# IStatement.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStatement
的用法示例。
在下文中一共展示了IStatement.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFormatter
public static IStatementFormatter GetFormatter( IIndentable indentable, StringBuilder outSql, IStatement statement )
{
Type formatterType;
if ( !_formatters.TryGetValue( statement.GetType(), out formatterType ) )
throw new FormatterNotImplementedException(
"Formatter not implemented for statement: " + statement.GetType().Name
);
var formatter = Activator.CreateInstance(
formatterType,
indentable,
outSql,
statement
) as IStatementFormatter;
if ( formatter == null )
throw new ArgumentNullException( "Formatter not instantiated: " + formatterType.Name );
return formatter;
}
示例2: TraverseChildren
public override void TraverseChildren(IStatement statement)
{
log.WriteTrace("Traversing {0} statement.", statement.GetType().Name);
var statementVisitor = new NewObjStatementVisitor(statement, log, registry);
statementVisitor.Traverse(statement);
var fieldReferenceVisitor = new FieldReferenceVisitor(statement, log, registry);
fieldReferenceVisitor.Traverse(statement);
var fieldAssignmentVisitor = new FieldAssignmentVisitor(statement, log, registry);
fieldAssignmentVisitor.Traverse(statement);
base.TraverseChildren(statement);
}
示例3: TestTryCombine
public void TestTryCombine([PexAssumeUnderTest]StatementForLoop target, IStatement s)
{
/// We should never be able to combine any filter statements currently!
var val = new Variables.ValSimple("true", typeof(bool));
var result = target.TryCombineStatement(s, null);
if (s.GetType() != typeof(StatementForLoop))
{
Assert.IsFalse(result, "Types not right");
}
else
{
var other = s as StatementForLoop;
Assert.AreEqual(other.ArrayLength == target.ArrayLength, result, "for loops not conssitent");
}
}
示例4: GetSql
public virtual string GetSql (IStatement statement)
{
if (statement == null)
throw new ArgumentNullException ("statement");
Type type = statement.GetType ();
if (type == typeof (SelectStatement))
return GetStatementSql (statement as SelectStatement);
else if (type == typeof (InsertStatement))
return GetStatementSql (statement as InsertStatement);
else if (type == typeof (UpdateStatement))
return GetStatementSql (statement as UpdateStatement);
else if (type == typeof (DeleteStatement))
return GetStatementSql (statement as DeleteStatement);
else if (type == typeof (DropStatement))
return GetStatementSql (statement as DropStatement);
else if (type == typeof (TruncateStatement))
return GetStatementSql (statement as TruncateStatement);
else
throw new NotImplementedException (type.FullName);
}
示例5: GetRefUrlFor
public static string GetRefUrlFor(IStatement s, CodeLocation caret)
{
if (s is IExpressionContainingStatement) {
var exprs = (s as IExpressionContainingStatement).SubExpressions;
IExpression targetExpr = null;
if (exprs != null)
foreach (var ex in exprs)
if (caret >= ex.Location &&
caret <= ex.EndLocation &&
(targetExpr = ExpressionHelper.SearchExpressionDeeply (ex, caret))
!= ex)
break;
if (targetExpr != null)
return GetRefUrlFor (targetExpr);
}
if (s is DeclarationStatement) {
var ds = s as DeclarationStatement;
foreach (var decl in ds.Declarations) {
if (caret >= decl.Location && caret <= decl.EndLocation) {
if (decl is DVariable) {
var dv = decl as DVariable;
if (dv.Initializer != null &&
caret >= dv.Location &&
caret <= dv.EndLocation)
return GetRefUrlFor (dv.Initializer);
}
}
}
}
if (s is StatementContainingStatement) {
var stmts = (s as StatementContainingStatement).SubStatements;
if (stmts != null)
foreach (var stmt in stmts) {
if (caret >= stmt.Location && caret <= stmt.EndLocation) {
var r = GetRefUrlFor (stmt, caret);
if (r != null)
return r;
}
}
}
var url = "statement.html#";
if (s is ForeachStatement && (s as ForeachStatement).IsRangeStatement)
url += "ForeachRangeStatement";
else if (s is StatementCondition)
{
var sc = (StatementCondition) s;
if(sc.Condition is DebugCondition)
url = "version.html#DebugCondition";
else if (sc.Condition is VersionCondition)
url = "version.html#VersionCondition";
else if (sc.Condition is StaticIfCondition)
url = "version.html#StaticIfCondition";
}
else
url += s.GetType ().Name;
return url;
}
示例6: GetRequest
/// <summary>
/// Gets the Request to send to a cassandra node based on the statement type
/// </summary>
internal IRequest GetRequest(IStatement statement)
{
ICqlRequest request = null;
if (statement is RegularStatement)
{
var s = (RegularStatement)statement;
s.ProtocolVersion = BinaryProtocolVersion;
var options = QueryProtocolOptions.CreateFromQuery(s, Configuration.QueryOptions);
options.ValueNames = s.QueryValueNames;
request = new QueryRequest(BinaryProtocolVersion, s.QueryString, s.IsTracing, options);
}
if (statement is BoundStatement)
{
var s = (BoundStatement)statement;
var options = QueryProtocolOptions.CreateFromQuery(s, Configuration.QueryOptions);
request = new ExecuteRequest(BinaryProtocolVersion, s.PreparedStatement.Id, null, s.IsTracing, options);
}
if (statement is BatchStatement)
{
var s = (BatchStatement)statement;
s.ProtocolVersion = BinaryProtocolVersion;
var consistency = Configuration.QueryOptions.GetConsistencyLevel();
if (s.ConsistencyLevel != null)
{
consistency = s.ConsistencyLevel.Value;
}
request = new BatchRequest(BinaryProtocolVersion, s, consistency);
}
if (request == null)
{
throw new NotSupportedException("Statement of type " + statement.GetType().FullName + " not supported");
}
//Set the outgoing payload for the request
request.Payload = statement.OutgoingPayload;
return request;
}
示例7: GetRequest
/// <summary>
/// Gets the Request to send to a cassandra node based on the statement type
/// </summary>
internal IRequest GetRequest(IStatement statement)
{
var defaultConsistency = Configuration.QueryOptions.GetConsistencyLevel();
if (statement is RegularStatement)
{
var s = (RegularStatement)statement;
var options = QueryProtocolOptions.CreateFromQuery(s, defaultConsistency);
options.ValueNames = s.QueryValueNames;
return new QueryRequest(BinaryProtocolVersion, s.QueryString, s.IsTracing, options);
}
if (statement is BoundStatement)
{
var s = (BoundStatement)statement;
var options = QueryProtocolOptions.CreateFromQuery(s, defaultConsistency);
return new ExecuteRequest(BinaryProtocolVersion, s.PreparedStatement.Id, null, s.IsTracing, options);
}
if (statement is BatchStatement)
{
var s = (BatchStatement)statement;
var consistency = defaultConsistency;
if (s.ConsistencyLevel != null)
{
consistency = s.ConsistencyLevel.Value;
}
return new BatchRequest(BinaryProtocolVersion, s, consistency);
}
throw new NotSupportedException("Statement of type " + statement.GetType().FullName + " not supported");
}
示例8: WriteStatement
//.........这里部分代码省略.........
}
if (value is IUsingStatement)
{
this.WriteUsingStatement(value as IUsingStatement, formatter);
return;
}
if (value is IFixedStatement)
{
this.WriteFixedStatement(value as IFixedStatement, formatter);
return;
}
if (value is IWhileStatement)
{
this.WriteWhileStatement(value as IWhileStatement, formatter);
return;
}
if (value is IDoStatement)
{
this.WriteDoStatement(value as IDoStatement, formatter);
return;
}
if (value is ITryCatchFinallyStatement)
{
this.WriteTryCatchFinallyStatement(value as ITryCatchFinallyStatement, formatter);
return;
}
if (value is IThrowExceptionStatement)
{
this.WriteThrowExceptionStatement(value as IThrowExceptionStatement, formatter);
return;
}
if (value is IAttachEventStatement)
{
this.WriteAttachEventStatement(value as IAttachEventStatement, formatter);
return;
}
if (value is IRemoveEventStatement)
{
this.WriteRemoveEventStatement(value as IRemoveEventStatement, formatter);
return;
}
if (value is ISwitchStatement)
{
this.WriteSwitchStatement(value as ISwitchStatement, formatter);
return;
}
if (value is IBreakStatement)
{
this.WriteBreakStatement(value as IBreakStatement, formatter);
return;
}
if (value is IContinueStatement)
{
this.WriteContinueStatement(value as IContinueStatement, formatter);
return;
}
if (value is IMemoryCopyStatement)
{
this.WriteMemoryCopyStatement(value as IMemoryCopyStatement, formatter);
return;
}
if (value is IMemoryInitializeStatement)
{
this.WriteMemoryInitializeStatement(value as IMemoryInitializeStatement, formatter);
return;
}
if (value is IDebugBreakStatement)
{
this.WriteDebugBreakStatement(value as IDebugBreakStatement, formatter);
return;
}
if (value is ILockStatement)
{
this.WriteLockStatement(value as ILockStatement, formatter);
return;
}
if (value is ICommentStatement)
{
this.WriteCommentStatement(value as ICommentStatement, formatter);
return;
}
throw new ArgumentException("Invalid statement type `" + value.GetType() + "`.", "value");
}
示例9: TranslateStatement
public IPhpStatement[] TranslateStatement(IStatement x)
{
if (!(x is CSharpBase)) throw new Exception("Błąd translacji " + x.GetType().FullName);
var op = new OptimizeOptions();
var s = new StatementSimplifier(op);
var a = new StatementTranslatorVisitor(_state);
var tmp = a.Visit(x as CSharpBase);
var result = new List<IPhpStatement>(tmp.Length);
result.AddRange(tmp.Select(i => s.Visit(i as PhpSourceBase)));
return result.ToArray();
}
示例10: VisitStatement
//.........这里部分代码省略.........
}
if (value is IWhileStatement)
{
this.VisitWhileStatement(value as IWhileStatement);
return;
}
if (value is IDoStatement)
{
this.VisitDoStatement(value as IDoStatement);
return;
}
if (value is ITryCatchFinallyStatement)
{
this.VisitTryCatchFinallyStatement(value as ITryCatchFinallyStatement);
return;
}
if (value is IThrowExceptionStatement)
{
this.VisitThrowExceptionStatement(value as IThrowExceptionStatement);
return;
}
if (value is IAttachEventStatement)
{
this.VisitAttachEventStatement(value as IAttachEventStatement);
return;
}
if (value is IRemoveEventStatement)
{
this.VisitRemoveEventStatement(value as IRemoveEventStatement);
return;
}
if (value is ISwitchStatement)
{
this.VisitSwitchStatement(value as ISwitchStatement);
return;
}
if (value is IBreakStatement)
{
this.VisitBreakStatement(value as IBreakStatement);
return;
}
if (value is IContinueStatement)
{
this.VisitContinueStatement(value as IContinueStatement);
return;
}
if (value is ICommentStatement)
{
this.VisitCommentStatement(value as ICommentStatement);
return;
}
if (value is IUsingStatement)
{
this.VisitUsingStatement(value as IUsingStatement);
return;
}
if (value is IFixedStatement)
{
this.VisitFixedStatement(value as IFixedStatement);
return;
}
if (value is ILockStatement)
{
this.VisitLockStatement(value as ILockStatement);
return;
}
if (value is IMemoryCopyStatement)
{
this.VisitMemoryCopyStatement(value as IMemoryCopyStatement);
return;
}
if (value is IMemoryInitializeStatement)
{
this.VisitMemoryInitializeStatement(value as IMemoryInitializeStatement);
return;
}
if (value is IDebugBreakStatement)
{
this.VisitDebugBreakStatement(value as IDebugBreakStatement);
return;
}
throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Invalid statement type '{0}'.", value.GetType().Name));
}
示例11: TryCombineStatement
/// <summary>
/// Can we combine? Yes, if and only if the same guy and same variables!
/// </summary>
/// <param name="statement"></param>
/// <param name="optimize"></param>
/// <returns></returns>
public bool TryCombineStatement(IStatement statement, ICodeOptimizationService optimize)
{
if (statement.GetType() != typeof(StatementRecordPairValues))
return false;
var other = statement as StatementRecordPairValues;
if (other._index.RawValue != _index.RawValue)
return false;
var isTheSame = _savers.Zip(other._savers, (f, s) => f.indexValue.RawValue == s.indexValue.RawValue && f.mapRecord.Type == s.mapRecord.Type).All(b => b);
if (!isTheSame)
{
return false;
}
// Now we can do them all.
foreach (var saver in _savers.Zip(other._savers, (f, s) => Tuple.Create(f, s)))
{
optimize.TryRenameVarialbeOneLevelUp(saver.Item2.mapRecord.RawValue, saver.Item1.mapRecord);
}
return true;
}