예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResetView"/> class.
        /// </summary>
        /// <param name="OperationString">The operation string.</param>
        public ResetView(string OperationString)
        {
            InitializeComponent();

            #region → Use MEF To load the View Model                        .

            if (!ViewModelBase.IsInDesignModeStatic)
            {
                // Use MEF To load the View Model
                CompositionInitializer.SatisfyImports(this);
            }

            #endregion

            #region → Pass OperationString to the view Model                .

            ((UserResetViewModel)this.DataContext).OperationString = OperationString;

            #endregion

            #region → Registeration for needed messages in eNegMessenger    .

            eNegMessanger.SendCustomMessage.Register(this, OnUpdateMessage);

            #endregion
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManageOrganizationView"/> class.
        /// </summary>
        public ManageOrganizationView()
        {
            InitializeComponent();

            #region → Use MEF To load the View Model                       .

            if (!ViewModelBase.IsInDesignModeStatic)
            {
                // Use MEF To load the View Model
                CompositionInitializer.SatisfyImports(this);
            }
            #endregion

            #region → Initialize the UserControl Width & Height            .

            ViewsAdjustSize ViewsAdjustSize = new ViewsAdjustSize(this);

            #endregion Intialize PageSize

            #region → Registeration for needed messages in eNegMessenger   .

            eNegMessanger.SendCustomMessage.Register(this, OnUpdateMessage);

            eNegMessanger.EditUserOrganizationMessage.Register(this, OnEditUserOrganizationMessage);
            #endregion
        }
예제 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public Charts()
        {
            InitializeComponent();

            // Resolves extensions for this page.
            CompositionInitializer.SatisfyImports(this);
        }
예제 #4
0
        public DemoHost()
        {
            InitializeComponent();

            Catalog = new List <ExportFactory <FrameworkElement, IDemoMetadata> >();
            CompositionInitializer.SatisfyImports(this);

            var items   = Catalog.OrderBy(v => v.Metadata.Name).ToList();
            var welcome = items.FirstOrDefault(m => m.Metadata.Name.Equals("welcome", System.StringComparison.InvariantCultureIgnoreCase));

            if (welcome != null)
            {
                items.Remove(welcome);
                items.Insert(0, welcome);
            }
            Catalog = items.ToReadOnlyCollection();

            m_items.ItemsSource = Catalog;

            m_items.SelectionChanged += (sender, args) =>
            {
                var item = m_items.SelectedItem as ExportFactory <FrameworkElement, IDemoMetadata>;
                if (item != null)
                {
                    using (var export = item.CreateExport())
                    {
                        m_container.Child = export.Value;
                    }
                }
            };

            m_items.SelectedIndex = 0;
        }
예제 #5
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     Container = new CompositionContainer(new DeploymentCatalog());
     CompositionHost.Initialize(Container);
     CompositionInitializer.SatisfyImports(this);
     RootVisual = new Commodities();
 }
예제 #6
0
 /// <summary>
 /// Called to import the references
 /// </summary>
 public void Import()
 {
     if (!DesignerProperties.IsInDesignTool)
     {
         CompositionInitializer.SatisfyImports(this);
     }
 }
예제 #7
0
        public UserEntityViewModule(ChildWindow aChileWindow, UserEntityViewType aUserEntityViewType, UserEntity aUserEntity, ObservableCollection <DepartmentEntity> aDepartmentEntity)
        {
            this.UserEntityVIewType = aUserEntityViewType;
            this.childWindow        = aChileWindow;
            this.UserEntity         = aUserEntity;
            this.DepartmentList     = aDepartmentEntity;
            if (String.IsNullOrEmpty(aUserEntity.UserName))
            {
                Title = "添加用户";
            }
            else
            {
                Title = "修改用户 编号:" + aUserEntity.UserID.ToString();
            }
            OnOK     = new DelegateCommand(OnOKCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
            OnClose  = new DelegateCommand(OnCloseCommand);

            if (aUserEntityViewType == UserEntityViewType.ADD)
            {
                IsAdd = true;
            }
            else
            {
                IsAdd = false;
            }

            CompositionInitializer.SatisfyImports(this);
        }
예제 #8
0
        /// <summary>
        /// Instructs MEF to satisfy all imports, against the current
        /// collection of catalogs,for the provided part.
        /// </summary>
        /// <param name="part">The object (MEF part) that should be composed</param>
        public static void ComposeParts(Object part)
        {
            try
            {
                // The logger is used before configruation and initialization
                // so we want to handle it in a special way.  We just want to
                // compose it using a single filtered catalog to find the default
                // logger.  Everything will be rebuilt and recomposed after
                // configruation.
                if (part is Logging.LoggerManager)
                {
                    // Create a Berico.LinkAnalysis.
                    FilteredCatalog loggerCatalog = BuildLoggerProviderCatalog(new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()));
                    primaryCatalog.Catalogs.Add(loggerCatalog);

                    CompositionHost.Initialize(new CompositionContainer(primaryCatalog));
                }

                // Now we compose and satisfy the imports for the provided Part
                CompositionInitializer.SatisfyImports(part);
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.WriteLogEntry(Logging.LogLevel.ERROR, "An error occurred trying to compose the parts for the provided object.", ex, null);
                }
                else
                {
                    // This is only for testing.  We don't really want to
                    // do this in the long run.
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FullRegisterView"/> class.
        /// </summary>
        public FullRegisterView()
        {
            InitializeComponent();


            #region " Use MEF To load the View Model "
            if (!ViewModelBase.IsInDesignModeStatic)
            {
                CompositionInitializer.SatisfyImports(this);
            }
            #endregion

            #region initialize the UserControl Width & Height

            ViewsAdjustSize viewsAdjustSize = new ViewsAdjustSize(this);

            #endregion initialize the UserControl Width & Height

            #region Initialize Registeration type
            if (!ViewModelBase.IsInDesignModeStatic)
            {
                ((UserRegisterViewModel)this.DataContext).IsQuickRegister = false;
            }
            #endregion

            #region Registeration for needed messages in eNegMessenger

            eNegMessanger.SendCustomMessage.Register(this, OnUpdateMessage);
            #endregion
        }
예제 #10
0
 /// <summary>
 /// Constructor sets up the necessary references
 /// </summary>
 public VisualStateSubscriptionBehavior()
 {
     if (!DesignerProperties.IsInDesignTool)
     {
         CompositionInitializer.SatisfyImports(this);
     }
 }
예제 #11
0
        public FileNode(AssemblyStream source, string resourcePath)
            : base(null)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (string.IsNullOrWhiteSpace(resourcePath))
            {
                throw new ArgumentNullException("resourcePath");
            }

            _source       = source;
            _resourcePath = resourcePath;
            _fileName     = Path.GetFileName(_resourcePath);

            _extension = Path.GetExtension(_fileName);
            if (!string.IsNullOrEmpty(_extension))
            {
                _extension = _extension.ToLowerInvariant();
            }

            Header          = CreateHeaderCore(DefaultImages.AssemblyBrowser.GetFileIcon(_fileName), null, resourcePath, true);
            DefaultStyleKey = typeof(FileNode);
            CompositionInitializer.SatisfyImports(this);
        }
예제 #12
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     CompositionInitializer.SatisfyImports(this);
     MPage.DataContext = Locator;
     //RootVisual = new MainPage();
     DispatcherHelper.Initialize();
 }
예제 #13
0
        /// <summary>
        /// Called by an application in order to initialize the application extension service.
        /// </summary>
        /// <param name="context">Provides information about the application state. </param>
        public void StartService(ApplicationServiceContext context)
        {
            var logLevel = LogSeverityLevel;

            if (context.ApplicationInitParams.ContainsKey(Constants.INIT_PARAM_LOGLEVEL))
            {
                logLevel =
                    (LogSeverity)
                    Enum.Parse(typeof(LogSeverity), context.ApplicationInitParams[Constants.INIT_PARAM_LOGLEVEL], true);
            }

            _mainCatalog = new AggregateCatalog(new DeploymentCatalog()); // empty one adds current deployment (xap)

            _container = new CompositionContainer(_mainCatalog);

            CompositionHost.Initialize(_container);
            CompositionInitializer.SatisfyImports(this);

            if (Logger == null)
            {
                ILogger defaultLogger = new DefaultLogger(logLevel);
                _container.ComposeExportedValue(defaultLogger);
            }
            else
            {
                Logger.SetSeverity(logLevel);
            }

            DeploymentService.Catalog   = _mainCatalog;
            DeploymentService.Container = _container;
            _mefDebugger = new MefDebugger(_container, Logger);
        }
예제 #14
0
 /// <summary>
 ///     On construction, resolve
 /// </summary>
 public VisualStateAggregatorTrigger()
 {
     if (!DesignerProperties.IsInDesignTool)
     {
         CompositionInitializer.SatisfyImports(this);
     }
 }
        public void When_SatisfyImports_is_called_parts_imports_are_satisfied()
        {
            CompositionHost._container = null;
            var part = new DummyPart();

            CompositionInitializer.SatisfyImports(part);
            Assert.IsNotNull(part.Import);
        }
예제 #16
0
파일: App.xaml.cs 프로젝트: cyrsis/MEF
 public App()
 {
     InitializeComponent();
     _mainCatalog = new AggregateCatalog(new DeploymentCatalog());
     _container   = new CompositionContainer(_mainCatalog);
     _container.ComposeExportedValue <IApplicationHost>(this);
     CompositionHost.Initialize(_container);
     CompositionInitializer.SatisfyImports(this);
 }
예제 #17
0
        private CloudDriveFactory InitializeCloudDriveFactory(string libPath)
        {
            CompositionInitializer.Preload(typeof(CloudFS.Interface.Composition.ICloudGateway));
            CompositionInitializer.Initialize(new[] { typeof(Program).Assembly }, libPath, "IgorSoft.CloudFS.Gateways.*.dll");
            var factory = new CloudDriveFactory();

            CompositionInitializer.SatisfyImports(factory);
            return(factory);
        }
예제 #18
0
 /// <summary>
 /// Called when the trigger fires
 /// </summary>
 /// <param name="parameter">Optional parameter that is not used</param>
 protected override void Invoke(object parameter)
 {
     if (_eventAggregator == null)
     {
         CompositionInitializer.SatisfyImports(this);
         _eventAggregator = EventAggregator;
     }
     _eventAggregator.Publish(Target.AsViewNavigationArgs());
 }
        private void InitializerContainer()
        {
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(CreateCatalog("HelloMEF.Extensions.xap"));

            CompositionHost.Initialize(new DeploymentCatalog(), catalog);
            CompositionInitializer.SatisfyImports(this);
        }
예제 #20
0
        public MainPage()
        {
            InitializeComponent();
            CompositionInitializer.SatisfyImports(this);

            this.Loaded += (s, a) =>
            {
                this.DataContext = this;
            };
        }
        public void CompositionInitializer_SatisfyImports_Succeeds()
        {
            CompositionInitializer.Initialize(new[] { typeof(CompositionInitializerTests).Assembly });

            var composablePart = Fixture.GetComposablePart();

            CompositionInitializer.SatisfyImports(composablePart);

            Assert.IsNotNull(composablePart.Component, "Composition of component failed");
        }
예제 #22
0
        public MainPage()
        {
            InitializeComponent();

            DesignerTabs.SelectionChanged += DesignerTabsSelectionChanged;
            CompositionInitializer.SatisfyImports(this);

            _viewmodel  = new DesignerViewModel();
            DataContext = _viewmodel;
        }
예제 #23
0
        public DesignSurfaceController(DesignSurface surface, FunctionDefinition workflow)
        {
            CompositionInitializer.SatisfyImports(this);

            _surface = surface;
            Workflow = workflow;

            InitializeWorkflowDefinition();
            InitializeSurface();
            CreateDefaultOutputActivity();
        }
예제 #24
0
파일: UnitTest1.cs 프로젝트: ivconsult/eNeg
        public void BuidUp()
        {
            CompositionInitializer.SatisfyImports(this);

            #region " Registeration for needed messages in eNegMessenger "
            //// register for RaiseErrorMessage
            //eNegMessanger.RaiseErrorMessage.Register(this, OnRaiseErrorMessage);
            //// register for PleaseConfirmMessage
            //eNegMessanger.ConfirmMessage.Register(this, OnConfirmMessage);
            #endregion
        }
예제 #25
0
파일: App.xaml.cs 프로젝트: cyrsis/MEF
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var catalog = new AggregateCatalog(new DeploymentCatalog());

            _extension = new DeploymentCatalog("SilverlightMEF.Extensions.xap");
            catalog.Catalogs.Add(_extension);
            var container = new CompositionContainer(catalog);

            CompositionHost.Initialize(container);
            container.ComposeExportedValue <ILaunchInterface>(this);
            CompositionInitializer.SatisfyImports(this);
        }
예제 #26
0
        public EditIndexViewModel(IndexDefinition index, IServer server)
        {
            DisplayName = "Edit Index";

            this.index  = index;
            this.server = server;

            CompositionInitializer.SatisfyImports(this);

            Name = index.Name;
            LoadFields();
        }
예제 #27
0
파일: Header.xaml.cs 프로젝트: cyrsis/MEF
 public Header()
 {
     InitializeComponent();
     if (DesignerProperties.IsInDesignTool)
     {
         HeaderTextString = "Design-time text";
     }
     else
     {
         CompositionInitializer.SatisfyImports(this);
     }
 }
예제 #28
0
        public ColumnChartViewModel()
        {
            // In design mode, simply return.
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            ChartData = new ObservableCollection <OrderStatistics>();

            // MEF: Compose this control
            CompositionInitializer.SatisfyImports(this);
        }
예제 #29
0
        /// <summary>
        /// Modifies the source data before passing it to the target for display in the UI.
        /// </summary>
        /// <returns>
        /// The value to be passed to the target dependency property.
        /// </returns>
        /// <param name="value">The source data being passed to the target.</param><param name="targetType">The <see cref="T:System.Type"/> of data expected by the target dependency property.</param><param name="parameter">An optional parameter to be used in the converter logic.</param><param name="culture">The culture of the conversion.</param>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return(value);
            }

            lock (_composedConverter)
            {
                if (_composedConverter.Router == null)
                {
                    CompositionInitializer.SatisfyImports(_composedConverter);
                }
            }

            if (_composedConverter.Router == null)
            {
                return(value);
            }

            // if the value is a view model and a view tag was passed, resolve them
            if (value is IViewModel)
            {
                // if tag is passed in
                if (parameter != null)
                {
                    return(_composedConverter.Router.GetNonSharedView(parameter.ToString(), value));
                }

                // first get the view model tag
                var exportAttribute =
                    (from c in value.GetType().GetCustomAttributes(true) where c is ExportAsViewModelAttribute select(ExportAsViewModelAttribute) c)
                    .FirstOrDefault();

                if (exportAttribute == null)
                {
                    return(value);
                }

                var viewModelTag = exportAttribute.ViewModelType;
                var views        = _composedConverter.Router.GetViewTagsForViewModel(viewModelTag);

                // we always assume the first view
                if (views.Length > 0)
                {
                    return(_composedConverter.Router.GetNonSharedView(views[0], value));
                }
            }

            return(value);
        }
예제 #30
0
        /// <summary>
        /// Completes initialization of the ExtensionManager class.  This will be called after
        /// all DeploymentCatalogs have finished downloading parts.
        /// </summary>
        /// <param name="catalogs">The external deployment catalogs to load</param>
        private static void CompleteInitialization(IEnumerable <DeploymentCatalog> catalogs)
        {
            lock (syncRoot)
            {
                AggregateCatalog tempCatalog = new AggregateCatalog();

                // Clear the primary catalog
                primaryCatalog.Catalogs.Clear();

                // Build a catalog containing all Parts in the entire assembly
                AssemblyCatalog assemblyCatalog = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly());

                foreach (DeploymentCatalog catalog in catalogs)
                {
                    tempCatalog.Catalogs.Add(catalog);
                }

                tempCatalog.Catalogs.Add(assemblyCatalog);

                // Create the two special catalogs for the logger and preference providers
                FilteredCatalog loggerProviderCatalog              = BuildLoggerProviderCatalog(tempCatalog);
                FilteredCatalog preferencesProviderCatalog         = BuildPreferenceProviderCatalog(tempCatalog);
                FilteredCatalog toolbarExtensionsCatalog           = BuildToolbarExtensionsCatalog(tempCatalog);
                FilteredCatalog toolPanelExtensionsCatalog         = BuildToolPanelExtensionsCatalog(tempCatalog);
                FilteredCatalog similarityMeasureExtensionsCatalog = BuildSimilarityMeasureExtensionsCatalog(tempCatalog);
                FilteredCatalog rankingCatalog = BuildRankingCatalog(tempCatalog);
                FilteredCatalog graphDataFormatExtensionsCatalog = BuildGraphDataFormatExtensionsCatalog(tempCatalog);
                FilteredCatalog actionCatalog = BuildActionCatalog(tempCatalog);
                FilteredCatalog layoutCatalog = BuildLayoutCatalog(tempCatalog);

                // Add the two filtered catalogs to the master catalog
                primaryCatalog.Catalogs.Add(loggerProviderCatalog);
                primaryCatalog.Catalogs.Add(preferencesProviderCatalog);
                primaryCatalog.Catalogs.Add(toolbarExtensionsCatalog);
                primaryCatalog.Catalogs.Add(toolPanelExtensionsCatalog);
                primaryCatalog.Catalogs.Add(similarityMeasureExtensionsCatalog);
                primaryCatalog.Catalogs.Add(graphDataFormatExtensionsCatalog);
                primaryCatalog.Catalogs.Add(actionCatalog);
                primaryCatalog.Catalogs.Add(layoutCatalog);
                primaryCatalog.Catalogs.Add(rankingCatalog);
            }

            // Reset the flags
            IsBusy      = false;
            initialized = true;

            // Satisfy the imports for the logger manager
            CompositionInitializer.SatisfyImports(Logging.LoggerManager.Instance);

            //Logging.LoggerManager.Instance.Level = ConfigurationManager.GetValue(ConfigurationManager.PARAMETER_LOGGER_LEVEL);
        }