Exemple #1
0
 private void Write(XmlWriter writer, Member member, Shape shape)
 {
     if (shape.IsStructure)
     {
         WriteStructure(writer, shape);
     }
     else if (shape.IsEnum)
     {
         var enumerationWrapper = this._model.Enumerations(true).First(x => x.Name == shape.Name);
         writer.WriteValue(enumerationWrapper.EnumerationValues.ElementAt(0).MarshallName);
     }
     else if (shape.IsString)
     {
         writer.WriteValue(shape.Name + "_Value");
     }
     else if (shape.IsInt)
     {
         writer.WriteValue(int.MaxValue);
     }
     else if (shape.IsLong)
     {
         writer.WriteValue(long.MaxValue);
     }
     else if (shape.IsFloat)
     {
         writer.WriteValue(float.MaxValue);
     }
     else if (shape.IsDouble)
     {
         writer.WriteValue(double.MaxValue);
     }
     else if (shape.IsDateTime)
     {
         writer.WriteValue(ValidatorUtils.GetTestDate(member, shape));
     }
     else if (shape.IsBoolean)
     {
         writer.WriteValue(true);
     }
     else if (shape.IsBlob)
     {
         writer.WriteValue(Constants.DEFAULT_BLOB_ENCODED);
     }
     else
     {
         throw new Exception("Unknown Type for shape " + shape.Name);
     }
 }
Exemple #2
0
        private void WriteStructure(JsonWriter writer, Member memberWithComplexShape, Shape structure)
        {
            var pushed = this._tcr.Push(structure.Name);

            if (!pushed)
            {
                return;
            }

            if (structure.PayloadMemberName != null)
            {
                this.WriteStructure(writer, structure.PayloadMember, structure.PayloadMember.Shape);
                return;
            }

            writer.WriteObjectStart();

            foreach (var member in structure.Members)
            {
                writer.WritePropertyName(member.MarshallName);

                if (member.OverrideDataType != null && string.Equals(member.OverrideDataType.Unmarshaller, "DateTimeEpochLongMillisecondsUnmarshaller"))
                {
                    writer.Write(ValidatorUtils.GetTestEpochTime().TotalMilliseconds);
                }
                else if (member.OverrideDataType != null && string.Equals(member.OverrideDataType.Unmarshaller, "Amazon.Runtime.Internal.Transform.DateTimeUnmarshaller"))
                {
                    writer.Write(Constants.DEFAULT_DATE.ToString(AWSSDKUtils.ISO8601DateFormat, CultureInfo.InvariantCulture));
                }
                else if (member.OverrideDataType != null && string.Equals(member.OverrideDataType.Unmarshaller, "Amazon.Runtime.Internal.Transform.DecimalUnmarshaller"))
                {
                    writer.Write(Constants.DEFAULT_DECIMAL.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    this.Write(writer, member, member.Shape);
                }
            }

            writer.WriteObjectEnd();

            if (pushed)
            {
                this._tcr.Pop();
            }
        }
Exemple #3
0
        private void Write(JsonWriter writer, Member member, Shape shape)
        {
            if (shape.IsDocument)
            {
                var document = InstantiateClassGenerator.Execute <DummyDocumentWrapper>().Document;

                DocumentMarshaller.Instance.Write(
                    writer,
                    document);
            }
            else if (shape.IsStructure)
            {
                WriteStructure(writer, member, shape);
            }
            else if (shape.IsList)
            {
                WriteArray(writer, member, shape);
            }
            else if (shape.IsMap)
            {
                WriteMap(writer, member, shape);
            }
            else if (shape.IsEnum)
            {
                var enumerationWrapper = this._model.Enumerations(true).First(x => x.Name == shape.Name);
                writer.Write(enumerationWrapper.EnumerationValues.ElementAt(0).MarshallName);
            }
            else if (shape.IsString)
            {
                writer.Write(shape.Name + "_Value");
            }
            else if (shape.IsInt)
            {
                writer.Write(int.MaxValue);
            }
            else if (shape.IsLong)
            {
                writer.Write(long.MaxValue);
            }
            else if (shape.IsDouble)
            {
                writer.Write(double.MaxValue);
            }
            else if (shape.IsFloat)
            {
                writer.Write(float.MaxValue);
            }
            else if (shape.IsDateTime)
            {
                writer.Write(ValidatorUtils.GetTestDate(member, shape));
            }
            else if (shape.IsBoolean)
            {
                writer.Write(true);
            }
            else if (shape.IsMemoryStream)
            {
                writer.Write(Constants.DEFAULT_BLOB_ENCODED);
            }
            else
            {
                throw new Exception("Unknown Type for shape " + shape.Name);
            }
        }