Beispiel #1
0
        public void AddNewSoft(Software software, string networkName)
        {
            if (string.IsNullOrEmpty(software.SoftwareType))
            {
                software.SoftwareType = "";
            }


            if (string.IsNullOrEmpty(software.CodeStr))
            {
                software.CodeStr = "";
            }


            if (software.Code == 0)
            {
                software.Code = long.Parse(software.CodeStr);
            }

            if (software.Code != 0)
            {
                software.CodeStr = software.Code.ToString();
            }

            if (string.IsNullOrEmpty(software.Effect))
            {
                software.Effect = "";
            }


            if (string.IsNullOrEmpty(software.InevitableEffect))
            {
                software.InevitableEffect = "";
            }

            if (string.IsNullOrEmpty(software.NodeTypesString))
            {
                software.NodeTypesString = "";
            }

            if (string.IsNullOrEmpty(software.seenInNet))
            {
                software.seenInNet = "";
            }

            if (!string.IsNullOrEmpty(networkName))
            {
                if (!software.seenInNet.Contains(networkName))
                {
                    software.seenInNet += $",{networkName}";
                }
            }

            if (software.SoftwareType.Equals("exploit"))
            {
                if (Exloits.ContainsKey(software.Code))
                {
                    throw new ArgumentException($"Expolit #{software.Code} is duplicated in library.");
                }

                Software.Add(software);
                Exloits.Add(software.Code, software);
            }
            else if (software.SoftwareType.Equals("defence"))
            {
                if (Defences.ContainsKey(software.Code))
                {
                    throw new ArgumentException($"Defence #{software.Code} is duplicated in library.");
                }

                Defences.Add(software.Code, software);
                Software.Add(software);
            }
            else
            {
                if (Unknown.ContainsKey(software.Code))
                {
                    throw new ArgumentException($"Unknown soft #{software.Code} is duplicated in library.");
                }

                Unknown.Add(software.Code, software);
                Software.Add(software);
            }

            if (All.ContainsKey(software.Code))
            {
                throw new ArgumentException($"Software  #{software.Code} is duplicated in library.");
            }

            All.Add(software.Code, software);
        }