示例#1
0
        protected override bool AddLookupItems(CSharpCodeCompletionContext context, IItemsCollector collector)
        {
            var rangeMarker = context.BasicContext.CaretDocumentOffset.CreateRangeMarker();

            foreach (var kc in KeyUtilities.EnumerateKeyContainers("Microsoft Strong Cryptographic Provider"))
            {
                var cspParameters = new CspParameters {
                    KeyContainerName = kc, Flags = CspProviderFlags.UseMachineKeyStore
                };
                using (var prov = new RSACryptoServiceProvider(cspParameters))
                {
                    if (!prov.CspKeyContainerInfo.Exportable)
                    {
                        continue;
                    }

                    var kp = new StrongNameKeyPair(prov.ExportCspBlob(true));
                    if (kp.PublicKey.Length != 160)
                    {
                        continue;
                    }

                    var lookupItem = new SimpleTextLookupItem($"\"{kc}\"", rangeMarker);
                    lookupItem.InitializeRanges(context.EvaluateRanges(), context.BasicContext);
                    collector.Add(lookupItem);
                }
            }

            return(true);
        }
示例#2
0
        protected override bool AddLookupItems(NitraCodeCompletionContext context, GroupedItemsCollector collector)
        {
            var documentRange      = context.CompletedElementRange.ReplaceRange;
            var replaceRangeMarker = documentRange.CreateRangeMarker(context.BasicContext.Document);

            foreach (var complationItem in context.ComplationItems)
            {
                string content     = null;
                string description = null;

                var symbol = complationItem as DeclarationSymbol;
                if (symbol != null && symbol.IsNameValid)
                {
                    content     = symbol.Name;
                    description = symbol.Kind;
                }

                var literal = complationItem as string;
                if (literal != null)
                {
                    content     = literal;
                    description = "keyword or literal";
                }

                if (!string.IsNullOrEmpty(content) && content[0] != '#')
                {
                    var item = new SimpleTextLookupItem(content, replaceRangeMarker);
                    item.InitializeRanges(context.CompletedElementRange, context.BasicContext);
                    var rr = item.Ranges;
                    collector.Add(item);
                }
            }
            return(true);
        }