コード例 #1
0
ファイル: XamlXmlReader.cs プロジェクト: cm4ker/Portable.Xaml
        void ProcessAttributesToMember(StartTagInfo sti, XamlType xt)
        {
            sti.Members.Capacity = Math.Max(sti.Members.Capacity, sti.Members.Count + sti.Attributes.Count);
            for (int i = 0; i < sti.Attributes.Count; i++)
            {
                var    p      = sti.Attributes[i];
                int    idx    = p.Key.IndexOf(':');
                string prefix = idx > 0 ? p.Key.Substring(0, idx) : String.Empty;
                string name   = idx > 0 ? p.Key.Substring(idx + 1) : p.Key;

                var am = FindAttachableMember(prefix, name);
                if (am != null)
                {
                    sti.Members.Add(new Pair(am, p.Value));
                    continue;
                }
                var xm = xt.GetMember(name);
                if (xm != null)
                {
                    sti.Members.Add(new Pair(xm, p.Value));
                }
                else
                {
                    // unknown attributes go through!
                    sti.Members.Add(new Pair(new XamlMember(name, xt, false), p.Value));
                }
            }
        }
コード例 #2
0
ファイル: XamlXmlReader.cs プロジェクト: pmq20/mono_forked
 void ProcessAttributesToMember(XamlSchemaContext sctx, StartTagInfo sti, XamlType xt)
 {
     foreach (var p in sti.Attributes)
     {
         int    idx    = p.Key.IndexOf(':');
         string prefix = idx > 0 ? p.Key.Substring(0, idx) : String.Empty;
         string aname  = idx > 0 ? p.Key.Substring(idx + 1) : p.Key;
         idx = aname.IndexOf('.');
         if (idx > 0)
         {
             string apns   = prefix.Length > 0 ? r.LookupNamespace(prefix) : r.NamespaceURI;
             var    apname = aname.Substring(0, idx);
             var    axtn   = new XamlTypeName(apns, apname, null);
             var    at     = sctx.GetXamlType(axtn);
             var    am     = at.GetAttachableMember(aname.Substring(idx + 1));
             if (am != null)
             {
                 sti.Members.Add(new Pair(am, p.Value));
             }
             // ignore unknown attribute
         }
         var xm = xt.GetMember(aname);
         if (xm != null)
         {
             sti.Members.Add(new Pair(xm, p.Value));
         }
         // ignore unknown attribute
     }
 }
コード例 #3
0
        void ProcessAttributesToMember(XamlSchemaContext sctx, StartTagInfo sti, XamlType xt)
        {
            foreach (var p in sti.Attributes)
            {
                int    nsidx   = p.Key.IndexOf(':');
                string prefix  = nsidx > 0 ? p.Key.Substring(0, nsidx) : String.Empty;
                string aname   = nsidx > 0 ? p.Key.Substring(nsidx + 1) : p.Key;
                int    propidx = aname.IndexOf('.');
                if (propidx > 0)
                {
                    string apns   = r.LookupNamespace(prefix);
                    var    apname = aname.Substring(0, propidx);
                    var    axtn   = new XamlTypeName(apns, apname, null);

                    if (xt.UnderlyingType == null)
                    {
                        var am = XamlMember.FromUnknown(aname.Substring(propidx + 1), apns, new XamlType(apns, apname, new List <XamlType>(), sctx));
                        sti.Members.Add(new Pair(am, p.Value));
                    }
                    else
                    {
                        var at = sctx.GetXamlType(axtn);
                        var am = at.GetAttachableMember(aname.Substring(propidx + 1));
                        if (am != null)
                        {
                            sti.Members.Add(new Pair(am, p.Value));
                        }
                        else
                        {
                            sti.Members.Add(new Pair(XamlMember.FromUnknown(aname, apns, new XamlType(apns, apname, new List <XamlType>(), sctx)), p.Value));
                        }
                    }
                }
                else
                {
                    var xm = xt.GetMember(aname);
                    if (xm != null)
                    {
                        sti.Members.Add(new Pair(xm, p.Value));
                    }
                    else
                    {
                        sti.Members.Add(new Pair(XamlMember.FromUnknown(p.Key, r.NamespaceURI, xt), p.Value));
                    }
                }
            }
        }
コード例 #4
0
ファイル: XamlXmlReader.cs プロジェクト: Benrnz/Portable.Xaml
        void ProcessAttributesToMember(StartTagInfo sti, XamlType xt)
        {
            foreach (var p in sti.Attributes)
            {
                int    idx    = p.Key.IndexOf(':');
                string prefix = idx > 0 ? p.Key.Substring(0, idx) : String.Empty;
                string name   = idx > 0 ? p.Key.Substring(idx + 1) : p.Key;

                var am = FindAttachableMember(prefix, name);
                if (am != null)
                {
                    sti.Members.Add(new Pair(am, p.Value));
                    continue;
                }
                var xm = xt.GetMember(name);
                if (xm != null)
                {
                    sti.Members.Add(new Pair(xm, p.Value));
                }
                // ignore unknown attribute
            }
        }
コード例 #5
0
		void ProcessAttributesToMember (XamlSchemaContext sctx, StartTagInfo sti, XamlType xt)
		{
			foreach (var p in sti.Attributes) {
				int idx = p.Key.IndexOf (':');
				string prefix = idx > 0 ? p.Key.Substring (0, idx) : String.Empty;
				string aname = idx > 0 ? p.Key.Substring (idx + 1) : p.Key;
				idx = aname.IndexOf ('.');
				if (idx > 0) {
					string apns = prefix.Length > 0 ? r.LookupNamespace (prefix) : r.NamespaceURI;
					var apname = aname.Substring (0, idx);
					var axtn = new XamlTypeName (apns, apname, null);
					var at = sctx.GetXamlType (axtn);
					var am = at.GetAttachableMember (aname.Substring (idx + 1));
					if (am != null)
						sti.Members.Add (new Pair (am, p.Value));
					// ignore unknown attribute
				}
				var xm = xt.GetMember (aname);
				if (xm != null)
					sti.Members.Add (new Pair (xm, p.Value));
				// ignore unknown attribute
			}
		}
コード例 #6
0
		void ProcessAttributesToMember (StartTagInfo sti, XamlType xt)
		{
			foreach (var p in sti.Attributes) {
				int idx = p.Key.IndexOf (':');
				string prefix = idx > 0 ? p.Key.Substring (0, idx) : String.Empty;
				string name = idx > 0 ? p.Key.Substring (idx + 1) : p.Key;

				var am = FindAttachableMember (prefix, name);
				if (am != null) {
					sti.Members.Add (new Pair (am, p.Value));
					continue;
				}
				var xm = xt.GetMember (name);
				if (xm != null)
					sti.Members.Add (new Pair (xm, p.Value));
				// ignore unknown attribute
			}
		}