本文整理汇总了C#中SymbolInfo类的典型用法代码示例。如果您正苦于以下问题:C# SymbolInfo类的具体用法?C# SymbolInfo怎么用?C# SymbolInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SymbolInfo类属于命名空间,在下文中一共展示了SymbolInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Level2
public Level2(Quote quote, SymbolInfo info)
{
this.CreatingTime = quote.CreatingTime;
this.Symbol = quote.Symbol;
this.Bids = Level2EntriesFromQuoteEntries(quote.Bids, info.RoundLot);
this.Asks = Level2EntriesFromQuoteEntries(quote.Asks, info.RoundLot);
}
示例2: TryClassifySymbol
private bool TryClassifySymbol(
NameSyntax name,
SymbolInfo symbolInfo,
SemanticModel semanticModel,
CancellationToken cancellationToken,
out IEnumerable<ClassifiedSpan> result)
{
if (symbolInfo.CandidateReason == CandidateReason.Ambiguous)
{
return TryClassifyAmbiguousSymbol(name, symbolInfo, semanticModel, cancellationToken, out result);
}
// Only classify if we get one good symbol back, or if it bound to a constructor symbol with
// overload resolution/accessibility errors, or bound to type/constructor and type wasn't creatable.
var symbol = TryGetSymbol(name, symbolInfo, semanticModel);
ClassifiedSpan classifiedSpan;
if (TryClassifySymbol(name, symbol, semanticModel, cancellationToken, out classifiedSpan))
{
result = SpecializedCollections.SingletonEnumerable(classifiedSpan);
return true;
}
result = null;
return false;
}
示例3: Resolve
public override FlatOperand Resolve(ExpressionSyntax expression, ArgumentListSyntax argumentList, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions)
{
FlatOperand fop_subject;
if (expression is IdentifierNameSyntax)
{
// typeof this
fop_subject = FlatOperand.ThisRef(FlatValue.FromType(result_type.ConvertedType));
}
else if (expression is MemberAccessExpressionSyntax)
{
MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)expression;
fop_subject = function.ResolveExpression(meas.Expression, null, instructions);
}
else
{
throw new NotImplementedException("GetMetaTable on expression type " + expression.GetType().ToString());
}
if (into_lvalue == null)
{
FlatOperand fop_register = function.AllocateRegister("");
into_lvalue = fop_register.GetLValue(function, instructions);
}
instructions.Add(FlatStatement.GETMETATABLE(into_lvalue, fop_subject));
return into_lvalue.AsRValue(FlatValue.Table());
}
示例4: ToStaticMethodInvocation
static SyntaxNode ToStaticMethodInvocation(SemanticModel model, InvocationExpressionSyntax invocation, MemberAccessExpressionSyntax memberAccess, SymbolInfo invocationRR)
{
var newArgumentList = invocation.ArgumentList.Arguments.ToList();
newArgumentList.Insert(0, SyntaxFactory.Argument(memberAccess.Expression.WithoutLeadingTrivia()));
var newTarget = memberAccess.WithExpression(SyntaxFactory.ParseTypeName(invocationRR.Symbol.ContainingType.ToMinimalDisplayString(model, memberAccess.SpanStart)));
return SyntaxFactory.InvocationExpression(newTarget, SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList<ArgumentSyntax>(newArgumentList)));
}
开发者ID:Kavignon,项目名称:RefactoringEssentials,代码行数:8,代码来源:InvokeAsStaticMethodCodeRefactoringProvider.cs
示例5: CalculatePriceBid
public static double CalculatePriceBid(SymbolInfo symbol)
{
FinancialCalculator financialCalculator = FdkStatic.Calculator;
double? rateK = financialCalculator.CalculateAssetRate(1, symbol.SettlementCurrency, "USD");
if (!rateK.HasValue)
return double.NaN;
return rateK.Value;
}
示例6: Main
static void Main(string[] args)
{
string strConn = ConfigurationManager.ConnectionStrings["DBModel.Properties.Settings.StockDataConnectionString"].ConnectionString;
List<SymbolInfo> symbolList = new List<SymbolInfo>();
//Load Symbols From CSV
using (StreamReader sr = File.OpenText(@"F:\Projects\Git\StockDownloader\LoadSymbol\ETF_List.csv"))
{
var line = sr.ReadLine();
while(line != null)
{
var items = line.Split(new char[] { ',' });
if(items.Length ==4)
{
var si = new SymbolInfo();
si.NativeSymbol = items[0];
si.Name = items[1];
si.Exchange = items[2];
si.NativeCountry = items[3];
if(si.IsValid())
{
symbolList.Add(si);
}
}
line = sr.ReadLine();
}
sr.Close();
}
using (StockDBDataContext dbContext = new StockDBDataContext(strConn))
{
foreach(var si in symbolList)
{
var stockSymbol = dbContext.StockSymbols.Where(s => s.Symbol == si.Symbol).SingleOrDefault();
if(stockSymbol == null)
{
stockSymbol = new StockSymbol() { Symbol = si.Symbol, StockName = si.Name, Country = si.Country, ETF = si.ETF };
dbContext.StockSymbols.InsertOnSubmit(stockSymbol);
}
else
{
stockSymbol.StockName = si.Name;
stockSymbol.Country = si.Country;
stockSymbol.ETF = si.ETF;
}
}
dbContext.SubmitChanges();
}
}
示例7: Add
public void Add(SymbolInfo symbol)
{
if (symbol is SymData32)
Add(((SymData32)symbol).Name, symbol);
else if (symbol is SymGProcRef)
Add(((SymGProcRef)symbol).Name, symbol);
else
throw new ApplicationException("Invalid symbol type in call to GlobalsHash.Add(): " + symbol.ToString());
}
示例8: SymbolInfosAreCompatible
public static bool SymbolInfosAreCompatible(SymbolInfo originalSymbolInfo, SymbolInfo newSymbolInfo, bool performEquivalenceCheck, bool requireNonNullSymbols = false)
{
try {
return (bool)symbolInfosAreCompatibleMethod.Invoke (null, new object [] { originalSymbolInfo, newSymbolInfo, performEquivalenceCheck, requireNonNullSymbols });
} catch (TargetInvocationException ex) {
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
return false;
}
}
示例9: CalculatePipsValue
public static double CalculatePipsValue(SymbolInfo symbol)
{
FinancialCalculator financialCalculator = FdkStatic.Calculator;
int decimals = symbol.Precision;
double contractSize = symbol.ContractMultiplier;
double? rateK = financialCalculator.CalculateAssetRate(1, symbol.SettlementCurrency, "USD");
if (!rateK.HasValue)
throw new InvalidOperationException(
string.Format("No rate for currency pair: {0}/USD", symbol.SettlementCurrency));
double formula = Math.Pow(10, -decimals) * contractSize * rateK.Value;
return formula;
}
示例10: split_lists
public static SymbolInfo split_lists(SymbolInfo si_left,SymbolInfo si_right)
{
if (si_left==null)
{
return si_right;
}
if (si_right==null)
{
return si_left;
}
SymbolInfo si=si_left;
while(si.Next!=null)
{
si=si.Next;
}
si.Next=si_right;
return si_left;
}
示例11: CanRewriteSymbol
// we use the semantic model to get the type information of the method being called
private static bool CanRewriteSymbol(SymbolInfo symbolInfo, out bool appendNewLine)
{
appendNewLine = false;
IMethodSymbol methodSymbol = symbolInfo.Symbol as IMethodSymbol;
if (methodSymbol == null) return false;
switch (methodSymbol.Name)
{
case "AppendLine":
case "Append":
if (methodSymbol.ContainingType.ToString() == "System.Text.StringBuilder")
{
appendNewLine = methodSymbol.Name == "AppendLine";
return true;
}
break;
}
return false;
}
示例12: Resolve
public override FlatOperand Resolve(InvocationExpressionSyntax node, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions)
{
if (!(node.Expression is MemberAccessExpressionSyntax))
{
throw new NotImplementedException("GETPROPERTY not on MemberAccessExpressionSyntax");
}
MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)node.Expression;
FlatOperand fop_subject = function.ResolveExpression(meas.Expression, null, instructions);
if (into_lvalue == null)
{
FlatOperand fop_register = function.AllocateRegister("");
into_lvalue = fop_register.GetLValue(function, instructions);
}
instructions.Add(FlatStatement.STRINGVAL(into_lvalue, fop_subject));
return into_lvalue.AsRValue(FlatValue.String(string.Empty));
}
示例13: TryGetSymbol
private static ISymbol TryGetSymbol(NameSyntax name, SymbolInfo symbolInfo, SemanticModel semanticModel)
{
if (symbolInfo.Symbol == null && symbolInfo.CandidateSymbols.Length > 0)
{
var firstSymbol = symbolInfo.CandidateSymbols[0];
switch (symbolInfo.CandidateReason)
{
case CandidateReason.NotAValue:
return firstSymbol;
case CandidateReason.NotCreatable:
// We want to color types even if they can't be constructed.
if (firstSymbol.IsConstructor() || firstSymbol is ITypeSymbol)
{
return firstSymbol;
}
break;
case CandidateReason.OverloadResolutionFailure:
// If we couldn't bind to a constructor, still classify the type.
if (firstSymbol.IsConstructor())
{
return firstSymbol;
}
break;
case CandidateReason.Inaccessible:
// If a constructor wasn't accessible, still classify the type if it's accessible.
if (firstSymbol.IsConstructor() && semanticModel.IsAccessible(name.SpanStart, firstSymbol.ContainingType))
{
return firstSymbol;
}
break;
}
}
return symbolInfo.Symbol;
}
示例14: add_name
public void add_name(string name,SymbolInfo si)
{
name=name_to_symtab(name);
object o=ht[name];
if (o==null)
{
SymbolInfoArrayList syal=new SymbolInfoArrayList();
syal.Add(si);
ht[name]=syal;
return;
}
else
{
/*if (si.symbol_kind==symbol_kind.sk_none)
{
throw new CompilerInternalError("Duplicate name definition");
}*/
SymbolInfoArrayList syal1=(SymbolInfoArrayList)o;
syal1.Add(si);
return;
}
}
示例15: GetDelegatingConstructor
public static IMethodSymbol GetDelegatingConstructor(
SemanticDocument document,
SymbolInfo symbolInfo,
ISet<IMethodSymbol> candidateInstanceConstructors,
INamedTypeSymbol containingType,
IList<ITypeSymbol> parameterTypes)
{
var symbol = symbolInfo.Symbol as IMethodSymbol;
if (symbol == null && symbolInfo.CandidateSymbols.Length == 1)
{
// Even though the symbol info has a non-viable candidate symbol, we are trying
// to speculate a base constructor invocation from a different position then
// where the invocation to it would be generated. Passed in candidateInstanceConstructors
// actually represent all accessible and invocable constructor symbols. So, we allow
// candidate symbol for inaccessible OR not creatable candidate reason if it is in
// the given candidateInstanceConstructors.
//
// Note: if we get either of these cases, we ensure that we can at least convert
// the parameter types we have to the constructor parameter types. This way we
// don't accidently think we delegate to a constructor in an abstract base class
// when the parameter types don't match.
if (symbolInfo.CandidateReason == CandidateReason.Inaccessible ||
(symbolInfo.CandidateReason == CandidateReason.NotCreatable && containingType.IsAbstract))
{
var method = symbolInfo.CandidateSymbols.Single() as IMethodSymbol;
if (ParameterTypesMatch(document, parameterTypes, method))
{
symbol = method;
}
}
}
if (symbol != null && candidateInstanceConstructors.Contains(symbol))
{
return symbol;
}
return null;
}