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;
		Type tpName = null;
		try {
			do
			{
				tpName = Type.GetType("System.Int32");
				serinfo1 = new SerializationInfo(tpName, new FormatterConverter());
				iCountTestcases++;
				if(serinfo1.MemberCount != 0)
				{
					iCountErrors++;
					Console.WriteLine("Err_0256csd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				serinfo1.AddValue("MyOwnField", 5, typeof(Int32));
				iCountTestcases++;
				if(serinfo1.MemberCount != 1)
				{
					iCountErrors++;
					Console.WriteLine("Err_8564cfdg! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				iCountTestcases++;
				if(serinfo1.GetInt16("MyOwnField") != 5)
				{
					iCountErrors++;
					Console.WriteLine("Err_675349fd! Wrong value returned, " + serinfo1.GetInt16("MyOwnField"));
				}
			} 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;
		}
	}
Example #2
0
        public void GetObjectData_SerializationInfo_AreEqual()
        {
            ISerializable obj  = TestStruct;
            var           info = new SerializationInfo(typeof(Year), new System.Runtime.Serialization.FormatterConverter());

            obj.GetObjectData(info, default(StreamingContext));

            Assert.AreEqual(1979, info.GetInt16("Value"));
        }
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            ChatPartner partner = (ChatPartner)obj;

            partner.PCName = info.GetString("PCName");
            partner.Port   = info.GetInt16("Port");
            partner.Ip     = (IPAddress)info.GetValue("Ip", IPAddress.None.GetType());
            return(partner);
        }
Example #4
0
        private PilotStudent(SerializationInfo info, StreamingContext ctxt)
        {
            int version = info.GetInt16("version");

            var fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(p => p.GetCustomAttribute(typeof(Versioning)) != null);

            IList <PropertyInfo> props = new List <PropertyInfo>(this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(p => p.GetCustomAttribute(typeof(Versioning)) != null));

            var propsAndFields = props.Cast <MemberInfo>().Union(fields.Cast <MemberInfo>());

            foreach (SerializationEntry entry in info)
            {
                MemberInfo prop = propsAndFields.FirstOrDefault(p => ((Versioning)p.GetCustomAttribute(typeof(Versioning))).Name == entry.Name);


                if (prop != null)
                {
                    if (prop is FieldInfo)
                    {
                        ((FieldInfo)prop).SetValue(this, entry.Value);
                    }
                    else
                    {
                        ((PropertyInfo)prop).SetValue(this, entry.Value);
                    }
                }
            }

            var notSetProps = propsAndFields.Where(p => ((Versioning)p.GetCustomAttribute(typeof(Versioning))).Version > version);

            foreach (MemberInfo notSet in notSetProps)
            {
                Versioning ver = (Versioning)notSet.GetCustomAttribute(typeof(Versioning));

                if (ver.AutoGenerated)
                {
                    if (notSet is FieldInfo)
                    {
                        ((FieldInfo)notSet).SetValue(this, ver.DefaultValue);
                    }
                    else
                    {
                        ((PropertyInfo)notSet).SetValue(this, ver.DefaultValue);
                    }
                }

                if (version == 1)
                {
                    this.Rating = GeneralHelpers.GetPilotStudentRating(this);
                }
                if (version < 3)
                {
                    this.Aircraft       = null;
                    this.AirlinerFamily = "";
                }
            }
        }
Example #5
0
        private Airliner(SerializationInfo info, StreamingContext ctxt)
        {
            int version = info.GetInt16("version");

            var fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(p => p.GetCustomAttribute(typeof(Versioning)) != null);

            IList <PropertyInfo> props = new List <PropertyInfo>(this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(p => p.GetCustomAttribute(typeof(Versioning)) != null));

            var propsAndFields = props.Cast <MemberInfo>().Union(fields.Cast <MemberInfo>());

            foreach (SerializationEntry entry in info)
            {
                MemberInfo prop = propsAndFields.FirstOrDefault(p => ((Versioning)p.GetCustomAttribute(typeof(Versioning))).Name == entry.Name);


                if (prop != null)
                {
                    if (prop is FieldInfo)
                    {
                        ((FieldInfo)prop).SetValue(this, entry.Value);
                    }
                    else
                    {
                        ((PropertyInfo)prop).SetValue(this, entry.Value);
                    }
                }
            }

            var notSetProps = propsAndFields.Where(p => ((Versioning)p.GetCustomAttribute(typeof(Versioning))).Version > version);

            foreach (MemberInfo notSet in notSetProps)
            {
                Versioning ver = (Versioning)notSet.GetCustomAttribute(typeof(Versioning));

                if (ver.AutoGenerated)
                {
                    if (notSet is FieldInfo)
                    {
                        ((FieldInfo)notSet).SetValue(this, ver.DefaultValue);
                    }
                    else
                    {
                        ((PropertyInfo)notSet).SetValue(this, ver.DefaultValue);
                    }
                }
            }

            this.Classes.RemoveAll(c => c == null);

            var doubleClasses = new List <AirlinerClass.ClassType>(this.Classes.Where(c => this.Classes.Count(cc => cc.Type == c.Type) > 1).Select(c => c.Type));

            foreach (var doubleClassType in doubleClasses)
            {
                var dClass = this.Classes.Last(c => c.Type == doubleClassType);
                this.Classes.Remove(dClass);
            }
        }
Example #6
0
        public Person(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("Name", name);
            info.AddValue("Born", born);

            name = info.GetString("Name");
            born = info.GetInt16("Born");
            CalculateAge();
        }
Example #7
0
        public Product(SerializationInfo info, StreamingContext context)
        {
            ProductID       = info.GetInt32("ProductID");
            ProductName     = info.GetString("ProductName");
            SupplierID      = info.GetInt32("SupplierID");
            CategoryID      = info.GetInt32("CategoryID");
            QuantityPerUnit = info.GetString("QuantityPerUnit");
            UnitPrice       = info.GetDecimal("UnitPrice");
            UnitsInStock    = info.GetInt16("UnitsInStock");
            UnitsOnOrder    = info.GetInt16("UnitsOnOrder");
            ReorderLevel    = info.GetInt16("ReorderLevel");
            Discontinued    = info.GetBoolean("Discontinued");
            Category        = null;
            var order_DetailsArray = (Order_Detail[])info.GetValue("Order_Details", typeof(Order_Detail[]));

            Order_Details = order_DetailsArray.ToList();
            Supplier      = (Supplier)info.GetValue("Supplier", typeof(Supplier));
        }
    public System.Object SetObjectData(System.Object obj,
                                       SerializationInfo info, StreamingContext context,
                                       ISurrogateSelector selector)
    {
        var data = (PlayerCharacterData)obj;

        data.Id     = info.GetString("id");
        data.DataId = info.GetInt32("dataId");
        // Backward compatible
        try { data.EntityId = info.GetInt32("entityId"); }
        catch { }
        data.CharacterName  = info.GetString("characterName");
        data.Level          = info.GetInt16("level");
        data.Exp            = info.GetInt32("exp");
        data.CurrentHp      = info.GetInt32("currentHp");
        data.CurrentMp      = info.GetInt32("currentMp");
        data.CurrentStamina = info.GetInt32("currentStamina");
        data.CurrentFood    = info.GetInt32("currentFood");
        data.CurrentWater   = info.GetInt32("currentWater");
        data.EquipWeapons   = (EquipWeapons)info.GetValue("equipWeapons", typeof(EquipWeapons));
        data.Attributes     = info.GetListValue <CharacterAttribute>("attributes");
        data.Skills         = info.GetListValue <CharacterSkill>("skills");
        data.SkillUsages    = info.GetListValue <CharacterSkillUsage>("skillUsages");
        data.Buffs          = info.GetListValue <CharacterBuff>("buffs");
        data.EquipItems     = info.GetListValue <CharacterItem>("equipItems");
        data.NonEquipItems  = info.GetListValue <CharacterItem>("nonEquipItems");
        data.Summons        = info.GetListValue <CharacterSummon>("summons");
        // Player Character
        data.StatPoint       = info.GetInt16("statPoint");
        data.SkillPoint      = info.GetInt16("skillPoint");
        data.Gold            = info.GetInt32("gold");
        data.CurrentMapName  = info.GetString("currentMapName");
        data.CurrentPosition = (Vector3)info.GetValue("currentPosition", typeof(Vector3));
        data.RespawnMapName  = info.GetString("respawnMapName");
        data.RespawnPosition = (Vector3)info.GetValue("respawnPosition", typeof(Vector3));
        data.LastUpdate      = info.GetInt32("lastUpdate");
        data.Hotkeys         = info.GetListValue <CharacterHotkey>("hotkeys");
        data.Quests          = info.GetListValue <CharacterQuest>("quests");
        this.InvokeInstanceDevExtMethods("SetObjectData", obj, info, context, selector);

        obj = data;
        return(obj);
    }
Example #9
0
        } // end constructor

        // Deserializer
        public Airport(SerializationInfo info, StreamingContext ctxt)
        {
            this.Iata = info.GetString("Iata");
            this.Icao = info.GetString("Icao");
            this.Name = info.GetString("Name");

            this.Region     = SaveGamePublic.SaveGame.Regions[info.GetString("Region")];
            this.Hub        = info.GetBoolean("Hub");
            this.Coordinate = (GeoCoordinate)info.GetValue("Coordinate", typeof(GeoCoordinate));

            this.Size = info.GetChar("Size");

            this.Municipality = info.GetString("Municipality");;

            this.RunwayLength     = info.GetInt16("RunwayLength");
            this.RunwayCount      = info.GetInt16("RunwayCount");
            this.Slots            = info.GetInt16("Slots");
            this._TotalPassengers = info.GetInt32("TotalPassengers");
        } // End Deserializer
        DateTimeOffset(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            _dateTime      = info.GetDateTime("DateTime");
            _offsetMinutes = info.GetInt16("OffsetMinutes");
        }
    public System.Object SetObjectData(System.Object obj,
                                       SerializationInfo info, StreamingContext context,
                                       ISurrogateSelector selector)
    {
        CharacterAttribute data = (CharacterAttribute)obj;

        data.dataId = info.GetInt32("dataId");
        data.amount = info.GetInt16("amount");
        obj         = data;
        return(obj);
    }
    public System.Object SetObjectData(System.Object obj,
                                       SerializationInfo info, StreamingContext context,
                                       ISurrogateSelector selector)
    {
        CharacterSkill data = (CharacterSkill)obj;

        data.dataId = info.GetInt32("dataId");
        data.level  = info.GetInt16("level");
        obj         = data;
        return(obj);
    }
        private ManufacturerContract(SerializationInfo info, StreamingContext ctxt)
        {
            int version = info.GetInt16("version");

            var fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(p => p.GetCustomAttribute(typeof(Versioning)) != null);

            IList <PropertyInfo> props = new List <PropertyInfo>(this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(p => p.GetCustomAttribute(typeof(Versioning)) != null));

            var propsAndFields = props.Cast <MemberInfo>().Union(fields.Cast <MemberInfo>());

            foreach (SerializationEntry entry in info)
            {
                MemberInfo prop = propsAndFields.FirstOrDefault(p => ((Versioning)p.GetCustomAttribute(typeof(Versioning))).Name == entry.Name);

                if (prop != null)
                {
                    if (prop.Name.ToLower() == "manufacturer")
                    {
                        string manufacturer = ((Manufacturer)entry.Value).Name;
                        this.Manufacturer = Manufacturers.GetManufacturer(manufacturer);
                    }
                    else
                    {
                        if (prop is FieldInfo)
                        {
                            ((FieldInfo)prop).SetValue(this, entry.Value);
                        }
                        else
                        {
                            ((PropertyInfo)prop).SetValue(this, entry.Value);
                        }
                    }
                }
            }

            var notSetProps = propsAndFields.Where(p => ((Versioning)p.GetCustomAttribute(typeof(Versioning))).Version > version);

            foreach (MemberInfo notSet in notSetProps)
            {
                Versioning ver = (Versioning)notSet.GetCustomAttribute(typeof(Versioning));

                if (ver.AutoGenerated)
                {
                    if (notSet is FieldInfo)
                    {
                        ((FieldInfo)notSet).SetValue(this, ver.DefaultValue);
                    }
                    else
                    {
                        ((PropertyInfo)notSet).SetValue(this, ver.DefaultValue);
                    }
                }
            }
        }
Example #14
0
    public System.Object SetObjectData(System.Object obj,
                                       SerializationInfo info, StreamingContext context,
                                       ISurrogateSelector selector)
    {
        CharacterItem data = (CharacterItem)obj;

        data.dataId = info.GetInt32("dataId");
        data.level  = info.GetInt16("level");
        data.amount = info.GetInt16("amount");
        // Backward compatible
        try
        {
            data.durability          = info.GetSingle("durability");
            data.exp                 = info.GetInt32("exp");
            data.lockRemainsDuration = info.GetSingle("lockRemainsDuration");
        }
        catch { }
        obj = data;
        return(obj);
    }
Example #15
0
        private Department GetDepartmentFromISerializable(ISerializable iSerializable)
        {
            Department        department = new Department();
            SerializationInfo si         = new SerializationInfo(iSerializable.GetType(), new FormatterConverter());

            iSerializable.GetObjectData(si, new StreamingContext());
            department.Name         = si.GetString("Name");
            department.DepartmentID = si.GetInt16("DepartmentID");
            department.GroupName    = si.GetString("GroupName");
            department.ModifiedDate = si.GetDateTime("ModifiedDate");
            return(department);
        }
        protected AbstractLibraryItem(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            this.FirstName   = info.GetString("FirstName");
            this.LastName    = info.GetString("LastName");
            this.PhoneType   = (PhoneType)info.GetInt16("PhoneType");
            this.PhoneNumber = info.GetString("PhoneNumber");
        }
Example #17
0
            public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
            {
                string @string = info.GetString("type");
                Type   type    = Type.GetType(@string, throwOnError: false);

                if (type == null)
                {
                    throw new KeyNotFoundException("Could not load type " + @string);
                }
                object result = null;

                Type[] genericArguments = type.GetGenericArguments();
                if (type.GetGenericTypeDefinition() == typeof(List <>))
                {
                    IList list = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(genericArguments));
                    short @int = info.GetInt16("length");
                    for (short num = 0; num < @int; num = (short)(num + 1))
                    {
                        byte[]   dataParameters = (byte[])info.GetValue(num.ToString(), typeof(byte[]));
                        object[] array          = ParameterDecoder(dataParameters);
                        list.Add(array[0]);
                    }
                    result = list;
                }
                else if (type.GetGenericTypeDefinition() == typeof(Dictionary <, >))
                {
                    IDictionary dictionary = (IDictionary)Activator.CreateInstance(typeof(Dictionary <, >).MakeGenericType(genericArguments));
                    short       int2       = info.GetInt16("length");
                    for (short num2 = 0; num2 < int2; num2 = (short)(num2 + 1))
                    {
                        byte[]   dataParameters2 = (byte[])info.GetValue("key_" + num2.ToString(), typeof(byte[]));
                        object[] array2          = ParameterDecoder(dataParameters2);
                        byte[]   dataParameters3 = (byte[])info.GetValue("value_" + num2.ToString(), typeof(byte[]));
                        object[] array3          = ParameterDecoder(dataParameters3);
                        dictionary.Add(array2[0], array3[0]);
                    }
                    result = dictionary;
                }
                return(result);
            }
Example #18
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[]));
            }
Example #19
0
 protected PhysicsSimulator(SerializationInfo info, StreamingContext context)
 {
     AllowedPenetrationDepth = info.GetSingle("AllowedPenetrationDepth");
     DampingCoef             = info.GetSingle("DampingCoef");
     Gravity          = (Vector2)info.GetValue("Gravity", typeof(Vector2));
     Bodies           = (List <Body>)info.GetValue("Bodies", typeof(List <Body>));
     SpeedCoef        = info.GetSingle("SpeedCoef");
     StickCoef        = info.GetSingle("StickCoef");
     MaxUpdatePerBody = info.GetInt16("MaxUpdatePerBody");
     Speed            = info.GetSingle("Speed");
     Ropes            = (List <Rope>)info.GetValue("Ropes", typeof(List <Rope>));
     ShowTriangles    = info.GetBoolean("ShowTriangles");
 }
Example #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Station"/> class from deserialized information.
 /// </summary>
 /// <param name="info"> The information from the deserialization process. </param>
 /// <param name="context"> The context of creating. </param>
 public Station(SerializationInfo info, StreamingContext context)
 {
     Id           = info.GetInt16("id");
     Code         = info.GetString("code");
     UIC          = info.GetInt32("uic");
     FullName     = info.GetString("naam");
     MiddleName   = info.GetString("middel_naam");
     ShortName    = info.GetString("korte_naam");
     FriendlyName = info.GetString("friendly");
     CountryCode  = info.GetString("land");
     Type         = (StationType)info.GetValue("type", typeof(StationType));
     Position     = new PointLatLng(info.GetDouble("geo_lat"), info.GetDouble("geo_lng"));
 }
Example #21
0
 protected SkillBook(SerializationInfo info, StreamingContext context)
 {
     Name        = info.GetString("ItemName");
     Num         = info.GetInt16("Num");
     SkillType   = info.GetInt16("SkillType");
     SkillLevel  = info.GetInt16("SkillLevel");
     SkillAttack = info.GetInt16("SkillAttack");
     UpgradeCost = info.GetInt16("UpgradeCost");
     UpgradeNum  = info.GetInt16("UpgradeNum");
     Cost        = info.GetInt16("Cost");
 }
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            var orderDetail = (Order_Detail)obj;

            orderDetail.Discount  = info.GetSingle(nameof(orderDetail.Discount));
            orderDetail.OrderID   = info.GetInt32(nameof(orderDetail.OrderID));
            orderDetail.ProductID = info.GetInt32(nameof(orderDetail.ProductID));
            orderDetail.Quantity  = info.GetInt16(nameof(orderDetail.Quantity));
            orderDetail.UnitPrice = info.GetDecimal(nameof(orderDetail.UnitPrice));
            orderDetail.Order     = (Order)info.GetValue(nameof(orderDetail.Order), typeof(Order));
            orderDetail.Product   = (Product)info.GetValue(nameof(orderDetail.Product), typeof(Product));
            return(orderDetail);
        }
    public System.Object SetObjectData(System.Object obj,
                                       SerializationInfo info, StreamingContext context,
                                       ISurrogateSelector selector)
    {
        CharacterBuff data = (CharacterBuff)obj;

        data.type   = (BuffType)info.GetByte("type");
        data.dataId = info.GetInt32("dataId");
        data.level  = info.GetInt16("level");
        data.buffRemainsDuration = info.GetSingle("buffRemainsDuration");
        obj = data;
        return(obj);
    }
 protected Coin(SerializationInfo info, StreamingContext context)
 {
     Name          = info.GetString("Name");
     Year          = info.GetInt16("Year");
     MonetaryValue = info.GetDecimal("MonetaryValue");
     Portait       = info.GetString("Portait");
     ReverseMotif  = info.GetString("ReverseMotif");
     //info.AddValue("Name", Name);
     //info.AddValue("Year", Year);
     //info.AddValue("MonetaryValue", MonetaryValue);
     //info.AddValue("Portait", Portait);
     //info.AddValue("ReverseMotif", ReverseMotif);
 }
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            var data = (Order_Detail)obj;

            data.OrderID   = info.GetInt32("OrderID");
            data.ProductID = info.GetInt32("ProductID");
            data.UnitPrice = info.GetDecimal("UnitPrice");
            data.Quantity  = info.GetInt16("Quantity");
            data.Discount  = (float)info.GetValue("Discount", typeof(float));
            data.Order     = (Order)info.GetValue("Order", typeof(Order));
            data.Product   = (Product)info.GetValue("Product", typeof(Product));
            return(data);
        }
Example #26
0
 public SimpleSerializable(SerializationInfo info, StreamingContext context)
 {
     Byte    = info.GetByte("Byte");
     Bool    = info.GetBoolean("Bool");
     Short   = info.GetInt16("Short");
     Int     = info.GetInt32("Int");
     Long    = info.GetInt64("Long");
     Float   = info.GetSingle("Float");
     Double  = info.GetDouble("Double");
     Decimal = info.GetDecimal("Decimal");
     Guid    = (Guid)info.GetValue("Guid", typeof(Guid));
     String  = info.GetString("String");
 }
Example #27
0
    public AuthorizeDirective(SerializationInfo info, StreamingContext context)
    {
        var node = info.GetValue(
            nameof(DirectiveNode),
            typeof(DirectiveNode))
                   as DirectiveNode;

        if (node == null)
        {
            Policy = info.GetString(nameof(Policy));
            Roles  = info.GetValue(nameof(Roles), typeof(List <string>)) as List <string>;
            Apply  = (ApplyPolicy)info.GetInt16(nameof(Apply));
        }
        else
        {
            ArgumentNode?policyArgument = node.Arguments
                                          .FirstOrDefault(t => t.Name.Value == "policy");
            ArgumentNode?rolesArgument = node.Arguments
                                         .FirstOrDefault(t => t.Name.Value == "roles");
            ArgumentNode?resolverArgument = node.Arguments
                                            .FirstOrDefault(t => t.Name.Value == "apply");

            Policy = (policyArgument is not null &&
                      policyArgument.Value is StringValueNode sv)
                ? sv.Value
                : null;

            if (rolesArgument is not null)
            {
                if (rolesArgument.Value is ListValueNode lv)
                {
                    Roles = lv.Items.OfType <StringValueNode>()
                            .Select(t => t.Value?.Trim())
                            .Where(s => !string.IsNullOrEmpty(s))
                            .ToArray() !;
                }
                else if (rolesArgument.Value is StringValueNode svn)
                {
                    Roles = new[] { svn.Value };
                }
            }

            Apply = ApplyPolicy.BeforeResolver;
            if (resolverArgument is not null &&
                resolverArgument.Value.Value is string s &&
                s == "AFTER_RESOLVER")
            {
                Apply = ApplyPolicy.AfterResolver;
            }
        }
    }
Example #28
0
        //
        protected StoreWorldDetail(SerializationInfo info, StreamingContext context)

        {
            _storeid      = info.GetInt64("sid");
            _storeworldid = info.GetInt64("swid");
            _year         = info.GetInt16("y");
            _available_work_time_hours = (decimal?)info.GetValue("_1", typeof(decimal?));
            _available_buffer_hours    = (double?)info.GetValue("_2", typeof(double?));
            _business_volume_hours     = (decimal?)info.GetValue("_3", typeof(decimal?));
            _targetedbusinessvolume    = (decimal?)info.GetValue("_4", typeof(decimal?));
            _netbusinessvolume1        = (decimal?)info.GetValue("_5", typeof(decimal?));
            _netbusinessvolume2        = (decimal?)info.GetValue("_6", typeof(decimal?));
            _benchmark_perfomance      = (double?)info.GetValue("_7", typeof(double?));
        }
Example #29
0
 protected SpiderSetting(SerializationInfo info, StreamingContext context)
 {
     this.name            = info.GetString("name");
     this.startUrl        = info.GetValue("startUrl", typeof(StartUrl)) as StartUrl;
     this.maxDepth        = info.GetInt16("maxDepth");
     this.allowRedirect   = info.GetBoolean("allowRedirect");
     this.requestTimeout  = info.GetInt32("requestTimeout");
     this.iOTimeout       = info.GetInt32("iOTimeout");
     this.readBufferSize  = info.GetInt32("readBufferSize");
     this.crawlThreads    = info.GetInt16("crawlThreads");
     this.processThreads  = info.GetInt16("processThreads");
     this.proxy           = info.GetValue("proxy", typeof(IWebProxy)) as IWebProxy;
     this.userAgent       = info.GetString("userAgent");
     this.referer         = info.GetString("referer");
     this.cookies         = info.GetValue("cookies", typeof(CookieCollection)) as CookieCollection;
     this.requestEncoding = info.GetValue("requestEncoding", typeof(Encoding)) as Encoding;
     this.urlExtractor    = info.GetValue("urlExtractor", typeof(UrlExtractor)) as UrlExtractor;
     this.contentHandlers = info.GetValue("contentHandlers", typeof(ContentHandlerCollection)) as ContentHandlerCollection;
     this.logger          = info.GetValue("logger", typeof(ILogger)) as ILogger;
     this.memLimitSize    = info.GetInt32("memLimitSize");
     this.depositePath    = info.GetString("depositePath");
     this.speedMode       = (SpeedModes)info.GetValue("speedMode", typeof(SpeedModes));
 }
Example #30
0
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            var od = obj as Order_Detail;

            if (od != null)
            {
                od.Product   = info.GetValue("Product", typeof(Product)) as Product;
                od.Order     = info.GetValue("Order", typeof(Order)) as Order;
                od.UnitPrice = info.GetDecimal("UnitPrice");
                od.Quantity  = info.GetInt16("Quantity");
                od.Discount  = info.GetSingle("Discount");
            }
            return(od);
        }
Example #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActiveScriptException"/> class with serialized data
 /// </summary>
 /// <param name="info">The object that holds the serialized data</param>
 /// <param name="context">The contextual information about the source or destination</param>
 private ActiveScriptException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info != null)
     {
         _errorCode     = info.GetInt32("ErrorCode");
         _errorWCode    = info.GetInt16("ErrorWCode");
         _sourceContext = info.GetUInt32("SourceContext");
         _subcategory   = info.GetString("Subcategory");
         _lineNumber    = info.GetUInt32("LineNumber");
         _columnNumber  = info.GetInt32("ColumnNumber");
         _sourceError   = info.GetString("SourceError");
     }
 }
Example #32
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;
		try {
			do
			{
				serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter());
				iCountTestcases++;
				if(serinfo1.MemberCount != 0)
				{
					iCountErrors++;
					Console.WriteLine("Err_0256csd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				serinfo1.AddValue("MyOwnField", 5, typeof(Int32));
				iCountTestcases++;
				if(serinfo1.MemberCount != 1)
				{
					iCountErrors++;
					Console.WriteLine("Err_8564cfdg! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				iCountTestcases++;
				if(serinfo1.GetInt16("MyOwnField") != 5)
				{
					iCountErrors++;
					Console.WriteLine("Err_675349fd! Wrong value returned, " + serinfo1.GetInt16("MyOwnField"));
				}
				serinfo1 = new SerializationInfo(typeof(MyOwnClass), new FormatterConverter());
				serinfo1.AddValue("MyOwnField_1", "5", typeof(Int32));
				serinfo1.AddValue("MyOwnField_2", "AnyValue", typeof(String));
				serinfo1.AddValue("MyOwnField_WhichIsNotInThisClass", "AnyValue", typeof(String));
				iCountTestcases++;
				if(serinfo1.MemberCount != 3)
				{
					iCountErrors++;
					Console.WriteLine("Err_6538fcd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				try {
					iCountTestcases++;
					serinfo1 = new SerializationInfo(null, new FormatterConverter());
					iCountErrors++;
					Console.WriteLine("Err_653fd! Exception not thrown");
					}catch(ArgumentNullException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_6439cd! Wrong exception thrown, " + ex);
				}
				try {
					iCountTestcases++;
					serinfo1 = new SerializationInfo(typeof(Int32), null);
					iCountErrors++;
					Console.WriteLine("Err_1065753cd! Exception not thrown");
					}catch(ArgumentNullException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
				}
			} 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;
		}
	}
Example #33
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;
		}
	}