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


C# App.IsAbstractApp方法代码示例

本文整理汇总了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;
        }
开发者ID:ratnazone,项目名称:ratna,代码行数:73,代码来源:AppManifestParser.cs

示例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;
        }
开发者ID:ratnazone,项目名称:ratna,代码行数:70,代码来源:AppEngine.cs


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