Example #1
0
 /// <summary>
 /// Resolves the <see cref="ViewModule"/> with the specified name.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static ViewModuleInfo ResolveViewModule(string name)
 {
     return(CompositionUtil.CreateContainer(CompositionUtil.DefaultGlobalCatalog)
            .GetExportedValues <IViewModuleProvider>()
            .SelectMany(i => i.GetViewModules().Where(j => j.Name == name))
            .FirstOrDefault(i => i != null));
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        public View()
        {
            this.container = CompositionUtil.CreateContainer(CompositionUtil.DefaultGlobalCatalog);

            this.server = new ViewServer();
            this.server.DocumentLoaded    += (s, a) => OnDocumentLoaded(a);
            this.server.DocumentUnloading += (s, a) => OnDocumentUnloading(a);

            // by default use ScriptManager
            this.enableScriptManager = true;
        }
Example #3
0
        /// <summary>
        /// Gets the <see cref="ExportProvider"/> for the given <see cref="XObject"/>.
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static ExportProvider Exports(this XObject self)
        {
            Contract.Requires <ArgumentNullException>(self != null);
            Contract.Ensures(Contract.Result <ExportProvider>() != null);

            // get or create the new object container annotation
            return(self.AnnotationOrCreate <ExportProvider>(() =>
            {
                var document = self.Document.Annotation <Document>();
                if (document == null)
                {
                    throw new InvalidOperationException();
                }

                // initialize new container
                var container = CompositionUtil.ConfigureContainer(new CompositionContainer(
                                                                       document.Configuration.ObjectCatalog,
                                                                       CompositionOptions.DisableSilentRejection,
                                                                       document.Container));

                if (self is XObject)
                {
                    container.WithExport <XObject>(self);
                }
                if (self is XDocument)
                {
                    container.WithExport <XDocument>((XDocument)self);
                }
                if (self is XElement)
                {
                    container.WithExport <XElement>((XElement)self);
                }
                if (self is XNode)
                {
                    container.WithExport <XNode>((XNode)self);
                }
                if (self is XAttribute)
                {
                    container.WithExport <XAttribute>((XAttribute)self);
                }

                return container;
            }));
        }
Example #4
0
        protected override void Dispose(bool disposing)
        {
            CompositionUtil.Clear();

            base.Dispose(disposing);
        }