コード例 #1
0
ファイル: Application.cs プロジェクト: fmaulanaa/moon
        public static void LoadComponent(object component, Uri resourceLocator)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            if (resourceLocator == null)
            {
                throw new ArgumentNullException("resourceLocator");
            }

            StreamResourceInfo sr = GetResourceStream(resourceLocator);

            if (sr == null)
            {
                // throws for case like a resource outside the XAP (e.g. DRT924) i.e. no assembly specified
                if (resourceLocator.ToString().IndexOf(';') == -1)
                {
                    throw new XamlParseException();
                }
                // otherwise simply return
                return;
            }

            Assembly loading_asm = component.GetType().Assembly;

            XamlLoader loader = XamlLoaderFactory.CreateLoader(loading_asm, resourceLocator, Deployment.Current.Surface.Native, PluginHost.Handle);

            loader.Hydrate(component, sr.Stream);
        }
コード例 #2
0
ファイル: Deployment.cs プロジェクト: ynkbt/moon
        void ReadManifest()
        {
            XamlLoader loader       = XamlLoaderFactory.CreateLoader(typeof(DependencyObject).Assembly, null, Surface.Native, PluginHost.Handle);
            string     app_manifest = Path.Combine(XapDir, "appmanifest.xaml");

            if (!File.Exists(app_manifest))
            {
                throw new MoonException(2103, "Invalid or malformed application: Check manifest");
            }

            Stream app_manifest_stream = null;

            try {
                app_manifest_stream = File.OpenRead(app_manifest);
                loader.Hydrate(this, app_manifest_stream);
            } catch (Exception e) {
                throw new MoonException(7016, e.Message);
            } finally {
                if (app_manifest_stream != null)
                {
                    app_manifest_stream.Close();
                }
            }

            if (RuntimeVersion == null)
            {
                throw new MoonException(2105, "No RuntimeVersion specified in AppManifest");
            }

            CompareRuntimeVersions();

            if (EntryPointAssembly == null)
            {
                throw new MoonException(2103, "Invalid or malformed application: Check manifest");
            }

            if (EntryPointType == null)
            {
                throw new Exception("No entrypoint defined in the AppManifest.xaml");
            }
        }