~bratsche/ubuntu/maverick/monodevelop/disable-appmenu

« back to all changes in this revision

Viewing changes to src/addins/AspNetAddIn/MonoDevelop.AspNet/ProjectRegisteredControls.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2009-03-17 17:55:55 UTC
  • mfrom: (1.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20090317175555-2w5qbmu0l5maq6fq
Tags: 1.9.3+dfsg-1ubuntu1
* FFe for Monodevelop 2 granted by motu-release team :)
* Merge from Debian Unstable , remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
using System;
30
30
using System.Collections.Generic;
31
31
using System.IO;
32
 
using System.Web.Configuration;
33
32
using System.Xml;
34
33
 
35
34
namespace MonoDevelop.AspNet
45
44
                        this.project = project;
46
45
                }
47
46
                
48
 
                public IList<TagPrefixInfo> GetInfosForPath (string webDirectory)
 
47
                public IList<RegistrationInfo> GetInfosForPath (string webDirectory)
49
48
                {
50
 
                        List<TagPrefixInfo> infos = new List<TagPrefixInfo> ();
 
49
                        List<RegistrationInfo> infos = new List<RegistrationInfo> ();
51
50
                        DirectoryInfo dir = new DirectoryInfo (webDirectory);
52
51
                        string projectRootParent = new DirectoryInfo (project.BaseDirectory).Parent.FullName;
53
 
                        while (dir != null && dir.FullName.Length < projectRootParent.Length && dir.FullName != projectRootParent)
 
52
                        while (dir != null && dir.FullName.Length > projectRootParent.Length && dir.FullName != projectRootParent)
54
53
                        {
55
54
                                string configPath = Path.Combine (dir.FullName, "web.config");
56
55
                                try {
66
65
                        return infos;
67
66
                }
68
67
                
69
 
                IEnumerable<TagPrefixInfo> GetInfosForFile (string filename)
 
68
                IEnumerable<RegistrationInfo> GetInfosForFile (string filename)
70
69
                {
71
70
                        WebConfig cached;
72
71
                        DateTime lastWriteUtc = File.GetLastWriteTimeUtc (filename);
79
78
                        return cached.Infos;
80
79
                }
81
80
                
82
 
                TagPrefixInfo[] LoadWebConfig (string configFile)
 
81
                RegistrationInfo[] LoadWebConfig (string configFile)
83
82
                {
84
 
                        List<TagPrefixInfo> list = new List<TagPrefixInfo> ();
 
83
                        List<RegistrationInfo> list = new List<RegistrationInfo> ();
85
84
                        using (XmlTextReader reader = new XmlTextReader (configFile))
86
85
                        {
87
86
                                reader.WhitespaceHandling = WhitespaceHandling.None;
92
91
                                        && reader.ReadToDescendant ("controls") && reader.NodeType == XmlNodeType.Element
93
92
                                    && reader.ReadToDescendant ("add") && reader.NodeType == XmlNodeType.Element) {
94
93
                                        do {
95
 
                                                list.Add (new TagPrefixInfo (
 
94
                                                list.Add (new RegistrationInfo (
 
95
                                                        configFile,
96
96
                                                        reader.GetAttribute ("tagPrefix"),
97
97
                                                        reader.GetAttribute ("namespace"),
98
98
                                                        reader.GetAttribute ("assembly"),
99
99
                                                        reader.GetAttribute ("tagName"),
100
100
                                                        reader.GetAttribute ("src")
101
101
                                                ));
 
102
                                                //Console.WriteLine (list[list.Count -1]);
102
103
                                        } while (reader.ReadToNextSibling ("add"));
103
104
                                }
104
105
                        }
109
110
                class WebConfig
110
111
                {
111
112
                        public DateTime LastWriteUtc;
112
 
                        public TagPrefixInfo[] Infos;
113
 
                }
 
113
                        public RegistrationInfo[] Infos;
 
114
                }
 
115
        }
 
116
        
 
117
        class RegistrationInfo
 
118
        {
 
119
                public string TagPrefix { get; set; }
 
120
                public string Namespace { get; set; }
 
121
                public string Assembly { get; set; }
 
122
                public string TagName { get; set; }
 
123
                public string Source { get; set; }
 
124
                public string ConfigFile { get; set; }
 
125
                
 
126
                public bool IsAssembly {
 
127
                        get {
 
128
                                return !string.IsNullOrEmpty (Assembly) && !String.IsNullOrEmpty (TagPrefix) && !string.IsNullOrEmpty (Namespace);
 
129
                        }
 
130
                }
 
131
                
 
132
                public bool IsUserControl {
 
133
                        get {
 
134
                                return !string.IsNullOrEmpty (TagName) && !String.IsNullOrEmpty (TagPrefix) && !string.IsNullOrEmpty (Source);
 
135
                        }
 
136
                }
 
137
                
 
138
                public bool PrefixMatches (string prefix)
 
139
                {
 
140
                         return 0 == string.Compare (TagPrefix, prefix, StringComparison.InvariantCultureIgnoreCase);
 
141
                }
 
142
                
 
143
                public bool NameMatches (string name)
 
144
                {
 
145
                         return 0 == string.Compare (TagName, name, StringComparison.InvariantCultureIgnoreCase);
 
146
                }
 
147
                
 
148
                public RegistrationInfo (string configFile, string tagPrefix, string _namespace, string assembly, string tagName, string src)
 
149
                {
 
150
                        ConfigFile = configFile;
 
151
                        TagPrefix = tagPrefix;
 
152
                        Namespace = _namespace;
 
153
                        Assembly = assembly;
 
154
                        TagName = tagName;
 
155
                        Source = src;
 
156
                }
 
157
                
 
158
                public override string ToString ()
 
159
                {
 
160
                        return string.Format("[RegistrationInfo: TagPrefix={0}, Namespace={1}, Assembly={2}, TagName={3}, Source={4}, ConfigFile={5}]",
 
161
                                             TagPrefix, Namespace, Assembly, TagName, Source, ConfigFile);
 
162
                }
 
163
 
114
164
        }
115
165
}