~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/TypeReference.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
//
32
32
 
33
33
using System;
34
 
using MonoDevelop.Projects.Serialization;
 
34
using System.ComponentModel;
 
35
using MonoDevelop.Core.Serialization;
35
36
 
36
37
namespace MonoDevelop.DesignerSupport.Toolbox
37
38
{
38
39
        [Serializable]
 
40
        [TypeConverter (typeof (TypeReferenceTypeConverter))]
39
41
        public class TypeReference
40
42
        {
41
43
                //private serialisable fields
42
44
                [ItemProperty ("location")]
43
 
                string assemblyLocation = "";
 
45
                string assemblyLocation = string.Empty;
44
46
                [ItemProperty ("assembly")]
45
 
                string assemblyName = "";
 
47
                string assemblyName = string.Empty;
46
48
                [ItemProperty ("name")]
47
 
                string typeName = "";
 
49
                string typeName = string.Empty;
48
50
                
49
51
                //for deserialisation
50
52
                public TypeReference ()
103
105
                
104
106
                #region property accessors for the private fields
105
107
                
 
108
                [DisplayNameAttribute ("Assembly Name")]
 
109
                [DescriptionAttribute ("The assembly name.")]
 
110
                [ReadOnly (true)]
106
111
                public string AssemblyName {
107
112
                        get { return assemblyName; }
108
113
                        set { assemblyName = value; }
109
114
                }
110
115
                
 
116
                [DisplayNameAttribute ("Type Name")]
 
117
                [DescriptionAttribute ("The fully-qualified type name.")]
 
118
                [ReadOnly (true)]
111
119
                public string TypeName {
112
120
                        get { return typeName; }
113
121
                        set { typeName = value; }
114
122
                }
115
123
                
 
124
                [DisplayNameAttribute ("Assembly Location")]
 
125
                [DescriptionAttribute ("The location of the assembly.")]
 
126
                [ReadOnly (true)]
116
127
                public string AssemblyLocation {
117
128
                        get { return assemblyLocation; }
118
129
                        set { assemblyLocation = value; }
137
148
                        
138
149
                        return type;
139
150
                }
 
151
                
 
152
                public MonoDevelop.Projects.ProjectReference GetProjectReference ()
 
153
                {
 
154
                        if (string.IsNullOrEmpty (assemblyLocation)) {
 
155
                                return new MonoDevelop.Projects.ProjectReference (
 
156
                                    MonoDevelop.Projects.ReferenceType.Gac,
 
157
                                    assemblyName);
 
158
                        } else {
 
159
                                return new MonoDevelop.Projects.ProjectReference (
 
160
                                    MonoDevelop.Projects.ReferenceType.Assembly,
 
161
                                    assemblyLocation);
 
162
                        }
 
163
                }
 
164
        }
 
165
        
 
166
        public class TypeReferenceTypeConverter : ExpandableObjectConverter
 
167
        {
 
168
                public override object ConvertTo (ITypeDescriptorContext context, 
 
169
                    System.Globalization.CultureInfo culture, object value, Type destinationType)
 
170
                {
 
171
                        if (destinationType == typeof(string))
 
172
                                return ((TypeReference)value).TypeName;
 
173
                        else
 
174
                                return base.ConvertTo (context, culture, value, destinationType); 
 
175
                }
 
176
                
 
177
                public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
 
178
                {
 
179
                        return destinationType == typeof(string) || base.CanConvertTo (context, destinationType);
 
180
                }
 
181
 
140
182
        }
141
183
}