internal static void SetSIFTLevelsProperty(this SIFTLevelsProperty property, string propertyValue)
        {
            property.EmptyValueIsSet = true;
            propertyValue            = RemoveSurroundingSquareBrackets(propertyValue);

            while (!string.IsNullOrEmpty(propertyValue))
            {
                property.EmptyValueIsSet = false;
                var siftLevelLine = Parsing.MustMatch(ref propertyValue, @"^\{(.*?)\}").Groups[1].Value;
                var fields        = siftLevelLine.Split(",".ToCharArray());
                var siftLevel     = property.Value.Add(new SIFTLevel());

                foreach (var field in fields)
                {
                    var field2    = field;
                    var match     = Parsing.MustMatch(ref field2, @"^([^:]+)(:(.*))?");
                    var fieldName = match.Groups[1].Value;
                    var aspect    = match.Groups[3].Value;

                    siftLevel.Components.Add(new SIFTLevelComponent(fieldName, aspect));
                }

                Parsing.TryMatch(ref propertyValue, @"^,\s?");
            }
        }
Пример #2
0
        public static void Write(this SIFTLevelsProperty property, bool isLastProperty, PropertiesStyle style, CSideWriter writer)
        {
            //SIFTLevelsToMaintain=[{G/L Account No.,Global Dimension 1 Code},
            //          {G/L Account No.,Global Dimension 1 Code,Global Dimension 2 Code},
            //          {G/L Account No.,Global Dimension 1 Code,Global Dimension 2 Code,Posting Date:Year},
            //          {G/L Account No.,Global Dimension 1 Code,Global Dimension 2 Code,Posting Date:Month},
            //          {G/L Account No.,Global Dimension 1 Code,Global Dimension 2 Code,Posting Date:Day}] }

            writer.Write("{0}=[", property.Name);
            writer.Indent(writer.Column);

            foreach (var siftLevel in property.Value)
            {
                writer.Write("{");
                writer.Write(string.Join(",", siftLevel.Components.Select(f => f.FieldName + (!string.IsNullOrEmpty(f.Aspect) ? string.Format(":{0}", f.Aspect) : string.Empty))));

                var isLastLine = (siftLevel == property.Value.Last());

                switch (isLastLine)
                {
                case true:
                    switch (isLastProperty)
                    {
                    case true:
                        writer.Write("}] ");
                        break;

                    default:
                        writer.WriteLine("}];");
                        break;
                    }
                    break;

                default:
                    writer.WriteLine("},");
                    break;
                }
            }

            writer.Unindent();
        }