本文整理汇总了C#中ResolutionContext类的典型用法代码示例。如果您正苦于以下问题:C# ResolutionContext类的具体用法?C# ResolutionContext怎么用?C# ResolutionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolutionContext类属于命名空间,在下文中一共展示了ResolutionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteCommand
public async override Task ExecuteCommand()
{
CalculateEffectivePackageSaveMode();
string installPath = ResolveInstallPath();
var packageSourceProvider = new NuGet.Configuration.PackageSourceProvider(Settings);
var sourceRepositoryProvider = new SourceRepositoryProvider(packageSourceProvider, ResourceProviders);
IEnumerable<SourceRepository> primarySources;
IEnumerable<SourceRepository> secondarySources;
GetEffectiveSources(sourceRepositoryProvider, out primarySources, out secondarySources);
if(Arguments.Count == 0)
{
throw new InvalidOperationException(NuGetResources.InstallCommandPackageIdMustBeProvided);
}
string packageId = Arguments[0];
NuGetPackageManager packageManager = new NuGetPackageManager(sourceRepositoryProvider, installPath);
ResolutionContext resolutionContext = new ResolutionContext(dependencyBehavior: DependencyBehavior, includePrelease: Prerelease);
FolderNuGetProject nugetProject = new FolderNuGetProject(installPath);
nugetProject.PackageSaveMode = EffectivePackageSaveMode;
if (Version == null)
{
await packageManager.InstallPackageAsync(nugetProject, packageId, resolutionContext, new Common.Console(),
primarySources, secondarySources, CancellationToken.None);
}
else
{
await packageManager.InstallPackageAsync(nugetProject, new PackageIdentity(packageId, new NuGetVersion(Version)), resolutionContext,
new Common.Console(), primarySources, secondarySources, CancellationToken.None);
}
}
示例2: EnumChildren
public static void EnumChildren(ICompletionDataGenerator cdgen,ResolutionContext ctxt, UserDefinedType udt, bool isVarInstance,
MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums)
{
var scan = new MemberCompletionEnumeration(ctxt, cdgen) { isVarInst = isVarInstance };
scan.DeepScanClass(udt, vis);
}
示例3: Evaluation
Evaluation(AbstractSymbolValueProvider vp) {
this.ValueProvider = vp;
if(vp!=null)
vp.ev = this;
this.eval = true;
this.ctxt = vp.ResolutionContext;
}
示例4: ResolutionResult
private ResolutionResult(object value, ResolutionContext context, Type memberType)
{
Value = value;
Context = context;
Type = ResolveType(value, memberType);
MemberType = memberType;
}
示例5: IsMatch
public bool IsMatch(ResolutionContext context)
{
return context.DestinationType.IsAssignableFrom(context.SourceType)
&& context.DestinationType.IsArray
&& context.SourceType.IsArray
&& !ElementsExplicitlyMapped(context);
}
示例6: UFCSResolver
UFCSResolver(ResolutionContext ctxt, ISemantic firstArg, int nameHash = 0, ISyntaxRegion sr = null)
: base(ctxt)
{
this.firstArgument = firstArg;
this.nameFilterHash = nameHash;
this.sr = sr;
}
示例7: Convert
public object Convert(Type enumSourceType, Type enumDestinationType, ResolutionContext context)
{
Type underlyingSourceType = Enum.GetUnderlyingType(enumSourceType);
var underlyingSourceValue = System.Convert.ChangeType(context.SourceValue, underlyingSourceType);
return Enum.ToObject(context.DestinationType, underlyingSourceValue);
}
示例8: GetStringType
public static ArrayType GetStringType(ResolutionContext ctxt, LiteralSubformat fmt = LiteralSubformat.Utf8)
{
ArrayType _t = null;
if (ctxt != null && ctxt.ScopedBlock != null)
{
var obj = ctxt.ParseCache.LookupModuleName(ctxt.ScopedBlock.NodeRoot as DModule, "object").FirstOrDefault();
if (obj != null)
{
string strType = fmt == LiteralSubformat.Utf32 ? "dstring" :
fmt == LiteralSubformat.Utf16 ? "wstring" :
"string";
var strNode = obj[strType];
if (strNode != null)
foreach (var n in strNode) {
_t = TypeDeclarationResolver.HandleNodeMatch(n, ctxt) as ArrayType;
if (_t != null)
break;
}
}
}
if (_t == null)
{
var ch = fmt == LiteralSubformat.Utf32 ? DTokens.Dchar :
fmt == LiteralSubformat.Utf16 ? DTokens.Wchar : DTokens.Char;
_t = new ArrayType(new PrimitiveType(ch, DTokens.Immutable));
}
return _t;
}
示例9: SearchForClassDerivatives
public static IEnumerable<TemplateIntermediateType> SearchForClassDerivatives(TemplateIntermediateType t, ResolutionContext ctxt)
{
if (!(t is ClassType || t is InterfaceType))
throw new ArgumentException ("t is expected to be a class or an interface, not " + (t != null ? t.ToString () : "null"));
var f = new ClassInterfaceDerivativeFinder (ctxt);
f.typeNodeToFind = t.Definition;
var bt = t;
while (bt != null) {
f.alreadyResolvedClasses.Add (bt.Definition);
bt = DResolver.StripMemberSymbols (bt.Base) as TemplateIntermediateType;
}
var filter = MemberFilter.Classes;
if (t is InterfaceType) // -> Only interfaces can inherit interfaces. Interfaces cannot be subclasses of classes.
{
filter |= MemberFilter.Interfaces;
f.isInterface = true;
}
f.IterateThroughScopeLayers (t.Definition.Location, filter);
return f.results; // return them.
}
示例10: ResolutionResult
private ResolutionResult(object value, ResolutionContext context)
{
_value = value;
_context = context;
_type = ResolveType(value, typeof(object));
_memberType = _type;
}
示例11: GetDoneVersionDebugSpecs
static void GetDoneVersionDebugSpecs(ConditionSet cs, MutableConditionFlagSet l, DBlockNode m, ResolutionContext ctxt)
{
if (m.StaticStatements == null || m.StaticStatements.Count == 0)
return;
foreach(var ss in m.StaticStatements)
{
if(ss is VersionSpecification)
{
var vs = (VersionSpecification)ss;
if(!_checkForMatchinSpecConditions(m,cs,ss,ctxt))
continue;
if(vs.SpecifiedId==null)
l.AddVersionCondition(vs.SpecifiedNumber);
else
l.AddVersionCondition(vs.SpecifiedId);
}
else if(ss is DebugSpecification)
{
var ds = (DebugSpecification)ss;
if(!_checkForMatchinSpecConditions(m,cs,ss, ctxt))
continue;
if (ds.SpecifiedId == null)
l.AddDebugCondition(ds.SpecifiedDebugLevel);
else
l.AddDebugCondition(ds.SpecifiedId);
}
}
}
示例12: InstallPackageByIdentityAsync
/// <summary>
/// Install package by Identity
/// </summary>
/// <param name="project"></param>
/// <param name="identity"></param>
/// <param name="resolutionContext"></param>
/// <param name="projectContext"></param>
/// <param name="isPreview"></param>
/// <param name="isForce"></param>
/// <param name="uninstallContext"></param>
/// <returns></returns>
protected async Task InstallPackageByIdentityAsync(NuGetProject project, PackageIdentity identity, ResolutionContext resolutionContext, INuGetProjectContext projectContext, bool isPreview, bool isForce = false, UninstallationContext uninstallContext = null)
{
List<NuGetProjectAction> actions = new List<NuGetProjectAction>();
// For Install-Package -Force
if (isForce)
{
PackageReference installedReference = project.GetInstalledPackagesAsync(CancellationToken.None).Result.Where(p =>
StringComparer.OrdinalIgnoreCase.Equals(identity.Id, p.PackageIdentity.Id)).FirstOrDefault();
if (installedReference != null)
{
actions.AddRange(await PackageManager.PreviewUninstallPackageAsync(project, installedReference.PackageIdentity, uninstallContext, projectContext, CancellationToken.None));
}
NuGetProjectAction installAction = NuGetProjectAction.CreateInstallProjectAction(identity, ActiveSourceRepository);
actions.Add(installAction);
}
else
{
actions.AddRange(await PackageManager.PreviewInstallPackageAsync(project, identity, resolutionContext, projectContext, ActiveSourceRepository, null, CancellationToken.None));
}
if (isPreview)
{
PreviewNuGetPackageActions(actions);
}
else
{
await PackageManager.ExecuteNuGetProjectActionsAsync(project, actions, this, CancellationToken.None);
}
}
示例13: IsMatch
public bool IsMatch(ResolutionContext context)
{
if (context == null) throw new ArgumentNullException("context");
bool toEnum = false;
return EnumToStringMapping(context, ref toEnum) || EnumToEnumMapping(context) || EnumToUnderlyingTypeMapping(context, ref toEnum);
}
示例14: Scan
/// <summary>
/// </summary>
/// <param name="ast">The syntax tree to scan</param>
/// <param name="symbol">Might not be a child symbol of ast</param>
/// <param name="ctxt">The context required to search for symbols</param>
/// <returns></returns>
public static IEnumerable<ISyntaxRegion> Scan(DModule ast, INode symbol, ResolutionContext ctxt, bool includeDefinition = true)
{
if (ast == null || symbol == null || ctxt == null)
return null;
var f = new ReferencesFinder(symbol, ast, ctxt);
using(ctxt.Push(ast))
ast.Accept (f);
var nodeRoot = symbol.NodeRoot as DModule;
if (includeDefinition && nodeRoot != null && nodeRoot.FileName == ast.FileName)
{
var dc = symbol.Parent as DClassLike;
if (dc != null && dc.ClassType == D_Parser.Parser.DTokens.Template &&
dc.NameHash == symbol.NameHash)
{
f.l.Insert(0, new IdentifierDeclaration(dc.NameHash)
{
Location = dc.NameLocation,
EndLocation = new CodeLocation(dc.NameLocation.Column + dc.Name.Length, dc.NameLocation.Line)
});
}
f.l.Insert(0, new IdentifierDeclaration(symbol.NameHash)
{
Location = symbol.NameLocation,
EndLocation = new CodeLocation(symbol.NameLocation.Column + symbol.Name.Length, symbol.NameLocation.Line)
});
}
return f.l;
}
示例15: IsMatch
public bool IsMatch(ResolutionContext context)
{
return typeof (LambdaExpression).IsAssignableFrom(context.SourceType)
&& context.SourceType != typeof (LambdaExpression)
&& typeof (LambdaExpression).IsAssignableFrom(context.DestinationType)
&& context.DestinationType != typeof (LambdaExpression);
}