Exemplo n.º 1
0
        public void Execute()
        {
            MyArgs test = new MyArgs
            {
                Value = 12,
            };

            byte[] buffer = new byte[256];
            using (MemoryStream ms = new MemoryStream(buffer))
            {
                Serializer.Serialize(ms, test);
            }

            using (MemoryStream ms = new MemoryStream(buffer))
            {
                Serializer.Deserialize<MyArgs>(ms);
            }
        }
Exemplo n.º 2
0
        public void Execute()
        {
            Program.ExpectFailure<InvalidOperationException>(() =>
            {
                MyArgs test = new MyArgs
                {
                    Value = 12,
                };

                byte[] buffer = new byte[256];
                using (MemoryStream ms = new MemoryStream(buffer))
                {
                    Serializer.Serialize(ms, test);
                }

                using (MemoryStream ms = new MemoryStream(buffer))
                {
                    Serializer.Deserialize<MyArgs>(ms);
                }
            }, "Dynamic type is not a contract-type: Int32");
        }
Exemplo n.º 3
0
 public object Call(MyArgs args)
 {
     return(Utils.ToNumber(args[0]));
 }
Exemplo n.º 4
0
 public void Print(object sender, MyArgs e)
 {
     Console.WriteLine("test");
     Console.ReadLine();
 }
Exemplo n.º 5
0
 public void handleEvent(Object sender, MyArgs args)
 {
     Console.WriteLine("Handler fired");
 }
 public void Raise(MyArgs args)
 {
     this._onChange(this, args);
 }
Exemplo n.º 7
0
 public object?Call(MyArgs args)
 {
     return(func(args));
 }
Exemplo n.º 8
0
 void MessageEventHandler(object sender, MyArgs e)
 {
     _output.WriteLine(e.Value.ToString());
 }
Exemplo n.º 9
0
 public static Razzie MyMethod(this Razzie razzie, MyArgs args)
 {
     razzie.FirstName = razzie.FirstName.ToUpper();
     return(razzie);
 }
 public void Process(MyArgs args)
 {
     mList.Add(args.Id);
 }
Exemplo n.º 11
0
 public virtual void Handle(MyArgs request)
 {
     successor?.Handle(request);
 }
Exemplo n.º 12
0
 public object Call(MyArgs args)
 {
     //if (args.m_args.Count == 0) return null;// 想了想,保证返回字符串吧
     return(Utils.ToString(args[0]));
 }
Exemplo n.º 13
0
        public bool ShowContent(string path, MyArgs args)
        {
            DirectoryInfo dir  = new DirectoryInfo(path);
            var           root = new DirectoryInfo(path);

            var folders = dir.GetDirectories().OrderBy(x => x.Name).ToArray();
            var files   = dir.GetFiles().OrderBy(x => x.Name).ToArray();

            var dirDictionary  = folders.ToDictionary(x => Array.IndexOf(folders, x) + "D");
            var fileDictionary = files.ToDictionary(x => Array.IndexOf(files, x) + "F");

            //Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"\nContent of folder {root.Name} : ");
            Console.WriteLine("ID | NAME");
            Console.ForegroundColor = ConsoleColor.Blue;

            Console.WriteLine(" R | ..");

            foreach (var folder in dirDictionary)
            {
                Console.WriteLine(folder.Key + " | " + folder.Value.Name);
            }

            Console.ForegroundColor = ConsoleColor.Cyan;

            foreach (var file in fileDictionary)
            {
                Console.WriteLine(file.Key + " | " + file.Value.Name);
            }

            Console.ResetColor();
            Console.WriteLine("");


            Console.WriteLine("Enter ID of folder to open or \n" +
                              "file to process with last options\n" +
                              "or leave blank to exit:");
            while (true)
            {
                string id = Console.ReadLine();

                if (string.IsNullOrEmpty(id))
                {
                    return(false);
                }
                else if (id == "R") //go to parent
                {
                    if (dir.Parent != null)
                    {
                        args.DirPath = dir.Parent.FullName;
                        return(ShowContent(args.DirPath, args));
                    }
                    else
                    {
                        Console.WriteLine("\nCant go top! Choose another: ");
                    }
                }
                else if (dirDictionary.ContainsKey(id))
                {
                    if (dirDictionary.TryGetValue(id, out DirectoryInfo takeFoldr))
                    {
                        args.DirPath = takeFoldr.FullName;
                        return(ShowContent(args.DirPath, args));
                    }
                }
                else if (fileDictionary.ContainsKey(id))
                {
                    if (fileDictionary.TryGetValue(id, out FileInfo takeFile))
                    {
                        args.FilePath = takeFile.FullName;
                    }

                    return(true);
                }
                else
                {
                    Console.WriteLine("Wrong ID !");
                }
            }
        }
 public async void SuccessGateAsync(object sender, MyArgs args)
 {
 }