コード例 #1
0
ファイル: SharedSirens.cs プロジェクト: progrocket/Slipe-Core
        protected void UpdateParams()
        {
            Dictionary <string, dynamic> d = MtaShared.GetDictionaryFromTable(MtaShared.GetVehicleSirenParams(vehicle.MTAElement), "System.String", "dynamic");

            type = (SirenType)d["SirenType"];
            Dictionary <string, bool> flags = MtaShared.GetDictionaryFromTable(d["Flags"], "System.String", "System.Boolean");

            visibleFromAllDirection = flags["360"];
            checkLOS      = flags["DoLOSCheck"];
            useRandomiser = flags["UseRandomiser"];
            silent        = flags["Silent"];
        }
コード例 #2
0
        public void SerializeHelper(object obj, SirenType sirenType)
        {
            if (sirenType.IsBuildIn)
            {
                switch (sirenType.Id)
                {
                case SirenTypeId.List:
                    break;

                case SirenTypeId.Dictionary:
                    break;

                case SirenTypeId.String:
                    Writer.OnString(obj as string);
                    break;

                case SirenTypeId.Blob:
                    Writer.OnMemoryData(obj as byte[]);
                    break;

                default:
                    Writer.OnValue(obj);
                    break;
                }
            }
            else
            {
                if (sirenType.IsCustomClass)
                {
                    SirenCustomClass sirenClass = sirenType as SirenCustomClass;
                    if (sirenClass.SerializeMethodInfo != null)
                    {
                        sirenClass.SerializeMethodInfo.Invoke(obj, new object[] { Writer });
                    }
                    else
                    {
                        SerializeStruct(obj, sirenClass);
                    }
                }
                else
                {
                    SerializeEnum(obj, sirenType as SirenCustomEnum);
                }
            }
        }
コード例 #3
0
        public void DeserializeHelper(Type type, ref object obj, SirenType sirenType)
        {
            if (sirenType.IsBuildIn)
            {
                switch (sirenType.Id)
                {
                case SirenTypeId.List:
                    break;

                case SirenTypeId.Dictionary:
                    break;

                case SirenTypeId.String:
                    obj = Reader.OnString();
                    break;

                case SirenTypeId.Blob:
                    obj = Reader.OnMemoryData();
                    break;

                default:
                    obj = Reader.OnValue(type);
                    break;
                }
            }
            else
            {
                if (sirenType.IsCustomClass)
                {
                    SirenCustomClass sirenClass = sirenType as SirenCustomClass;
                    if (sirenClass.DeserializeMethodInfo != null)
                    {
                        sirenClass.DeserializeMethodInfo.Invoke(obj, new object[] { Reader });
                    }
                    else
                    {
                        DeserializeStruct(ref obj, sirenClass);
                    }
                }
                else
                {
                    obj = DeserializeEnum(sirenType as SirenCustomEnum);
                }
            }
        }