Ejemplo n.º 1
0
 private KeyValuePair <string, string> ParseParameter(IDocumentGeneratorParameter visitable)
 {
     if (visitable is BooleanParameter)
     {
         BooleanParameter b = visitable as BooleanParameter;
         return(new KeyValuePair <string, string>(b.LookingTag, Convert.ToString(b.Value)));
     }
     if (visitable is CharParameter)
     {
         CharParameter ch = visitable as CharParameter;
         return(new KeyValuePair <string, string>(ch.LookingTag, ch.Value.ToString()));
     }
     if (visitable is FloatParameter)
     {
         FloatParameter f = visitable as FloatParameter;
         return(new KeyValuePair <string, string>(f.LookingTag, f.Value.ToString("00.000")));
     }
     if (visitable is GuidParameter)
     {
         GuidParameter g = visitable as GuidParameter;
         return(new KeyValuePair <string, string>(g.LookingTag, g.Value.ToString()));
     }
     if (visitable is IntParameter)
     {
         IntParameter i = visitable as IntParameter;
         return(new KeyValuePair <string, string>(i.LookingTag, i.Value.ToString()));
     }
     if (visitable is StringParameter)
     {
         StringParameter s = visitable as StringParameter;
         return(new KeyValuePair <string, string>(s.LookingTag, HttpUtility.HtmlDecode(s.Value)));
     }
     if (visitable is DateTimeParameter)
     {
         DateTimeParameter d = visitable as DateTimeParameter;
         return(new KeyValuePair <string, string>(d.LookingTag, d.Value.ToShortDateString()));
     }
     throw new DSWException($"Parameter '{visitable.GetType().Name}' is not correct", null, DSWExceptionCode.Invalid);
 }
Ejemplo n.º 2
0
        private void Mapper(IDocumentGeneratorParameter visitable)
        {
            if (visitable is BooleanParameter)
            {
                BooleanParameter v = visitable as BooleanParameter;
                MappedParameters.Add(new SC.BuildValueModel()
                {
                    IsHTML = false,
                    Name   = v.Name,
                    Value  = v.Value.ToString()
                });
                return;
            }
            if (visitable is CharParameter)
            {
                CharParameter v = visitable as CharParameter;
                MappedParameters.Add(new SC.BuildValueModel()
                {
                    IsHTML = false,
                    Name   = v.Name,
                    Value  = v.Value.ToString()
                });
                return;
            }
            if (visitable is FloatParameter)
            {
                FloatParameter v = visitable as FloatParameter;
                MappedParameters.Add(new SC.BuildValueModel()
                {
                    IsHTML = false,
                    Name   = v.Name,
                    Value  = v.Value.ToString()
                });
                return;
            }
            if (visitable is GuidParameter)
            {
                GuidParameter v = visitable as GuidParameter;
                MappedParameters.Add(new SC.BuildValueModel()
                {
                    IsHTML = false,
                    Name   = v.Name,
                    Value  = v.Value.ToString()
                });
                return;
            }
            if (visitable is IntParameter)
            {
                IntParameter v = visitable as IntParameter;
                MappedParameters.Add(new SC.BuildValueModel()
                {
                    IsHTML = false,
                    Name   = v.Name,
                    Value  = v.Value.ToString()
                });
                return;
            }
            if (visitable is StringParameter)
            {
                StringParameter v = visitable as StringParameter;
                MappedParameters.Add(new SC.BuildValueModel()
                {
                    IsHTML = v.HasHtmlValue,
                    Name   = v.Name,
                    Value  = WebUtility.HtmlDecode(v.Value)
                });
                return;
            }
            if (visitable is DateTimeParameter)
            {
                DateTimeParameter v = visitable as DateTimeParameter;
                MappedParameters.Add(new SC.BuildValueModel()
                {
                    IsHTML = false,
                    Name   = v.Name,
                    Value  = v.Value.ToShortDateString()
                });
                return;
            }

            throw new DSWException(string.Concat("Parameter '", visitable.GetType().Name, "' is not correct"), null, DSWExceptionCode.Invalid);
        }