本文整理汇总了C#中IDataContext.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.GetComponent方法的具体用法?C# IDataContext.GetComponent怎么用?C# IDataContext.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataContext
的用法示例。
在下文中一共展示了IDataContext.GetComponent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateContent
protected override string GenerateContent(IDataContext context, string outputFolder)
{
var bound = context.GetComponent<ISettingsStore>().BindToContextTransient(ContextRange.ApplicationWide);
foreach (TemplateApplicability applicability in Enum.GetValues(typeof(TemplateApplicability)))
CreateXml(applicability, bound, outputFolder, GeneralHelpers.GetCurrentVersion(), context);
return "Code templates";
}
示例2: GenerateContent
protected override string GenerateContent(IDataContext context, string outputFolder)
{
const string caTopicId = "CA_Chunks";
var caLibrary = XmlHelpers.CreateHmTopic(caTopicId);
var tablesByLanguage = new Dictionary<string, XElement>();
var sortedActions = context.GetComponent<IContextActionTable>().AllActions.OrderBy(ca => ca.Name);
var caPath = GeneralHelpers.GetCaPath(context);
caLibrary.Root.Add(
new XComment("Total context actions in ReSharper " +
GeneralHelpers.GetCurrentVersion() + ": " +
sortedActions.Count()));
foreach (var ca in sortedActions)
{
var lang = ca.Group ?? "Unknown";
if (!tablesByLanguage.ContainsKey(lang))
tablesByLanguage.Add(lang,
XmlHelpers.CreateTwoColumnTable("Name",
"Description", "40%"));
var exampleTable = ExtractExamples(ca, caPath, lang);
tablesByLanguage.GetValue(lang).Add(new XElement("tr",
new XElement("td", new XElement("b", ca.Name)),
new XElement("td",
ca.Description ?? "", exampleTable,
XmlHelpers.CreateInclude("CA_Static_Chunks",
ca.MergeKey.NormalizeStringForAttribute()))));
}
foreach (var table in tablesByLanguage)
{
var languageChunk =
XmlHelpers.CreateChunk("ca_" +
table.Key
.NormalizeStringForAttribute());
string langText = table.Key == "Common"
? "common use"
: table.Key;
languageChunk.Add(new XElement("p",
"ReSharper provides the following context actions for " +
langText + ":"));
languageChunk.Add(table.Value);
caLibrary.Root.Add(languageChunk);
}
caLibrary.Save(Path.Combine(outputFolder, caTopicId + ".xml"));
return "Context actions";
}
示例3: Execute
public void Execute(IDataContext context, DelegateExecute nextExecute)
{
var solution = context.GetData(ProjectModelConstants.SOLUTION);
if (solution == null)
{
MessageBox.ShowError("Cannot execute the Go To action because there's no solution open.");
return;
}
var definition = Lifetimes.Define(solution.GetLifetime());
var locks = Shell.Instance.GetComponent<IShellLocks>();
var tasks = Shell.Instance.GetComponent<ITaskHost>();
TipsManager.Instance.FeatureIsUsed("LocateFileInSolutionExplorer", (string)null);
var controller = new LocateFileController(definition.Lifetime, solution, locks, tasks);
EnableShowInFindResults(controller, definition);
new GotoByNameMenu(context.GetComponent<GotoByNameMenuComponent>(),
definition,
controller.Model,
context.GetComponent<UIApplication>().MainWindow,
context.GetData(GotoByNameDataConstants.CurrentSearchText));
}
示例4: GenerateContent
protected override string GenerateContent(IDataContext context, string outputFolder)
{
const string postfixTopicId = "Postfix_Templates_Generated";
var postfixLibrary = XmlHelpers.CreateHmTopic(postfixTopicId);
var postfixChunk = XmlHelpers.CreateChunk("postfix_table");
var macroTable = XmlHelpers.CreateTable(new[] {"Shortcut", "Description", "Example"}, null);
var allSortedPostfix =
context.GetComponent<PostfixTemplatesManager>()
.AllRegisteredPostfixTemplates.OrderBy(template => template.Annotations.TemplateName);
postfixLibrary.Root.Add(
new XComment("Total postifix templates in ReSharper " +
GeneralHelpers.GetCurrentVersion() + ": " + allSortedPostfix.Count()));
foreach (var postTempalte in allSortedPostfix)
{
var postfixRow = new XElement("tr");
var shortcut = postTempalte.Annotations.TemplateName;
var description = postTempalte.Annotations.Description;
var example = postTempalte.Annotations.Example;
var shortcutCell = XElement.Parse("<td><b>." + shortcut + "</b></td>");
shortcutCell.Add(new XAttribute("id", shortcut));
var descriptionCell = XElement.Parse("<td>" + description + "</td>");
var exampleCell = new XElement("td", new XElement("code", example));
postfixRow.Add(shortcutCell, descriptionCell, exampleCell);
macroTable.Add(postfixRow);
}
postfixChunk.Add(macroTable);
postfixLibrary.Root.Add(postfixChunk);
postfixLibrary.Save(Path.Combine(outputFolder, postfixTopicId + ".xml"));
return "Postfix templates";
}
示例5: CreateXml
private void CreateXml(TemplateApplicability applicability, IContextBoundSettingsStore bound,
string saveDirectoryPath, string version, IDataContext context)
{
string type;
ScopeFilter scopeFilter = ScopeFilter.Language;
switch (applicability)
{
case TemplateApplicability.Live:
type = "Live";
break;
case TemplateApplicability.Surround:
type = "Surround";
break;
case TemplateApplicability.File:
type = "File";
scopeFilter = ScopeFilter.Project;
break;
default: return;
}
var topicId = "Reference__Templates_Explorer__" + type + "_Templates";
var fileName = Path.Combine(saveDirectoryPath, topicId + ".xml");
var topic = XmlHelpers.CreateHmTopic(topicId);
var topicRoot = topic.Root;
topicRoot.Add(new XElement("p",
new XElement("menupath", "ReSharper | Templates Explorer | " + type + " Templates")));
topicRoot.Add(new XElement("p",
"This section lists all predefined " + type + " templates in ReSharper " + version + "."));
topicRoot.Add(new XElement("p", XmlHelpers.CreateInclude("Templates__Template_Basics__Template_Types", type)));
var summaryTable = XmlHelpers.CreateTable(new[] {"Template", "Description"}, new[] {"20%", "80%"});
var summaryItems = new List<Tuple<string, XElement>>();
var tables = new Dictionary<string, XElement>();
var defaultTemplates = context.GetComponent<StoredTemplatesProvider>()
.EnumerateTemplates(bound, applicability, false);
var myScopeCategoryManager = context.GetComponent<ScopeCategoryManager>();
foreach (var template in defaultTemplates)
{
var templateIdPresentable = !template.Shortcut.IsNullOrEmpty() ? template.Shortcut : template.Description;
templateIdPresentable = Regex.Replace(templateIdPresentable, "&Enum", "Enum");
var currentTemplateLangs = new List<string>();
var imported = String.Empty;
var scopeString = String.Empty;
var cat = String.Empty;
foreach (var category in template.Categories)
{
if (category.Contains("Imported"))
{
imported = category;
break;
}
if (category.Contains("C#")) cat = "C#";
if (category.Contains("VB.NET")) cat = "VB.NET";
}
foreach (var point in template.ScopePoints)
{
foreach (var provider in myScopeCategoryManager.GetCoveredProviders(scopeFilter, point))
{
var lang = provider.CategoryCaption;
if (lang == "ASP.NET" && type == "Surround" && !cat.IsNullOrEmpty()) { lang = lang + "(" + cat + ")"; }
if (!lang.IsNullOrEmpty())
{
currentTemplateLangs.Add(lang);
if (!tables.ContainsKey(lang)) {
tables.Add(lang, XmlHelpers.CreateTable(new[] {"Template", "Details"}, new[] {"20%", "80%"}));
}
}
}
if (currentTemplateLangs.Count == 0)
{
MessageBox.ShowExclamation(String.Format("The '{0}' template has no associated languages",
templateIdPresentable));
}
scopeString += " " + point.PresentableShortName + ",";
}
scopeString = scopeString.TrimEnd(',');
var paramElement = new XElement("list");
foreach (var param in template.Fields)
{
var expr = param.Expression as MacroCallExpressionNew;
var paramItemElement = new XElement("li", new XElement("code", param.Name));
if (expr != null)
{
var macro = MacroDescriptionFormatter.GetMacroAttribute(expr.Definition);
paramItemElement.Add(" - " + macro.LongDescription + " (",
XmlHelpers.CreateHyperlink(macro.Name, "Template_Macros", macro.Name),
")");
}
else
paramItemElement.Add(" - " + "no macro");
//.........这里部分代码省略.........
示例6: GenerateContent
protected override string GenerateContent(IDataContext context, string outputFolder)
{
var shortcutsXmlDoc = new XDocument();
var actionMapElement = new XElement("Keymap");
shortcutsXmlDoc.Add(actionMapElement);
XmlHelpers.AddAutoGenComment(shortcutsXmlDoc.Root);
const string menuPathLibId = "Menupath_by_ID";
var menuPathLibrary = XmlHelpers.CreateHmTopic(menuPathLibId);
const string accessIntroLibId = "AccessIntro_by_ID";
var accessIntroLibrary = XmlHelpers.CreateHmTopic(accessIntroLibId);
var actionManager = context.GetComponent<IActionManager>();
var productcatalogs = context.GetComponent<IPartCatalogSet>();
var actionParts = PartSelector.LeafsAndHides.SelectParts(
productcatalogs.Catalogs.SelectMany(catalog => catalog.GetPartsWithAttribute<ActionAttribute>().ToEnumerable()))
.ToList();
foreach (PartCatalogType actionPart in actionParts)
{
var attributes = actionPart.GetPartAttributes<ActionAttribute>();
if (attributes.Count == 0)
Assertion.Fail("{0} has no ActionAttribute", actionPart);
if (attributes.Count > 1)
Assertion.Fail("{0} has {1} ActionAttribute annotations. Only one annotation is supported.",
actionPart, attributes.Count);
PartCatalogAttribute attribute = attributes.GetItemAt(0);
var actionId =
(attribute.ArgumentsOptional[ActionAttribute.ActionAttribute_ActionId].GetStringValueIfDefined() ??
StringSource.Empty).ToRuntimeString();
if (actionId.IsEmpty())
actionId = ActionDefines.GetIdFromName(actionPart.LocalName);
var actionText =
(attribute.ArgumentsOptional[ActionAttribute.ActionAttribute_Text].GetStringValueIfDefined() ??
StringSource.Empty).ToRuntimeString();
if (actionText.IsEmpty())
actionText = actionId;
actionText = actionText.Replace("&", String.Empty);
var vsShortcuts =
attribute.ArgumentsOptional[ActionAttribute.ActionAttribute_VsShortcuts].GetArrayValueIfDefined();
var ideaShortcuts =
attribute.ArgumentsOptional[ActionAttribute.ActionAttribute_IdeaShortcuts].GetArrayValueIfDefined();
if (actionId.Equals("CompleteCodeBasic")) vsShortcuts = new object[] { "Control+Space" };
if (actionId.Equals("CompleteStatement")) vsShortcuts = new object[] { "Control+Shift+Enter" };
if (actionId.Equals("CompleteCodeBasic")) ideaShortcuts = new object[] { "Control+Space" };
if (actionId.Equals("CompleteStatement")) ideaShortcuts = new object[] { "Control+Shift+Enter" };
string pathToTheRoot;
try
{
pathToTheRoot =
(context.GetComponent<ActionPresentationHelper>()
.GetPathPresentationToRoot(actionManager.Defs.GetActionDefById(actionId)));
}
catch (Exception e)
{
pathToTheRoot = "";
}
if (!pathToTheRoot.IsEmpty() && !actionText.IsEmpty())
pathToTheRoot = pathToTheRoot.Replace('→', '|') + " | " + actionText;
var actionElement = new XElement("Action");
var pattern = new Regex("[_.]");
actionId = pattern.Replace(actionId, String.Empty);
actionElement.Add(
new XAttribute("id", actionId),
new XAttribute("title", actionText),
new XAttribute("menupath", pathToTheRoot));
var accessIntroChunk = XmlHelpers.CreateChunk(actionId);
var accessIntroWrapper = new XElement("p");
if (!pathToTheRoot.IsNullOrEmpty())
{
var menupPathChunk = XmlHelpers.CreateChunk(actionId);
pathToTheRoot =
pathToTheRoot.Replace("ReSharper | Navigate ", "%navigateMenu%")
.Replace("ReSharper | Windows ", "%windowsMenu%");
menupPathChunk.Add(new XElement("menupath", pathToTheRoot));
accessIntroWrapper.Add(new XElement("menupath", pathToTheRoot));
accessIntroWrapper.Add(new XElement("br"));
menuPathLibrary.Root.Add(menupPathChunk);
}
if (ideaShortcuts != null || vsShortcuts != null)
{
accessIntroWrapper.Add(new XElement("shortcut", new XAttribute("key", actionId)));
accessIntroWrapper.Add(new XElement("br"));
}
accessIntroWrapper.Add(new XElement("code", String.Format("ReSharper_{0}", actionId),
new XAttribute("product", "rs,dcv")));
accessIntroChunk.Add(accessIntroWrapper);
accessIntroLibrary.Root.Add(accessIntroChunk);
AddShortcuts(ideaShortcuts, actionElement, "rs");
AddShortcuts(vsShortcuts, actionElement, "vs");
if (actionId == "ParameterInfoShow")
actionElement.Add(new XElement("Shortcut", "Control+Shift+Space", new XAttribute("layout", "vs")));
//.........这里部分代码省略.........
示例7: GetPathFromSettings
private static string GetPathFromSettings(IDataContext context, Expression<Func<RsDocSettingsKey, string>> expression, string description)
{
var contextBoundSettingsStore =
context.GetComponent<ISettingsStore>().BindToContextTransient(ContextRange.ApplicationWide);
var path = contextBoundSettingsStore.GetValue(expression);
if (string.IsNullOrEmpty(path))
{
using (var brwsr = new FolderBrowserDialog() {Description = description})
{
if (brwsr.ShowDialog() == DialogResult.Cancel) return null;
path = brwsr.SelectedPath;
contextBoundSettingsStore.SetValue(expression, path);
}
}
return path;
}