コード例 #1
0
 public Knowledge(int id, string title, DateTime date, string content, bool isNew, KnowledgeType type)
 {
     Id      = id;
     Title   = title;
     Date    = date;
     Content = content;
     IsNew   = isNew;
     Type    = type;
 }
コード例 #2
0
 // overload constructor
 public Knowledge(int ID, string name, string description, ElementType element, KnowledgeType type, float value, Sprite sprite)
 {
     myID          = ID;
     myName        = name;
     myDescription = description;
     myElement     = element;
     myType        = type;
     myValue       = value;
     mySprite      = sprite;
 }
コード例 #3
0
 public override void OnResponse(string data)
 {
     base.OnResponse(data);
     if (data != "")
     {
         string[] strs = data.Split('$');
         foreach (string str in strs)
         {
             string[]      s       = str.Split('&');
             int           id      = int.Parse(s[0]);
             string        title   = s[1];
             DateTime      date    = DateTime.Parse(s[2]);
             string        content = s[3];
             bool          isNew   = s[4] == "1";
             KnowledgeType type    = (KnowledgeType)Enum.Parse(typeof(KnowledgeType), s[5]);
             knowledges.Add(new Knowledge(id, title, date, content, isNew, type));
         }
     }
     isUpdate = true;
 }
コード例 #4
0
 public void ListKnowledges(List <Knowledge> knowledges, KnowledgeType type = KnowledgeType.All)
 {
     for (int i = 0; i < layout.childCount; i++)
     {
         Destroy(layout.GetChild(i).gameObject);
     }
     knowledgeItems.Clear();
     this.knowledges = new List <Knowledge>(knowledges);
     foreach (Knowledge knowledge in knowledges)
     {
         if (type != KnowledgeType.All && knowledge.Type == type)
         {
             knowledgeItems.Add(Instantiate(knowledgeItem, layout).GetComponent <KnowledgeItem>().Set(knowledge, this));
         }
         else if (type == KnowledgeType.All)
         {
             knowledgeItems.Add(Instantiate(knowledgeItem, layout).GetComponent <KnowledgeItem>().Set(knowledge, this));
         }
     }
 }
コード例 #5
0
ファイル: KnowledgeDAO.cs プロジェクト: CrixalisAs/AcneShare
        public List <Knowledge> GetKnowledges(MySqlConnection conn)
        {
            MySqlDataReader reader = null;

            try
            {
                MySqlCommand cmd = new MySqlCommand("select * from knowledge",
                                                    conn);
                reader = cmd.ExecuteReader();
                List <Knowledge> knowledges = new List <Knowledge>();
                while (reader.Read())
                {
                    int           id      = reader.GetInt32("id");
                    string        title   = reader.GetString("title");
                    string        date    = reader.GetString("date");
                    string        content = reader.GetString("content");
                    byte          isNew   = reader.GetByte("isNew");
                    KnowledgeType type    = (KnowledgeType)reader.GetInt32("type");
                    knowledges.Add(new Knowledge(id, title, DateTime.Parse(date), content, isNew == 1, type));
                }
                knowledges.Reverse();
                return(knowledges);
            }
            catch (Exception e)
            {
                Console.WriteLine("在VerifyUser时出现异常:" + e);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(null);
        }
コード例 #6
0
    string ParseKnowledgeJson()
    {
        StringBuilder sb        = new StringBuilder();
        TextAsset     itemText  = Resources.Load <TextAsset>("Json/Knowledges");
        JsonData      itemsData = JsonMapper.ToObject(itemText.text);

        foreach (JsonData itemData in itemsData)
        {
            string        title   = itemData["title"].ToString();
            string        content = itemData["content"].ToString();
            KnowledgeType type    = (KnowledgeType)Enum.Parse(typeof(KnowledgeType), itemData["type"].ToString());
            sb.Append(title);
            sb.Append('&');
            sb.Append(content);
            sb.Append('&');
            sb.Append(type);
            sb.Append('$');
        }
        if (!string.IsNullOrEmpty(sb.ToString()))
        {
            sb.Remove(sb.Length - 1, 1);
        }
        return(sb.ToString());
    }
コード例 #7
0
 public SkillUIModel(KnowledgeType skillType, string name)
 {
     SkillType = skillType;
     Name      = name;
 }
コード例 #8
0
 public Knowledge(Agent newAgent, KnowledgeType newKnowledgeType, IStatement newStatement)
 {
     agent         = newAgent;
     knowledgeType = newKnowledgeType;
     statement     = newStatement;
 }
コード例 #9
0
ファイル: Form1.cs プロジェクト: radusecrieru/BanVerifier
        private Knowledge ParseKnowledge(JObject jsonKnowledge)
        {
            Agent         agent         = null;
            KnowledgeType knowledgeType = KnowledgeType.believes; // Random initializaiton.
            IStatement    statement     = null;

            if (jsonKnowledge.Property("id") != null)
            {
                JObject jSender = new JObject(jsonKnowledge.Property("id"));
                string  id      = (string)jSender.Properties().Select(p => p.Value).ElementAt(0);
                agent = protocol.Agents.Where(p => p.Id == id).ElementAt(0);
            }

            if (jsonKnowledge.Property("type") != null)
            {
                JObject jSender = new JObject(jsonKnowledge.Property("type"));
                string  type    = (string)jSender.Properties().Select(p => p.Value).ElementAt(0);
                knowledgeType = (KnowledgeType)Enum.Parse(typeof(KnowledgeType), type);
            }

            if (jsonKnowledge.Property("key") != null)
            {
                JObject jKey      = new JObject(jsonKnowledge.Property("key"));
                JObject jKeyValue = (JObject)jKey.Properties().Select(p => p.Value).ElementAt(0);

                string agt1 = jKeyValue.Property("a1").Value.ToString();
                string agt2 = jKeyValue.Property("a2").Value.ToString();

                Key newKey = new Key();

                Agent ag1 = protocol.Agents.Where(p => p.Id == agt1).ElementAt(0);
                Agent ag2 = protocol.Agents.Where(p => p.Id == agt2).ElementAt(0);

                newKey.agents.Add(ag1);
                newKey.agents.Add(ag2);

                if ((protocol.Keys.Where(p => p.agents.ElementAt(0).Id == agt1 && p.agents.ElementAt(1).Id == agt2)).Count() != 0)
                {
                    Key foundKey = protocol.Keys.Where(p => p.agents.ElementAt(0).Id == agt1 && p.agents.ElementAt(1).Id == agt2).ElementAt(0);
                    statement = foundKey;
                }
                else
                {
                    protocol.Keys.Add(newKey);
                    statement = newKey;
                }
            }

            if (jsonKnowledge.Property("nonce") != null)
            {
                JObject jNonce      = new JObject(jsonKnowledge.Property("nonce"));
                JObject jNonceValue = (JObject)jNonce.Properties().Select(p => p.Value).ElementAt(0);

                string id    = jNonceValue.Property("id").Value.ToString();
                bool   fresh = Boolean.Parse(jNonceValue.Property("fresh").Value.ToString());

                Nonce newNonce = new Nonce(id);

                newNonce.Fresh = fresh;

                statement = newNonce;
            }

            if (jsonKnowledge.Property("knowledge") != null)
            {
                JObject jKnowledge = new JObject(jsonKnowledge.Property("knowledge"));
                statement = ParseKnowledge((JObject)jKnowledge.Properties().Select(p => p.Value).ElementAt(0));
            }


            if (agent != null)
            {
                return(new Knowledge(agent, knowledgeType, statement));
            }
            else
            {
                return(null);
            }
        }
コード例 #10
0
 public Knowledge(string title, string content, KnowledgeType type)
 {
     Title   = title;
     Content = content;
     Type    = type;
 }
コード例 #11
0
 public BaseKnowledge(KnowledgeType type)
 {
     Type = type;
 }