public void LoadCollection(IEnumerable <TInterface> collection)
 {
     PrivateCollection.Clear();
     foreach (var c in collection)
     {
         PrivateCollection.Add((TImplementation)c);
     }
 }
        public void Remove(string guid)
        {
            var toRemove = PrivateCollection.FirstOrDefault(c => c.Guid == guid);

            if (toRemove != null)
            {
                PrivateCollection.Remove(toRemove);
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModel&lt;TController, TModel&gt;"/> class.
        /// </summary>
        public ViewModel()
        {
            // Initialize service availability
            this.allowUndoRedo   = this.IsUndoRedoAvailable;
            this.allowSearch     = this.IsSearchAvailable;
            this.allowValidation = this.IsValidationAvailable;

            // Subscribe to controller events
            this.Controller.Created += this.OnCreated;
            this.Controller.Opening += this.OnOpening;
            this.Controller.Opened  += this.OnOpened;
            this.Controller.Closing += this.OnClosing;
            this.Controller.Closed  += this.OnClosed;
            this.Controller.Saving  += this.OnSaving;
            this.Controller.Saved   += this.OnSaved;

            // Initialize status events list
            this.statusEvents = new PrivateCollection <StatusEvent> (out this.statusEventsKey);

            // Initialize recent files list
            this.recentFiles = new RecentFilesCollection(this.Controller);

            // Attach to udno manager
            if (this.IsUndoRedoAvailable)
            {
                this.UndoManager.AfterUndo += this.OnAfterUndo;
                this.UndoManager.AfterRedo += this.OnAfterRedo;
            }

            // Attach to search engine
            if (this.IsSearchAvailable)
            {
                this.SearchEngine.StatusChanged  += this.OnSearchEngineStatusChanged;
                this.SearchEngine.SearchComplete += this.OnSearchEngineSearchComplete;
                this.searchResults = new SearchResultCollection(this.SearchEngine);
            }

            // Attach to validation manager
            if (this.IsValidationAvailable)
            {
                this.ValidationManager.StatusChanged += this.OnValidationManagerStatusChanged;
                this.validationResults = new ValidationResultCollection(this.ValidationManager);
            }

            // Get the default application name using the assembly level AssemblyProductAttribute,
            // which is usually defined in the AssemblyInfo.cs file.
            Assembly entryAssembly = Assembly.GetEntryAssembly();

            if (entryAssembly != null)
            {
                object[] assemblyProductAttributes = entryAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                if ((assemblyProductAttributes != null) && (assemblyProductAttributes.Length > 0))
                {
                    this.applicationName = ((AssemblyProductAttribute)assemblyProductAttributes[0]).Product;
                }
            }
        }
 public void Add(TInterface entity)
 {
     PrivateCollection.Add((TImplementation)entity);
 }