Example #1
0
        public StarMapFeature(SerializationInfo info, StreamingContext context)
        {
            //m_Stride = info.GetInt32("m_Stride");
            //m_BytesPerPixel = info.GetInt32("m_BytesPerPixel");
            m_MaxBrightness = info.GetByte("m_MaxBrightness");

            m_MaxBrightnessFirstKey = info.GetUInt64("m_MaxBrightnessFirstKey");
            m_MaxBrightnessPixels   = info.GetInt32("m_MaxBrightnessPixels");
            m_Generation            = info.GetInt32("m_Generation");
            m_Merges = info.GetInt32("m_Merges");

            m_FeatureId = info.GetInt32("FeatureId");
            m_Intencity = info.GetUInt32("m_Intencity");

            int count = info.GetInt32("m_Pixels.Count");
            int idx   = -1;

            m_Pixels = new SortedDictionary <ulong, uint>();
            for (int i = 0; i < count; i++)
            {
                idx++;
                ulong key = info.GetUInt64(string.Format("m_Pixels.{0}.Key", idx));
                uint  val = info.GetUInt32(string.Format("m_Pixels.{0}.Value", idx));
                m_Pixels.Add(key, val);
            }
        }
Example #2
0
 protected BaseLogEntry(SerializationInfo info, StreamingContext context)
 {
     this.TargetID  = info.GetUInt64(nameof(TargetID));
     this.ActorID   = info.GetUInt64(nameof(ActorID));
     this.ServerID  = info.GetUInt64(nameof(ServerID));
     this.TimeStamp = info.GetDateTime(nameof(TimeStamp));
 }
Example #3
0
 protected JournalEntry(SerializationInfo info, StreamingContext context)
 {
     Created = info.GetDateTime("Created");
     if (!_unsignedIdsInJournal.HasValue)
     {
         try
         {
             Id = info.GetUInt64("Id");
             _unsignedIdsInJournal = true;
         }
         catch (Exception)
         {
             Id = (ulong)info.GetInt64("Id");
             _unsignedIdsInJournal = false;
         }
     }
     else if (_unsignedIdsInJournal.Value)
     {
         Id = info.GetUInt64("Id");
     }
     else
     {
         Id = (ulong)info.GetInt64("Id");
     }
 }
Example #4
0
 public 配置基类(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _上次保存时间 = info.GetDateTime("上次保存时间");
     _创建时间   = info.GetDateTime("创建时间");
     _版本     = info.GetUInt64("版本");
     _变更次数   = info.GetUInt64("变更次数");
 }
Example #5
0
 /// <summary>
 /// Конструктор для десериализации
 /// </summary>
 /// <param name="info">Класс <see cref="SerializationInfo"/> для информации о сериализации</param>
 /// <param name="context">Источник для сериализации</param>
 protected FiscalStatusFlags(SerializationInfo info, StreamingContext context)
 {
     OpenedShift    = info.GetBoolean("OpenedShift");
     OverShift      = info.GetBoolean("OverShift");
     Locked         = info.GetBoolean("Locked");
     Fiscalized     = info.GetBoolean("Fiscalized");
     DocumentAmount = info.GetUInt64("DocumentAmount");
     CashInDrawer   = info.GetUInt64("CashInDrawer");
 }
Example #6
0
 protected ResultException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     Result        = info.GetUInt64("Result");
     LogPath       = info.GetString("LogPath");
     FileName      = info.GetString("FileName");
     ClientVersion = (Version)info.GetValue("ClientVersion", typeof(Version));
 }
Example #7
0
    protected KinectSkeleton(SerializationInfo info, StreamingContext context) : this()
    {
        try
        {
            valid = info.GetBoolean("valid");
            ID    = info.GetUInt64("ID");
            handLeftConfidence  = info.GetByte("HandLeftConfidence");
            handRightConfidence = info.GetByte("HandRightConfidence");
            handLeftState       = info.GetByte("HandLeftState");
            handRightState      = info.GetByte("HandRightState");

            // Deserialize joint positions and orientations
            SerializableVector3[] jointPositions3D = (SerializableVector3[])info.GetValue("JointPositions3D", typeof(SerializableVector3[]));

            for (int jointIndex = 0; jointIndex < JOINT_COUNT; ++jointIndex)
            {
                this.jointPositions3D[jointIndex] = (Vector3)jointPositions3D[jointIndex];
            }

            this.jointStates = (TrackingState[])info.GetValue("JointStates", typeof(KinectSkeleton.TrackingState[]));

            /*SerializableVector3[] FacePositions3D = (SerializableVector3[])info.GetValue("FacePositions3D", typeof(SerializableVector3[]));
             * for (int faceIndex = 0; faceIndex < FACE_POSITION_COUNT; ++faceIndex)
             * {
             *  this.facePositions3D[faceIndex] = FacePositions3D.Length > faceIndex ? (Vector3)FacePositions3D[faceIndex] : Vector3.zero;
             * }
             *
             * this.faceOrientationYPR = Vec3((SerializableVector3)info.GetValue("FaceOrientationYPR", typeof(SerializableVector3)));
             * faceOrientation = Quaternion.Euler(faceOrientationYPR);*/
        }
        catch (Exception ex)
        {
            Debug.LogError(ex);
        }
    }
Example #8
0
        public void BinaryFormatterTest()
        {
            var contract = new TestContract {
                Id = new UnifiedId(8U)
            };
            var bf = new BinaryFormatter();

            using (var ms = new MemoryStream())
            {
                bf.Serialize(ms, contract);
                var arr = ms.ToArray();
                Assert.Equal(289, arr.Length);

                ms.Position = 0;
                var deserialized = (TestContract)bf.Deserialize(ms);
                Assert.Equal(contract.Id, deserialized.Id);
            }

            var info = new SerializationInfo(typeof(UnifiedId), new FormatterConverter());

            contract.Id.GetObjectData(info, default);
            var hash = info.GetUInt64("hash");

            Assert.Equal(contract.Id.ToUInt64(), hash);
        }
 protected CompilationOptions(SerializationInfo info, StreamingContext context)
 {
     Initialize(
         outputKind: (OutputKind)info.GetInt32(OutputKindString),
         moduleName: info.GetString(ModuleNameString),
         mainTypeName: info.GetString(MainTypeNameString),
         scriptClassName: info.GetString(ScriptClassNameString),
         cryptoKeyContainer: info.GetString(CryptoKeyContainerString),
         cryptoKeyFile: info.GetString(CryptoKeyFileString),
         delaySign: (bool?)info.GetValue(DelaySignString, typeof(bool?)),
         optimize: info.GetBoolean(OptimizeString),
         checkOverflow: info.GetBoolean(CheckOverflowString),
         fileAlignment: info.GetInt32(FileAlignmentString),
         baseAddress: info.GetUInt64(BaseAddressString),
         platform: (Platform)info.GetInt32(PlatformString),
         generalDiagnosticOption: (ReportDiagnostic)info.GetInt32(GeneralDiagnosticOptionString),
         warningLevel: info.GetInt32(WarningLevelString),
         specificDiagnosticOptions: ((Dictionary <string, ReportDiagnostic>)info.GetValue(SpecificDiagnosticOptionsString, typeof(Dictionary <string, ReportDiagnostic>))).ToImmutableDictionary(),
         highEntropyVirtualAddressSpace: info.GetBoolean(HighEntropyVirtualAddressSpaceString),
         debugInformationKind: (DebugInformationKind)info.GetInt32(DebugInformationKindString),
         subsystemVersion: (SubsystemVersion)info.GetValue(SubsystemVersionString, typeof(SubsystemVersion)),
         concurrentBuild: info.GetBoolean(ConcurrentBuildString),
         xmlReferenceResolver: XmlFileResolver.Default,
         sourceReferenceResolver: SourceFileResolver.Default,
         metadataReferenceResolver: MetadataFileReferenceResolver.Default,
         metadataReferenceProvider: MetadataFileReferenceProvider.Default,
         assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default,
         strongNameProvider: new DesktopStrongNameProvider(),
         metadataImportOptions: (MetadataImportOptions)info.GetByte(metadataImportOptionsString));
 }
Example #10
0
 private CSharpSerializableCompilationOptions(SerializationInfo info, StreamingContext context)
 {
     this.options = new CSharpCompilationOptions(
         outputKind: (OutputKind)info.GetInt32(OutputKindString),
         moduleName: info.GetString(ModuleNameString),
         mainTypeName: info.GetString(MainTypeNameString),
         scriptClassName: info.GetString(ScriptClassNameString),
         usings: (string[])info.GetValue(UsingsString, typeof(string[])),
         cryptoKeyContainer: info.GetString(CryptoKeyContainerString),
         cryptoKeyFile: info.GetString(CryptoKeyFileString),
         delaySign: (bool?)info.GetValue(DelaySignString, typeof(bool?)),
         optimizationLevel: (OptimizationLevel)info.GetInt32(OptimizeString),
         checkOverflow: info.GetBoolean(CheckOverflowString),
         allowUnsafe: info.GetBoolean(AllowUnsafeString),
         fileAlignment: info.GetInt32(FileAlignmentString),
         baseAddress: info.GetUInt64(BaseAddressString),
         platform: (Platform)info.GetInt32(PlatformString),
         generalDiagnosticOption: (ReportDiagnostic)info.GetInt32(GeneralDiagnosticOptionString),
         warningLevel: info.GetInt32(WarningLevelString),
         specificDiagnosticOptions: ((Dictionary <string, ReportDiagnostic>)info.GetValue(SpecificDiagnosticOptionsString, typeof(Dictionary <string, ReportDiagnostic>))).ToImmutableDictionary(),
         highEntropyVirtualAddressSpace: info.GetBoolean(HighEntropyVirtualAddressSpaceString),
         subsystemVersion: SubsystemVersion.Create(info.GetInt32(SubsystemVersionMajorString), info.GetInt32(SubsystemVersionMinorString)),
         runtimeMetadataVersion: info.GetString(RuntimeMetadataVersionString),
         concurrentBuild: info.GetBoolean(ConcurrentBuildString),
         xmlReferenceResolver: XmlFileResolver.Default,
         sourceReferenceResolver: SourceFileResolver.Default,
         metadataReferenceResolver: MetadataFileReferenceResolver.Default,
         metadataReferenceProvider: MetadataFileReferenceProvider.Default,
         assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default,
         strongNameProvider: new DesktopStrongNameProvider(),
         metadataImportOptions: (MetadataImportOptions)info.GetByte(MetadataImportOptionsString),
         features: ((string[])info.GetValue(FeaturesString, typeof(string[]))).AsImmutable());
 }
Example #11
0
 protected RaceData(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     CardID    = info.GetUInt64("RaceData_CardID");
     RaceNo    = info.GetInt32("RaceData_RaceNo");
     StartTime = info.GetDateTime("RaceData_StartTime");
 }
Example #12
0
        protected ISerializableTestObject(SerializationInfo info, StreamingContext context)
        {
            _stringValue         = info.GetString("stringValue");
            _intValue            = info.GetInt32("intValue");
            _dateTimeOffsetValue = (DateTimeOffset)info.GetValue(
                "dateTimeOffsetValue",
                typeof(DateTimeOffset)
                );
            _personValue     = (Person)info.GetValue("personValue", typeof(Person));
            _nullPersonValue = (Person)info.GetValue("nullPersonValue", typeof(Person));
            _nullableInt     = (int?)info.GetValue("nullableInt", typeof(int?));

            _booleanValue  = info.GetBoolean("booleanValue");
            _byteValue     = info.GetByte("byteValue");
            _charValue     = info.GetChar("charValue");
            _dateTimeValue = info.GetDateTime("dateTimeValue");
            _decimalValue  = info.GetDecimal("decimalValue");
            _shortValue    = info.GetInt16("shortValue");
            _longValue     = info.GetInt64("longValue");
            _sbyteValue    = info.GetSByte("sbyteValue");
            _floatValue    = info.GetSingle("floatValue");
            _ushortValue   = info.GetUInt16("ushortValue");
            _uintValue     = info.GetUInt32("uintValue");
            _ulongValue    = info.GetUInt64("ulongValue");
        }
        protected NativeTypes(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            Bool     = info.GetBoolean(nameof(Bool));
            Byte     = info.GetByte(nameof(Byte));
            Sbyte    = info.GetSByte(nameof(Sbyte));
            Char     = info.GetChar(nameof(Char));
            Decimal  = info.GetDecimal(nameof(Decimal));
            Double   = info.GetDouble(nameof(Double));
            Float    = info.GetSingle(nameof(Float));
            Int      = info.GetInt32(nameof(Int));
            Uint     = info.GetUInt32(nameof(Uint));
            Long     = info.GetInt64(nameof(Long));
            Ulong    = info.GetUInt64(nameof(Ulong));
            Short    = info.GetInt16(nameof(Short));
            Ushort   = info.GetUInt16(nameof(Ushort));
            String   = info.GetString(nameof(String));
            DateTime = info.GetDateTime(nameof(DateTime));
            Guid     = Guid.Parse(info.GetString(nameof(Guid)));
            Null     = info.GetValue(nameof(Null), typeof(object));
        }
Example #14
0
 /// <summary>
 /// Creates a new <see cref="ConfigurationFrame"/> from serialization parameters.
 /// </summary>
 /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param>
 /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param>
 protected ConfigurationFrame(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     // Deserialize configuration frame
     m_frameHeader = (CommonFrameHeader)info.GetValue("frameHeader", typeof(CommonFrameHeader));
     m_idCode      = info.GetUInt64("idCode64Bit");
 }
        public void SerializationInfo_AddGet()
        {
            var value = new Serializable();
            var si    = new SerializationInfo(typeof(Serializable), new FormatterConverter());
            var sc    = new StreamingContext();

            value.GetObjectData(si, sc);

            Assert.AreEqual(typeof(Serializable), si.ObjectType);
            Assert.AreEqual(typeof(Serializable).FullName, si.FullTypeName);
            // TODO: Implement AssemblyName property
            // Assert.AreEqual(typeof(Serializable).Assembly.FullName, si.AssemblyName);

            Assert.AreEqual(15, si.MemberCount);

            Assert.AreEqual(true, si.GetBoolean("bool"));
            Assert.AreEqual("hello", si.GetString("string"));
            Assert.AreEqual('a', si.GetChar("char"));

            Assert.AreEqual(byte.MaxValue, si.GetByte("byte"));

            Assert.AreEqual(decimal.MaxValue, si.GetDecimal("decimal"));
            Assert.AreEqual(double.MaxValue, si.GetDouble("double"));
            Assert.AreEqual(short.MaxValue, si.GetInt16("short"));
            Assert.AreEqual(int.MaxValue, si.GetInt32("int"));
            Assert.AreEqual(long.MaxValue, si.GetInt64("long"));
            Assert.AreEqual(sbyte.MaxValue, si.GetSByte("sbyte"));
            Assert.AreEqual(float.MaxValue, si.GetSingle("float"));
            Assert.AreEqual(ushort.MaxValue, si.GetUInt16("ushort"));
            Assert.AreEqual(uint.MaxValue, si.GetUInt32("uint"));
            Assert.AreEqual(ulong.MaxValue, si.GetUInt64("ulong"));
            Assert.AreEqual(DateTime.MaxValue, si.GetDateTime("datetime"));
        }
Example #16
0
 /// <summary>Initializes a new instance of Hero based on the serialization info.</summary>
 /// <param name="info">The serialization info.</param>
 /// <param name="context">The streaming context.</param>
 private Hero(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     m_Value = info.GetUInt64("Value");
 }
Example #17
0
 /// <summary>
 /// 将 <see cref="HandleUnion"/> 结构的新实例初始化为指定序列化信息和上下文表示的值。
 /// </summary>
 /// <param name="info">包含序列化所需信息的对象。</param>
 /// <param name="context">包含序列化流的源和目标的上下文对象。</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="info"/> 为 <see langword="null"/>。</exception>
 /// <exception cref="InvalidCastException">
 /// 名为 <c>Value</c> 的值无法转换为无符号指针或句柄。</exception>
 /// <exception cref="OverflowException">
 /// 在字大小为 4 字节的计算机上对值为 8 字节的指针或句柄进行反序列化。</exception>
 /// <exception cref="SerializationException">
 /// 在 <paramref name="info"/> 中未找到名为 <c>Value</c> 的值。</exception>
 private HandleUnion(SerializationInfo info, StreamingContext context) : this()
 {
     if (info is null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     this.UIntPtr = checked ((nuint)info.GetUInt64("Value"));
 }
Example #18
0
 /// <summary>
 /// 将 <see cref="QWordUnion"/> 结构的新实例初始化为指定序列化信息和上下文表示的值。
 /// </summary>
 /// <param name="info">包含序列化所需信息的对象。</param>
 /// <param name="context">包含序列化流的源和目标的上下文对象。</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="info"/> 为 <see langword="null"/>。</exception>
 /// <exception cref="InvalidCastException">
 /// 名为 <c>Value</c> 的值无法转换为 64 位无符号整数。</exception>
 /// <exception cref="SerializationException">
 /// 在 <paramref name="info"/> 中未找到名为 <c>Value</c> 的值。</exception>
 private QWordUnion(SerializationInfo info, StreamingContext context) : this()
 {
     if (info is null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     this.UInt64 = info.GetUInt64("Value");
 }
 protected JsonSerializationException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.Code              = (ErrorCode)info.GetInt32("Code");
     this.LineNumber        = info.GetInt32("LineNumber");
     this.ColumnNumber      = info.GetInt32("ColumnNumber");
     this.CharactersWritten = info.GetUInt64("CharactersWritten");
 }
Example #20
0
            protected Primitives(SerializationInfo info, StreamingContext context)
            {
                SerializationCtorCalled = true;

                Byte  = info.GetByte("byte");
                Bytes = (byte[])info.GetValue("bytes", typeof(byte[]));

                Sbyte  = info.GetSByte("sbyte");
                Sbytes = (sbyte[])info.GetValue("sbytes", typeof(sbyte[]));

                Bool  = info.GetBoolean("bool");
                Bools = (bool[])info.GetValue("bools", typeof(bool[]));

                Char  = info.GetChar("char");
                Chars = (char[])info.GetValue("chars", typeof(char[]));

                Short  = info.GetInt16("short");
                Shorts = (short[])info.GetValue("shorts", typeof(short[]));

                Ushort  = info.GetUInt16("ushort");
                Ushorts = (ushort[])info.GetValue("ushorts", typeof(ushort[]));

                Int  = info.GetInt32("int");
                Ints = (int[])info.GetValue("ints", typeof(int[]));

                Uint  = info.GetUInt32("uint");
                Uints = (uint[])info.GetValue("uints", typeof(uint[]));

                Long  = info.GetInt64("long");
                Longs = (long[])info.GetValue("longs", typeof(long[]));

                Ulong  = info.GetUInt64("ulong");
                Ulongs = (ulong[])info.GetValue("ulongs", typeof(ulong[]));

                Float  = info.GetSingle("float");
                Floats = (float[])info.GetValue("floats", typeof(float[]));

                Double  = info.GetDouble("double");
                Doubles = (double[])info.GetValue("doubles", typeof(double[]));

                Decimal  = info.GetDecimal("decimal");
                Decimals = (decimal[])info.GetValue("decimals", typeof(decimal[]));

                Guid  = (Guid)info.GetValue("guid", typeof(Guid));
                Guids = (Guid[])info.GetValue("guids", typeof(Guid[]));

                DateTime  = info.GetDateTime("datetime");
                DateTimes = (DateTime[])info.GetValue("datetimes", typeof(DateTime[]));

                String  = info.GetString("string");
                Strings = (string[])info.GetValue("strings", typeof(string[]));

                IntPtr  = (IntPtr)info.GetInt64("intptr");
                IntPtrs = (IntPtr[])info.GetValue("intptrs", typeof(IntPtr[]));

                UIntPtr  = (UIntPtr)info.GetInt64("uintptr");
                UIntPtrs = (UIntPtr[])info.GetValue("uintptrs", typeof(UIntPtr[]));
            }
Example #21
0
 /// <summary>
 /// Try to get the desired serialized UInt64 element. If not present, use
 /// defVal instead.
 /// </summary>
 public static void TryGetUInt64(SerializationInfo info, ref UInt64 var, String name, UInt64 defVal)
 {
     try
     {
         var = defVal;
         var = info.GetUInt64(name);
     }
     catch (Exception) { }
 }
Example #22
0
        public void GetObjectData_SerializationInfo_AreEqual()
        {
            ISerializable obj  = TestStruct;
            var           info = new SerializationInfo(typeof(DateSpan), new FormatterConverter());

            obj.GetObjectData(info, default);

            Assert.AreEqual(532575944699UL, info.GetUInt64("Value"));
        }
 protected ComponentAlreadyExistsException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info != null)
     {
         this.component = info.GetString("component");
         this.entity    = info.GetUInt64("entity");
     }
 }
Example #24
0
        private UIntPtr(SerializationInfo info, StreamingContext context)
        {
            ulong @uint = info.GetUInt64("value");

            if (UIntPtr.Size == 4 && @uint > (ulong)-1)
            {
                throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue"));
            }
            this.m_value = @uint;
        }
Example #25
0
        private unsafe UIntPtr(SerializationInfo info, StreamingContext context)
        {
            ulong uint64 = info.GetUInt64("value");

            if (UIntPtr.Size == 4 && uint64 > (ulong)uint.MaxValue)
            {
                throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue"));
            }
            this.m_value = (void *)uint64;
        }
Example #26
0
        private unsafe UIntPtr(SerializationInfo info, StreamingContext context)
        {
            ulong num = info.GetUInt64("value");

            if ((Size == 4) && (num > 0xffffffffL))
            {
                throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue"));
            }
            this.m_value = (void *)num;
        }
Example #27
0
 public Funcionario(SerializationInfo info, StreamingContext context)
 {
     Codigo          = info.GetUInt64("FuncionarioCodigo");
     Nome            = info.GetString("FuncionarioNome");
     Usuario         = info.GetString("FuncionarioUsuario");
     Senha           = info.GetString("FuncionarioSenha");
     Comissionado    = info.GetBoolean("FuncionarioComissionado");
     Funcao          = info.GetString("FuncionarioFuncao");
     Salario         = info.GetSingle("FuncionarioSalario");
     UltimoPagamento = info.GetDateTime("FuncionarioUltimoPagamento");
 }
Example #28
0
        private unsafe UIntPtr(SerializationInfo info, StreamingContext context)
        {
            ulong l = info.GetUInt64("value");

            if (Size == 4 && l > UInt32.MaxValue)
            {
                throw new ArgumentException(SR.Serialization_InvalidPtrValue);
            }

            _value = (void *)l;
        }
Example #29
0
        private UIntPtr(SerializationInfo info, StreamingContext context)
        {
            ulong value = info.GetUInt64("value");

#if TARGET_32BIT
            if (value > uint.MaxValue)
            {
                throw new ArgumentException(SR.Serialization_InvalidPtrValue);
            }
#endif

            _value = (nuint)value;
        }
Example #30
0
 internal RawBlock(SerializationInfo info, StreamingContext context)
     : this(
         index : info.GetUInt64("index"),
         timestamp : info.GetString("timestamp"),
         nonce : info.GetValue <byte[]>("nonce"),
         rewardBenificiary : info.GetValue <byte[]>("reward_beneficiary"),
         difficulty : info.GetUInt32("difficulty"),
         previousHash : info.GetValueOrDefault <byte[]>("previous_hash", null),
         transactions : info.GetValue <IEnumerable>("transactions"),
         hash : info.GetValue <byte[]>("hash")
         )
 {
 }
Example #31
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		SerializationInfo serinfo1 = null;
		Boolean fValue;
		Char chValue;
		SByte sbtValue;
		Byte btValue;
		Int16 i16Value;
		Int32 i32Value;
		Int64 i64Value;
		UInt16 ui16Value;
		UInt32 ui32Value;
		UInt64 ui64Value;
		Double dblValue;
		Single sglValue;
		DateTime dtValue;
		Decimal dcmValue;
		StringBuilder sbldr1;
		String strValue;
		Random rnd1;
		try {
			do
			{
				strLoc="Loc_6573cd";
				serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter());
				iCountTestcases++;
				if(serinfo1.MemberCount != 0)
				{
					iCountErrors++;
					Console.WriteLine("Err_0246sd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				strLoc="Loc_6853vd";
				fValue = false;
				serinfo1.AddValue("Boolean_1", fValue);
				iCountTestcases++;
				if(serinfo1.GetBoolean("Boolean_1") != fValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetBoolean("Boolean_1"));
				}
				fValue = true;
				serinfo1.AddValue("Boolean_2", fValue);
				iCountTestcases++;
				if(serinfo1.GetBoolean("Boolean_2") != fValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_6753vd! wrong value returned, " + serinfo1.GetBoolean("Boolean_2"));
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("Boolean_2", fValue);
					iCountErrors++;
					Console.WriteLine("Err_1065753cd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("Large String, ticks, " + Environment.TickCount);
				sbldr1 = new StringBuilder("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
				fValue = false;
				serinfo1.AddValue(sbldr1.ToString(), fValue);
				iCountTestcases++;
				if(serinfo1.GetBoolean(sbldr1.ToString()) != fValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_6538fvd! wrong value returned, " + serinfo1.GetBoolean(sbldr1.ToString()));
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue(null, fValue);
					iCountErrors++;
					Console.WriteLine("Err_0156ds! Exception not thrown");
					}catch(ArgumentNullException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_57834fd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("Char ticks, " + Environment.TickCount);
				rnd1 = new Random();
				for(int i=0; i<50; i++) {
					strLoc="Loc_6753cd_" + i;
					chValue = (Char)(65536 * rnd1.NextDouble());
					strValue = "Char_" + i;
					serinfo1.AddValue(strValue, chValue);
					iCountTestcases++;
					if(serinfo1.GetChar(strValue)!= chValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_65730dsw_" + i + "! Wrong Char returned, " + serinfo1.GetChar(strValue));
					}
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("Char_1", 'a');
					iCountErrors++;
					Console.WriteLine("Err_643cd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_02457fd! Wrong exception thrown, " + ex);
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("Boolean_1", 'a');
					iCountErrors++;
					Console.WriteLine("Err_5732fcd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_024568fd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("SByte ticks, " + Environment.TickCount);
				for(int i=(int)SByte.MinValue; i<(int)SByte.MaxValue; i++) {
					strLoc="Loc_56473vd_" + i;
					sbtValue = (SByte)i;;
					strValue = "SByte_" + i;
					serinfo1.AddValue(strValue, sbtValue);
					iCountTestcases++;
					if(serinfo1.GetSByte(strValue)!= sbtValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_4627fds_" + i + "! Wrong Sbyte returned, " + serinfo1.GetSByte(strValue));
					}
				}
				Console.WriteLine("Byte ticks, " + Environment.TickCount);
				for(int i=(int)Byte.MinValue; i<(int)Byte.MaxValue; i++) {
					strLoc="Loc_01192ds_" + i;
					btValue = (Byte)i;;
					strValue = "Byte_" + i;
					serinfo1.AddValue(strValue, btValue);
					iCountTestcases++;
					if(serinfo1.GetByte(strValue)!= btValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_0267fe_" + i + "! Wrong byte returned, " + serinfo1.GetByte(strValue));
					}
				}
				Console.WriteLine("Int16 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_012965565ds_" + i;
					i16Value = (short)((int)Int16.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i16Value = (short)(-1 * i16Value);
					strValue = "Int16_" + i;
					serinfo1.AddValue(strValue, i16Value);
					iCountTestcases++;
					if(serinfo1.GetInt16(strValue)!= i16Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_0267fe_" + i + "! Wrong value returned, " + serinfo1.GetInt16(strValue));
					}
				}
				Console.WriteLine("Int32 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_015643ds_" + i;
					i32Value = (int)(Int32.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i32Value = (-1 * i32Value);
					strValue = "Int32_" + i;
					serinfo1.AddValue(strValue, i32Value);
					iCountTestcases++;
					if(serinfo1.GetInt32(strValue)!= i32Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_5427ds_" + i + "! Wrong value returned, " + serinfo1.GetInt32(strValue));
					}
				}
				Console.WriteLine("Int64 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_625bfg_" + i;
					i64Value = (long)((long)Int64.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i64Value = (long)(-1 * i64Value);
					strValue = "Int64_" + i;
					serinfo1.AddValue(strValue, i64Value);
					iCountTestcases++;
					if(serinfo1.GetInt64(strValue)!= i64Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_6427dc_" + i + "! Wrong value returned, " + serinfo1.GetInt64(strValue));
					}
				}
				Console.WriteLine("UInt16 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_6473cd_" + i;
					ui16Value = (ushort)((int)UInt16.MaxValue * rnd1.NextDouble());
					strValue = "UInt16_" + i;
					serinfo1.AddValue(strValue, ui16Value);
					iCountTestcases++;
					if(serinfo1.GetUInt16(strValue)!= ui16Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_748vd_" + i + "! Wrong value returned, " + serinfo1.GetUInt16(strValue));
					}
				}
				Console.WriteLine("UInt32 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_7573cd_" + i;
					ui32Value = (uint)(UInt32.MaxValue * rnd1.NextDouble());
					strValue = "UInt32_" + i;
					serinfo1.AddValue(strValue, ui32Value);
					iCountTestcases++;
					if(serinfo1.GetUInt32(strValue)!= ui32Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_4738cd_" + i + "! Wrong value returned, " + serinfo1.GetUInt32(strValue));
					}
				}
				Console.WriteLine("UInt64 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_63dc_" + i;
					ui64Value = (ulong)(UInt64.MaxValue * rnd1.NextDouble());
					strValue = "UInt64_" + i;
					serinfo1.AddValue(strValue, ui64Value);
					iCountTestcases++;
					if(serinfo1.GetUInt64(strValue)!= ui64Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_6583fd_" + i + "! Wrong value returned, " + serinfo1.GetUInt64(strValue));
					}
				}
				Console.WriteLine("Double ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_7539cd_" + i;
					dblValue = Double.MaxValue * rnd1.NextDouble();
					if(rnd1.NextDouble()<0.5)
					dblValue = (-1 * dblValue);
					strValue = "Double_" + i;
					serinfo1.AddValue(strValue, dblValue);
					iCountTestcases++;
					if(serinfo1.GetDouble(strValue)!= dblValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_653cfd_" + i + "! Wrong value returned, " + serinfo1.GetDouble(strValue));
					}
				}
				Console.WriteLine("Single ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_0247fd_" + i;
					sglValue = (float)(Single.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					sglValue = (-1 * sglValue);
					strValue = "Single_" + i;
					serinfo1.AddValue(strValue, sglValue);
					iCountTestcases++;
					if(serinfo1.GetSingle(strValue)!= sglValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetSingle(strValue));
					}
				}
				strValue = "This is a String";
				serinfo1.AddValue("String_1", strValue);
				iCountTestcases++;
				if(!serinfo1.GetString("String_1").Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_1"));
				}
				strValue = "";
				serinfo1.AddValue("String_2", strValue);
				iCountTestcases++;
				if(!serinfo1.GetString("String_2").Equals(String.Empty))
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_2"));
				}
				strValue = null;
				serinfo1.AddValue("String_3", strValue);
				iCountTestcases++;
				if(serinfo1.GetString("String_3") != null)
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_3"));
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("String_2", fValue);
					iCountErrors++;
					Console.WriteLine("Err_1065753cd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("Single ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_0247fd_" + i;
					dblValue = (double)(DateTime.MaxValue.ToOADate() * rnd1.NextDouble());
					strValue = "DateTime_" + i;
					dtValue = DateTime.FromOADate(dblValue);
					serinfo1.AddValue(strValue, dtValue);
					iCountTestcases++;
					if(serinfo1.GetDateTime(strValue)!= dtValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetDateTime(strValue));
					}
				}
				for(int i=0; i<50; i++) {
					strLoc="Loc_0247fd_" + i;
					dcmValue = (Decimal)((double)Decimal.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
						dcmValue = (Decimal)(-1 * dcmValue);
					strValue = "Decimal_" + i;
					serinfo1.AddValue(strValue, dcmValue);
					iCountTestcases++;
					if(serinfo1.GetDecimal(strValue)!= dcmValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_2342fdsg_" + i + "! Wrong value returned, " + serinfo1.GetDecimal(strValue));
					}
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}