Esempio n. 1
0
        public Probe GetProbeFromDay()
        {
            Probe Probe = XMLSerializerHelper.DeserializeProbeFromXML()
                          .First(x => x.PublicationDate == DateTime.Now.ToShortDateString());

            return(Probe);
        }
    protected virtual void Load()
    {
        string savePath = OpenFileDialogue();

        if (savePath == "")
        {
            return;
        }
        Graph <NodeType, ConnectionType> graphDeserialized = XMLSerializerHelper.Deserialize <Graph <NodeType, ConnectionType> >(savePath);

        m_Graph.m_Nodes       = new List <NodeType>();
        m_Graph.m_Connections = new List <ConnectionType>();

        foreach (var nodeDeserialized in graphDeserialized.m_Nodes)
        {
            m_Graph.m_Nodes.Add(GetAsFinalType().DeserializeNode(nodeDeserialized));
        }

        foreach (var connectionDeserialized in graphDeserialized.m_Connections)
        {
            var        inPoint        = m_Graph.m_Nodes.First(n => n.m_InPoint.m_Id == connectionDeserialized.m_InPoint.m_Id).m_InPoint;
            var        outPoint       = m_Graph.m_Nodes.First(n => n.m_OutPoint.m_Id == connectionDeserialized.m_OutPoint.m_Id).m_OutPoint;
            Connection connectionBase = new Connection(inPoint, outPoint, OnClickRemoveConnection);
            m_Graph.m_Connections.Add(GetAsFinalType().CreateConnection(connectionBase));
        }
    }
Esempio n. 3
0
        public void TriggerDialogue(string tag)
        {
            Assert.IsFalse(m_IsInDialogue, "Already in dialogue, cannot start another one");
            string   filename = Application.streamingAssetsPath + ms_DialogueDirectory + tag + ".xml";
            Dialogue dialogue = XMLSerializerHelper.Deserialize <Dialogue>(filename);

            m_Dialogue = dialogue;
            StartDialogue();
        }
 public Customers GetCustomers()
 {
     using (var reader = new StreamReader(@"F:\DefaultCollection\Connector Design\BasicConnectorSolution\WebserviceY\App_Data\Customers.xml"))
     {
         var xml = reader.ReadToEnd();
         var ser = new XMLSerializerHelper<Customers>();
         return ser.Deserialize(xml);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the data and returns a customer object.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public Customer GetData(string value)
 {
     using (var reader = new StreamReader(@"F:\DefaultCollection\Connector Design\BasicConnectorSolution\WebserviceX\App_Data\Customers.xml"))
     {
         var xml = reader.ReadToEnd();
         var ser = new XMLSerializerHelper<Customers>();
         return ser.Deserialize(xml).Find(c => c.CustomerId == value);
     }
 }
Esempio n. 6
0
 private void UpdateProbe(ProbeViewModel model)
 {
     model.Answers.Single(m => m.IsChecked).Value += 1;
     XMLSerializerHelper.AddOrUpdate(new Probe
     {
         Question        = model.Question,
         PublicationDate = model.PublicationDate,
         Answers         = model.Answers.Select(x => new Answer {
             Text = x.Text, Value = x.Value.ToString()
         }).ToList()
     });
 }
Esempio n. 7
0
        public ActionResult AddProbe(ProbeViewModel model)
        {
            Probe probe = new Probe
            {
                PublicationDate = model.PublicationDate,
                Question        = model.Question,
                Answers         = model.Answers.Where(x => x.Text != null).Select(x => new Answer {
                    Text = x.Text, Value = "0"
                }).ToList()
            };

            XMLSerializerHelper.AddOrUpdate(probe);
            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
    protected virtual void Load()
    {
        string savePath = OpenFileDialogue();

        if (savePath == "")
        {
            return;
        }
        Graph <NodeType, ConnectionType> graphDeserialized = XMLSerializerHelper.Deserialize <Graph <NodeType, ConnectionType> >(savePath);

        m_Graph.m_Nodes       = new List <NodeType>();
        m_Graph.m_Connections = new List <ConnectionType>();

        foreach (var nodeDeserialized in graphDeserialized.m_Nodes)
        {
            m_Graph.m_Nodes.Add(GetAsFinalType().DeserializeNode(nodeDeserialized));
        }

        foreach (var connectionDeserialized in graphDeserialized.m_Connections)
        {
            ConnectionPoint outPoint = null;
            foreach (Node n in m_Graph.m_Nodes)
            {
                outPoint = n.GetConnectionPoint(connectionDeserialized.m_OutPoint.m_Id);
                if (outPoint != null)
                {
                    break;
                }
            }
            ConnectionPoint inPoint = null;
            foreach (Node n in m_Graph.m_Nodes)
            {
                inPoint = n.GetConnectionPoint(connectionDeserialized.m_InPoint.m_Id);
                if (inPoint != null)
                {
                    break;
                }
            }
            Connection     connectionBase = new Connection(inPoint, outPoint, OnClickRemoveConnection);
            ConnectionType connection     = GetAsFinalType().CreateConnection(connectionBase);
            m_Graph.m_Connections.Add(connection);
            inPoint.OnConnectionMade(connection);
            outPoint.OnConnectionMade(connection);
            outPoint.GetNode().OnConnectionMade(connection);
            inPoint.GetNode().OnConnectionMade(connection);
        }
    }
Esempio n. 9
0
        private ProbeViewModel GetProbeFormDay()
        {
            var            probeIsChecked = this.ControllerContext.HttpContext.Request.Cookies["ProbeChecked"];
            ProbeViewModel Probe          = XMLSerializerHelper.DeserializeProbeFromXML()
                                            .Select(x => new ProbeViewModel
            {
                Question        = x.Question,
                PublicationDate = x.PublicationDate,
                IsChecked       = probeIsChecked != null && x.PublicationDate == probeIsChecked.Value ? true : false,
                Answers         = x.Answers.Select(z => new AnswerViewModel
                {
                    Text          = z.Text,
                    Value         = int.Parse(z.Value),
                    ValueProgress = int.Parse(z.Value) != 0 ? (int)(int.Parse(z.Value) / (double)x.Answers.Sum(y => int.Parse(y.Value)) * 100): 0
                }).ToList(),
            }).First(x => x.PublicationDate == DateTime.Now.ToShortDateString());

            return(Probe);
        }
Esempio n. 10
0
        public static void InitConfig()
        {
            Models.ConfigModel model = null;

            var file = string.Format("{0}/Config/WechatSetting.config", AppDomain.CurrentDomain.BaseDirectory);

            if (File.Exists(file))
            {
                model = XMLSerializerHelper.DeSerialize <Models.ConfigModel>(file);
            }

            if (model != null)
            {
                ApiModel.AppID          = model.AppID;
                ApiModel.AppSecret      = model.AppSecret;
                ApiModel.Token          = model.Token;
                ApiModel.EncodingAESKey = model.EncodingAESKey;
                ApiModel.MchID          = model.MchID;
                ApiModel.MchAPISecret   = model.MchAPISecret;
            }
        }
    protected override void Save(string savePath)
    {
        base.Save(savePath);
        // When the game will want to read the dialogue it does not care about visual stuff
        // so we serialize the gameplay info in another file in StreamingAssets
        Dialogue.Dialogue dialogue   = new Dialogue.Dialogue();
        string            rootNodeID = "";

        foreach (DialogueNode node in m_Graph.m_Nodes)
        {
            dialogue.AddNode(node.m_Node);
            if (node.IsRoot())
            {
                Assert.IsTrue(rootNodeID == "", "several root node found, this dialogue is ill formed");
                rootNodeID = node.m_ID;
            }
        }
        dialogue.m_RootNodeID = rootNodeID;
        string filename = Path.GetFileName(savePath);

        XMLSerializerHelper.Serialize(dialogue, Application.streamingAssetsPath + "/Dialogues/" + filename);
    }
Esempio n. 12
0
 public void PostProbe(Probe probe)
 {
     XMLSerializerHelper.AddOrUpdate(probe);
 }
Esempio n. 13
0
    public void SaveObject(AnyObject objectToSave, string filename)
    {
        string path = Application.streamingAssetsPath + m_SaveDirectory + filename;

        XMLSerializerHelper.Serialize(objectToSave, path);
    }
Esempio n. 14
0
    public AnyObject GetSavedObject(System.Type type, string filename)
    {
        string path = Application.streamingAssetsPath + m_SaveDirectory + filename;

        return(XMLSerializerHelper.Deserialize(path, type));
    }
Esempio n. 15
0
 protected virtual void Save(string savePath)
 {
     XMLSerializerHelper.Serialize(m_Graph, savePath);
 }