IsTranslated() public method

public IsTranslated ( object obj ) : bool
obj object
return bool
Example #1
0
        public static void GetProps(ObjectWrapper wrapper, XmlElement parent_elem)
        {
            ClassDescriptor klass = wrapper.ClassDescriptor;

            foreach (ItemGroup group in klass.ItemGroups)
            {
                foreach (ItemDescriptor item in group)
                {
                    PropertyDescriptor prop = item as PropertyDescriptor;
                    if (prop == null)
                    {
                        continue;
                    }
                    if (!prop.VisibleFor(wrapper.Wrapped) || !prop.CanWrite || prop.Name == "Name")                             // Name is written in the id attribute
                    {
                        continue;
                    }

                    object value = prop.GetValue(wrapper.Wrapped);

                    // If the property has its default value, we don't need to write it
                    if (value == null || (prop.HasDefault && prop.IsDefaultValue(value)))
                    {
                        continue;
                    }

                    string val = prop.ValueToString(value);
                    if (val == null)
                    {
                        continue;
                    }

                    XmlElement prop_elem = parent_elem.OwnerDocument.CreateElement("property");
                    prop_elem.SetAttribute("name", prop.Name);
                    if (val.Length > 0)
                    {
                        prop_elem.InnerText = val;
                    }

                    if (prop.Translatable && prop.IsTranslated(wrapper.Wrapped))
                    {
                        prop_elem.SetAttribute("translatable", "yes");
                        string tcx = prop.TranslationContext(wrapper.Wrapped);
                        if (tcx != null && tcx.Length > 0)
                        {
                            prop_elem.SetAttribute("context", "yes");
                            prop_elem.InnerText = tcx + "|" + prop_elem.InnerText;
                        }
                        string tcm = prop.TranslationComment(wrapper.Wrapped);
                        if (tcm != null && tcm.Length > 0)
                        {
                            prop_elem.SetAttribute("comments", prop.TranslationComment(wrapper.Wrapped));
                        }
                    }

                    parent_elem.AppendChild(prop_elem);
                }
            }
        }
Example #2
0
 internal protected virtual CodeExpression GenerateObjectCreation(GeneratorContext ctx)
 {
     if (ClassDescriptor.InitializationProperties != null)
     {
         CodeExpression[] paramters = new CodeExpression [ClassDescriptor.InitializationProperties.Length];
         for (int n = 0; n < paramters.Length; n++)
         {
             PropertyDescriptor prop = ClassDescriptor.InitializationProperties [n];
             paramters [n] = ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated(Wrapped));
         }
         return(new CodeObjectCreateExpression(WrappedTypeName.ToGlobalTypeRef(), paramters));
     }
     else
     {
         return(new CodeObjectCreateExpression(WrappedTypeName.ToGlobalTypeRef()));
     }
 }
Example #3
0
        protected virtual void GeneratePropertySet(GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
        {
            object oval = prop.GetValue(Wrapped);

            if (oval == null || (prop.HasDefault && prop.IsDefaultValue(oval)))
            {
                return;
            }

            CodeExpression val = ctx.GenerateValue(oval, prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated(Wrapped));
            CodeExpression cprop;

            TypedPropertyDescriptor tprop = prop as TypedPropertyDescriptor;

            if (tprop == null || tprop.GladeProperty == prop)
            {
                cprop = new CodePropertyReferenceExpression(var, prop.Name);
            }
            else
            {
                cprop = new CodePropertyReferenceExpression(var, tprop.GladeProperty.Name);
                cprop = new CodePropertyReferenceExpression(cprop, prop.Name);
            }
            ctx.Statements.Add(new CodeAssignStatement(cprop, val));
        }
Example #4
0
		protected virtual void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
		{
			object oval = prop.GetValue (Wrapped);
			if (oval == null || (prop.HasDefault && prop.IsDefaultValue (oval)))
				return;
				
			CodeExpression val = ctx.GenerateValue (oval, prop.RuntimePropertyType, prop.Translatable && prop.IsTranslated (Wrapped));
			CodeExpression cprop;
			
			TypedPropertyDescriptor tprop = prop as TypedPropertyDescriptor;
			if (tprop == null || tprop.GladeProperty == prop) {
				cprop = new CodePropertyReferenceExpression (var, prop.Name);
			} else {
				cprop = new CodePropertyReferenceExpression (var, tprop.GladeProperty.Name);
				cprop = new CodePropertyReferenceExpression (cprop, prop.Name);
			}
			ctx.Statements.Add (new CodeAssignStatement (cprop, val));
		}