void AnalyzePropertyAttr(TypeDefinition typeDef, XamlContext txt, XAttribute attr)
        {
            XamlPropertyName name = XamlPropertyName.Parse(typeDef, attr.Name, txt);

            name.Xmlns = attr.Parent.GetPrefixOfNamespace(name.Xmlns);
            var prop = ResolveProperty(name.TypeDef, name.PropertyName);

            if (prop != null && Assemblies.Contains(prop.DeclaringType.Module.Assembly))
            {
                IXmlLineInfo li   = attr as IXmlLineInfo;
                string       line = txt.lines[li.LineNumber - 1];
                int          end  = line.IndexOf('=', li.LinePosition - 1);
                string       str  = line.Substring(li.LinePosition - 1, end - li.LinePosition + 1);
                var          r    = new XamlPropertyNameReference()
                {
                    Name = name
                };
                txt.refers.Add(new XamlRef()
                {
                    lineNum = li.LineNumber - 1,
                    index   = li.LinePosition - 1,
                    length  = end - li.LinePosition + 1,
                    name    = name,
                    refer   = r
                });
                ((prop as IAnnotationProvider).Annotations[RenRef] as List <IReference>).Add(r);
            }

            if (name.Xmlns == "x" && name.PropertyName == "Class")
            {
                IXmlLineInfo li       = attr as IXmlLineInfo;
                string       line     = txt.lines[li.LineNumber - 1];
                int          start    = line.IndexOf('=', li.LinePosition - 1) + 2;
                int          end      = line.IndexOf(line[start - 1], start);
                string       fullName = line.Substring(start, end - start);

                TypeDefinition type = txt.context.MainModule.GetType(fullName);
                if (type != null)
                {
                    var n = new XamlClrName()
                    {
                        Namespace = type.Namespace, Name = type.Name
                    };
                    var r = new XamlClrNameReference()
                    {
                        Name = n
                    };
                    txt.refers.Add(new XamlRef()
                    {
                        lineNum = li.LineNumber - 1,
                        index   = start,
                        length  = end - start,
                        name    = n,
                        refer   = r
                    });
                    ((type as IAnnotationProvider).Annotations[RenRef] as List <IReference>).Add(r);
                }
            }
        }
Beispiel #2
0
        void AnalyzePropertyAttr(TypeDefinition typeDef, XamlContext txt, XAttribute attr)
        {
            XamlPropertyName name = XamlPropertyName.Parse(typeDef, attr.Name, txt);
            name.Xmlns = attr.Parent.GetPrefixOfNamespace(name.Xmlns);
            var prop = ResolveProperty(name.TypeDef, name.PropertyName);
            if (prop != null && Assemblies.Contains(prop.DeclaringType.Module.Assembly))
            {
                IXmlLineInfo li = attr as IXmlLineInfo;
                string line = txt.lines[li.LineNumber - 1];
                int end = line.IndexOf('=', li.LinePosition - 1);
                string str = line.Substring(li.LinePosition - 1, end - li.LinePosition + 1);
                var r = new XamlPropertyNameReference() { Name = name };
                txt.refers.Add(new XamlRef()
                {
                    lineNum = li.LineNumber - 1,
                    index = li.LinePosition - 1,
                    length = end - li.LinePosition + 1,
                    name = name,
                    refer = r
                });
                ((prop as IAnnotationProvider).Annotations[RenRef] as List<IReference>).Add(r);
            }

            if (name.Xmlns == "x" && name.PropertyName == "Class")
            {
                IXmlLineInfo li = attr as IXmlLineInfo;
                string line = txt.lines[li.LineNumber - 1];
                int start = line.IndexOf('=', li.LinePosition - 1) + 2;
                int end = line.IndexOf(line[start - 1], start);
                string fullName = line.Substring(start, end - start);

                TypeDefinition type = txt.context.MainModule.GetType(fullName);
                if (type != null)
                {
                    var n = new XamlClrName() { Namespace = type.Namespace, Name = type.Name };
                    var r = new XamlClrNameReference() { Name = n };
                    txt.refers.Add(new XamlRef()
                    {
                        lineNum = li.LineNumber - 1,
                        index = start,
                        length = end - start,
                        name = n,
                        refer = r
                    });
                    ((type as IAnnotationProvider).Annotations[RenRef] as List<IReference>).Add(r);
                }
            }
        }