PageRenderTime 64ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/stable-1.2.0/Server/DefaultDocument/FilesCollection.cs

#
C# | 60 lines | 45 code | 7 blank | 8 comment | 4 complexity | 3cc1e7cb6f44bf3c81ec21a188aa0a5e MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. //-----------------------------------------------------------------------
  2. // <copyright>
  3. // Copyright (C) Ruslan Yakushev for the PHP Manager for IIS project.
  4. //
  5. // This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
  6. // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
  7. // </copyright>
  8. //-----------------------------------------------------------------------
  9. using System;
  10. using Microsoft.Web.Administration;
  11. namespace Web.Management.PHP.DefaultDocument
  12. {
  13. public sealed class FilesCollection : ConfigurationElementCollectionBase<FileElement>
  14. {
  15. public new FileElement this[string value]
  16. {
  17. get
  18. {
  19. for (int i = 0; (i < this.Count); i = (i + 1))
  20. {
  21. FileElement element = base[i];
  22. if ((string.Equals(element.Value, value, StringComparison.OrdinalIgnoreCase) == true))
  23. {
  24. return element;
  25. }
  26. }
  27. return null;
  28. }
  29. }
  30. public FileElement AddCopy(FileElement file)
  31. {
  32. FileElement element = CreateElement();
  33. CopyAttributes(file, element);
  34. return Add(element);
  35. }
  36. public FileElement AddCopyAt(int index, FileElement file)
  37. {
  38. FileElement element = CreateElement();
  39. CopyAttributes(file, element);
  40. return AddAt(index, element);
  41. }
  42. private static void CopyAttributes(ConfigurationElement source, ConfigurationElement destination)
  43. {
  44. foreach (ConfigurationAttribute attribute in source.Attributes)
  45. {
  46. if (!attribute.IsInheritedFromDefaultValue)
  47. {
  48. destination[attribute.Name] = attribute.Value;
  49. }
  50. }
  51. }
  52. }
  53. }