当前位置: 首页>>代码示例>>C#>>正文


C# IDataContext.GetData方法代码示例

本文整理汇总了C#中IDataContext.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.GetData方法的具体用法?C# IDataContext.GetData怎么用?C# IDataContext.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataContext的用法示例。


在下文中一共展示了IDataContext.GetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resolve

        public void Resolve(IDataContext context, Action<IQuickDocPresenter, PsiLanguageType> resolved)
        {
            var elements = context.GetData(PsiDataConstants.DECLARED_ELEMENTS);
            Assertion.AssertNotNull(elements, "elements != null");

            var document = context.GetData(DocumentModelDataConstants.DOCUMENT);
            IProjectFile projectFile = null;
            if (document != null)
                projectFile = myDocumentManager.TryGetProjectFile(document);

            var defaultLanguage = PresentationUtil.GetPresentationLanguageByContainer(projectFile, mySolution);

            foreach (var element in elements.OfType<IClrDeclaredElement>())
            {
                var eventFunction = GetEventFunction(element);
                if (eventFunction != null)
                {
                    var presenter = new UnityEventFunctionQuickDocPresenter(eventFunction, element, myQuickDocTypeMemberProvider,
                        myTheming, myHelpSystem);
                    resolved(presenter, defaultLanguage);
                    return;
                }

                var eventFunctionForParameter = GetEventFunctionFromParameter(element as IParameter);
                if (eventFunctionForParameter != null)
                {
                    var presenter = new UnityEventFunctionQuickDocPresenter(eventFunctionForParameter, element.ShortName, element,
                        myQuickDocTypeMemberProvider, myTheming, myHelpSystem);
                    resolved(presenter, defaultLanguage);
                    return;
                }
            }
        }
开发者ID:JetBrains,项目名称:resharper-unity,代码行数:33,代码来源:UnityEventFunctionQuickDocProvider.cs

示例2: IsAvailable

        public bool IsAvailable(IDataContext dataContext)
        {
            ISolution solution = dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
            if (solution == null)
                return false;
            #if SDK70
            IDocument document = dataContext.GetData(JetBrains.DocumentModel.DataConstants.DOCUMENT);
            #else
            IDocument document = dataContext.GetData(JetBrains.IDE.DataConstants.DOCUMENT);
            #endif

            if (document == null)
                return false;
            #if SDK70
            DocumentOffset documentOffset = dataContext.GetData(JetBrains.DocumentModel.DataConstants.DOCUMENT_OFFSET);
            #else
            DocumentOffset documentOffset = dataContext.GetData(JetBrains.IDE.DataConstants.DOCUMENT_OFFSET);
            #endif
            if (documentOffset == null)
                return false;
            IPsiSourceFile psiSourceFile = document.GetPsiSourceFile(solution);
            if (psiSourceFile != null)
            {
                // todo make this resolvable also via the AllTypes... line
                var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();

                return solution.GetComponent<SolutionAnalyzer>()
                               .Analyze()
                               .Any(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
            }

            return false;
        }
开发者ID:dpvreony-forks,项目名称:AgentMulder,代码行数:33,代码来源:RegisteredComponentsContextSearch.cs

示例3: GetRegisteredComponentsRequest

        public RegisteredComponentsSearchRequest GetRegisteredComponentsRequest(IDataContext dataContext)
        {
            ISolution solution = dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
            if (solution == null)
            {
                throw new InvalidOperationException("Unable to get the solution");
            }

            var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();

            IDocument document = dataContext.GetData(JetBrains.IDE.DataConstants.DOCUMENT);
            if (document == null)
                return null;

            IPsiSourceFile psiSourceFile = document.GetPsiSourceFile(solution);
            if (psiSourceFile == null)
            {
                return null;
            }

            var registration = solution.GetComponent<IPatternManager>().GetRegistrationsForFile(psiSourceFile)
                .FirstOrDefault(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
            if (registration == null)
            {
                return null;
            }

            return new RegisteredComponentsSearchRequest(solution, locks, registration.Registration);
        }
开发者ID:hmemcpy,项目名称:AgentMulder,代码行数:29,代码来源:RegisteredComponentsContextSearch.cs

示例4: Execute

            public void Execute(IDataContext context, DelegateExecute nextExecute)
            {
                var solution = context.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);
                var textControl = context.GetData(TextControl.DataContext.DataConstants.TEXT_CONTROL);
                if (textControl != null && solution != null && myLookupWindowManager.CurrentLookup == null)
                {
                  const string commandName = "Expand postfix template";
                  var updateCookie = myChangeUnitFactory.CreateChangeUnit(textControl, commandName);
                  try
                  {
                using (myCommandProcessor.UsingCommand(commandName))
                {
                  var template = GetTemplateFromTextControl(textControl, solution);
                  if (template != null)
                  {
                var nameRange = new TextRange(textControl.Caret.PositionValue.ToDocOffset()); // looks wrong?
                // invoke item completion manually
                template.Accept(textControl, nameRange,
                  LookupItemInsertType.Replace, Suffix.Empty, solution, false);
                return;
                  }

                  updateCookie.Dispose();
                }
                  }
                  catch
                  {
                updateCookie.Dispose();
                throw;
                  }
                }

                nextExecute();
            }
开发者ID:Restuta,项目名称:PostfixCompletion,代码行数:34,代码来源:PostfixTemplatesTracker.cs

示例5: CanNavigate

        public bool CanNavigate(IDataContext context)
        {
            var project = context.GetData(ProjectModelDataConstants.PROJECT);
            if (project == null || !project.IsUnityProject()) return false;

            var declaredElements = context.GetData(PsiDataConstants.DECLARED_ELEMENTS);
            return declaredElements != null && declaredElements.Any(e => IsEventFunction(e) || IsParameterForEventFunction(e as IParameter));
        }
开发者ID:JetBrains,项目名称:resharper-unity,代码行数:8,代码来源:UnityEventFunctionQuickDocProvider.cs

示例6: GetElementAtCaret

        /// <summary>
        /// Gets the element at caret.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>The element at caret.</returns>
        protected static IElement GetElementAtCaret(IDataContext context)
        {
            ISolution solution = context.GetData(DataConstants.SOLUTION);
            if (solution == null) {
                return null;
            }

            ITextControl textControl = context.GetData(DataConstants.TEXT_CONTROL);
            if (textControl == null) {
                return null;
            }

            return TextControlToPsi.GetElementFromCaretPosition<IElement>(solution, textControl);
        }
开发者ID:tcabanski,项目名称:SouthSideDevToys,代码行数:19,代码来源:ActionHandlerBase.cs

示例7: GetCandidates

        public IList<IDeclaredElement> GetCandidates(IDataContext context)
        {
            var reference = context.GetData(DataConstants.REFERENCE);
              var rer = reference as INitraAst;
              if (rer != null)
            return new IDeclaredElement[] { reference.Resolve().Result.DeclaredElement };

              var declaredElements = context.GetData(DataConstants.DECLARED_ELEMENTS);

              if (declaredElements != null)
            return declaredElements.ToArray();

              return EmptyList<IDeclaredElement>.InstanceList;
        }
开发者ID:lhsail,项目名称:Nitra,代码行数:14,代码来源:NitraContextSearchImpl.cs

示例8: GetTypeElement

    /// <summary>
    /// Gets type element from context 
    /// </summary>
    /// <param name="context">Action context</param>
    /// <param name="instance">If true, only instance memebers are relevant, e.g. context points to instance of type</param>
    /// <returns>ITypeElement instance or null</returns>
    public static ITypeElement GetTypeElement(IDataContext context, out bool instance)
    {
      // Obtain declared element from context
      // This may be from source code (from caret), or from various tree views displaying elements

      var declaredElements = context.GetData(DataConstants.DECLARED_ELEMENTS);
      if (declaredElements == null || declaredElements.IsEmpty())
      {
        instance = false;
        return null;
      }

      IDeclaredElement declaredElement = declaredElements.First();

      // If we have type, just return it
      var typeElement = declaredElement as ITypeElement;
      if (typeElement != null)
      {
        instance = false;
        return typeElement;
      }

      // If it is constructor, return containing type
      var constructor = declaredElement as IConstructor;
      if (constructor != null)
      {
        instance = false;
        return constructor.GetContainingType();
      }

      // Element has type attached to it, e.g. method return type, property or field type
      var typeOwner = declaredElement as ITypeOwner;
      if (typeOwner != null)
      {
        // It is instance of type, which is returned, so provide caller with this information
        instance = true;
        return GetTypeElement(typeOwner.Type);
      }

      // Try to guess type of expression
      ITextControl textControl = context.GetData(TextControl.DataContext.DataConstants.TEXT_CONTROL);
      ISolution solution = context.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);
      if (textControl != null && solution != null)
      {
        // TODO: Implement expression processing
      }

      instance = false;
      return null;
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:56,代码来源:TypeInterfaceUtil.cs

示例9: CreateWorkflow

 public IEnumerable<IRefactoringWorkflow> CreateWorkflow(IDataContext dataContext)
 {
     yield return new SharedToExtensionWorkflow(
         dataContext.GetData(DataConstants.SOLUTION),
         SharedToExtensionWorkflow.WorkflowDirection.SharedToExtension,
         SharedToExtensionAction.ActionId);
 }
开发者ID:ThatShawGuy,项目名称:VBSharper,代码行数:7,代码来源:SharedToExtensionWorkflowProvider.cs

示例10: Execute

    public void Execute(IDataContext context, DelegateExecute nextExecute)
    {
      // Get solution from context in which action is executed
      ISolution solution = context.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);
      if (solution == null)
        return;

      var documentManager = solution.GetComponent<DocumentManager>();
      var shellLocks = solution.GetComponent<IShellLocks>();
      var settingStore = solution.GetComponent<ISettingsStore>();
      var mainWindow = solution.GetComponent<IMainWindow>();
      
      // Ask user about search string
      FindTextSearchRequest searchRequest;
      using (var dialog = new EnterSearchStringDialog(settingStore.BindToContextTransient(ContextRange.Smart((lt, contexts) => context))))
      {
        if (dialog.ShowDialog(mainWindow) != DialogResult.OK)
          return;

        // Create request, descriptor, perform search and show results 
        searchRequest = new FindTextSearchRequest(solution, dialog.SearchString, dialog.CaseSensitive, dialog.SearchFlags, documentManager);
      }

      using (shellLocks.UsingReadLock())
      {
        var descriptor = new FindTextDescriptor(searchRequest);
        descriptor.Search();
        FindResultsBrowser.ShowResults(descriptor);
      }
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:30,代码来源:FindTextAction.cs

示例11: Initialize

 public override bool Initialize(IDataContext context)
 {
     IDocument data = context.GetData(JetBrains.DocumentModel.DataConstants.DOCUMENT);
     if (data == null) return false;
     Marker = JetBrains.DocumentManagers.RangeMarkerExtentions.CreateRangeMarker(new DocumentRange(data, new TextRange(ITextControlCaretEx.Offset(this.TextControl.Caret))), DocumentManager.GetInstance(Solution));
     return IsAvailable(context);
 }
开发者ID:ulex,项目名称:resharper-introduce-ns-alias,代码行数:7,代码来源:IntoduceNsAliasWorkflow.cs

示例12: Update

      public bool Update(IDataContext dataContext, ActionPresentation presentation, DelegateUpdate nextUpdate)
      {
        var solution = dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
        if (solution == null)
          return nextUpdate();

        var textControl = dataContext.GetData(JetBrains.TextControl.DataContext.DataConstants.TEXT_CONTROL);
        if (textControl == null)
          return nextUpdate();

        var doc = dataContext.GetData(JetBrains.DocumentModel.DataConstants.DOCUMENT);
        if (doc == null)
          return nextUpdate();

        return true;
      }
开发者ID:derigel23,项目名称:Nitra,代码行数:16,代码来源:FindUsagesHandler.cs

示例13: IsAvailable

 // Hides the menu item if it's not a Unity project
 public override bool IsAvailable(IDataContext dataContext)
 {
     var project = dataContext.GetData(ProjectModelDataConstants.PROJECT);
     if (project == null || !project.IsUnityProject())
         return false;
     return base.IsAvailable(dataContext);
 }
开发者ID:JetBrains,项目名称:resharper-unity,代码行数:8,代码来源:GenerateUnityEventFunctionsWorkflow.cs

示例14: Execute

        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            var textControl = context.GetData(DataConstants.TEXT_CONTROL);
            GC.KeepAlive(textControl);

            DateTime lastInvocation, utcNow = DateTime.UtcNow;
            lock (syncLock)
            {
                lastInvocation = this.lastLocateInvocation;
                this.lastLocateInvocation = utcNow;
            }

            const int doubleKeyPressDelay = 500;
            if (utcNow.Subtract(lastInvocation).TotalMilliseconds < doubleKeyPressDelay)
            {
                var locateFileAction = actionManager.TryGetAction(LocateFileAction.Id) as IExecutableAction;
                if (locateFileAction != null)
                {
                    locateFileAction.Execute(context);
                    return;
                }
            }

            if (lastUnderlyingActionUpdate)
            {
                nextExecute();
            }
        }
开发者ID:hmemcpy,项目名称:ReSharper.LocateFileInSolutionExplorer,代码行数:28,代码来源:LocateFileActionHandler.cs

示例15: GetOriginTypeElement

        private static ITypeElement GetOriginTypeElement(IDataContext dataContext, DeclaredElementTypeUsageInfo initialTarget)
        {
            var data = dataContext.GetData(DataConstants.REFERENCES);
            if (data == null) {
                return null;
            }

            foreach (var current in data.OfType<IQualifiableReference>()) {
                if (!Equals(current.Resolve().DeclaredElement, initialTarget)) {
                    continue;
                }

                var qualifierWithTypeElement = current.GetQualifier() as IQualifierWithTypeElement;

                if (qualifierWithTypeElement == null) {
                    continue;
                }

                var qualifierTypeElement = qualifierWithTypeElement.GetQualifierTypeElement();
                if (qualifierTypeElement != null) {
                    return qualifierTypeElement;
                }
            }
            return null;
        }
开发者ID:jcdekoning,项目名称:Teapot,代码行数:25,代码来源:GenericImplementationContextSearch.cs


注:本文中的IDataContext.GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。