Inheritance: Stetic.ClassDescriptor
Example #1
0
        protected override ClassDescriptor LoadClassDescriptor(XmlElement element)
        {
            string name = element.GetAttribute("type");

            TypeDefinition cls = null;

            Stetic.ClassDescriptor typeClassDescriptor;
            string tname;

            if (element.HasAttribute("baseClassType"))
            {
                tname = element.GetAttribute("baseClassType");
                typeClassDescriptor = Stetic.Registry.LookupClassByName(tname);
            }
            else
            {
                cls = assembly.MainModule.Types [name];
                if (cls == null)
                {
                    return(null);
                }

                // Find the nearest type that can be loaded
                typeClassDescriptor = FindType(assembly, cls);
                tname = cls.Name;
                if (typeClassDescriptor != null)
                {
                    element.SetAttribute("baseClassType", typeClassDescriptor.Name);
                    objects_dirty = true;
                }
            }

            if (typeClassDescriptor == null)
            {
                Console.WriteLine("Descriptor not found: " + tname);
                return(null);
            }

            XmlElement steticDefinition = null;

            XmlDocument gui = cache [this.name].GuiDocument;

            if (gui != null)
            {
                string wrappedTypeName = element.GetAttribute("type");
                steticDefinition = (XmlElement)gui.DocumentElement.SelectSingleNode("widget[@id='" + wrappedTypeName + "']");
            }

            CecilClassDescriptor cd = new CecilClassDescriptor(this, element, typeClassDescriptor, steticDefinition, cls);

            if (canGenerateCode && !cd.CanGenerateCode)
            {
                canGenerateCode = false;
            }
            return(cd);
        }
		protected override ClassDescriptor LoadClassDescriptor (XmlElement element)
		{
			string name = element.GetAttribute ("type");
			
			TypeDefinition cls = null;
			Stetic.ClassDescriptor typeClassDescriptor = null;
			string tname;
			
			if (element.HasAttribute ("baseClassType")) {
				tname = element.GetAttribute ("baseClassType");
				typeClassDescriptor = Stetic.Registry.LookupClassByName (tname);
			} else {
				cls = assembly.MainModule.Types [name];
				if (cls != null) {
					// Find the nearest type that can be loaded
					typeClassDescriptor = FindType (assembly, cls);
					tname = cls.Name;
					if (typeClassDescriptor != null) {
						element.SetAttribute ("baseClassType", typeClassDescriptor.Name);
						objects_dirty = true;
					}
				}
			}
			
			if (typeClassDescriptor == null) {
				Console.WriteLine ("Descriptor not found: " + name);
				return null;
			}
			
			XmlElement steticDefinition = null;
			
			XmlDocument gui = cache [filename].GuiDocument;
			if (gui != null) {
				string wrappedTypeName = element.GetAttribute ("type");
				steticDefinition = (XmlElement) gui.DocumentElement.SelectSingleNode ("widget[@id='" + wrappedTypeName + "']");
			}
			
			CecilClassDescriptor cd = new CecilClassDescriptor (this, element, typeClassDescriptor, steticDefinition, cls);
			
			if (canGenerateCode && !cd.CanGenerateCode)
				canGenerateCode = false;
			return cd;
		}