/// <summary>
        /// 获得本地数据的一份深度复制副本
        /// </summary>
        public TestProject_ExcelEntity_Test DeepCopy()
        {
            var buff   = SerializeUtility.Serialize(this);
            var entity = SerializeUtility.DeSerialize <TestProject_ExcelEntity_Test>(buff);

            return(entity);
        }
            public void Execute()
            {
                var loadingOperation = (AsyncLoadSceneOperation)LoadingOperationHandle.Target;

                LoadingOperationHandle.Free();

                object[] objectReferences = null;
#if !UNITY_DOTSRUNTIME
                objectReferences = (object[])ObjectReferencesHandle.Target;
                ObjectReferencesHandle.Free();
#endif

                try
                {
                    using (var reader = new MemoryBinaryReader(FileContent))
                    {
                        k_ProfileDeserializeWorld.Begin();
                        SerializeUtility.DeserializeWorld(Transaction, reader, objectReferences);
                        k_ProfileDeserializeWorld.End();
                    }
                }
                catch (Exception exc)
                {
                    loadingOperation._LoadingFailure   = exc.Message;
                    loadingOperation._LoadingException = exc;
                }
            }
 private void EnsureLoadAtlasInfo(string finalAppId)
 {
     if (!appAtlasInfoDict.ContainsKey(finalAppId))
     {
         //沙盒目录图集
         var       sandboxPath = projectInfo.CurrentProjectAssetDatabaseDirPath;
         AtlasInfo atlasInfo   = null;
         if (File.Exists(sandboxPath))
         {
             var atlasInfobytes = File.ReadAllBytes(sandboxPath);
             atlasInfo = SerializeUtility.DeSerialize <AtlasInfo>(atlasInfobytes);
             appAtlasInfoDict.Add(finalAppId, atlasInfo);
         }
         else
         {
             //Streaming 目录图集
             //#if UNITY_EDITOR
             //因程序集工程为编译完成的代码,此处无需编译,故新增 UNITY_EDITOR 宏。
             //#elif UNITY_STANDALONE_WIN
             var streamPath = projectInfo.CurrentProjectAssetDatabaseDirPath;
             if (File.Exists(streamPath))
             {
                 var atlasInfobytes = File.ReadAllBytes(streamPath);
                 atlasInfo = SerializeUtility.DeSerialize <AtlasInfo>(atlasInfobytes);
                 appAtlasInfoDict.Add(finalAppId, atlasInfo);
             }
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 从文件中加载引用关系
 /// </summary>
 private bool LoadAllRelationFromFile(bool enableLog = true)
 {
     try
     {
         if (File.Exists(m_RecordFilePath))
         {
             m_Graph = (RelationGraph)SerializeUtility.ReadFile(m_RecordFilePath);
             if (enableLog)
             {
                 EditorUtility.DisplayDialog("提示", "读取引用关系成功.", "确定");
             }
             return(true);
         }
         else
         {
             if (enableLog)
             {
                 EditorUtility.DisplayDialog("提示", "Asset引用关系缓存文件不存在,您需要先加载所有所有Asset的引用关系.", "确定");
             }
             return(false);
         }
     }
     catch (Exception ex)
     {
         if (enableLog)
         {
             EditorUtility.DisplayDialog("提示", "读取引用关系失败.\n" + ex.ToString(), "确定");
         }
         return(false);
     }
 }
Ejemplo n.º 5
0
        private void InitAssetInfo()
        {
            var bytes = File.ReadAllBytes(
                $"{Application.streamingAssetsPath}/{ProjectInfoDati.GetActualInstance().DevelopProjectName}/Config/AssetInfo.byte");

            _infos = SerializeUtility.DeSerialize <Dictionary <char, Dictionary <string, AssetInfo> > >(bytes);
        }
        private static JobStatusChanged ParseResponseToPortalJobStatusChangeResponse(string requestContent, DateTime nextPermittedPollTime)
        {
            var deserialized = SerializeUtility.Deserialize <portalsignaturejobstatuschangeresponse>(requestContent);
            var portalJobStatusChangeResponse = DataTransferObjectConverter.FromDataTransferObject(deserialized, nextPermittedPollTime);

            return(portalJobStatusChangeResponse);
        }
Ejemplo n.º 7
0
        static byte[] Write(EntityManager manager, Mode mode)
        {
            if (mode == Mode.Binary)
            {
                using (var writer = new TestBinaryWriter())
                {
                    SerializeUtility.SerializeWorld(manager, writer);
                    return(writer.content.ToArray());
                }
            }
            else
            {
                // Save the World to a memory buffer via a a Stream Writer
                using (var memStream = new MemoryStream())
                    using (var sw = new StreamWriter(memStream))
                    {
                        sw.NewLine = "\n";
                        if (mode == Mode.Yaml)
                        {
                            SerializeUtility.SerializeWorldIntoYAML(manager, sw, false);
                        }
                        else if (mode == Mode.YamlDumpChunk)
                        {
                            SerializeUtility.SerializeWorldIntoYAML(manager, sw, true);
                        }

                        sw.Flush();
                        memStream.Seek(0, SeekOrigin.Begin);
                        return(memStream.ToArray());
                    }
            }
        }
Ejemplo n.º 8
0
        private LegoUIMeta GetUIMetaAtEditor(string uiId)
        {
            if (metaPathDict == null)
            {
                metaPathDict = new Dictionary <string, string>();
                var    app      = ProjectInfoDati.GetActualInstance();
                string metaDir  = string.Empty;
                var    pathDict = IOUtility.GetPathDictionary(metaDir, s => s.EndsWith(".txt"));
                foreach (var kv in pathDict)
                {
                    metaPathDict.Add(kv.Key.ToLower(), kv.Value);
                }
            }

            if (!metaPathDict.ContainsKey(uiId))
            {
                Debug.Log($"id为{uiId}的元数据不存在!");
                return(null);
            }

            var path    = metaPathDict[uiId];
            var content = File.ReadAllText(path);
            var uiMeta  = UnityEngine.JsonUtility.FromJson <LegoUIMeta>(content);

            uiMeta.Reset();
            var bytes   = SerializeUtility.Serialize(uiMeta);
            var newMeta = SerializeUtility.DeSerialize <LegoUIMeta>(bytes);

            uiMetaDict.Add(uiId, newMeta);
            return(uiMeta);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Verify expression expected output equals to actual output
        /// </summary>
        /// <param name="message"></param>
        public void Verify(string message = "")
        {
            for (var i = 0; i < ExpectedOutputs.Length; i++)
            {
                if (ExpectedOutputs[i] is char)
                {
                    ExpectedOutputs[i] = TypeUtility.CastValueWithRespectToType(ExpectedOutputs[i], typeof(int));
                }

                if (ExpressionInfo?.ReturnType == typeof(char))
                {
                    ExpectedOutputs[i] = TypeUtility.CastValueWithRespectToType(ExpectedOutputs[i], typeof(char));
                }

                if (!Regex.Replace(SerializeUtility.Serialize(ExpectedOutputs[i]), "\\\\u", "\\u").Equals(
                        Regex.Replace(SerializeUtility.Serialize(ActualOutputs[i]), "\\\\u", "\\u")))
                {
                    var methodName = string.IsNullOrEmpty(message) ?
                                     "" :
                                     $"Testing Expression: {message}";

                    throw new NoMatchedException($"{methodName} {_errorMessages[i]}");
                }
            }
        }
Ejemplo n.º 10
0
        public YuAIBehaviorTree LoadCurrentHaviourTree(string behaviourId)
        {
            var writePath   = $"{Application.streamingAssetsPath}/{ProjectInfoDati.GetActualInstance().DevelopProjectName}/Config/BehaviourTreeData.byte";
            var newInstance = SerializeUtility.DeSerialize <BehaviorTreeVisualization>(writePath);

            instance = newInstance;
            return(CreateBehaviourTree());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// It is a constructor. Used to take over connection information.
        /// </summary>
        /// <param name="executeContextWindowHandle">
        /// Windowshandle that belongs to the target process.
        /// Operations are carried out in the thread of this window.
        /// <param name="bin">Connection information serialized binary.</param>
#else
        /// <summary>
        /// コンストラクタです。接続情報を引き継ぐときに使います。
        /// </summary>
        /// <param name="executeContextWindowHandle">接続対象プロセスの処理実行スレッドのウィンドウハンドル。</param>
        /// <param name="bin">接続情報がシリアライズされたバイナリ。</param>
#endif
        public WindowsAppFriend(IntPtr executeContextWindowHandle, byte[] bin)
        {
            ResourcesLocal.Initialize();
            ProtocolMessageManager.Initialize();
            _systemController = (SystemController)SerializeUtility.Deserialize(bin);
            _context          = new ExecuteContext(_systemController.StartFriendlyConnector(executeContextWindowHandle));
            NativeMethods.GetWindowThreadProcessId(executeContextWindowHandle, out _processId);
        }
Ejemplo n.º 12
0
 public void Execute()
 {
     SerializeUtility.DeserializeWorld(Transaction, Reader, SharedCount);
     for (int i = 0; i < SharedCount; ++i)
     {
         Transaction.ManagedComponentStore.RemoveReference(i + 1);
     }
 }
Ejemplo n.º 13
0
        public static void Deserialize(EntityManager manager, BinaryReader reader, ReferencedUnityObjects objRefs)
        {
            DeserializeObjectReferences(objRefs, out var objectReferences);
            var transaction = manager.BeginExclusiveEntityTransaction();

            SerializeUtility.DeserializeWorld(transaction, reader, objectReferences);
            manager.EndExclusiveEntityTransaction();
        }
Ejemplo n.º 14
0
        public async Task <directsignerresponse> RequestNewRedirectUrl(Uri signerUrl)
        {
            var responseMessage = await _httpClient.PostAsync(signerUrl, null).ConfigureAwait(false);

            var responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(SerializeUtility.Deserialize <directsignerresponse>(responseContent));
        }
Ejemplo n.º 15
0
        public unsafe void SerializeEntitiesWorksWithChunkComponents()
        {
            var dummyEntity = CreateEntityWithDefaultData(0); //To ensure entity indices are offset

            var e1 = m_Manager.CreateEntity();

            m_Manager.AddComponentData(e1, new EcsTestData(1));
            m_Manager.AddChunkComponentData <EcsTestData3>(e1);
            m_Manager.SetChunkComponentData(m_Manager.GetChunk(e1), new EcsTestData3(42));
            var e2 = m_Manager.CreateEntity();

            m_Manager.AddComponentData(e2, new EcsTestData2(2));
            m_Manager.AddChunkComponentData <EcsTestData3>(e2);
            m_Manager.SetChunkComponentData(m_Manager.GetChunk(e2), new EcsTestData3(57));

            m_Manager.DestroyEntity(dummyEntity);
            // disposed via reader
            var writer = new TestBinaryWriter();

            int[] sharedData;
            SerializeUtility.SerializeWorld(m_Manager, writer, out sharedData);
            var reader = new TestBinaryReader(writer);

            var deserializedWorld = new World("SerializeEntities Test World 3");
            var entityManager     = deserializedWorld.EntityManager;

            SerializeUtility.DeserializeWorld(entityManager.BeginExclusiveEntityTransaction(), reader, 0);
            entityManager.EndExclusiveEntityTransaction();

            try
            {
                var group1 = entityManager.CreateEntityQuery(typeof(EcsTestData));
                var group2 = entityManager.CreateEntityQuery(typeof(EcsTestData2));

                Assert.AreEqual(1, group1.CalculateEntityCount());
                Assert.AreEqual(1, group2.CalculateEntityCount());

                var entities1 = group1.ToEntityArray(Allocator.TempJob);
                var entities2 = group2.ToEntityArray(Allocator.TempJob);

                var new_e1 = entities1[0];
                var new_e2 = entities2[0];

                entities1.Dispose();
                entities2.Dispose();

                Assert.AreEqual(1, entityManager.GetComponentData <EcsTestData>(new_e1).value);
                Assert.AreEqual(42, entityManager.GetChunkComponentData <EcsTestData3>(new_e1).value0);

                Assert.AreEqual(2, entityManager.GetComponentData <EcsTestData2>(new_e2).value0);
                Assert.AreEqual(57, entityManager.GetChunkComponentData <EcsTestData3>(new_e2).value0);
            }
            finally
            {
                deserializedWorld.Dispose();
                reader.Dispose();
            }
        }
Ejemplo n.º 16
0
        public static byte[] SerializeWorld(EntityManager entityManager, out object[] referencedObjects)
        {
            using (var binaryWriter = new MemoryBinaryWriter())
            {
                SerializeUtility.SerializeWorld(entityManager, binaryWriter, out referencedObjects);

                return(binaryWriter.GetDataArray());
            }
        }
Ejemplo n.º 17
0
        //[MenuItem("Yu/AssetBundle/更新当前应用的AssetBundle依赖数据")]
        /// <summary>
        /// Bundle To Bundle 依赖数据
        /// </summary>
        private static void CreateAppDependInfoMenu()
        {
            var currentApp    = ProjectInfoDati.GetActualInstance();
            var path          = BundlePathHelper.GetAppBundleDependInfoPath();
            var bundlePath    = currentApp.AssetBundleBuildDir + "AssetBundle";
            var appDependInfo = ProjectBundleDependInfo.Create(bundlePath);

            SerializeUtility.SerializeAndWriteTo(appDependInfo, path);
            Debug.Log($"应用{currentApp.DevelopProjectName}的AssetBundle依赖数据更新完成!");
        }
Ejemplo n.º 18
0
        public void SerializeDoesntRemapOriginalHeapBuffers()
        {
            var dummyEntity = CreateEntityWithDefaultData(0); //To ensure entity indices are offset

            var e1 = m_Manager.CreateEntity();

            m_Manager.AddComponentData(e1, new EcsTestData(1));
            var e2 = m_Manager.CreateEntity();

            m_Manager.AddComponentData(e2, new EcsTestData2(2));

            m_Manager.AddBuffer <TestBufferElement>(e1);
            var buffer1 = m_Manager.GetBuffer <TestBufferElement>(e1);

            for (int i = 0; i < 1024; ++i)
            {
                buffer1.Add(new TestBufferElement {
                    entity = e2, value = 2
                });
            }

            m_Manager.AddBuffer <TestBufferElement>(e2);
            var buffer2 = m_Manager.GetBuffer <TestBufferElement>(e2);

            for (int i = 0; i < 8; ++i)
            {
                buffer2.Add(new TestBufferElement {
                    entity = e1, value = 1
                });
            }

            m_Manager.DestroyEntity(dummyEntity);
            // disposed via reader
            var writer = new TestBinaryWriter();

            int[] sharedData;
            SerializeUtility.SerializeWorld(m_Manager, writer, out sharedData);

            buffer1 = m_Manager.GetBuffer <TestBufferElement>(e1);
            for (int i = 0; i < buffer1.Length; ++i)
            {
                Assert.AreEqual(e2, buffer1[i].entity);
                Assert.AreEqual(2, buffer1[i].value);
            }

            buffer2 = m_Manager.GetBuffer <TestBufferElement>(e2);
            for (int i = 0; i < buffer2.Length; ++i)
            {
                Assert.AreEqual(e1, buffer2[i].entity);
                Assert.AreEqual(1, buffer2[i].value);
            }

            writer.Dispose();
        }
Ejemplo n.º 19
0
    public static XDict <T, U> DeserializeXDict <T, U>(string path)
    {
        XDict <T, U> result;

        using (StreamReader streamReader = new StreamReader(path))
        {
            string json = streamReader.ReadToEnd();
            result = SerializeUtility.DeserializeXDictFromMemory <T, U>(json);
        }
        return(result);
    }
Ejemplo n.º 20
0
        /// <summary>
        /// アプリケーション設定を保存します。
        /// </summary>
        /// <param name="settings">アプリケーション設定の保存先ファイルのパスを表す文字列。</param>
        /// <param name="savedPath">設定ファイルの保存先をフルパスで指定します。 ※ 省略可能</param>
        public static void SaveSettings(ImaZipCoreProto01Settings settings, string savedPath = "")
        {
            var xmlPath = AppSettingsService.getSettingFilePath();

            if (!string.IsNullOrEmpty(savedPath))
            {
                xmlPath = savedPath;
            }

            SerializeUtility.SerializeToFile <ImaZipCoreProto01Settings>(xmlPath, settings);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 保存到文件
 /// </summary>
 public static void Save()
 {
     try
     {
         SerializeUtility.WriteFile(ms_SavePath, Instance);
     }
     catch (Exception ex)
     {
         DebugUtility.ShowExceptionMessageBox("保存设置失败\n" + ms_SavePath, ex);
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 现在考虑到多个进程之间可能会冲突,暂时这样处理
 /// </summary>
 private void Save(string path, List <CSVLayout> list)
 {
     try
     {
         SerializeUtility.WriteFile(path, list);
     }
     catch (Exception ex)
     {
         DebugUtility.ShowExceptionMessageBox("保存CSVLayout失败\n" + path, ex);
     }
 }
        private void MessageReadCallback(IAsyncResult ar)
        {
            string content    = string.Empty;
            int    SplitIndex = 0;

            StateObject state       = (StateObject)ar.AsyncState;
            Socket      handler     = state.workSocket;
            string      parseString = string.Empty;

            byte[] data;

            try
            {
                int databytesRead = handler.EndReceive(ar);
                if (databytesRead > 0)
                {
                    state.sb.Append(Encoding.UTF8.GetString(state.buffer, 0, databytesRead));

                    content = state.sb.ToString();
                    if (content.Contains("\n"))
                    {
                        do
                        {
                            SplitIndex  = content.IndexOf("\n");
                            parseString = content.Substring(0, SplitIndex);
                            state.sb.Remove(0, SplitIndex + 1);
                            data        = Convert.FromBase64String(parseString);
                            parseString = Encoding.UTF8.GetString(data);

                            _MessageSessionContract = SerializeUtility.DeSerialize <MessageSessionContract>(parseString);
                            if (_MessageSessionContract != null)
                            {
                                _MessageSessionContract.MessageContent = Encoding.UTF8.GetString(Convert.FromBase64String(_MessageSessionContract.MessageContent));

                                if (_MessageInterfaceTable.ContainsKey(_TargetID))
                                {
                                    _MessageInterfaceTable[_TargetID].OnMessageReceive((IMessageContent)_MessageSessionContract);
                                }
                            }
                        } while (state.sb.ToString().Contains("\n"));
                    }
                    handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(MessageReadCallback), state);
                }
                else
                {
                    _ReceiveFlag.Set();
                }
            }
            catch (Exception e)
            {
                //Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 24
0
    public void PlayGame()
    {
        string[] possibleLevels = SerializeUtility.GetAllLevels();

        foreach (string possibleLevel in possibleLevels)
        {
            LevelSelectionButton levelSelectionButton = Instantiate(levelSelectionButtonPrefab, levelSelectionButtonsParent.transform).GetComponent <LevelSelectionButton>();
            levelSelectionButton.SetLevel(possibleLevel);
        }

        levelSelectionPanel.SetActive(true);
    }
Ejemplo n.º 25
0
        public T GetSystemConfig(Enums.SystemSettingKeyEnum settingKey)
        {
            var systemSettingsDic = DataCacheManager.DataCacheManager.GetCacheManagerInstance().GetSystemSettingsFromCache();

            if (systemSettingsDic.ContainsKey(settingKey.ToString()))
            {
                var configXml = DataCacheManager.DataCacheManager.GetCacheManagerInstance().GetSystemSettingsFromCache()[settingKey.ToString()];
                return(SerializeUtility <T> .XmlDeserialize(configXml));
            }

            return(default(T));
        }
Ejemplo n.º 26
0
    static void LoadWorld(EntityManager entityManager, object[] objectTable)
    {
        string filePath = Application.persistentDataPath + "/test.bin";

        using (var binaryReader = new StreamBinaryReader(filePath))
        {
            ExclusiveEntityTransaction transaction = entityManager.BeginExclusiveEntityTransaction();

            SerializeUtility.DeserializeWorld(transaction, binaryReader, objectTable);

            entityManager.EndExclusiveEntityTransaction();
        }
    }
        public BundlePathInfoHelepr()
        {
            string path = null;

            projectConfig = ProjectInfoDati.GetActualInstance();

            if (UnityModeUtility.IsEditorMode)
            {
                path = /*projectConfig.Helper.LocalHttpRootDir +*/ $"{projectConfig.DevelopProjectName}_AssetBundleInfo.bytes";
                var bytes = File.ReadAllBytes(path);
                projectAssetToBundleMap = SerializeUtility.DeSerialize <ProjectAssetsToBundleMapInfo>(bytes);
            }
        }
Ejemplo n.º 28
0
        public void Login()
        {
            var launcher   = Launcher.Instance;
            var playerName = nameInputField.text;

            if (string.IsNullOrEmpty(playerName))
            {
                launcher.PanelManager.warningPanel.Show(400, 200, "Please input a player name.");
                return;
            }
            launcher.Connect();
            SerializeUtility.SaveContent(Application.persistentDataPath + LAST_LOGIN, playerName);
        }
Ejemplo n.º 29
0
    static void SaveWorld(EntityManager entityManager, out object[] objectTable)
    {
        string filePath = Application.persistentDataPath + "/test.bin";

        if (File.Exists(filePath))
        {
            File.Delete(filePath);
        }

        using (var binaryWriter = new StreamBinaryWriter(filePath))
        {
            SerializeUtility.SerializeWorld(entityManager, binaryWriter, out objectTable);
        }
    }
Ejemplo n.º 30
0
            public void Successful_manifest_to_bytes()
            {
                //Arrange
                var manifest = DomainUtility.GetPortalManifest();
                var manifestDataTranferObject = DataTransferObjectConverter.ToDataTransferObject(manifest);
                var expectedResult            = SerializeUtility.Serialize(manifestDataTranferObject);

                //Act
                var bytes        = manifest.Bytes;
                var actualResult = Encoding.UTF8.GetString(bytes);

                //Assert
                Assert.Equal(expectedResult, actualResult);
            }
 public Options LoadOptions()
 {
     SerializeUtility<Options> utility = new SerializeUtility<Options>();
     Options options = null;
     try
     {
         if (File.Exists(SerializeUtility<Options>.GetFilePath(OptionsFilename)))
         {
             options = utility.DeserializeData(OptionsFilename);
         }
     }
     finally
     {
         if (options == null)
         {
             options = new Options();
         }
     }
     return options;
 }
 public void SaveOptions(Options options)
 {
     SerializeUtility<Options> utility = new SerializeUtility<Options>();
     utility.SerializeData(options, OptionsFilename);
 }