Esempio n. 1
0
        public static void Main()
        {
            var           key1 = new Key("Key1");
            var           key2 = new Key("Key2");
            var           key3 = new Key("Key3");
            WalterlvValue value2;

            var table = new ConditionalWeakTable <Key, WalterlvValue>
            {
                { key1, new WalterlvValue() },
                { key2, (value2 = new WalterlvValue()) },
                { key3, new WalterlvValue() }
            };

            var weak2 = new WeakReference(key2);

            key2 = null;
            key3 = null;

            GC.Collect();

            Console.WriteLine($@"key1 = {key1?.ToString() ?? "null"}
key2 = {key2?.ToString() ?? "null"}, weak2 = {weak2.Target ?? "null"}
key3 = {key3?.ToString() ?? "null"}
Table = {{{string.Join(", ", table.Select(x => $"{x.Key} = {x.Value}"))}}}");
            Console.WriteLine(value2);
            Console.ReadLine();
        }
Esempio n. 2
0
        /// <summary>
        /// Called when the user interface culture associated with the current application changes.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An <see cref="EventArgs"/> that contains the event data.</param>
        private static void OnCultureChanged(object sender, EventArgs e)
        {
            ResourceProvider[] providers = table.Select(p => p.Value).ToArray();

            for (int i = 0; i < providers.Length; i++)
            {
                providers[i].OnPropertyChanged(EventArgsCache.ObjectPropertyChanged);
            }
        }