Beispiel #1
0
        public IEnumerable GetProperties(object obj)
        {
            Wrapper.Action action = obj as Wrapper.Action;
            if (action != null)
            {
                foreach (ItemGroup iset in action.ClassDescriptor.ItemGroups)
                {
                    foreach (ItemDescriptor it in iset)
                    {
                        PropertyDescriptor prop = it as PropertyDescriptor;

                        if (!prop.VisibleFor(action.Wrapped) || !prop.CanWrite)
                        {
                            continue;
                        }

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

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

                        yield return(it);
                    }
                }
            }
            else if (obj is ActionGroup)
            {
                yield return("name");                   // ActionGroup only has one property, the name
            }
            else
            {
                yield break;
            }
        }
		protected virtual void GenerateChildPropertySet (GeneratorContext ctx, CodeVariableReferenceExpression var, ClassDescriptor containerChildClass, PropertyDescriptor prop, object child)
		{
			if (containerChildClass.InitializationProperties != null && Array.IndexOf (containerChildClass.InitializationProperties, prop) != -1)
				return;
			
			// Design time
			if (prop.Name == "AutoSize")
				return;
				
			object oval = prop.GetValue (child);
			if (oval == null || (prop.HasDefault && prop.IsDefaultValue (oval)))
				return;
				
			CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, prop.Name);
			CodeExpression val = ctx.GenerateValue (oval, prop.RuntimePropertyType, prop.Translatable);
			ctx.Statements.Add (new CodeAssignStatement (cprop, val));
		}