本文整理汇总了C#中MonoDevelop.Projects.DotNetProject.StripImplicitNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# DotNetProject.StripImplicitNamespace方法的具体用法?C# DotNetProject.StripImplicitNamespace怎么用?C# DotNetProject.StripImplicitNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Projects.DotNetProject
的用法示例。
在下文中一共展示了DotNetProject.StripImplicitNamespace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}