本文整理汇总了C#中SymbolInfo类的典型用法代码示例。如果您正苦于以下问题:C# SymbolInfo类的具体用法?C# SymbolInfo怎么用?C# SymbolInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SymbolInfo类属于命名空间,在下文中一共展示了SymbolInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:ihalankou,项目名称:FdkUtilities,代码行数:7,代码来源:Level2.cs
示例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;
}
开发者ID:jkotas,项目名称:roslyn,代码行数:26,代码来源:NameSyntaxClassifier.cs
示例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());
}
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:27,代码来源:Intrinsics.cs
示例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;
}
开发者ID:ihalankou,项目名称:rFdk,代码行数:8,代码来源:FdkSymbolInfo.cs
示例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();
}
}
开发者ID:henrylanca,项目名称:StockDownloader,代码行数:58,代码来源:Program.cs
示例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());
}
开发者ID:0unit,项目名称:map2dbg,代码行数:9,代码来源:PdbUtils.cs
示例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;
}
}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:9,代码来源:SpeculationAnalyzer.cs
示例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;
}
开发者ID:ihalankou,项目名称:rFdk,代码行数:12,代码来源:FdkSymbolInfo.cs
示例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;
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:18,代码来源:NVSymbolTable.cs
示例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;
}
开发者ID:m0sa,项目名称:PrecompilationDemo,代码行数:20,代码来源:StringBuilderInterpolationOptimizer.cs
示例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));
}
开发者ID:Noob536,项目名称:ls2csc,代码行数:19,代码来源:Intrinsics.cs
示例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;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:42,代码来源:NameSyntaxClassifier.cs
示例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;
}
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:22,代码来源:NVSymbolTable.cs
示例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;
}
开发者ID:hbarve1,项目名称:roslyn,代码行数:39,代码来源:GenerateConstructorHelpers.cs
示例16: ImportStaticClassWithUsing
Document ImportStaticClassWithUsing(Document document, SemanticModel model, SyntaxNode root, SyntaxNode node, SymbolInfo info, CancellationToken cancellationToken)
{
var cu = root as CompilationUnitSyntax;
var visitor = new SearchImportReplacementsVisitor(model, info, cancellationToken);
visitor.Visit(root);
cu = (CompilationUnitSyntax)root.TrackNodes(visitor.ReplaceNodes);
foreach (var ma in visitor.ReplaceNodes)
{
var current = cu.GetCurrentNode<MemberAccessExpressionSyntax>(ma);
cu = cu.ReplaceNode(current, current.Name.WithAdditionalAnnotations(Formatter.Annotation));
}
var staticUsing = SyntaxFactory
.UsingDirective(SyntaxFactory.ParseName(info.Symbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat)))
.WithStaticKeyword(SyntaxFactory.Token(SyntaxKind.StaticKeyword))
.WithAdditionalAnnotations(Formatter.Annotation);
cu = cu.AddUsingDirective(staticUsing, node, true);
return document.WithSyntaxRoot(cu);
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:22,代码来源:ImportStaticClassWithUsingCodeRefactoringProvider.cs
示例17: GetDelegatingConstructor
public static IMethodSymbol GetDelegatingConstructor(SymbolInfo symbolInfo, ISet<IMethodSymbol> candidateInstanceConstructors, INamedTypeSymbol containingType)
{
var symbol = symbolInfo.Symbol as IMethodSymbol;
if (symbol == null && symbolInfo.CandidateSymbols.Count() == 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.
if (symbolInfo.CandidateReason == CandidateReason.Inaccessible ||
(symbolInfo.CandidateReason == CandidateReason.NotCreatable && containingType.IsAbstract))
{
symbol = symbolInfo.CandidateSymbols.Single() as IMethodSymbol;
}
}
if (symbol != null && candidateInstanceConstructors.Contains(symbol))
{
return symbol;
}
return null;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:23,代码来源:GenerateConstructorHelpers.cs
示例18: Find
/*public override base_scope top_scope
{
get
{
return _up_scope;
}
}*/
public override SymbolInfo Find(string name)
{
SymbolInfo si=null;
if (NetHelper.IsNetNamespace(name.ToLower()) == true)
{
compiled_namespace_node cnn = new compiled_namespace_node(name);
si = new SymbolInfo(cnn);
}
else
{
//Type t = Type.GetType("System."+name,false,true);
Type t=null;
int i=0;
t = NetHelper.FindType(name);
if (t != null)
{
compiled_type_node ctn = compiled_type_node.get_type_node(t);
ctn.Scope = new NetTypeScope(ctn.compiled_type);
si = new SymbolInfo(ctn);
}
else {
while ((t==null)&&(i<_unar.Count))
{
t=_assembly.GetType(_unar[i].namespace_name+"."+name,false,true);
i++;
}
if (t != null)
{
compiled_type_node ctn = compiled_type_node.get_type_node(t);
ctn.Scope = new NetTypeScope(ctn.compiled_type);
si = new SymbolInfo(ctn);
NetHelper.AddType(name,t);
}
}
}
return si;
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:45,代码来源:NetHelper.bak.cs
示例19: GetSymbolsOffOfBoundExpression
private static ImmutableArray<ISymbol> GetSymbolsOffOfBoundExpression(
CSharpSyntaxContext context,
ExpressionSyntax originalExpression,
ExpressionSyntax expression,
SymbolInfo leftHandBinding,
INamespaceOrTypeSymbol container,
CancellationToken cancellationToken)
{
var useBaseReferenceAccessibility = false;
var excludeInstance = false;
var excludeStatic = false;
var symbol = leftHandBinding.GetBestOrAllSymbols().FirstOrDefault();
if (symbol != null)
{
// If the thing on the left is a type, namespace or alias and the original
// expression was parenthesized, we shouldn't show anything in IntelliSense.
if (originalExpression.IsKind(SyntaxKind.ParenthesizedExpression) &&
symbol.MatchesKind(SymbolKind.NamedType,
SymbolKind.Namespace,
SymbolKind.Alias))
{
return ImmutableArray<ISymbol>.Empty;
}
// If the thing on the left is a lambda expression, we shouldn't show anything.
if (symbol.Kind == SymbolKind.Method &&
((IMethodSymbol)symbol).MethodKind == MethodKind.AnonymousFunction)
{
return ImmutableArray<ISymbol>.Empty;
}
// If the thing on the left is an event that can't be used as a field, we shouldn't show anything
if (symbol.Kind == SymbolKind.Event &&
!context.SemanticModel.IsEventUsableAsField(originalExpression.SpanStart, (IEventSymbol)symbol))
{
return ImmutableArray<ISymbol>.Empty;
}
// If the thing on the left is a this parameter (e.g. this or base) and we're in a static context,
// we shouldn't show anything
if (symbol.IsThisParameter() &&
expression.IsInStaticContext())
{
return ImmutableArray<ISymbol>.Empty;
}
// What is the thing on the left?
switch (symbol.Kind)
{
case SymbolKind.NamedType:
case SymbolKind.Namespace:
excludeInstance = true;
container = (INamespaceOrTypeSymbol)symbol;
break;
case SymbolKind.Alias:
excludeInstance = true;
container = ((IAliasSymbol)symbol).Target;
break;
case SymbolKind.Parameter:
var parameter = (IParameterSymbol)symbol;
excludeStatic = true;
// case:
// base.|
if (parameter.IsThis && !object.Equals(parameter.Type, container))
{
useBaseReferenceAccessibility = true;
}
break;
default:
excludeStatic = true;
break;
}
}
else if (container != null)
{
excludeStatic = true;
}
else
{
return ImmutableArray<ISymbol>.Empty;
}
Debug.Assert(!excludeInstance || !excludeStatic);
Debug.Assert(!excludeInstance || !useBaseReferenceAccessibility);
// nameof(X.|
// Show static and instance members.
if (context.IsNameOfContext)
{
excludeInstance = false;
excludeStatic = false;
}
//.........这里部分代码省略.........
开发者ID:orthoxerox,项目名称:roslyn,代码行数:101,代码来源:CSharpRecommendationService.cs
示例20: GetSymbolInfoWorker
internal override SymbolInfo GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
ValidateSymbolInfoOptions(options);
// in case this is right side of a qualified name or member access (or part of a cref)
node = SyntaxFactory.GetStandaloneNode(node);
var model = this.GetMemberModel(node);
SymbolInfo result;
XmlNameAttributeSyntax attrSyntax;
CrefSyntax crefSyntax;
if (model != null)
{
// Expression occurs in an executable code (method body or initializer) context. Use that
// model to get the information.
result = model.GetSymbolInfoWorker(node, options, cancellationToken);
// If we didn't get anything and were in Type/Namespace only context, let's bind normally and see
// if any symbol comes out.
if ((object)result.Symbol == null && result.CandidateReason == CandidateReason.None && node is ExpressionSyntax && SyntaxFacts.IsInNamespaceOrTypeContext((ExpressionSyntax)node))
{
var binder = this.GetEnclosingBinder(GetAdjustedNodePosition(node));
if (binder != null)
{
// Wrap the binder in a LocalScopeBinder because Binder.BindExpression assumes there
// will be one in the binder chain and one isn't necessarily required for the batch case.
binder = new LocalScopeBinder(binder);
var diagnostics = DiagnosticBag.GetInstance();
BoundExpression bound = binder.BindExpression((ExpressionSyntax)node, diagnostics);
diagnostics.Free();
SymbolInfo info = GetSymbolInfoForNode(options, bound, bound, boundNodeForSyntacticParent: null, binderOpt: null);
if ((object)info.Symbol != null)
{
result = new SymbolInfo(null, ImmutableArray.Create<ISymbol>(info.Symbol), CandidateReason.NotATypeOrNamespace);
}
else if (!info.CandidateSymbols.IsEmpty)
{
result = new SymbolInfo(null, info.CandidateSymbols, CandidateReason.NotATypeOrNamespace);
}
}
}
}
else if (node.Parent.Kind() == SyntaxKind.XmlNameAttribute && (attrSyntax = (XmlNameAttributeSyntax)node.Parent).Identifier == node)
{
result = SymbolInfo.None;
var binder = this.GetEnclosingBinder(GetAdjustedNodePosition(node));
if (binder != null)
{
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
var symbols = binder.BindXmlNameAttribute(attrSyntax, ref useSiteDiagnostics);
// NOTE: We don't need to call GetSymbolInfoForSymbol because the symbols
// can only be parameters or type parameters.
Debug.Assert(symbols.All(s => s.Kind == SymbolKind.TypeParameter || s.Kind == SymbolKind.Parameter));
switch (symbols.Length)
{
case 0:
result = SymbolInfo.None;
break;
case 1:
result = SymbolInfoFactory.Create(symbols, LookupResultKind.Viable, isDynamic: false);
break;
default:
result = SymbolInfoFactory.Create(symbols, LookupResultKind.Ambiguous, isDynamic: false);
break;
}
}
}
else if ((crefSyntax = node as CrefSyntax) != null)
{
int adjustedPosition = GetAdjustedNodePosition(crefSyntax);
result = GetCrefSymbolInfo(adjustedPosition, crefSyntax, options, HasParameterList(crefSyntax));
}
else
{
// if expression is not part of a member context then caller may really just have a
// reference to a type or namespace name
var symbol = GetSemanticInfoSymbolInNonMemberContext(node, bindVarAsAliasFirst: (options & SymbolInfoOptions.PreserveAliases) != 0);
result = (object)symbol != null ? GetSymbolInfoForSymbol(symbol, options) : SymbolInfo.None;
}
return result;
}
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:90,代码来源:SyntaxTreeSemanticModel.cs
注:本文中的SymbolInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论