~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Project/Src/WixElementBase.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.IO;
 
6
using System.Text;
 
7
using System.Xml;
 
8
 
 
9
namespace ICSharpCode.WixBinding
 
10
{
 
11
        public abstract class WixElementBase : XmlElement
 
12
        {
 
13
                public WixElementBase(string localName, WixDocument document)
 
14
                        : base(document.GetWixNamespacePrefix(), localName, WixNamespaceManager.Namespace, document)
 
15
                {
 
16
                }
 
17
                
 
18
                public string Id {
 
19
                        get { return GetAttribute("Id"); }
 
20
                        set { SetAttribute("Id", value); }
 
21
                }
 
22
                
 
23
                public string GetXml(WixTextWriter wixWriter)
 
24
                {
 
25
                        StringBuilder xml = new StringBuilder();
 
26
                        StringWriter stringWriter = new StringWriter(xml);
 
27
                        using (XmlWriter xmlWriter = wixWriter.Create(stringWriter)) {
 
28
                                WriteTo(xmlWriter);
 
29
                        }
 
30
                        return RemoveWixNamespace(xml.ToString());
 
31
                }
 
32
                
 
33
                string RemoveWixNamespace(string xml)
 
34
                {
 
35
                        string namespaceDeclaration = String.Concat(" xmlns=\"", WixNamespaceManager.Namespace, "\"");
 
36
                        return xml.Replace(namespaceDeclaration, String.Empty);
 
37
                }
 
38
                
 
39
                protected WixDocument OwnerWixDocument {
 
40
                        get { return (WixDocument)OwnerDocument; }
 
41
                }
 
42
        }
 
43
}