コード例 #1
0
        public void ExampleObscuredLeakiness()
        {
            var repo = new ObscuredLeakinessLetterRepo();
            var good = repo.Letters;
            var evil = repo.Letters;

            good.Subscribe(
                Console.WriteLine);
            //Be naughty
            var asSubject = evil as ISubject <string>;

            if (asSubject != null)
            {
                //So naughty, 1 is not a letter!
                asSubject.OnNext("1");
            }
            else
            {
                Console.WriteLine("could not sabotage");
            }

            //A
            //B
            //C
            //1
        }
コード例 #2
0
ファイル: Encapsulating.cs プロジェクト: pudae/lplpl
 private static void Func1()
 {
     var repo = new ObscuredLeakinessLetterRepo();
       // var repo = new LetterRepo();
       var good = repo.GetLetters();
       var evil = repo.GetLetters();
       good.Subscribe(
       Console.WriteLine);
       //Be naughty
       var asSubject = evil as ISubject<string>;
       if (asSubject != null)
       {
     //So naughty, 1 is not a letter!
     asSubject.OnNext("1");
       }
       else
       {
     Console.WriteLine("could not sabotage");
       }
 }