本文整理匯總了C#中System.App.IsAbstractApp方法的典型用法代碼示例。如果您正苦於以下問題:C# App.IsAbstractApp方法的具體用法?C# App.IsAbstractApp怎麽用?C# App.IsAbstractApp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.App
的用法示例。
在下文中一共展示了App.IsAbstractApp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Parse
/// <summary>
/// Constructs App from the manifest
/// </summary>
/// <param name="root">Root of the manifest xml</param>
/// <returns>App object</returns>
public static App Parse(XmlDocument root)
{
#region argument
if (root == null)
{
throw new ArgumentNullException("root");
}
#endregion
XmlNode manifest = root.SelectSingleNode("manifest");
App app = new App();
try
{
app.Name = manifest.SelectSingleNode("name").InnerText;
app.Publisher = manifest.SelectSingleNode("publisher").InnerText;
app.Description = manifest.SelectSingleNode("description").InnerText;
app.UniqueId = new Guid(manifest.SelectSingleNode("uniqueid").InnerText);
app.Version = Version.Parse(manifest.SelectSingleNode("version").InnerText);
app.Scope = (AppScope)Enum.Parse(typeof(AppScope), manifest.SelectSingleNode("scope").InnerText, true);
app.File = manifest.SelectSingleNode("file").Attributes["name"].Value;
}
catch (NullReferenceException)
{
throw new MessageException(ResourceManager.GetMessage(AppsMessages.ManadatoryFieldsMissing));
}
// for abstract apps, file entry must be defined.
if (app.IsAbstractApp())
{
try
{
app.FileEntry = manifest.SelectSingleNode("file").Attributes["entry"].Value;
}
catch (NullReferenceException)
{
throw new MessageException(ResourceManager.GetMessage(AppsMessages.ManadatoryFieldsMissing));
}
// make sure the file is an assembly extension.
if (!app.File.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
{
throw new MessageException(ResourceManager.GetMessage(AppsMessages.FileNameMustBeAssembly));
}
}
XmlNode node = manifest.SelectSingleNode("url");
if (node != null)
{
app.Url = node.InnerText;
}
//icon
node = manifest.SelectSingleNode("icon");
if (node != null)
{
app.IconUrl = node.InnerText;
}
//add fields
AddFields(app, manifest);
//add references to the app.
AddReferences(app, manifest);
return app;
}
示例2: GetDefinedApp
private static AbstractApp GetDefinedApp(App app)
{
if (app == null)
{
throw new ArgumentNullException("app");
}
AbstractApp definedApp = null;
if (app.IsAbstractApp())
{
// get the app file and entry.
string file = app.File;
string entry = app.FileEntry;
// load the assembly, it will throw exception if needed.
Assembly assembly = AssemblyUtility.Load(
HttpContext.Current.Server.MapPath(string.Format("{0}/{1}/{2}", SitePaths.App, app.Location, app.File))
);
// load the app from the assembly
Type type = assembly.GetType(entry, false);
if (type == null)
{
// unable to load the class from the assembly
throw new MessageException(
string.Format(ResourceManager.GetLiteral("Admin.Apps.AppEntryNotFound"), entry, app.File)
);
}
// create the abstractapp
try
{
definedApp = Activator.CreateInstance(type) as AbstractApp;
definedApp.InvokedApp = app;
}
catch (Exception exception)
{
// not a valid type for abstractapp
logger.Log(LogLevel.Warn, "Unable to create abstractapp of type : {0}. Exception - {1}", type, exception);
}
if (definedApp == null)
{
// unable to create app
throw new MessageException(
string.Format(ResourceManager.GetLiteral("Admin.Apps.InvalidAppEntry"), app.FileEntry)
);
}
}
else
{
// throw as the app is not of the scope
// that can be translated into AbstractApp.
throw new InvalidOperationException("app");
}
#if DEBUG
if (definedApp == null)
{
//something went wrong
throw new InvalidOperationException("definedApp should not be null now");
}
#endif
return definedApp;
}