本文整理汇总了C#中MonoDevelop.Projects.DotNetProject.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# DotNetProject.GetService方法的具体用法?C# DotNetProject.GetService怎么用?C# DotNetProject.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Projects.DotNetProject
的用法示例。
在下文中一共展示了DotNetProject.GetService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddViewDialog
public AddViewDialog (DotNetProject project)
{
this.project = project;
aspFlavor = project.GetService<AspNetAppProjectFlavor> ();
Build ();
provider = project.LanguageBinding.GetCodeDomProvider ();
var viewEngines = GetProperViewEngines ();
loadedTemplateList = new Dictionary<string, IList<string>> ();
foreach (var engine in viewEngines) {
viewEngineCombo.AppendText (engine);
loadedTemplateList[engine] = aspFlavor.GetCodeTemplates ("AddView", engine);
}
viewEngineCombo.Active = 0;
InitializeTemplateStore (loadedTemplateList);
ContentPlaceHolders = new List<string> ();
string siteMaster = aspFlavor.VirtualToLocalPath ("~/Views/Shared/Site.master", null);
if (project.Files.GetFile (siteMaster) != null)
masterEntry.Text = "~/Views/Shared/Site.master";
placeholderCombo.Model = primaryPlaceholderStore;
UpdateTypePanelSensitivity (null, null);
UpdateMasterPanelSensitivity (null, null);
Validate ();
}
示例2: AddControllerDialog
public AddControllerDialog (DotNetProject project)
{
Build ();
var ext = project.GetService<AspNetAppProjectFlavor> ();
provider = project.LanguageBinding.GetCodeDomProvider ();
loadedTemplateList = ext.GetCodeTemplates ("AddController");
bool foundEmptyTemplate = false;
int templateIndex = 0;
foreach (string file in loadedTemplateList) {
string name = System.IO.Path.GetFileNameWithoutExtension (file);
templateCombo.AppendText (name);
if (!foundEmptyTemplate) {
if (name == "Empty") {
templateCombo.Active = templateIndex;
foundEmptyTemplate = true;
} else
templateIndex++;
}
}
if (!foundEmptyTemplate)
throw new Exception ("The Empty.tt template is missing.");
nameEntry.Text = "Controller";
nameEntry.Position = 0;
Validate ();
}
示例3: GenerateCodeBehind
public static BuildResult GenerateCodeBehind (
DotNetProject project,
string filename,
WebFormsParsedDocument document,
out CodeCompileUnit ccu)
{
ccu = null;
var result = new BuildResult ();
string className = document.Info.InheritedClass;
AddErrorsToResult (result, filename, document.GetErrorsAsync().Result);
if (result.ErrorCount > 0)
return result;
if (string.IsNullOrEmpty (className))
return result;
var refman = new WebFormsTypeContext { Project = project, Doc = document };
refman.CreateCompilation (default(CancellationToken)).Wait ();
var memberList = new WebFormsMemberListBuilder (refman, document.XDocument);
memberList.Build ();
AddErrorsToResult (result, filename, memberList.Errors);
if (result.ErrorCount > 0)
return result;
//initialise the generated type
ccu = new CodeCompileUnit ();
var namespac = new CodeNamespace ();
ccu.Namespaces.Add (namespac);
var typeDecl = new CodeTypeDeclaration {
IsClass = true,
IsPartial = true,
};
namespac.Types.Add (typeDecl);
//name the class and namespace
int namespaceSplit = className.LastIndexOf ('.');
if (namespaceSplit > -1) {
namespac.Name = project.StripImplicitNamespace (className.Substring (0, namespaceSplit));
typeDecl.Name = className.Substring (namespaceSplit + 1);
} else {
typeDecl.Name = className;
}
string masterTypeName = null;
if (!String.IsNullOrEmpty (document.Info.MasterPageTypeName)) {
masterTypeName = document.Info.MasterPageTypeName;
} else if (!String.IsNullOrEmpty (document.Info.MasterPageTypeVPath)) {
try {
var ext = project.GetService<AspNetAppProjectFlavor> ();
ProjectFile resolvedMaster = ext.ResolveVirtualPath (document.Info.MasterPageTypeVPath, document.FileName);
WebFormsParsedDocument masterParsedDocument = null;
if (resolvedMaster != null)
masterParsedDocument = TypeSystemService.ParseFile (project, resolvedMaster.FilePath).Result as WebFormsParsedDocument;
if (masterParsedDocument != null && !String.IsNullOrEmpty (masterParsedDocument.Info.InheritedClass))
masterTypeName = masterParsedDocument.Info.InheritedClass;
} catch (Exception ex) {
LoggingService.LogWarning ("Error resolving master page type", ex);
}
if (string.IsNullOrEmpty (masterTypeName)) {
var msg = string.Format ("Could not find type for master '{0}'", document.Info.MasterPageTypeVPath);
result.AddError (filename, msg);
return result;
}
}
if (masterTypeName != null) {
var masterProp = new CodeMemberProperty {
Name = "Master",
Type = new CodeTypeReference (masterTypeName),
HasGet = true,
HasSet = false,
Attributes = MemberAttributes.Public | MemberAttributes.New | MemberAttributes.Final,
};
masterProp.GetStatements.Add (new CodeMethodReturnStatement (
new CodeCastExpression (masterTypeName,
new CodePropertyReferenceExpression (
new CodeBaseReferenceExpression (), "Master"))));
typeDecl.Members.Add (masterProp);
}
//shortcut building the existing members type map
if (memberList.Members.Count == 0)
return result;
var cls = refman.GetTypeByMetadataName (className);
var members = GetDesignerMembers (memberList.Members.Values, cls, filename);
//add fields for each control in the page
foreach (var member in members) {
var type = new CodeTypeReference (member.Type.ToDisplayString (SymbolDisplayFormat.CSharpErrorMessageFormat));
typeDecl.Members.Add (new CodeMemberField (type, member.Name) { Attributes = MemberAttributes.Family });
}
return result;
}