void Start() { audioSource.Play(); //播放音效 text.GetComponent <TextMesh>().text = NameHandler.randomPerson(); //得到名字 glass_anim.Play(); //播放动画 glass_animator.SetBool("isReturn", false); //设置动画机参数 }
static void Main(string[] args) { Console.WriteLine("Chain of Work!"); ///1.Promotes decoupling of Request from Handler object ///2.When a requet belongs to several different categories,so. ///it will either process the request or send to the next handler. ///The below example demonstrates validating object in multiple steps Person person = new Person() { Name = "Tanuja", Age = 30, Income = 200 }; Request request = new Request() { Data = person }; NameHandler nameHandler = new NameHandler(); AgeHandler ageHandler = new AgeHandler(); IncomeHandler incomeHandler = new IncomeHandler(); nameHandler.SetNextHandler(ageHandler); ageHandler.SetNextHandler(incomeHandler); nameHandler.Process(request); foreach (string item in request.ValidationMessages) { Console.WriteLine(item); } Console.ReadLine(); }
IEnumerator WaitFewSeconds_text()//0.5s后随机更改名字,否则会使结果提前出现。待恢复动画 播放完再播放音效 { yield return(new WaitForSeconds(0.5f)); text.GetComponent <TextMesh>().text = NameHandler.randomPerson(); //audioSource.Play();//播放音效 }
private string BuildPath(INode megaNzNode, Dictionary <string, INode> megaNzNodeDictionary) { if (megaNzNode.Type == NodeType.Root) { return(string.Empty); } if (megaNzNode.Type != NodeType.File) { var parentNode = megaNzNodeDictionary[megaNzNode.ParentId]; var path = BuildPath(parentNode, megaNzNodeDictionary) + @"\" + megaNzNode.Name; return(path); } else { // Extract the filename, removing the last modification date (only for file) string filename; DateTime datetime; NameHandler.ExtractFilenameAndDateTimeFromRemoteFilename(megaNzNode.Name, out filename, out datetime); var parentNode = megaNzNodeDictionary[megaNzNode.ParentId]; var path = BuildPath(parentNode, megaNzNodeDictionary) + @"\" + filename; return(path); } }
public void BuilRemoteFolderName_forAFolder_shouldBuildTheCorrectFolderName() { var folderName = "foldername"; var result = NameHandler.BuildRemoteFolderName(folderName); Assert.AreEqual("foldername", result); }
public void BuilRemoteFilename_forAFile_shouldBuildTheCorrectFilename() { var lastModificationDate = new DateTime(2016, 1, 1, 0, 0, 0); var filename = "filename.jpg"; var result = NameHandler.BuildRemoteFileName(filename, lastModificationDate); Assert.AreEqual("filename_[[2016-1-1-0-0-0]].jpg", result); }
private void Update() { //测试使用 if (Input.GetKeyDown(KeyCode.A)) { for (int i = 0; i < 38; i++) { NameHandler.randomPerson(); } } }
public void ExtractFileNameAndDateTimeFromName_shouldReturnTheCorrectDateTime() { const string oringalFilename = "filename_[[2016-1-1-0-0-0]].jpeg"; string extractedFilename; DateTime extractedDatetime; NameHandler.ExtractFilenameAndDateTimeFromRemoteFilename(oringalFilename, out extractedFilename, out extractedDatetime); Assert.AreEqual(new DateTime(2016, 1, 1, 0, 0, 0), extractedDatetime); }
//弹出金币 void jumpCoin() { //audioSource.clip = coinAudio; //audioSource.Play(); Debug.Log("发送"); coinClip.Play(); string text = NameHandler.randomPerson(); Text.GetComponent <TextMesh>().text = text; coin.active = true; }
/// <summary> /// Initialises a list of orders /// </summary> void Initialise_(int count) { var names = new NameHandler(); for (var i = 0; i < count; i++) { // generate a customer var customerName = names.GetName(); var order = OrderFactory.GetOrder(); _customers.Add(new CustomerOrder(customerName, order)); } }
public void Initialize() { NameHandler.OnSetNameAsObservable() .Subscribe(name => { Set(name); SetPhoton(name); Render(name); }) .AddTo(Disposable); Render(NameEntity.Load()); SetPhoton(NameEntity.Load()); }
public void Execute(IMegaApiClient megaApiClient, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { using (var filestream = fileManager.GetStreamToReadFile(SourcePath)) { var sourceFileName = System.IO.Path.GetFileName(SourcePath); var remoteFileName = NameHandler.BuildRemoteFileName(sourceFileName, LastModifiedDate); var parentMegaNzNode = megaNzItemCollection.GetByPath(DestinationPath); var newMegaNzNode = megaApiClient.UploadAsync(filestream, remoteFileName, parentMegaNzNode, progressNotifier).Result; megaNzItemCollection.Add(newMegaNzNode); } }
public State() { logger = Log.ForContext <State>(); var origin = new Context <Shell.Types.IShellData>("ORIGIN"); var functions = new Context <Shell.Types.Function>("ORIGIN"); contexts = new List <Tuple <Context <Shell.Types.IShellData>, Context <Shell.Types.Function> > > { new Tuple <Context <Types.IShellData>, Context <Types.Function> >(origin, functions) }; all_namespaces = new Dictionary <string, Shell.Types.Namespace>(); this.Variables = new VariableHandler(this); this.Functions = new FunctionHandler(this); this.Namespaces = new NamespaceHandler(this); this.Names = new NameHandler(this); }
public MegaNzItem(INode megaNzNode, Dictionary <string, INode> megaNzNodeDictionary) { MegaNzNode = megaNzNode; switch (megaNzNode.Type) { case NodeType.Root: Name = @"\"; Type = ItemType.Folder; Path = @"\"; Size = 0; break; case NodeType.Directory: Name = megaNzNode.Name; Type = ItemType.Folder; Path = BuildPath(megaNzNode, megaNzNodeDictionary) + @"\"; Size = 0; break; case NodeType.File: Type = ItemType.File; Path = BuildPath(megaNzNode, megaNzNodeDictionary); Size = megaNzNode.Size; // Extract the filename, removing the last modification date string filename; DateTime datetime; NameHandler.ExtractFilenameAndDateTimeFromRemoteFilename(megaNzNode.Name, out filename, out datetime); Name = filename; LastModified = datetime; break; default: throw new InvalidOperationException("Not able to create an item for INode that are not Directory or File"); } }
public void Execute_withAnUploadCommand_shouldUploadTheMegaNzItemCollection() { // Arrange const string filename = "File1.jpeg"; var sourcePath = @"c:\testing\" + filename; var lastModifiedDate = new DateTime(2016, 1, 1, 0, 0, 0); // The command list to be executed var commandList = new ICommand[] { new UploadFileCommand() { SourcePath = sourcePath, DestinationPath = @"\", LastModifiedDate = lastModifiedDate } }; // the initial MegaNZ node list const string rootName = @"\"; const string rootPath = @"\"; const string rootMegaNzId = "0"; var mockMegaNzNodeForRemoteRoot = new Mock <INode>(MockBehavior.Strict); mockMegaNzNodeForRemoteRoot.SetupGet(m => m.Id).Returns(rootMegaNzId); mockMegaNzNodeForRemoteRoot.SetupGet(m => m.Type).Returns(NodeType.Root); var remoteItems = new List <MegaNzItem> { new MegaNzItem(mockMegaNzNodeForRemoteRoot.Object, rootName, ItemType.Folder, rootPath, 0) }; var megaNzItemCollection = new MegaNzItemCollection(remoteItems); const string newFileMegaNzId = "1"; var uploadResultNode = new MegaNzNodeMock { Id = newFileMegaNzId, Name = NameHandler.BuildRemoteFileName(filename, lastModifiedDate), ParentId = rootMegaNzId, Size = 1024, Type = NodeType.File, LastModificationDate = new DateTime(2016, 1, 1, 0, 0, 0) }; // The name of the uploaded file var uploadedFileName = NameHandler.BuildRemoteFileName(filename, lastModifiedDate); var mockMegaApiClient = new Mock <IMegaApiClient>(MockBehavior.Strict); var mockProgressNotifier = new Mock <IProgress <double> >(MockBehavior.Strict); mockMegaApiClient.Setup(m => m.UploadAsync(It.IsAny <Stream>(), uploadedFileName, It.Is <INode>(node => node.Id == rootMegaNzId), mockProgressNotifier.Object)) .ReturnsAsync(uploadResultNode); var mockFileManager = new Mock <IFileManager>(MockBehavior.Strict); mockFileManager.Setup(m => m.GetStreamToReadFile(sourcePath)).Returns((FileStream)null); // Act var executor = new CommandExecutor(mockMegaApiClient.Object, _mockLogger.Object); executor.Execute(commandList, megaNzItemCollection, mockFileManager.Object, mockProgressNotifier.Object); // Assert megaNzItemCollection.GetList().Should().Contain(item => item.MegaNzNode.Id == newFileMegaNzId); }
void Start() { Invoke("goNextSence", 5); NameHandler.localText(path + "NameList.txt"); //Debug.Log(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase); }