Showing the changes to Source/Libraries/GSF.Web/Hosting/VirtualFileBaseCollection.cs (1 of 628 files). Show all
Unified · Split
| @@ -0,0 +1,300 @@ | ||
| 1 | +//******************************************************************************************************* | |
| 2 | +// VirtualFileBaseCollection.cs - Gbtc | |
| 3 | +// | |
| 4 | +// Tennessee Valley Authority, 2010 | |
| 5 | +// No copyright is claimed pursuant to 17 USC � 105. All Other Rights Reserved. | |
| 6 | +// | |
| 7 | +// This software is made freely available under the TVA Open Source Agreement (see below). | |
| 8 | +// | |
| 9 | +// Code Modification History: | |
| 10 | +// ----------------------------------------------------------------------------------------------------- | |
| 11 | +// 05/04/2010 - Pinal C. Patel | |
| 12 | +// Generated original version of source code. | |
| 13 | +// | |
| 14 | +//******************************************************************************************************* | |
| 15 | + | |
| 16 | +#region [ TVA Open Source Agreement ] | |
| 17 | +/* | |
| 18 | + | |
| 19 | + THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE,REPRODUCTION, DISTRIBUTION, | |
| 20 | + MODIFICATION AND REDISTRIBUTION OF CERTAIN COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE | |
| 21 | + TENNESSEE VALLEY AUTHORITY, A CORPORATE AGENCY AND INSTRUMENTALITY OF THE UNITED STATES GOVERNMENT | |
| 22 | + ("GOVERNMENT AGENCY"). GOVERNMENT AGENCY IS AN INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT | |
| 23 | + DISTRIBUTIONS OR REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, DISTRIBUTES, | |
| 24 | + MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED HEREIN, OR ANY PART THEREOF, IS, BY THAT | |
| 25 | + ACTION, ACCEPTING IN FULL THE RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. | |
| 26 | + | |
| 27 | + Original Software Designation: openPDC | |
| 28 | + Original Software Title: The GSF Open Source Phasor Data Concentrator | |
| 29 | + User Registration Requested. Please Visit https://naspi.tva.com/Registration/ | |
| 30 | + Point of Contact for Original Software: J. Ritchie Carroll <mailto:jrcarrol@tva.gov> | |
| 31 | + | |
| 32 | + 1. DEFINITIONS | |
| 33 | + | |
| 34 | + A. "Contributor" means Government Agency, as the developer of the Original Software, and any entity | |
| 35 | + that makes a Modification. | |
| 36 | + | |
| 37 | + B. "Covered Patents" mean patent claims licensable by a Contributor that are necessarily infringed by | |
| 38 | + the use or sale of its Modification alone or when combined with the Subject Software. | |
| 39 | + | |
| 40 | + C. "Display" means the showing of a copy of the Subject Software, either directly or by means of an | |
| 41 | + image, or any other device. | |
| 42 | + | |
| 43 | + D. "Distribution" means conveyance or transfer of the Subject Software, regardless of means, to | |
| 44 | + another. | |
| 45 | + | |
| 46 | + E. "Larger Work" means computer software that combines Subject Software, or portions thereof, with | |
| 47 | + software separate from the Subject Software that is not governed by the terms of this Agreement. | |
| 48 | + | |
| 49 | + F. "Modification" means any alteration of, including addition to or deletion from, the substance or | |
| 50 | + structure of either the Original Software or Subject Software, and includes derivative works, as that | |
| 51 | + term is defined in the Copyright Statute, 17 USC � 101. However, the act of including Subject Software | |
| 52 | + as part of a Larger Work does not in and of itself constitute a Modification. | |
| 53 | + | |
| 54 | + G. "Original Software" means the computer software first released under this Agreement by Government | |
| 55 | + Agency entitled openPDC, including source code, object code and accompanying documentation, if any. | |
| 56 | + | |
| 57 | + H. "Recipient" means anyone who acquires the Subject Software under this Agreement, including all | |
| 58 | + Contributors. | |
| 59 | + | |
| 60 | + I. "Redistribution" means Distribution of the Subject Software after a Modification has been made. | |
| 61 | + | |
| 62 | + J. "Reproduction" means the making of a counterpart, image or copy of the Subject Software. | |
| 63 | + | |
| 64 | + K. "Sale" means the exchange of the Subject Software for money or equivalent value. | |
| 65 | + | |
| 66 | + L. "Subject Software" means the Original Software, Modifications, or any respective parts thereof. | |
| 67 | + | |
| 68 | + M. "Use" means the application or employment of the Subject Software for any purpose. | |
| 69 | + | |
| 70 | + 2. GRANT OF RIGHTS | |
| 71 | + | |
| 72 | + A. Under Non-Patent Rights: Subject to the terms and conditions of this Agreement, each Contributor, | |
| 73 | + with respect to its own contribution to the Subject Software, hereby grants to each Recipient a | |
| 74 | + non-exclusive, world-wide, royalty-free license to engage in the following activities pertaining to | |
| 75 | + the Subject Software: | |
| 76 | + | |
| 77 | + 1. Use | |
| 78 | + | |
| 79 | + 2. Distribution | |
| 80 | + | |
| 81 | + 3. Reproduction | |
| 82 | + | |
| 83 | + 4. Modification | |
| 84 | + | |
| 85 | + 5. Redistribution | |
| 86 | + | |
| 87 | + 6. Display | |
| 88 | + | |
| 89 | + B. Under Patent Rights: Subject to the terms and conditions of this Agreement, each Contributor, with | |
| 90 | + respect to its own contribution to the Subject Software, hereby grants to each Recipient under Covered | |
| 91 | + Patents a non-exclusive, world-wide, royalty-free license to engage in the following activities | |
| 92 | + pertaining to the Subject Software: | |
| 93 | + | |
| 94 | + 1. Use | |
| 95 | + | |
| 96 | + 2. Distribution | |
| 97 | + | |
| 98 | + 3. Reproduction | |
| 99 | + | |
| 100 | + 4. Sale | |
| 101 | + | |
| 102 | + 5. Offer for Sale | |
| 103 | + | |
| 104 | + C. The rights granted under Paragraph B. also apply to the combination of a Contributor's Modification | |
| 105 | + and the Subject Software if, at the time the Modification is added by the Contributor, the addition of | |
| 106 | + such Modification causes the combination to be covered by the Covered Patents. It does not apply to | |
| 107 | + any other combinations that include a Modification. | |
| 108 | + | |
| 109 | + D. The rights granted in Paragraphs A. and B. allow the Recipient to sublicense those same rights. | |
| 110 | + Such sublicense must be under the same terms and conditions of this Agreement. | |
| 111 | + | |
| 112 | + 3. OBLIGATIONS OF RECIPIENT | |
| 113 | + | |
| 114 | + A. Distribution or Redistribution of the Subject Software must be made under this Agreement except for | |
| 115 | + additions covered under paragraph 3H. | |
| 116 | + | |
| 117 | + 1. Whenever a Recipient distributes or redistributes the Subject Software, a copy of this Agreement | |
| 118 | + must be included with each copy of the Subject Software; and | |
| 119 | + | |
| 120 | + 2. If Recipient distributes or redistributes the Subject Software in any form other than source code, | |
| 121 | + Recipient must also make the source code freely available, and must provide with each copy of the | |
| 122 | + Subject Software information on how to obtain the source code in a reasonable manner on or through a | |
| 123 | + medium customarily used for software exchange. | |
| 124 | + | |
| 125 | + B. Each Recipient must ensure that the following copyright notice appears prominently in the Subject | |
| 126 | + Software: | |
| 127 | + | |
| 128 | + No copyright is claimed pursuant to 17 USC � 105. All Other Rights Reserved. | |
| 129 | + | |
| 130 | + C. Each Contributor must characterize its alteration of the Subject Software as a Modification and | |
| 131 | + must identify itself as the originator of its Modification in a manner that reasonably allows | |
| 132 | + subsequent Recipients to identify the originator of the Modification. In fulfillment of these | |
| 133 | + requirements, Contributor must include a file (e.g., a change log file) that describes the alterations | |
| 134 | + made and the date of the alterations, identifies Contributor as originator of the alterations, and | |
| 135 | + consents to characterization of the alterations as a Modification, for example, by including a | |
| 136 | + statement that the Modification is derived, directly or indirectly, from Original Software provided by | |
| 137 | + Government Agency. Once consent is granted, it may not thereafter be revoked. | |
| 138 | + | |
| 139 | + D. A Contributor may add its own copyright notice to the Subject Software. Once a copyright notice has | |
| 140 | + been added to the Subject Software, a Recipient may not remove it without the express permission of | |
| 141 | + the Contributor who added the notice. | |
| 142 | + | |
| 143 | + E. A Recipient may not make any representation in the Subject Software or in any promotional, | |
| 144 | + advertising or other material that may be construed as an endorsement by Government Agency or by any | |
| 145 | + prior Recipient of any product or service provided by Recipient, or that may seek to obtain commercial | |
| 146 | + advantage by the fact of Government Agency's or a prior Recipient's participation in this Agreement. | |
| 147 | + | |
| 148 | + F. In an effort to track usage and maintain accurate records of the Subject Software, each Recipient, | |
| 149 | + upon receipt of the Subject Software, is requested to register with Government Agency by visiting the | |
| 150 | + following website: https://naspi.tva.com/Registration/. Recipient's name and personal information | |
| 151 | + shall be used for statistical purposes only. Once a Recipient makes a Modification available, it is | |
| 152 | + requested that the Recipient inform Government Agency at the web site provided above how to access the | |
| 153 | + Modification. | |
| 154 | + | |
| 155 | + G. Each Contributor represents that that its Modification does not violate any existing agreements, | |
| 156 | + regulations, statutes or rules, and further that Contributor has sufficient rights to grant the rights | |
| 157 | + conveyed by this Agreement. | |
| 158 | + | |
| 159 | + H. A Recipient may choose to offer, and to charge a fee for, warranty, support, indemnity and/or | |
| 160 | + liability obligations to one or more other Recipients of the Subject Software. A Recipient may do so, | |
| 161 | + however, only on its own behalf and not on behalf of Government Agency or any other Recipient. Such a | |
| 162 | + Recipient must make it absolutely clear that any such warranty, support, indemnity and/or liability | |
| 163 | + obligation is offered by that Recipient alone. Further, such Recipient agrees to indemnify Government | |
| 164 | + Agency and every other Recipient for any liability incurred by them as a result of warranty, support, | |
| 165 | + indemnity and/or liability offered by such Recipient. | |
| 166 | + | |
| 167 | + I. A Recipient may create a Larger Work by combining Subject Software with separate software not | |
| 168 | + governed by the terms of this agreement and distribute the Larger Work as a single product. In such | |
| 169 | + case, the Recipient must make sure Subject Software, or portions thereof, included in the Larger Work | |
| 170 | + is subject to this Agreement. | |
| 171 | + | |
| 172 | + J. Notwithstanding any provisions contained herein, Recipient is hereby put on notice that export of | |
| 173 | + any goods or technical data from the United States may require some form of export license from the | |
| 174 | + U.S. Government. Failure to obtain necessary export licenses may result in criminal liability under | |
| 175 | + U.S. laws. Government Agency neither represents that a license shall not be required nor that, if | |
| 176 | + required, it shall be issued. Nothing granted herein provides any such export license. | |
| 177 | + | |
| 178 | + 4. DISCLAIMER OF WARRANTIES AND LIABILITIES; WAIVER AND INDEMNIFICATION | |
| 179 | + | |
| 180 | + A. No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER | |
| 181 | + EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT | |
| 182 | + SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 183 | + PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR | |
| 184 | + FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS | |
| 185 | + AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR | |
| 186 | + RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS | |
| 187 | + RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND | |
| 188 | + LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT | |
| 189 | + "AS IS." | |
| 190 | + | |
| 191 | + B. Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST GOVERNMENT AGENCY, ITS | |
| 192 | + AGENTS, EMPLOYEES, CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE | |
| 193 | + OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM | |
| 194 | + SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE | |
| 195 | + SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS GOVERNMENT AGENCY, ITS AGENTS, | |
| 196 | + EMPLOYEES, CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY | |
| 197 | + LAW. THE FOREGOING RELEASE AND INDEMNIFICATION SHALL APPLY EVEN IF THE LIABILITIES, DEMANDS, DAMAGES, | |
| 198 | + EXPENSES OR LOSSES ARE CAUSED, OCCASIONED, OR CONTRIBUTED TO BY THE NEGLIGENCE, SOLE OR CONCURRENT, OF | |
| 199 | + GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE | |
| 200 | + IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. | |
| 201 | + | |
| 202 | + 5. GENERAL TERMS | |
| 203 | + | |
| 204 | + A. Termination: This Agreement and the rights granted hereunder will terminate automatically if a | |
| 205 | + Recipient fails to comply with these terms and conditions, and fails to cure such noncompliance within | |
| 206 | + thirty (30) days of becoming aware of such noncompliance. Upon termination, a Recipient agrees to | |
| 207 | + immediately cease use and distribution of the Subject Software. All sublicenses to the Subject | |
| 208 | + Software properly granted by the breaching Recipient shall survive any such termination of this | |
| 209 | + Agreement. | |
| 210 | + | |
| 211 | + B. Severability: If any provision of this Agreement is invalid or unenforceable under applicable law, | |
| 212 | + it shall not affect the validity or enforceability of the remainder of the terms of this Agreement. | |
| 213 | + | |
| 214 | + C. Applicable Law: This Agreement shall be subject to United States federal law only for all purposes, | |
| 215 | + including, but not limited to, determining the validity of this Agreement, the meaning of its | |
| 216 | + provisions and the rights, obligations and remedies of the parties. | |
| 217 | + | |
| 218 | + D. Entire Understanding: This Agreement constitutes the entire understanding and agreement of the | |
| 219 | + parties relating to release of the Subject Software and may not be superseded, modified or amended | |
| 220 | + except by further written agreement duly executed by the parties. | |
| 221 | + | |
| 222 | + E. Binding Authority: By accepting and using the Subject Software under this Agreement, a Recipient | |
| 223 | + affirms its authority to bind the Recipient to all terms and conditions of this Agreement and that | |
| 224 | + Recipient hereby agrees to all terms and conditions herein. | |
| 225 | + | |
| 226 | + F. Point of Contact: Any Recipient contact with Government Agency is to be directed to the designated | |
| 227 | + representative as follows: J. Ritchie Carroll <mailto:jrcarrol@tva.gov>. | |
| 228 | + | |
| 229 | +*/ | |
| 230 | +#endregion | |
| 231 | + | |
| 232 | +using System; | |
| 233 | +using System.Collections.Generic; | |
| 234 | +using System.Collections.ObjectModel; | |
| 235 | +using System.Web.Hosting; | |
| 236 | + | |
| 237 | +namespace GSF.Web.Hosting | |
| 238 | +{ | |
| 239 | + /// <summary> | |
| 240 | + /// A strongly typed <see cref="System.Collections.ObjectModel.KeyedCollection{T, T}" /> | |
| 241 | + /// where each element is a <see cref="System.Web.Hosting.VirtualFileBase" /> and is keyed | |
| 242 | + /// off of the <see cref="System.Web.Hosting.VirtualFileBase.VirtualPath" /> | |
| 243 | + /// property. | |
| 244 | + /// </summary> | |
| 245 | + /// <remarks> | |
| 246 | + /// <para> | |
| 247 | + /// The default constructor for this collection does a culture-invariant case-insensitive | |
| 248 | + /// comparison on the keys. This allows for proper case-insensitive web-oriented | |
| 249 | + /// behavior that is generally expected. | |
| 250 | + /// </para> | |
| 251 | + /// </remarks> | |
| 252 | + /// <seealso cref="System.Web.Hosting.VirtualFileBase" /> | |
| 253 | + public class VirtualFileBaseCollection : KeyedCollection<String, VirtualFileBase> | |
| 254 | + { | |
| 255 | + /// <summary> | |
| 256 | + /// Initializes a new instance of the <see cref="GSF.Web.Hosting.VirtualFileBaseCollection" /> class that uses a case-insensitive comparer. | |
| 257 | + /// </summary> | |
| 258 | + /// <seealso cref="GSF.Web.Hosting.VirtualFileBaseCollection" /> | |
| 259 | + public VirtualFileBaseCollection() : base(StringComparer.InvariantCultureIgnoreCase) { } | |
| 260 | + | |
| 261 | + /// <summary> | |
| 262 | + /// Initializes a new instance of the <see cref="GSF.Web.Hosting.VirtualFileBaseCollection" /> class that uses the specified equality comparer. | |
| 263 | + /// </summary> | |
| 264 | + /// <param name="comparer"> | |
| 265 | + /// The implementation of the <see cref="System.Collections.Generic.IEqualityComparer{T}" /> | |
| 266 | + /// generic interface to use when comparing keys, or <see langword="null" /> to use the default | |
| 267 | + /// equality comparer for the type of the key, obtained from <see cref="System.Collections.Generic.EqualityComparer{T}.Default" />. | |
| 268 | + /// </param> | |
| 269 | + /// <seealso cref="GSF.Web.Hosting.VirtualFileBaseCollection" /> | |
| 270 | + public VirtualFileBaseCollection(IEqualityComparer<String> comparer) : base(comparer) { } | |
| 271 | + | |
| 272 | + /// <summary> | |
| 273 | + /// Initializes a new instance of the <see cref="GSF.Web.Hosting.VirtualFileBaseCollection" /> class that uses the specified equality comparer. | |
| 274 | + /// </summary> | |
| 275 | + /// <param name="comparer"> | |
| 276 | + /// The implementation of the <see cref="System.Collections.Generic.IEqualityComparer{T}" /> | |
| 277 | + /// generic interface to use when comparing keys, or <see langword="null" /> to use the default | |
| 278 | + /// equality comparer for the type of the key, obtained from <see cref="System.Collections.Generic.EqualityComparer{T}.Default" />. | |
| 279 | + /// </param> | |
| 280 | + /// <param name="dictionaryCreationThreshold"> | |
| 281 | + /// The number of elements the collection can hold without creating a lookup dictionary | |
| 282 | + /// (0 creates the lookup dictionary when the first item is added), or ?1 to specify that | |
| 283 | + /// a lookup dictionary is never created. | |
| 284 | + /// </param> | |
| 285 | + /// <seealso cref="GSF.Web.Hosting.VirtualFileBaseCollection" /> | |
| 286 | + public VirtualFileBaseCollection(IEqualityComparer<String> comparer, int dictionaryCreationThreshold) : base(comparer, dictionaryCreationThreshold) { } | |
| 287 | + | |
| 288 | + /// <summary> | |
| 289 | + /// Extracts the key from the specified element. | |
| 290 | + /// </summary> | |
| 291 | + /// <param name="item"> | |
| 292 | + /// The <see cref="System.Web.Hosting.VirtualFileBase" /> element from which to extract the key (<see cref="System.Web.Hosting.VirtualFileBase.VirtualPath" />). | |
| 293 | + /// </param> | |
| 294 | + /// <seealso cref="GSF.Web.Hosting.VirtualFileBaseCollection" /> | |
| 295 | + protected override String GetKeyForItem(VirtualFileBase item) | |
| 296 | + { | |
| 297 | + return item.VirtualPath; | |
| 298 | + } | |
| 299 | + } | |
| 300 | +} | |