2 // Copyright (C) 2010 Novell Inc. http://novell.com
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 using System.Collections.Generic;
25 using System.ComponentModel;
27 using System.Reflection;
28 using System.Xaml.Schema;
32 public class XamlDirective : XamlMember
34 class DirectiveMemberInvoker : XamlMemberInvoker
36 XamlDirective directive;
38 public DirectiveMemberInvoker (XamlDirective directive)
43 public XamlDirective (string xamlNamespace, string name)
44 : this (new string [] {xamlNamespace}, name, new XamlType (typeof (object), new XamlSchemaContext (new XamlSchemaContextSettings ())), null, AllowedMemberLocations.Any)
46 if (xamlNamespace == null)
47 throw new ArgumentNullException ("xamlNamespace");
51 public XamlDirective (IEnumerable<string> xamlNamespaces, string name, XamlType xamlType, XamlValueConverter<TypeConverter> typeConverter, AllowedMemberLocations allowedLocation)
52 : base (true, xamlNamespaces != null ? xamlNamespaces.FirstOrDefault () : null, name)
54 if (xamlNamespaces == null)
55 throw new ArgumentNullException ("xamlNamespaces");
57 throw new ArgumentNullException ("xamlType");
60 xaml_namespaces = new List<string> (xamlNamespaces);
61 AllowedLocation = allowedLocation;
62 type_converter = typeConverter;
64 invoker = new DirectiveMemberInvoker (this);
67 public AllowedMemberLocations AllowedLocation { get; private set; }
68 XamlValueConverter<TypeConverter> type_converter;
70 XamlMemberInvoker invoker;
72 IList<string> xaml_namespaces;
74 // this is for XamlLanguage.UnknownContent
75 internal bool InternalIsUnknown {
76 set { is_unknown = value; }
79 public override int GetHashCode ()
81 throw new NotImplementedException ();
84 public override IList<string> GetXamlNamespaces ()
86 return xaml_namespaces;
89 protected override sealed ICustomAttributeProvider LookupCustomAttributeProvider ()
91 return null; // as documented.
94 protected override sealed XamlValueConverter<XamlDeferringLoader> LookupDeferringLoader ()
96 return null; // as documented.
99 protected override sealed IList<XamlMember> LookupDependsOn ()
101 return null; // as documented.
104 protected override sealed XamlMemberInvoker LookupInvoker ()
109 protected override sealed bool LookupIsAmbient ()
114 protected override sealed bool LookupIsEvent ()
119 protected override sealed bool LookupIsReadOnly ()
124 protected override sealed bool LookupIsReadPublic ()
129 protected override sealed bool LookupIsUnknown ()
134 protected override sealed bool LookupIsWriteOnly ()
139 protected override sealed bool LookupIsWritePublic ()
144 protected override sealed XamlType LookupTargetType ()
149 protected override sealed XamlType LookupType ()
154 protected override sealed XamlValueConverter<TypeConverter> LookupTypeConverter ()
156 if (type_converter == null)
157 type_converter = base.LookupTypeConverter ();
158 return type_converter;
161 protected override sealed MethodInfo LookupUnderlyingGetter ()
166 protected override sealed MemberInfo LookupUnderlyingMember ()
171 protected override sealed MethodInfo LookupUnderlyingSetter ()
176 public override string ToString ()
178 return String.IsNullOrEmpty (PreferredXamlNamespace) ? Name : String.Concat ("{", PreferredXamlNamespace, "}", Name);