1 #region Copyright (c) Microsoft Corporation
2 /// <copyright company='Microsoft Corporation'>
3 ///    Copyright (c) Microsoft Corporation. All Rights Reserved.
4 ///    Information Contained Herein is Proprietary and Confidential.
5 /// </copyright>
6 #endregion
7 
8 using System;
9 using XmlSerialization = System.Xml.Serialization;
10 
11 #if WEB_EXTENSIONS_CODE
12 namespace System.Web.Compilation.WCFModel
13 #else
14 namespace Microsoft.VSDesigner.WCFModel
15 #endif
16 {
17     /// <summary>
18     /// This class presents a single file referenced by a svcmap file
19     /// </summary>
20     /// <remarks></remarks>
21 #if WEB_EXTENSIONS_CODE
22     internal class ExtensionFile : ExternalFile
23 #else
24     [CLSCompliant(true)]
25     public class ExtensionFile : ExternalFile
26 #endif
27     {
28         // Extension Item Name
29         private string m_Name;
30 
31         // content buffer
32         private byte[] m_ContentBuffer;
33 
34         /// <summary>
35         /// Constructor
36         /// </summary>
37         /// <remarks> Must support a default construct for XmlSerializer</remarks>
ExtensionFile()38         public ExtensionFile()
39         {
40             m_Name = string.Empty;
41         }
42 
43         /// <summary>
44         /// Constructor
45         /// </summary>
46         /// <param name="name">name of extension item</param>
47         /// <param name="fileName">Suggested File Name</param>
ExtensionFile(string name, string fileName, byte[] content)48         public ExtensionFile(string name, string fileName, byte[] content)
49             : base(fileName)
50         {
51             this.Name = name;
52             m_ContentBuffer = content;
53 
54             IsExistingFile = false;
55         }
56 
57         /// <summary>
58         /// Content of the extension file
59         /// </summary>
60         /// <value></value>
61         /// <remarks></remarks>
62         [XmlSerialization.XmlIgnore()]
63         public byte[] ContentBuffer
64         {
65             get
66             {
67                 return m_ContentBuffer;
68             }
69             set
70             {
71                 m_ContentBuffer = value;
72                 ErrorInLoading = null;
73             }
74         }
75 
76         /// <summary>
77         /// whether the content is buffered
78         /// </summary>
79         /// <value></value>
80         /// <remarks></remarks>
81         internal bool IsBufferValid
82         {
83             get
84             {
85                 return (m_ContentBuffer != null);
86             }
87         }
88 
89         /// <summary>
90         /// Name in the storage
91         /// </summary>
92         /// <value></value>
93         /// <remarks></remarks>
94         [XmlSerialization.XmlAttribute()]
95         public string Name
96         {
97             get
98             {
99                 return m_Name;
100             }
101             set
102             {
103                 if (value == null)
104                 {
105                     throw new ArgumentNullException("value");
106                 }
107                 m_Name = value;
108             }
109         }
110 
111         /// <summary>
112         ///  the function is called when the metadata is removed, and we need clean up the content
113         /// </summary>
114         /// <remarks></remarks>
CleanUpContent()115         internal void CleanUpContent()
116         {
117             ErrorInLoading = null;
118             m_ContentBuffer = null;
119         }
120 
121     }
122 }
123 
124