GetEmbeddedIcon() static private method

static private GetEmbeddedIcon ( AssemblyDefinition asm, string iconname ) : Gdk.Pixbuf
asm Mono.Cecil.AssemblyDefinition
iconname string
return Gdk.Pixbuf
		public CecilClassDescriptor (CecilWidgetLibrary lib, XmlElement element, ClassDescriptor typeClassDescriptor, XmlElement steticDefinition, TypeDefinition cls)
		{
			this.cecilLib = lib;
			this.steticDefinition = steticDefinition;
			this.typeClassDescriptor = typeClassDescriptor;
			wrappedTypeName = element.GetAttribute ("type");
			type = cls;
			Load (element);
			type = null;
			canGenerateCode = true;
			
			string baseType = element.GetAttribute ("base-type");
			if (baseType.Length > 0) {
				wrapperClassDescriptor = Registry.LookupClassByName (baseType);
				if (wrapperClassDescriptor == null)
					throw new InvalidOperationException ("Unknown base type: " + baseType);
			} else {
				wrapperClassDescriptor = typeClassDescriptor;
			}
			
			if (steticDefinition == null && !AllowChildren && NeedsBlackBox (typeClassDescriptor.Name)) {
				// It is not possible to create instances of that widget, instead we'll have
				// to create the typical custom widget black box.
				
				if (!CanCreateWidgetInstance (wrapperClassDescriptor.Name))
					throw new InvalidOperationException ("Can't load widget type '" + Name + "'. Instances of that type can't be created because the type can't be loaded into the process.");
				
				useCustomWidgetBox = true;
			}
			
			widgetId = Name.ToLower ();
			int i = widgetId.LastIndexOf ('.');
			if (i != -1) {
				if (i != widgetId.Length - 1)
					widgetId = widgetId.Substring (i+1);
				else
					widgetId = widgetId.Replace (".", "");
			}
			
			string iconName = element.GetAttribute ("icon");
			icon = lib.GetEmbeddedIcon (iconName);
			
			// If the class is a custom widget created using stetic, it means that it has
			// simple property and there is no custom logic, so it is safe to generate code
			// for this class.
			if (steticDefinition != null)
				canGenerateCode = true;

			// If it has a custom wrapper, then it definitely has custom logic, so it can't generate code 				
			if (element.HasAttribute ("wrapper"))
				canGenerateCode = false;
		}
Example #2
0
        public CecilClassDescriptor(CecilWidgetLibrary lib, XmlElement element, ClassDescriptor typeClassDescriptor, XmlElement steticDefinition, TypeDefinition cls)
        {
            this.cecilLib            = lib;
            this.steticDefinition    = steticDefinition;
            this.typeClassDescriptor = typeClassDescriptor;
            wrappedTypeName          = element.GetAttribute("type");
            type = cls;
            Load(element);
            type            = null;
            canGenerateCode = true;

            string baseType = element.GetAttribute("base-type");

            if (baseType.Length > 0)
            {
                wrapperClassDescriptor = Registry.LookupClassByName(baseType);
                if (wrapperClassDescriptor == null)
                {
                    throw new InvalidOperationException("Unknown base type: " + baseType);
                }
            }
            else
            {
                wrapperClassDescriptor = typeClassDescriptor;
            }

            if (steticDefinition == null && !AllowChildren && NeedsBlackBox(typeClassDescriptor.Name))
            {
                // It is not possible to create instances of that widget, instead we'll have
                // to create the typical custom widget black box.

                if (!CanCreateWidgetInstance(wrapperClassDescriptor.Name))
                {
                    throw new InvalidOperationException("Can't load widget type '" + Name + "'. Instances of that type can't be created because the type can't be loaded into the process.");
                }

                useCustomWidgetBox = true;
            }

            widgetId = Name.ToLower();
            int i = widgetId.LastIndexOf('.');

            if (i != -1)
            {
                if (i != widgetId.Length - 1)
                {
                    widgetId = widgetId.Substring(i + 1);
                }
                else
                {
                    widgetId = widgetId.Replace(".", "");
                }
            }

            string iconName = element.GetAttribute("icon");

            icon = lib.GetEmbeddedIcon(iconName);

            // If the class is a custom widget created using stetic, it means that it has
            // simple property and there is no custom logic, so it is safe to generate code
            // for this class.
            if (steticDefinition != null)
            {
                canGenerateCode = true;
            }

            // If it has a custom wrapper, then it definitely has custom logic, so it can't generate code
            if (element.HasAttribute("wrapper"))
            {
                canGenerateCode = false;
            }
        }