BlockList

We found 10 examples in language CSharp for this search. You will see 27 fragments of code.

        public void UpdateList()
        {
            List<DomainBlocklist> Blocklists = App.client.GetDomainBlocklists();
            if (Blocklists == null)
                return;

            BlocklistList.Clear();
            foreach (var Blocklist in Blocklists)
                AddItem(Blocklist);
        }

        private void AddItem(DomainBlocklist Blocklist)
        {
            var Item = new BlocklistItem(Blocklist);
            Item.PropertyChanged += Item_PropertyChanged;
            BlocklistList.Add(Item);
        }

        private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            App.client.UpdateDomainBlocklist((sender as BlocklistItem).Blocklist);
        }

        private void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            foreach (BlocklistItem Item in new List<BlocklistItem>(listGrid.SelectedItems.Cast<BlocklistItem>()))
            {
                App.client.RefreshDomainBlocklist(Item.Blocklist.Url);
            }
        }


        private static byte[] GetDataIn(byte serviceCount, byte[] serviceCodeList, byte blockCount, byte[] blockList)
        {
            DataWriter dataWriter = new DataWriter();

            dataWriter.WriteByte(serviceCount);
            dataWriter.WriteBytes(serviceCodeList);
            dataWriter.WriteByte(blockCount);
            dataWriter.WriteBytes(blockList);

            return dataWriter.DetachBuffer().ToArray();
        }


		
        /// <summary>
        /// Clear all blocks
        /// </summary>
        public static void Clear()
        {
            foreach (KeyValuePair<short,Block> br in BlockList)
            {
                br.Value.Image.Dispose(); // Reload images
            }
            BlockList.Clear();
            TotalImages = 0;
        }

        /// <summary>
        /// Save blocks to file.
        /// </summary>
        public static void Save()
        {
            List<string> lolfile = new List<string>();
            foreach (KeyValuePair<short, Block> p in BlockList)
            {
                lolfile.Add(string.Join("\t",new string[] { p.Key.ToString(), p.Key.ToString() + ".png", p.Value.Name }));
            }
            File.WriteAllLines("blocks.txt",lolfile.ToArray());
        }


        public static Color GetColor(byte b)
        {
            if (!BlockList.ContainsKey(b))
            {
                Console.WriteLine("BlockList does not contain a definition for {0} (0x{0:X2}).", b);
                return Color.Red;
            }
            return BlockList[b].Color;
        }
        public static Block Get(short type)
        {
            if (!BlockList.ContainsKey(type))
            {
                Console.WriteLine("BlockList does not contain a definition for {0} (0x{0:X2}).", type);
                Block b = new Block();
                b.Color = Color.Black;
                b.ID = type;
                b.Image = GetQuestionMark();
                b.Name = "[UNKNOWN]";
                return b;
            }
            return BlockList[type];
        }

        public static Block Find(string p)
        {
            foreach (KeyValuePair<short, Block> b in BlockList)
            {
                if (b.Value.Name.StartsWith(p))
                    return b.Value;
            }
            return null;
        }


        public void AddDefaultLists()
        {
            foreach (var Url in DefaultLists)
            {
                if (!Blocklists.ContainsKey(Url))
                {
                    DomainBlocklist blocklist = new DomainBlocklist() { Url = Url };
                    AddDomainBlocklistImpl(blocklist);
                }
            }
        }


        void addCurrentGridLocationToBlockList(int column, int row)
        {
            Block currentBlock = grid[column, row];
            if (currentBlock == null)
            {
                blockList.Add(new NullBlock());
            }
            else
            {
                blockList.Add(currentBlock);
            }
        }

        void markBlocksVertically()
        {
            for (int column = 0; column < GridSize.Width; column++)
            {
                blockList.Clear();

                //Fill the blockList with blocks for the current column..
                for (int row = 0; row < GridSize.Height; row++)
                {
                    addCurrentGridLocationToBlockList(column, row);
                }

                markBlockToDestroyUsingBlockList();
            }
        }

        void markBlocksHorizontally()
        {
            for (int row = 0; row < GridSize.Height; row++)
            {
                blockList.Clear();

                //Fill the blockList with blocks for the current row..				
                for (int column = 0; column < GridSize.Width; column++)
                {
                    addCurrentGridLocationToBlockList(column, row);
                }

                markBlockToDestroyUsingBlockList();

            }
        }

    public void Save(string FileName)
    {
        fileName = FileName;
        BlockList blockList = readJson(@"/Saves/template.json");
        writeJson(blockList, fileName);
        clearJson(@"/Saves/template.json");
    }
    private void writeJson(BlockList blockList, string fileName)
    {
        string filePath = Application.dataPath + fileName;
        StreamWriter sw = new StreamWriter(filePath);
        string json = JsonMapper.ToJson(blockList.list);
        json = "{ \"list\":" + json + "}";
        sw.WriteLine(json);
        sw.Close();
        sw.Dispose();
    }
    private BlockList readJson(string fileName)
    {
        string filePath = Application.dataPath + fileName;
        StreamReader sr = new StreamReader(filePath);
        JsonReader js = new JsonReader(sr);
        BlockList blockList = JsonMapper.ToObject<BlockList>(js);
        sr.Close();
        return blockList;
    }
    private void DestroyTree(BlockList oldBlockList)
    {
        for (int i = oldBlockList.list.Count - 1; i > 0; i--)
        {
            DestroyImmediate(GameObject.Find(oldBlockList.list[i].Pos.ToString()));
        }
        DestroyImmediate(GameObject.Find(oldBlockList.list[0].Pos.ToString()));
    }


		public static void Initialize()
		{
			Blocklist.FilePath = Path.Combine(Core.SavePath, Blocklist.string_0);
			if (Core.DatabaseType.Equals("FILE"))
			{
				Blocklist.Initialized = Blocklist.LoadAsTextFile();
			}
			if (Core.DatabaseType.Equals("MYSQL"))
			{
				Blocklist.Initialized = Blocklist.LoadAsDatabaseSQL();
			}
		}

		public static bool LoadAsTextFile()
		{
			if (!File.Exists(Blocklist.FilePath))
			{
				File.CreateText(Blocklist.FilePath).Close();
			}
			Blocklist.list_0 = File.ReadAllLines(Blocklist.FilePath).ToList<string>();
			return true;
		}

		public static int SaveAsTextFile()
		{
			File.WriteAllLines(Blocklist.FilePath, Blocklist.list_0.ToArray());
			return Blocklist.list_0.Count;
		}

		public static bool LoadAsDatabaseSQL()
		{
			MySQL.Result result = MySQL.Query("SELECT * FROM `db_blocked_ip`;", false);
			if (result != null)
			{
				foreach (MySQL.Row current in result.Row)
				{
					string asString = current.Get("ip_address").AsString;
					if (!Blocklist.list_0.Contains(asString))
					{
						Blocklist.list_0.Add(asString);
					}
				}
			}
			return true;
		}

		public static bool Exists(string ipAddress)
		{
			return Blocklist.list_0.Contains(ipAddress);
		}

		public static void Add(string ipAddress)
		{
			if (!Blocklist.list_0.Contains(ipAddress))
			{
				Blocklist.list_0.Add(ipAddress);
			}
			if (Core.DatabaseType.Equals("MYSQL"))
			{
				MySQL.Update(string.Format("REPLACE INTO `db_blocked_ip` (`ip_address`) VALUES ('{0}');", ipAddress));
			}
			if (Core.DatabaseType.Equals("FILE"))
			{
				Blocklist.SaveAsTextFile();
			}
		}


	public void NewDefaultTetrisBlock()
	{
		if (CheckGameOver()) return;
		FallTimeChange();
		for (int i = 0; i < 3; i++) // 1, 2, 3번을 앞으로 하나씩 땡겨옴
		{
			blockList[i] = blockList[i + 1];
		}
		blockList[3] = Instantiate(blocks[Random.Range(0, blocks.Length)], transform.position, Quaternion.identity); // 새로운 블록 하나 생성 (3번)

		SetBlockPosition();
	}


        private static byte[] GetDataIn(byte serviceCount, byte[] serviceCodeList, byte blockCount, byte[] blockList)
        {
            DataWriter dataWriter = new DataWriter();

            dataWriter.WriteByte(serviceCount);
            dataWriter.WriteBytes(serviceCodeList);
            dataWriter.WriteByte(blockCount);
            dataWriter.WriteBytes(blockList);

            return dataWriter.DetachBuffer().ToArray();
        }


        [TestMethod, Description("fill in with a valid return from the telnet method and convert the result")]
        public void CheckValidTelnetStringAndReturnSomeResults()
        {
            var testee = "-2 22.31 blocklist blocklist\n-1 8.24 cache cache\n0 35.31 192.168.1.1 opnsense.localdomain\n1 19.39 1.0.0.1 one.one.one.one\n2 15.60 1.1.1.1 one.one.one.one\n---EOM---";

            _telnetResultConverter.Convert(testee).Wait();

            var dictionaryExpected = new Dictionary<string, IBaseResult>
            {
                {"-2", new DoubleOutputNumberedElement(22.31d, -2, "blocklist blocklist")},
                {"-1", new DoubleOutputNumberedElement(8.24d, -1, "cache cache")},
                {"0", new DoubleOutputNumberedElement(35.31d, 0, "192.168.1.1 opnsense.localdomain")},
                {"1", new DoubleOutputNumberedElement(19.39d, 1, "1.0.0.1 one.one.one.one")},
                {"2", new DoubleOutputNumberedElement(15.6d, 2, "1.1.1.1 one.one.one.one")}
            };

            var dictionaryResult =
                _telnetResultConverter.DictionaryOpt.ValueOr(new ConcurrentDictionary<string, IBaseResult>());
            dictionaryResult.Should().BeEquivalentTo(dictionaryExpected);

            _telnetResultConverter.GetPiholeCommand().ToString().Should()
                .Be(PiholeCommands.Forwarddestinations.ToString());
            

            var jsonExpected =
                "[{\"Count\":8.24,\"Position\":-1,\"IpOrHost\":\"cache cache\"},{\"Count\":22.31,\"Position\":-2,\"IpOrHost\":\"blocklist blocklist\"},{\"Count\":35.31,\"Position\":0,\"IpOrHost\":\"192.168.1.1 opnsense.localdomain\"},{\"Count\":19.39,\"Position\":1,\"IpOrHost\":\"1.0.0.1 one.one.one.one\"},{\"Count\":15.6,\"Position\":2,\"IpOrHost\":\"1.1.1.1 one.one.one.one\"}]";

            var orderedExpectedJson = OrderJsonArrayString(jsonExpected, "Position").ValueOr("");
            var orderedCurrentJson =
                OrderJsonArrayString(_telnetResultConverter.GetJsonObjectFromDictionaryAsync(false).Result, "Position")
                    .ValueOr("");

            orderedExpectedJson.Should().NotBeEmpty();
            orderedCurrentJson.Should().NotBeEmpty();

            orderedCurrentJson.Should().Be(orderedExpectedJson);
        }

Azure.Storage.Blobs.Models.BlockList : Object

Methods :

public DateTimeOffset get_LastModified()
public ETag get_ETag()
public String get_ContentType()
public Int64 get_BlobContentLength()
public IEnumerable<BlobBlock> get_CommittedBlocks()
public IEnumerable<BlobBlock> get_UncommittedBlocks()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods