Exemplo n.º 1
0
        private static void SaveDecorators(IDecoratable decoratable, CodeWriter writer)
        {
            foreach (Decorator decorator in decoratable.Decorators)
            {
                DecoratorDef decoratorDef = decorator.Definition;
                writer.Write("[{0}", decoratorDef.Name);

                if (decorator.Arguments.Count > 0 && decoratorDef.Properties.Count > 0)
                {
                    writer.Write("(");

                    Boolean isFirst = true;
                    for (Int32 i = 0; i < decorator.Arguments.Count; i += 1)
                    {
                        DecoratorPropertyDef propertyDef = decorator.Arguments[i].Definition;
                        if (!decorator.Arguments[i].Value.Equals(propertyDef.Default))
                        {
                            if (!isFirst)
                            {
                                writer.Write(", ");
                            }
                            else
                            {
                                isFirst = false;
                            }

                            writer.Write("{0} = {1}", propertyDef.Name, decorator.Arguments[i].Value);
                        }
                    }

                    writer.Write(")");
                }
                writer.WriteLine("]");
            }
        }
Exemplo n.º 2
0
        private static void SaveDecorator(DecoratorDef decoratorDef, CodeWriter writer)
        {
            SaveComments(decoratorDef, writer);
            SaveDecorators(decoratorDef, writer);

            writer.Write("decorator {0} {{", decoratorDef.Name);
            writer.Indent();

            if (decoratorDef.DefinedConstants.Count > 0)
            {
                writer.NewLine();
                SaveConstants(decoratorDef, writer);
            }

            SaveTypeScope(decoratorDef, writer);

            if (decoratorDef.Properties.Count > 0)
            {
                writer.NewLine();
                for (Int32 index = 0; index < decoratorDef.Properties.Count; index += 1)
                {
                    DecoratorPropertyDef propertyDef = decoratorDef.Properties[index];
                    SaveComments(propertyDef, writer);
                    SaveDecorators(propertyDef, writer);

                    if (propertyDef.Default == null)
                    {
                        writer.WriteLine("{0} {1};", propertyDef.Type, propertyDef.Name);
                    }
                    else
                    {
                        writer.WriteLine("{0} {1} = {2};", propertyDef.Type, propertyDef.Name, propertyDef.Default);
                    }
                    if (index + 1 < decoratorDef.Properties.Count)
                    {
                        writer.NewLine();
                    }
                }
            }

            writer.Dedent();
            writer.WriteLine("}");
        }
Exemplo n.º 3
0
 public DecoratorPropertyValue(DecoratorPropertyDef definition, Literal value, Boolean isDefault)
 {
     Definition = definition;
     Value      = value;
     IsDefault  = isDefault;
 }