Ejemplo n.º 1
0
        private static void AddSection(DocX document, IIndicator i, bool detail, int level1, int?level2 = null, int?level3 = null)
        {
            var sb       = new StringBuilder();
            var color    = Color.Black;
            var fontSize = 12;

            if (level3 != null)
            {
                sb.Append($"{level1}.{level2}.{level3} ");
            }
            else if (level2 != null)
            {
                sb.Append($"{level1}.{level2} ");
                color = _blue;
            }
            else
            {
                sb.Append($"{level1} ");
                color    = _blue;
                fontSize = 14;
            }

            var value = i.Value?.ToString() ?? "N/A";

            sb.Append($"{i.Name}: {value}");
            if (i.Weight != null)
            {
                sb.Append($" ({i.Weight:N2})");
            }

            document.InsertParagraph(sb.ToString()).Color(color).FontSize(fontSize);
            if (i.UserOverride != null)
            {
                document.InsertParagraph($"Value set by assessor" + (i.OverrideComment != null ? $": {i.OverrideComment}" : ".")).Alignment = Alignment.center;
            }
            if (!detail || i.Value == null || i.UserOverride != null || !_detailStrategy.ContainsKey(i.GetType()))
            {
                return;
            }

            // detail
            _detailStrategy[i.GetType()](document, i);
        }
Ejemplo n.º 2
0
        static void SaveCore(IIndicator indicator, Stream stream, StreamingContextStates state = StreamingContextStates.All)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (!indicator.GetType().IsSerializable)
            {
                throw new InvalidOperationException("In order support indicator saving its type must be marked with Serializable attribute.");
            }

            var formatter = new BinaryFormatter
            {
                Context = new StreamingContext(state)
            };

            formatter.Serialize(stream, indicator);
        }
Ejemplo n.º 3
0
 public IIndicator CreateInstance(IIndicator indicator)
 {
     return((IIndicator)Activator.CreateInstance(indicator.GetType()));
 }
Ejemplo n.º 4
0
        public static bool IsNonPeriodIndicator(this IIndicator indicator)
        {
            bool result = NonPeriodIndicatorTypes.Contains(indicator.GetType());

            return(result);
        }