コード例 #1
0
    void Start()
    {
        SerializeManager <PlayerScore> serializer = new SerializeManager <PlayerScore>();
        PlayerScore myData = new PlayerScore("matt", 200);

        output = serializer.SerializeObject(myData);
    }
コード例 #2
0
ファイル: SaveManager.cs プロジェクト: calport/Dial-A-Demon
    public void LoadGame()
    {
        if (File.Exists(_saveJsonPath))
        {
            //read the file
            var json       = SerializeManager.ReadJsonString(_saveJsonPath);
            var jsonObject = JSON.Parse(json);
            inkJson = SerializeManager.ReadJsonString(Services.saveManager.inkjsonPath);

            //Load info from save
            //plot should run before text, since text manager needs its info
            Services.plotManager.LoadFromFile(jsonObject);
            Services.textManager.LoadFromFile(jsonObject);
            Services.phoneManager.Load(jsonObject);
            Services.plotManager.UpdatePlayerOffTime();
            Services.textManager.UpdatePlayerOffTime();


            //TODO: maybe pause the game and then at here unpause it
            Debug.Log("Game Loaded");
        }
        else
        {
            Debug.Log("No game saved!");
        }
    }
コード例 #3
0
        private void SerializeDeserializeJSON()
        {
            SerializeManager.SerializeJSON(_storage, "serializeJSON.txt");
            var storage = SerializeManager.DeserializeJSON <Storage>("serializeJSON.txt");

            Logger.Log("Storage was serialized and deserialized");
        }
コード例 #4
0
ファイル: MainModel.cs プロジェクト: romayavorskyi/KMA
        private void SerializeDeserializeBinary()
        {
            SerializeManager.SerializeBinary(_storage, "serializebinary.txt");
            var storage = SerializeManager.DeserializeBinary <Storage>("serializebinary.txt");

            Logger.Log("Storage was serialized and deserialized");
        }
コード例 #5
0
        private void ClosingMain(object sender, CancelEventArgs e)
        {
            List <SoundStore> soundStores = new List <SoundStore>();

            foreach (Sound sound in sounds)
            {
                soundStores.Add(new SoundStore(sound));
            }

            SerializeManager.Save(soundStores);
        }
コード例 #6
0
        private void SerializeDeserializeXML()
        {
            var firstUser = _storage?.Users?.Values?.FirstOrDefault();

            if (firstUser != null)
            {
                SerializeManager.SerializeXML(firstUser, "serializeXML.txt");
                var deserializedFirstUser = SerializeManager.DeserializeXML <UserModel>("serializeXML.txt");
                Logger.Log("Storage was serialized and deserialized");
            }
        }
コード例 #7
0
 public void SaveCredentialsForAutoLogin(UserCredentials creds)
 {
     try
     {
         SerializeManager.Serialize <UserCredentials>(creds, StaticResources.CurrentUserSerializedPath);
         Logger.Log("Current user was serialized");
     }
     catch (Exception e)
     {
         Logger.Log("Current user was not saved", e);
     }
 }
コード例 #8
0
 private void SerializeDeserializeBinary()
 {
     try
     {
         SerializeManager.SerializeBinary(_storage, "serializebinary.txt");
         var storage = SerializeManager.DeserializeBinary <Storage>("serializebinary.txt");
         Logger.Log("Storage was serialized and deserialized");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error handling");
     }
 }
コード例 #9
0
        public MainWindow()
        {
            InitializeComponent();

            SoundList.ItemsSource = sounds;

            List <SoundStore> sndStores = SerializeManager.Load <List <SoundStore> >();

            foreach (SoundStore sndStore in sndStores)
            {
                sounds.Add(sndStore.Export());
            }
        }
コード例 #10
0
ファイル: ReadJson.cs プロジェクト: fenixrtr7/GameDevEsp
    // Start is called before the first frame update
    void Start()
    {
        DataArrowList listArrow = new DataArrowList();
        DataArrow     one       = new DataArrow("1", "r", "0");
        DataArrow     two       = new DataArrow("1", "r", "1");

        listArrow.listData.Add(one);
        listArrow.listData.Add(two);

        string dataAsJson = JsonUtility.ToJson(listArrow);

        //Debug.Log(dataAsJson);
        SerializeManager.Save("Assets/GameDEVJAM/JsonSong/Newcsvjson.json", dataAsJson);

        Read(sPath);
    }
コード例 #11
0
        public void TryToAutoSignIn()
        {
            try
            {
                var  userCredentials = SerializeManager.Deserialize <UserCredentials>(StaticResources.CurrentUserSerializedPath);
                User currentUser;

                try
                {
                    currentUser = ChatService.GetUserByLogin(userCredentials.Login);
                }
                catch (Exception ex)
                {
                    Logger.Log("Failed to get user by login", ex);
                    return;
                }

                if (currentUser == null)
                {
                    Logger.Log("User " + userCredentials.Login + "does not exist");
                    return;
                }
                try
                {
                    if (!currentUser.CheckPassword(userCredentials.Password))
                    {
                        Logger.Log("Wrong password " + userCredentials.Password);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(
                        String.Format(WpfApp1.Properties.Resources.SignIn_FailedToValidatePassword, Environment.NewLine, ex.Message), ex);
                    return;
                }
                CurrentUser = currentUser;
                Logger.Log("Auto signed in as " + userCredentials.Login);
            }
            catch (Exception e)
            {
                Logger.Log("Old user was not loaded", e);
            }
        }
コード例 #12
0
        public MainWindow()
        {
            // deserializing user when app starts
            // if such users exists do autologin else redirect to login
            var user            = SerializeManager.Deserialize <User>(StationManager.UserFilePath);
            var userNameIsEmpty = String.IsNullOrEmpty(user?.UserName);

            // In case the previous function returned new User()
            if (!userNameIsEmpty)
            {
                try
                {
                    StationManager.CurrentUser = WordsCountServiceWrapper.GetUserByName(user.UserName);
                }
                catch (Exception e)
                {
                    Logger.Log("Error getting user", e);
                }

                if (StationManager.CurrentUser != null)
                {
                    // writing logs (what current user have just done)
                    Logger.Log($"User {StationManager.CurrentUser?.UserName} was autologged-in");

                    try
                    {
                        StationManager.CurrentUser.LastVisit = DateTime.Now;
                        WordsCountServiceWrapper.EditEntity(StationManager.CurrentUser);
                    }
                    catch (Exception e)
                    {
                        Logger.Log("Error updating user", e);
                    }

                    GoToCabinet();
                    return;
                }

                Logger.Log("Error on autologin");
            }

            Login();
        }
コード例 #13
0
ファイル: ReadJson.cs プロジェクト: fenixrtr7/GameDevEsp
    public void Read(string path)
    {
        if (!File.Exists(path))
        {
            return;
        }

        string        json = SerializeManager.Load(path);
        DataArrowList data = JsonUtility.FromJson <DataArrowList>(json);

        if (data == null)
        {
            return;
        }

        // foreach (DataArrow d in data.listData)
        // {
        //     Debug.Log("Time Stamp " + d.timestamp);
        // }
    }
コード例 #14
0
        /// <summary>
        /// Фиксирует принятый пакет.
        /// Дожидается оставшихся пакетов, если такие имееются,
        /// либо же десериализирует данные и передает их в обработку всем подсписчикам события "ClientReceivedMessage"
        /// </summary>
        private static void ReceiveCallback(IAsyncResult ar)
        {
            try
            {
                var state     = (ClientStateObject)ar.AsyncState;
                var socket    = state.Client.Socket;
                var bytesRead = socket.EndReceive(ar);

                if (bytesRead > 0)
                {
                    state.ReceivedBytes.AddRange(state.Buffer.Take(bytesRead));
                }

                if (state.MessageReceived)
                {
                    var messageType = (MessageType)state.ReceivedBytes[MessageExtensions.HEADER_LENGTH];
                    var message     = SerializeManager.Deserialise(messageType, state.ReceivedBytes.ToArray());

                    EventManager.RaiseOnMainThread(EventType.ReceivedMessage, messageType, message, state.Client);

                    state.Client._receiveDone.Set();
                }
                else
                {
                    socket.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, ReceiveCallback, state);
                }
            }
            catch (SocketException se)
            {
                if (se.ErrorCode == 0x80004005)
                {
                    var state = (ClientStateObject)ar.AsyncState;
                    state.Client.SafeDispose();
                    //ToDo: mb reconnect?
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
            }
        }
コード例 #15
0
        public static void Start()
        {
            new System.Threading.Thread(() =>
            {
                if (File.Exists(SessionBagFile))
                {
                    _SessionPools = SerializeManager <ConcurrentDictionary <string, SessionIdentity> > .Deserialize(SessionBagFile);
                    if (_SessionPools == null)
                    {
                        _SessionPools = new ConcurrentDictionary <string, SessionIdentity>();
                    }
                }
                runningstate = true;
                int tick     = 0;
                int tick2    = 0;
                while (runningstate)
                {
                    System.Threading.Thread.Sleep(1000);
                    tick  += 1000;
                    tick2 += 1000;
                    if (tick / 1000 >= 5 * 60) //5分钟 写入磁盘一次
                    {
                        SaveSessionToDisk();
                        tick = 0;
                    }

                    //test
                    if (true)
                    {
                        RemoveExpiredSession();
                    }
                    //end test

                    if (tick2 / 1000 >= 3600 * 24) //24个小时清理一次过期session
                    {
                        RemoveExpiredSession();
                        tick2 = 0;
                    }
                }
            }).Start();
        }
コード例 #16
0
ファイル: Form1.cs プロジェクト: Andriy1236/Gl_Task
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (label1.Text == string.Empty)
                {
                    MessageBox.Show("Please, add folder for serialization");
                    return;
                }
                if (label2.Text == string.Empty)
                {
                    MessageBox.Show("Please, add a folder for serialized file");
                    return;
                }
                SerializeManager serializeManager = new SerializeManager();
                var folder = serializeManager.GetFolder(label1.Text);
                serializeManager.SerializeFolder(folder, label2.Text);

                MessageBox.Show("The folder was serialized");
            }
            catch (OutOfMemoryException)
            {
                MessageBox.Show("The folder size too big");
            }
            catch (UnauthorizedAccessException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                label1.Text = string.Empty;
                label2.Text = string.Empty;
            }
        }
コード例 #17
0
    private void Update()
    {
        AllTcpRequestData requestData = null;

        while (mAllTcpRequestDatas.TryDequeue(out requestData))
        {
            int protocolID = SocketHead.GetPacketProtocolID(requestData.RequestMessage, 4);

            if (protocolID == ProtocolCommand.RequestHearBeat)
            {
                Debug.Log($"收到{requestData.mClientSocket.RemoteEndPoint} 心跳包");


                HeartbeatResponse response = new HeartbeatResponse()
                {
                    mSystemTime = System.DateTime.UtcNow.Ticks
                };
                string responseStr = SerializeManager.SerializeObject(response);
                TcpServerUIComponent.Instance.mTcpServer.SendMessage(ProtocolCommand.ResponseHearBeat, responseStr, requestData.mClientSocket);
            }
            else if (protocolID == ProtocolCommand.RequestLogin)
            {
                string message = Encoding.UTF8.GetString(requestData.RequestMessage, SocketHead.S_HeadLength, requestData.RequestMessage.Length - SocketHead.S_HeadLength);
                Debug.Log($"接收到来自{requestData.mClientSocket.RemoteEndPoint} 的登录信息{message}");


                LoginRequest request = SerializeManager.DeserializeObject <LoginRequest>(message);

                LoginResponse response = new LoginResponse();
                response.mUserName  = request.mUserName;
                response.mToken     = "xyz";
                response.mIsSuccess = true;

                string responseStr = SerializeManager.SerializeObject(response);
                TcpServerUIComponent.Instance.mTcpServer.SendMessage(ProtocolCommand.ResponseLogin, responseStr, requestData.mClientSocket);
            }
        }
    }
コード例 #18
0
        public CabinetWindow()
        {
            InitializeComponent();
            try
            {
                var user = SerializeManager.Deserialize <User>(User.FileName);

                //якщо не існує файлу з серіалізованим користувачем, то ми відкриваємо вікно Логіну
                if (user == null)
                {
                    OpenLoginWindow();
                }
                //в іншому випадку користувача десеріалізують
                else
                {
                    var curUser = BoSiReminderService_Wrapper.GetUser(user.Id);
                    if (curUser == null)
                    {
                        OpenLoginWindow();
                    }
                    else
                    {
                        curUser.PreviousLog = DateTime.Now;
                        BoSiReminderService_Wrapper.EditUser(curUser);

                        //встановлюємо поточного користувача та відриваємо вікно Кабінету
                        StationManager.CurrentUser = curUser;
                        InitializeCabinet();
                    }
                }
            }
            catch (Exception ex)
            {
                LogWriter.LogWrite("Exception while Initializing cabinet window", ex);
            }
        }
コード例 #19
0
    public void LoadFromFile(JSONNode jsonObject)
    {
        var textJsonObj = jsonObject["text"];

        bool isLastDialogueFinished = textJsonObj["isLastDialogueFinished"];

        //prepare finished msg
        var jsonDialogueLengthInfo = textJsonObj["dialogueLengthInfo"];
        var jsonDialogueMessages   = textJsonObj["dialogueMessages"];
        var _msgContent            = new List <MessageContent>();

        foreach (var jsonMsg in jsonDialogueMessages.Values)
        {
            var msg = new MessageContent();
            Enum.TryParse <MessageBubbleType>(jsonMsg["messageType"], out msg.messageType);
            msg.content   = jsonMsg["content"];
            msg.shootTime = new SerializeManager.JsonDateTime(Convert.ToInt64((string)jsonMsg["shootTime"]));
            if (jsonMsg["fileBubbleName"] != null)
            {
                msg.fileBubbleName = jsonMsg["fileBubbleName"];
            }
            if (jsonMsg["fileContentName"] != null)
            {
                msg.fileContentName = jsonMsg["fileContentName"];
            }
            _msgContent.Add(msg);
        }
        var _msgLengthInfo = new List <int>();

        foreach (var length in jsonDialogueLengthInfo.Values)
        {
            _msgLengthInfo.Add(length);
        }
        MessageContent[][] arrayInfo = SerializeManager.Deserialize2DArray(_msgLengthInfo, _msgContent);

        if (Services.saveManager.inkJson != "")
        {
            currentStory.state.LoadJson(Services.saveManager.inkJson);
        }

        //get the info from the save file
        foreach (var msgArray in arrayInfo)
        {
            _dialogueMessages.Add(msgArray);
        }
        if (!isLastDialogueFinished)
        {
            if (_dialogueMessages.Count > 0)
            {
                var leftDialogue = _dialogueMessages[_dialogueMessages.Count - 1];
                _currentDialogueMessages = leftDialogue.ToList();
                _dialogueMessages.Remove(_dialogueMessages[_dialogueMessages.Count - 1]);
            }
        }
        if (textJsonObj["lastTimeStamp"] != null)
        {
            _lastTimeStamp = new SerializeManager.JsonDateTime(Convert.ToInt64((string)textJsonObj["lastTimeStamp"]));
        }

        //recreate dialogues
        _LoadInitialDialogue();
        _LoadMoreDialogue();
        _LoadCurrentPlotMessageDuringPlayerOffTime();
    }
コード例 #20
0
    public JSONObject Save(JSONObject jsonObject)
    {
        //save the data
        var isLastDialogueFinished = false;

        if (_currentDialogueMessages.Count != 0)
        {
            WrapAndSavePlotDialogues();
        }
        else
        {
            isLastDialogueFinished = true;
        }

        var dialogueLengthInfo = new List <int>();
        var dialogueMessages   = new List <MessageContent>();

        SerializeManager.Serialize2DArray(_dialogueMessages.ToArray(), out dialogueLengthInfo, out dialogueMessages);

        if (currentStory != null)
        {
            File.WriteAllText(Services.saveManager.inkjsonPath, Services.textManager.currentStory.state.ToJson(), Encoding.UTF8);
        }
        else
        {
            File.WriteAllText(Services.saveManager.inkjsonPath, "");
        }

        //write them in the json file
        var textJsonObj = new JSONObject();

        textJsonObj.Add("isLastDialogueFinished", isLastDialogueFinished);
        var jsonDialogueLengthInfo = new JSONArray();

        foreach (var lengthInfo in dialogueLengthInfo)
        {
            jsonDialogueLengthInfo.Add(lengthInfo);
        }
        textJsonObj.Add("dialogueLengthInfo", jsonDialogueLengthInfo);
        var jsonDialogueContent = new JSONArray();

        foreach (var msg in dialogueMessages)
        {
            var msgObj = new JSONObject();
            msgObj.Add("messageType", msg.messageType.ToString());
            msgObj.Add("content", msg.content);
            var shootTimeString = (SerializeManager.JsonDateTime)msg.shootTime;
            msgObj.Add("shootTime", shootTimeString.value.ToString());
            if (!ReferenceEquals(msg.fileBubbleName, null))
            {
                msgObj.Add("fileBubbleName", msg.fileBubbleName);
            }
            if (!ReferenceEquals(msg.fileContentName, null))
            {
                msgObj.Add("fileBubbleName", msg.fileContentName);
            }
            jsonDialogueContent.Add(msgObj);
        }
        textJsonObj.Add("dialogueMessages", jsonDialogueContent);
        if (_lastTimeStamp != DateTime.MinValue)
        {
            var stringTimeStamp = (SerializeManager.JsonDateTime)_lastTimeStamp;
            textJsonObj.Add("lastTimeStamp", stringTimeStamp.value.ToString());
        }


        jsonObject.Add("text", textJsonObj);
        return(jsonObject);
    }
コード例 #21
0
 private static void SaveSessionToDisk()
 {
     SerializeManager <ConcurrentDictionary <string, SessionIdentity> > .Serialize(SessionBagFile, _SessionPools);
 }
コード例 #22
0
        public static byte[] GetMultipartFormData(Dictionary <string, object> postParameters, string boundary)
        {
            Stream formDataStream = new System.IO.MemoryStream();
            bool   needsCLRF      = false;

            foreach (var param in postParameters)
            {
                // Thanks to feedback from commenters, add a CRLF to allow multiple parameters to be added.
                // Skip it on the first parameter, add it to subsequent parameters.
                if (needsCLRF)
                {
                    formDataStream.Write(encoding.GetBytes("\r\n"), 0, encoding.GetByteCount("\r\n"));
                }
                needsCLRF = true;
                if (param.Value is FileParameter)
                {
                    FileParameter fileToUpload = (FileParameter)param.Value;
                    // Add just the first part of this param, since we will write the file data directly to the Stream
                    string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n",
                                                  boundary,
                                                  param.Key,
                                                  fileToUpload.FileName ?? param.Key,
                                                  fileToUpload.ContentType ?? "application/octet-stream");

                    formDataStream.Write(encoding.GetBytes(header), 0, encoding.GetByteCount(header));
                    // Write the file data directly to the Stream, rather than serializing it to a string.
                    formDataStream.Write(fileToUpload.File, 0, fileToUpload.File.Length);
                }
                else if (param.Value is LoadOptions)
                {
                    string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; objectname=\"{2}\"\r\nContent-Type: {3}\r\n\r\n",
                                                  boundary, param.Key, param.Key, "application/octet-stream");
                    formDataStream.Write(encoding.GetBytes(header), 0, encoding.GetByteCount(header));
                    byte[] objData = SerializeManager.SerializeObject(param.Value);
                    formDataStream.Write(objData, 0, objData.Length);
                }
                else if (param.Value is byte[])
                {
                    string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; objectname=\"{2}\"\r\nContent-Type: {3}\r\n\r\n",
                                                  boundary, param.Key, param.Key, "application/octet-stream");
                    formDataStream.Write(encoding.GetBytes(header), 0, encoding.GetByteCount(header));
                    byte[] objdata = param.Value as byte[];
                    formDataStream.Write(objdata, 0, objdata.Length);
                }
                else
                {
                    string postData = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}",
                                                    boundary,
                                                    param.Key,
                                                    param.Value);
                    formDataStream.Write(encoding.GetBytes(postData), 0, encoding.GetByteCount(postData));
                }
            }

            // Add the end of the request.  Start with a newline
            string footer = "\r\n--" + boundary + "--\r\n";

            formDataStream.Write(encoding.GetBytes(footer), 0, encoding.GetByteCount(footer));

            // Dump the Stream into a byte[]
            formDataStream.Position = 0;
            byte[] formData = new byte[formDataStream.Length];
            formDataStream.Read(formData, 0, formData.Length);
            formDataStream.Close();

            return(formData);
        }
コード例 #23
0
    /**
     * 发送数据包
     *
     * 发送的数据格式:
     * ----------2---------------4--------------------2--------------data---------------------
     * -------字节长度----------序列id----------------消息类型---------消息体(model)--------------
     */
    public void Send(NetProto.Api.ENetMsgId msgId, IMessage model)
    {
        byte[] data = SerializeManager.Serialize(model);         // 序列化对象

        Int16  id          = (Int16)msgId;
        UInt16 payloadSize = 6; // sizeof(seqid) + sizeof(msgid)

        //payloadSize += (UInt16)data.Length;
        payloadSize += (UInt16)data.Length;

        // payload
        byte[] payload = new byte[payloadSize];

        // seqid
        Byte[] _seqid = BitConverter.GetBytes(seqId);
        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_seqid);
        }
        _seqid.CopyTo(payload, 0);

        // opcode
        Byte[] _opcode = BitConverter.GetBytes(id);
        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_opcode);
        }
        _opcode.CopyTo(payload, 4);

        // data
        if (data != null)
        {
            data.CopyTo(payload, 6);
        }

        // try encrypt
        byte[] encrypted = EncryptStream(payload);

        // =>pack
        byte[] buffer = new byte[2 + payloadSize]; // sizeof(header) + payloadSize

        // =>header
        Byte[] _header = BitConverter.GetBytes(payloadSize);
        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_header);
        }
        _header.CopyTo(buffer, 0);

        // =>payload
        encrypted.CopyTo(buffer, 2);

        sendDone.Reset();

        // 发出一条消息后重置心跳时间
        heartbeatCount = 0;

        try
        {
            //Debug.Log("msgId---------------send : " + msgId);
            socket.BeginSend(buffer, 0, buffer.Length, 0, new AsyncCallback(SendCallback), socket);
            sendDone.WaitOne();
        }
        catch (Exception e)
        {
            isConnected = false;
            // 如果socket已经断了,报这个异常
            // System.Net.Sockets.SocketException: The socket is not connected
            Debug.Log(e.ToString());
            startReConnect();
        }
    }
コード例 #24
0
        /// <summary>
        /// Item creation sample
        /// </summary>
        /// <para>
        ///     Requires an authenticated data context
        /// </para>
        /// <para>
        ///     The user must have create permissions on the parent
        /// </para>
        /// <param name="context">The context.</param>
        private static void CreateItemSample(AuthenticatedSitecoreDataContext context)
        {
            //Dictionary<string, string> fieldstoUpdate = new Dictionary<string, string>();
            //fieldstoUpdate.Add("Sitemap Item Order", "test Value");
            //var query = new SitecoreCreateQuery
            //{
            //    ItemId = "{CBC4876C-EBDD-4472-899B-DC09933E2ED7}",
            //    Template = "{790F9670-EE94-40C4-8233-4168528341B7}",
            //    Database = "master",
            //    Name="test",
            //    FieldsToUpdate = fieldstoUpdate,
            //    FieldsToReturn = new List<string>
            //                                        {
            //                                            "Name",
            //                                            ""
            //                                        }
            //};

            //Dictionary<string, string> fieldstoUpdate = new Dictionary<string, string>();
            //fieldstoUpdate.Add("Sitemap Item Order", "test Value");
            //fieldstoUpdate.Add("Sitemap Title", "test Value");
            //var query = new SitecoreCreateQuery
            //{
            //    ItemId = "{CBC4876C-EBDD-4472-899B-DC09933E2ED7}",
            //    Database = "master",
            //    FieldsToUpdate = fieldstoUpdate,
            //    Language = "en",
            //    FieldsToReturn = new List<string>
            //                                        {
            //                                            "Name",
            //                                            "Sitemap Title"
            //                                        }
            //};

            Dictionary <string, string> fieldstoUpdate = new Dictionary <string, string>();

            fieldstoUpdate.Add("Sitemap Item Order", "test Value");
            fieldstoUpdate.Add("Sitemap Title", "test Value");
            LoadOptions loadOptions = new LoadOptions();

            loadOptions.Database = "master";
            string loadoption   = SerializeManager.SerializeLoadOption(loadOptions);
            string dataSyncItem = string.Empty;
            var    query        = new SitecoreAdvanceCreateQuery(Mindtree.Sitecore.WebApi.Client.SitecoreQueryType.AdvanceCreate, Mindtree.Sitecore.WebApi.Client.ResponseFormat.Json)
            {
                ItemId      = "{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}",
                Database    = "master",
                loadOptions = loadoption,
                syncItem    = dataSyncItem,
                RetainID    = true,
            };

            //Media Version Create Query
            //FileStream fs = new FileStream(@"C:\data\unnamed.gif", FileMode.OpenOrCreate);
            //Dictionary<string, string> fieldstoUpdate = new Dictionary<string, string>();
            //fieldstoUpdate.Add("Width", "114");
            //fieldstoUpdate.Add("Height", "114");
            //fieldstoUpdate.Add("Alt", "Test File");
            //var query = new SitecoreCreateVersionQuery
            //{
            //    Items = "{4989E299-AE7B-42D5-A030-DAB9B0FF564F}",
            //    ItemId = "{4989E299-AE7B-42D5-A030-DAB9B0FF564F}",
            //    Database = "master",
            //    FieldsToUpdate = fieldstoUpdate,
            //    MediaItemStream=fs,
            //    Language = "en",
            //    FieldsToReturn = new List<string>
            //                                        {
            //                                            "Size",
            //                                            "Extention"
            //                                        }
            //};

            ISitecoreWebResponse response = context.GetResponse <SitecoreWebResponse>(query);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                WriteResponseMeta(response);

                foreach (WebApiItem item in response.Result.Items)
                {
                    Wl("path", item.Path);
                    WriteFields(item);
                }
            }
            else
            {
                WriteError(response);
            }

            Nl();
        }
コード例 #25
0
ファイル: SerialiseToXML.cs プロジェクト: solsticehc/citadel
 void Start()
 {
     SerializeManager<PlayerScore2> serializer = new SerializeManager<PlayerScore2>();
     PlayerScore2 myData = new PlayerScore2("matt", 200);
     output = serializer.SerializeObject(myData);
 }
コード例 #26
0
 void OnEnable()
 {
     i = this;
 }