Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GBT/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/VBA/ExcelVbaModuleCollection.cs @ 12495

Last change on this file since 12495 was 12495, checked in by gkronber, 9 years ago

#2261: merged trunk changes to branch
r12494
#2403: added a null check in the MatlabParameterVectorEvaluator to prevent exceptions when clearstate is called


r12493
#2369: added support for squared errors and relative errors to error-characteristic-curve view


r12492
#2392: implemented PearsonsRCalculator to fix incorrect correlation values in the correlation matrix.


r12491
#2402 don't set task state to waiting when it fails


r12490
#2401 added missing Mono.Cecil plugin dependency


r12488
#2400 - Interfaces for Capaciated-, PickupAndDelivery- and TimeWindowed-ProblemInstances now specify an additional penalty parameter to set the current penalty factor for the constraint relaxation. - The setter of the penalty-property in ...


r12485
#2374 made RegressionSolution and ClassificationSolution non-abstract


r12482
#2320: Fixed warnings in unit test solutions introduced in r12420 by marking methods as obsolete.


r12481
#2320: Fixed AfterDeserialization of GEArtifialAntEvaluator.


r12480
#2320: Fixed error in symbolicexpressiontree crossover regarding the wiring of lookup parameters if persisted file is loaded.


r12479
#2397 moved GeoIP project into ExtLibs


r12478
#2329 fixed bug in simple code editor


r12476
#2331 removed outdated plugins


r12475
#2368 fixed compile warnings


r12474
#2399 worked on Mono project prepare script


r12473
#2329 added a simple code editor for Linux


r12472
#2399 - fixed MathJax.js file name - worked on Mono project prepare script


r12471
#2399 worked on Mono project prepare script


r12470
#2399 fixed pre-build events in project files


r12465
#2399 worked on mono project prepare script


r12464
#2399 added patch to project


r12463
#2399 fixed EPPlus so that it compiles on Linux


r12461
#2398: Skip root and start symbols when calculating impacts and replacement values in the pruning operators.


r12458
#2354 show label when no data is displayed and don't show the legend


r12457
#2353 removed duplicated call to Any() in Hive Status page


r12456
#2368 fixed modifier


r12455
#2368 added support in persistence for typecaches in streams


r12445
#2394: Changed Web.config compilation from debug to release to force script bundling. Changed history loading type from lazy to eager loading to increase performance. Fixed "getCoreStatus" typo in statusCtrl.js


r12443
#2394: Fixed UserTaskQuery and GetStatusHistory in the WebApp.Status plugin


r12442
#2394 added nuget folders to svn ignore list


r12435
#2394: Improved PluginManager and updated hive status monitor.


r12434
#2396 added symbolic expression tree formatter for C#


r12433
#2395: Minor change in DoubleValue.GetValue.


r12432
#2395 Use simple round-trip format for doubles because G17 prints some strange numbers (20.22 to 20.219999999999999999). Some accuracy can still be lost on 64bit machines, but should be very rare and minimal. double.MaxValue can still be pa...


r12431
#2395 Fixed parsing issues by using the G17 format.


r12430
#2394 added missing package config


r12429
#2394 added missing package config


r12428
#2394 added web app and status page to trunk


r12424
#2320: Adapted plugin file and updated project file of SymbolicExpressionTreeEncoding.


r12422
#2320: Merged the encoding class and all accompanying changes in the trunk.


r12401
#2387 Fixed a bug where the automatic selection of the first element behaved differently for the NewItemDialog.


r12400
#2387 Forgot to commit a file.


r12399
#2387 - Added context-menu for expanding and collapsing tree-nodes. - Improve response time when expanding/collapsing all nodes for TypeSelector and NewItemDialog.


r12398
#2387 - Added clearSearch-button in TypeSelector. - Adapted behavior of TypeSelector and NewItemDialog that a selected node stays selected as long as it matches the search criteria.


r12397
#2387 - Adapted behavior of the matching in the TypeSelector that it behave the same as the NewItemDialog. The search string is tokenized by space and matches if all tokens are contained, (eg. "Sym Reg" matches "SymbolicRegression...")...


r12393
#2025 - Removed Expand/CollapseAll buttons. - Removed cycling of items.


r12392
#2386: Updated GetHashCode method in the EnumerableBoolEqualityComparer.


File size: 8.1 KB
Line 
1/*******************************************************************************
2 * You may amend and distribute as you like, but don't remove this header!
3 *
4 * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
5 * See http://www.codeplex.com/EPPlus for details.
6 *
7 * Copyright (C) 2011  Jan Källman
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
17 * See the GNU Lesser General Public License for more details.
18 *
19 * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
20 * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
21 *
22 * All code and executables are provided "as is" with no warranty either express or implied.
23 * The author accepts no liability for any damage or loss of business that this product may cause.
24 *
25 * Code change notes:
26 *
27 * Author             Change            Date
28 *******************************************************************************
29 * Jan Källman    Added   12-APR-2012
30 *******************************************************************************/
31using System;
32using System.Collections.Generic;
33using System.Linq;
34using System.Text;
35
36namespace OfficeOpenXml.VBA
37{
38    /// <summary>
39    /// Base class for VBA collections
40    /// </summary>
41    /// <typeparam name="T"></typeparam>
42    public class ExcelVBACollectionBase<T> : IEnumerable<T>
43    {
44        internal protected List<T> _list=new List<T>();       
45        public IEnumerator<T> GetEnumerator()
46        {
47            return _list.GetEnumerator();
48        }
49
50        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
51        {
52            return _list.GetEnumerator();
53        }
54        /// <summary>
55        /// Indexer
56        /// </summary>
57        /// <param name="Name">Name</param>
58        /// <returns></returns>
59        public T this [string Name]
60        {
61            get
62            {
63                return _list.Find((f) => f.GetType().GetProperty("Name").GetValue(f, null).ToString().Equals(Name,StringComparison.InvariantCultureIgnoreCase));
64            }
65        }
66        /// <summary>
67        /// Indexer
68        /// </summary>
69        /// <param name="Index">Position</param>
70        /// <returns></returns>
71        public T this[int Index]
72        {
73            get
74            {
75                return _list[Index];
76            }
77        }
78        /// <summary>
79        /// Number of items in the collection
80        /// </summary>
81        public int Count
82        {
83            get { return _list.Count; }
84        }
85        /// <summary>
86        /// If a specific name exists in the collection
87        /// </summary>
88        /// <param name="Name">The name</param>
89        /// <returns>True if the name exists</returns>
90        public bool Exists(string Name)
91        {
92            return _list.Exists((f) => f.GetType().GetProperty("Name").GetValue(f, null).ToString().Equals(Name,StringComparison.InvariantCultureIgnoreCase));
93        }
94        /// <summary>
95        /// Removes the item
96        /// </summary>
97        /// <param name="Item"></param>
98        public void Remove(T Item)
99        {
100            _list.Remove(Item);
101        }
102        /// <summary>
103        /// Removes the item at the specified index
104        /// </summary>
105        /// <param name="index">THe index</param>
106        public void RemoveAt(int index)
107        {
108            _list.RemoveAt(index);
109        }
110       
111        internal void Clear()
112        {
113            _list.Clear();
114        }
115    }
116    /// <summary>
117    /// Collection class for VBA modules
118    /// </summary>
119    public class ExcelVbaModuleCollection : ExcelVBACollectionBase<ExcelVBAModule>
120    {
121        ExcelVbaProject _project;
122        internal ExcelVbaModuleCollection (ExcelVbaProject project)
123      {
124            _project=project;
125      }
126        internal void Add(ExcelVBAModule Item)
127        {
128            _list.Add(Item);
129        }
130        /// <summary>
131        /// Adds a new VBA Module
132        /// </summary>
133        /// <param name="Name">The name of the module</param>
134        /// <returns>The module object</returns>
135        public ExcelVBAModule AddModule(string Name)
136        {
137            if (this[Name] != null)
138            {
139                throw(new ArgumentException("Vba modulename already exist."));
140            }
141            var m = new ExcelVBAModule();
142            m.Name = Name;
143            m.Type = eModuleType.Module;
144            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_Name", Value = Name, DataType = eAttributeDataType.String });
145            m.Type = eModuleType.Module;
146            _list.Add(m);
147            return m;
148        }
149        /// <summary>
150        /// Adds a new VBA class
151        /// </summary>
152        /// <param name="Name">The name of the class</param>
153        /// <param name="Exposed">Private or Public not createble</param>
154        /// <returns>The class object</returns>
155        public ExcelVBAModule AddClass(string Name, bool Exposed)
156        {
157            var m = new ExcelVBAModule();
158            m.Name = Name;           
159            m.Type = eModuleType.Class;
160            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_Name", Value = Name, DataType = eAttributeDataType.String });
161            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_Base", Value = "0{FCFB3D2A-A0FA-1068-A738-08002B3371B5}", DataType = eAttributeDataType.String });
162            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_GlobalNameSpace", Value = "False", DataType = eAttributeDataType.NonString });
163            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_Creatable", Value = "False", DataType = eAttributeDataType.NonString });
164            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_PredeclaredId", Value = "False", DataType = eAttributeDataType.NonString });
165            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_Exposed", Value = Exposed ? "True" : "False", DataType = eAttributeDataType.NonString });
166            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_TemplateDerived", Value = "False", DataType = eAttributeDataType.NonString });
167            m.Attributes._list.Add(new ExcelVbaModuleAttribute() { Name = "VB_Customizable", Value = "False", DataType = eAttributeDataType.NonString });
168
169            //m.Code = _project.GetBlankClassModule(Name, Exposed);
170            m.Private = !Exposed;
171            //m.ClassID=
172            _list.Add(m);
173            return m;
174        }
175    }
176    /// <summary>
177    /// A collection of the vba projects references
178    /// </summary>
179    public class ExcelVbaReferenceCollection : ExcelVBACollectionBase<ExcelVbaReference>
180    {       
181        internal ExcelVbaReferenceCollection()
182        {
183
184        }
185        /// <summary>
186        /// Adds a new reference
187        /// </summary>
188        /// <param name="Item">The reference object</param>
189        public void Add(ExcelVbaReference Item)
190        {
191            _list.Add(Item);
192        }
193    }
194    /// <summary>
195    /// A collection of the module level attributes
196    /// </summary>
197    public class ExcelVbaModuleAttributesCollection : ExcelVBACollectionBase<ExcelVbaModuleAttribute>
198    {
199        internal string GetAttributeText()
200        {
201            StringBuilder sb=new StringBuilder();
202
203            foreach (var attr in this)
204            {
205                sb.AppendFormat("Attribute {0} = {1}\r\n", attr.Name, attr.DataType==eAttributeDataType.String ? "\"" + attr.Value + "\"" : attr.Value);
206            }
207            return sb.ToString();
208        }
209    }
210}
Note: See TracBrowser for help on using the repository browser.