public void AddSubtypeAtRuntime() { var messageBase = RuntimeTypeModel.Default[typeof(MessageBase)]; // this could be explicit in code, or via some external config file // that you process at startup messageBase.AddSubType(10, typeof(Echo)); // would need to **reliably** be 10 messageBase.AddSubType(11, typeof(Foo)); messageBase.AddSubType(12, typeof(Bar)); // etc // test it... Echo echo = new Echo { Message = "Some message", ErrorMessage = "XXXXX" }; MessageBase echo1; using (var ms = new MemoryStream()) { Serializer.NonGeneric.Serialize(ms, echo); ms.Position = 0; echo1 = (MessageBase)Serializer.NonGeneric.Deserialize(typeof(MessageBase), ms); } Assert.AreSame(echo.GetType(), echo1.GetType()); Assert.AreEqual(echo.ErrorMessage, echo1.ErrorMessage); Assert.AreEqual(echo.Message, ((Echo)echo1).Message); }
private void button1_Click(object sender, EventArgs e) { string result = ""; Echo e1 = new Echo(); Echo e2 = new Echo(); int x = 0; while (x<4) { result = result + e1.Hello() + "\n"; e1.count = e1.count + 1; if (x>0) { e2.count = e2.count + 1; } if (x>1) { e2.count = e2.count + e1.count; } x = x + 1; } MessageBox.Show(result+"Count: " +e2.count); }
public Echo Any(Echo request) { return(request); }
public void Run(string[] args) { var conArgs = new ConArgs(args, "-"); var name = conArgs[1]; var resp = Http.PostFor <JSend>($"{Program.SUPPORT_URL}/Install", new Dictionary <string, object> { ["name"] = name, }); try { if (resp.IsSuccess()) { var model = resp.data as JObject; var cli_version = model["cli_version"].Value <string>(); if (new Version(Program.CLI_VERSION) >= new Version(cli_version)) { int fileCount = model["count"].Value <int>(); int fileDownload = 0; int fileSkip = 0; int fileDone() => fileDownload + fileSkip; int fileVerifySuccess = 0; int fileVerifyFailed = 0; int colLength1 = fileCount * 2 + 1; int[] tableLengths = new[] { colLength1, 67 - colLength1, 7 }; List <string> extractFileList = new List <string>(); foreach (var item in model["files"] as JArray) { var url = item["url"].Value <string>(); var md5 = item["md5"].Value <string>(); var fileName = item["fileName"].Value <string>(); var saveas = $@"{Program.DOWNLOAD_DIRECTORY}\{fileName}"; var extract = item["extract"].Value <bool>(); if (!File.Exists(saveas) || FileUtility.ComputeMD5(saveas) != md5) { #region Download files using (var file = new FileStream(saveas, FileMode.Create)) { var web = new HttpAccess(); web.DownloadProgress += (sender, _url, received, length) => { Echo.Row(new[] { $"{fileDone() + 1}/{fileCount}", $"| {fileName}", ((double)received / length).ToString("0.00%") }, tableLengths); }; int retry = 0, allowedRetry = 3; retry: try { web.GetDownload(file, url); if (extract) { extractFileList.Add(saveas); } fileDownload++; } catch (Exception ex) { Echo.Line(); if (retry < allowedRetry) { Echo.Print($" {ex.Message}, retry {++retry}/{allowedRetry}").Line(); goto retry; } else { Echo.Print($" File can not be downloaded from {url}").Line(); Echo.AskYN("Retry?", out var ansRetry); if (ansRetry) { retry = 0; goto retry; } else { fileSkip++; continue; } } } } #endregion #region Check file md5 var status = ""; if (FileUtility.ComputeMD5(saveas) == md5) { fileVerifySuccess++; status = "Safe"; } else { fileVerifyFailed++; status = "WARNING"; } Echo.Row(new[] { $"{fileDone()}/{fileCount}", $"| {Path.GetFileName(saveas)}", status }, tableLengths).Line(); #endregion } else { if (extract) { extractFileList.Add(saveas); } fileDownload++; Echo.Row(new[] { $"{fileDone()}/{fileCount}", $"| {Path.GetFileName(saveas)}", "Found" }, tableLengths).Line(); } } Echo .Line() .Print($" " + $"{fileDownload} downloaded." + $" {fileVerifySuccess} safe, {fileVerifyFailed} warning, {fileSkip} skiped.").Line() .Print($"---- All files has been downloaded using engine {typeof(Http).FullName} ----").Line() .Line(); // Setup void extractFiles() { foreach (var file in extractFileList) { ZipFile.ExtractToDirectory(file, Program.ProjectInfo.ProjectRoot, true); Echo.Print($"Extract {file} done.").Line(); } Echo .Print($"---- Extract files completed ----").Line() .Line(); }; if (fileVerifyFailed > 0) { Echo.AskYN("Setup now?", out var ans); if (ans) { extractFiles(); } } else { extractFiles(); } } else { Echo.Print($"Install service requires the lowest cli tool version: {cli_version}.").Line(); } } else { AlertUtility.PrintErrorMessage(resp); } } catch (JsonReaderException ex) { Echo.Print($"Error occurred. ({ex.Message})").Line(); } }
public VoiceResponse Echo(Echo echo) { this.Append(echo); return(this); }
static Node ParseCommand() { Node node; switch (tokens.Current.Type) { case TokenTypes.IDEN: { node = new Identifier(tokens.Current.Value); tokens.SelectNext(); if (tokens.Current.Type != TokenTypes.EQUAL) { throw new RaulException($"Expected '=' after Identifier at {tokens.Position}"); } tokens.SelectNext(); node = new Assignment(node, ParseRelExpression()); break; } case TokenTypes.KEYWORD: { switch (tokens.Current.Value) { case Keywords.ECHO: { tokens.SelectNext(); node = new Echo(ParseRelExpression()); break; } case Keywords.WHILE: { tokens.SelectNext(); if (tokens.Current.Type != TokenTypes.LPAR) { throw new RaulException($"Expected '(' after WHILE stmnt at {tokens.Position}"); } tokens.SelectNext(); Node condition = ParseRelExpression(); if (tokens.Current.Type != TokenTypes.RPAR) { throw new RaulException($"Expected ')' after WHILE stmnt at {tokens.Position}"); } tokens.SelectNext(); node = new WhileNode(condition, ParseCommand()); return(node); } case Keywords.IF: { tokens.SelectNext(); if (tokens.Current.Type != TokenTypes.LPAR) { throw new RaulException($"Expected '(' after IF stmnt at {tokens.Position}"); } tokens.SelectNext(); Node condition = ParseRelExpression(); if (tokens.Current.Type != TokenTypes.RPAR) { throw new RaulException($"Expected ')' after IF stmnt at {tokens.Position}"); } tokens.SelectNext(); Node cond_true = ParseCommand(); if (tokens.Current.Type == TokenTypes.KEYWORD && tokens.Current.Value == Keywords.ELSE) { tokens.SelectNext(); node = new IfNode(condition, cond_true, ParseCommand()); } else { node = new IfNode(condition, cond_true); } return(node); } default: { throw new RaulException($"Hum... Nao era pra esse erro ser possivel..."); } } break; } case TokenTypes.LBRACE: { node = ParseBlock(); return(node); } default: { throw new RaulException($"Unexpected symbol at {tokens.Position}"); } } if (tokens.Current.Type == TokenTypes.SEMI) { tokens.SelectNext(); return(node); } else { throw new RaulException($"Expected ';' at {tokens.Position}"); } }
public void AddUser(Echo user) { _users.Add(user.Username, user.ActorRef); }
public HPF(float c, float r, int v, Echo e) { cutoff = c; resonance = r; if (v == 1) { reverb = AudioReverbPreset.Concerthall; } else if (v == 2) { reverb = AudioReverbPreset.Drugged; } else { reverb = AudioReverbPreset.Off; } echo = e; }
public ReturnValue SendEcho(XmlDocument message) { return(this.execute(Echo.Create(message, this.Settings))); }
public ReturnValue SendEcho(string message) { return(this.execute(Echo.Create(message, this.Settings))); }
public object Any(Echo request) { return new EchoResponse { Result = "Hello, {0}!".Fmt(request.Name) }; }
/// <summary> /// The seed. /// </summary> public void Seed() { // Create dummy users if (!_context.Users.Any()) { foreach (var userString in UserSeedData) { var user = new User { Id = userString.UserGoogleId, Name = userString.Name, Email = userString.Email, Tag = userString.Tag, Picture = userString.Picture }; _context.Users.Add(user); _context.SaveChanges(); } // Create dummy followers foreach (var followerSeed in FollowerSeedData) { var sourceUser = _context.Users.Single(u => u.Id == followerSeed.SourceUserGoogleId); _context.Users.Single(u => u.Id == followerSeed.UserGoogleIdToFollow).Followers.Add(sourceUser); _context.SaveChanges(); } } // Create dummy topics if (!_context.Topics.Any()) { foreach (var topicName in TopicSeedData) { var topic = new Topic { Name = topicName }; _context.Topics.Add(topic); _context.SaveChanges(); } } // Create dummy messages if (!_context.Messages.Any()) { foreach (var messageSeed in MessageSeedData) { var user = _context.Users.Single(u => u.Id == messageSeed.UserGoogleId); Message parentMessage = null; if (messageSeed.ParentMessageId > 0) { parentMessage = _context.Messages.Single(m => m.Id == messageSeed.ParentMessageId); } var message = new Message { Creator = user, CreationDate = DateTime.UtcNow, MessageContent = messageSeed.MessageBody, ParentMessage = parentMessage }; _context.Messages.Add(message); // Add message to topic ( if it has a topic ) if (messageSeed.TopicId > 0) { var topic = _context.Topics.Single(t => t.Id == messageSeed.TopicId); topic.Messages.Add(message); } _context.SaveChanges(); } // Create dummy favorite data foreach (var favoriteSeed in FavoriteSeedData) { var message = _context.Messages.Single(m => m.Id == favoriteSeed.MessageId); _context.Users.Single(u => u.Id == favoriteSeed.SourceUserGoogleId).Favorites.Add(message); _context.SaveChanges(); } } // Create dummy echo data if (!_context.Echoes.Any()) { foreach (var echoSeed in EchoSeedData) { var message = _context.Messages.Single(m => m.Id == echoSeed.MessageIdToEcho); var user = _context.Users.Single(u => u.Id == echoSeed.SourceUserGoogleId); var echo = new Echo { Creator = user, CreationDate = DateTime.UtcNow, SourceMessage = message }; _context.Echoes.Add(echo); _context.SaveChanges(); } } // Create dummy notification data if (!_context.Notifications.Any()) { foreach (var notificationSeed in NotificationSeedData) { var user = _context.Users.Single(u => u.Id == notificationSeed.SourceUserId); Message message = null; if (notificationSeed.SourceMessageId > 0) { message = _context.Messages.Single(m => m.Id == notificationSeed.SourceMessageId); } Topic topic = null; if (notificationSeed.SourceTopicId > 0) { topic = _context.Topics.Single(t => t.Id == notificationSeed.SourceTopicId); } var ownerUser = _context.Users.Single(u => u.Id == notificationSeed.OwnerGoogleId); var notification = new Notification { Owner = ownerUser, CreationDate = DateTime.UtcNow, NotificationType = (int)notificationSeed.NotificationType, SourceMessage = message, SourceUser = user, SourceTopic = topic, NotificationStatus = (int)notificationSeed.NotificationStatus }; _context.Notifications.Add(notification); _context.SaveChanges(); } } }
public string Any(Echo req) => $"{HostContext.ServiceName} is echoing {req.Input}";
/** * //注册请求 POST * Dictionary<string,string> dic = new Dictionary<string, string> (); * dic.Add("Action","1"); * dic.Add("usrname","xys"); * dic.Add("psw","123456"); * * StartCoroutine(POST("http://192.168.1.12/login.php",dic)); * */ //POST请求 IEnumerator POST <T>(string url, Action <object, object> callBack, Dictionary <string, object> param) { WWWForm form = new WWWForm(); if (param != null) { foreach (KeyValuePair <string, object> post_arg in param) { if (post_arg.Value != null) { form.AddField(post_arg.Key, post_arg.Value.ToString()); } } } //第一种方法 //这是get请求的头参数 Hashtable headers = form.headers; //headers.Remove ("Content-Type"); //headers.Add("Content-Type", "application/json"); //headers.Add("Content-Type", "application/x-www-form-urlencoded"); if (param.ContainsKey("token")) { headers.Add("Authorization", param["token"]); } WWW www = new WWW(url, form.data, headers); //第二种方法 //WWW www = new WWW(url, form); yield return(www); if (www.isDone) { string data = ""; if (www.error != null) { data = "{'result':-100,'msg':'" + www.error + "'}"; //PopMessageManager.show(data); } else { data = www.text; //PopMessageManager.show("ok"); } if (callBack != null) { Echo.Log("callBack:" + data); T t = JsonMapper.ToObject <T> (data); Filter(t); callBack(t, data); } } }
public static string C2SEcho(string msg) { Echo data = new Echo(msg); return(JsonMapper.ToJson(data)); }
static void Main(string[] args) { var face = new Face (new TcpTransport(), new TcpTransport.ConnectionInfo("localhost")); // For now, when setting face.setCommandSigningInfo, use a key chain with // a default private key instead of the system default key chain. This // is OK for now because NFD is configured to skip verification, so it // ignores the system default key chain. var identityStorage = new MemoryIdentityStorage(); var privateKeyStorage = new MemoryPrivateKeyStorage(); var keyChain = new KeyChain (new IdentityManager(identityStorage, privateKeyStorage), new SelfVerifyPolicyManager(identityStorage)); keyChain.setFace(face); // Initialize the storage. var keyName = new Name("/testname/DSK-123"); var certificateName = keyName.getSubName(0, keyName.size() - 1).append ("KEY").append(keyName.get(-1)).append("ID-CERT").append("0"); identityStorage.addKey(keyName, KeyType.RSA, new Blob(DEFAULT_RSA_PUBLIC_KEY_DER)); privateKeyStorage.setKeyPairForKeyName (keyName, KeyType.RSA, new ByteBuffer(DEFAULT_RSA_PUBLIC_KEY_DER), new ByteBuffer(DEFAULT_RSA_PRIVATE_KEY_DER)); face.setCommandSigningInfo(keyChain, certificateName); var echo = new Echo(keyChain, certificateName); var prefix = new Name("/testecho"); Console.Out.WriteLine("Register prefix " + prefix.toUri()); face.registerPrefix(prefix, echo, echo); // The main event loop. // Wait to receive one interest for the prefix. while (echo.responseCount_ < 1) { face.processEvents(); // We need to sleep for a few milliseconds so we don't use 100% of // the CPU. System.Threading.Thread.Sleep(5); } }
public MainPageViewModel(IFermentationControllerAPI fermApi, IScreen hostScreen) { var retry = Polly.Policy.Handle <WebException>().WaitAndRetryAsync(1, x => TimeSpan.FromSeconds(Math.Pow(2, x))); HostScreen = hostScreen; SetTimeToNow = ReactiveCommand.CreateAsyncTask(async _ => { var secFromEpoch = DateTimeMixins.SecondsFromEpoch(); await retry.ExecuteAsync(() => fermApi.SetTime(secFromEpoch)); }); Echo = ReactiveCommand.CreateAsyncTask(async _ => { var response = await retry.ExecuteAsync(() => fermApi.Echo(this.EchoText)); return(response); }); Echo.ToProperty(this, vm => vm.EchoResponse, out _EchoResponse); GetStatus = ReactiveCommand.CreateAsyncTask(async _ => { string output = string.Empty; var response = await retry.ExecuteAsync(fermApi.GetStatus); var theData = Convert.FromBase64String(response); using (var ms = new MemoryStream(theData)) { var systemTime = ms.ReadUInt32(); var systemMode = ms.ReadByte(); var regMode = ms.ReadByte(); var probe0Assignment = ms.ReadByte(); var probe0Temp = ms.ReadUInt16(); var probe1Assignment = ms.ReadByte(); var probe1Temp = ms.ReadUInt16(); var heatRelayStatus = ms.ReadByte(); var coolRelayStatus = ms.ReadByte(); var runningProfile = ms.ReadString(64); var profileStepIdx = ms.ReadUInt16(); var profileStepTemp = ms.ReadUInt16(); var profileStepTimeRemaining = ms.ReadUInt32(); var manualSetpointTemp = ms.ReadUInt16(); var profileStartTime = ms.ReadUInt32(); output += string.Format("System Time:{0}\n", DateTimeMixins.TimeFromEpoch(systemTime)); output += string.Format("System Mode:{0}\n", systemMode); output += string.Format("Regulation Mode:{0}\n", regMode); output += string.Format("Probe0 Assign:{0}\n", probe0Assignment); output += string.Format("Probe0 Temp C:{0}\n", probe0Temp / 10.0); output += string.Format("Probe1 Assign:{0}\n", probe1Assignment); output += string.Format("Probe1 Temp C:{0}\n", probe1Temp / 10.0); output += string.Format("Heat Relay Status:{0}\n", heatRelayStatus); output += string.Format("Cool Relay Status:{0}\n", coolRelayStatus); output += string.Format("Running Profile:{0}\n", runningProfile); output += string.Format("Profile Step Index:{0}\n", profileStepIdx); output += string.Format("Profile Step Temperature C:{0}\n", profileStepTemp / 10.0); output += string.Format("Profile Step Time Remaining:{0}\n", profileStepTimeRemaining); output += string.Format("Manual Setpoint Temp C:{0}\n", manualSetpointTemp / 10.0); output += string.Format("Profile Start Time:{0}\n", DateTimeMixins.TimeFromEpoch(profileStartTime)); } return(output); }); GetStatus.ThrownExceptions .Select(x => new UserError("Status cannot be retrieved", "Check your connected to the TEMPERATURE wifi")) .SelectMany(UserError.Throw); GetStatus.ToProperty(this, vm => vm.StatusResponse, out _StatusResponse); NavigateToCreateProfilePage = ReactiveCommand.Create(); NavigateToCreateProfilePage .Subscribe(_ => HostScreen.Router.Navigate.Execute(new CreateProfileViewModel(hostScreen, fermApi))); NavigateToPreferencesPage = ReactiveCommand.Create(); NavigateToPreferencesPage .Subscribe(_ => HostScreen.Router.Navigate.Execute(new PreferencesPageViewModel(hostScreen, new UserSettings()))); }
public ExternalDevicePort(string devicename,Echo echomess) { this.devicename = devicename; this.EchoMess = echomess; }
void OnEnable() { source = GetComponent <AudioSource3D>(); filter = new Echo(AudioListener3D.Current.SampleRate, Strength, Delay); source.AddFilter(filter); }
public void LoadParams(TextAsset filterParams) { string[] line = filterParams.text.Split ('\n'); int readLine = 0; do { string filterType = ""; if (line[readLine].Contains ("Chorus")) { filterType = "Chorus"; } else if (line[readLine].Contains ("Echo")) { filterType = "Echo"; } else if (line[readLine].Contains ("LPF")) { filterType = "LPF"; } else if (line[readLine].Contains ("HPF")) { filterType = "HPF"; } else { break; } int track = 0; do { readLine++; if (line[readLine].Contains("#")) { ArrayList filter = new ArrayList(4); readLine++; while (readLine < line.Length && line[readLine].Contains(":")) { if (filterType == "HPF" && line[readLine].Split(':')[0].Trim() == "echo") { if (line[readLine].Split(':')[1].Trim() == "1") { float[] temp = new float[4]; readLine++; for (int i = 0; i < 4; i++) { readLine++; temp[i] = float.Parse (line[readLine].Split(':')[1]); } filter.Add (new Echo(temp[0], temp[1], temp[2], temp[3])); } else { filter.Add (null); } } else { filter.Add (float.Parse (line[readLine].Split(':')[1])); } readLine++; } if (filterType == "Chorus" && filter.Count == 7) { chorusEffects[track] = new Chorus((float)filter[0], (float)filter[1], (float)filter[2], (float)filter[3], (float)filter[4], (float)filter[5], (float)filter[6]); } else if (filterType == "Echo" && filter.Count == 4) { echoEffects[track] = new Echo((float)filter[0], (float)filter[1], (float)filter[2], (float)filter[3]); } else if (filterType == "LPF" && filter.Count == 3) { LPFEffects[track] = new LPF((float)filter[0], (float)filter[1], Convert.ToInt32 ((float)filter[2])); } else if (filterType == "HPF" && filter.Count == 4) { HPFEffects[track] = new HPF((float)filter[0], (float)filter[1], Convert.ToInt32 ((float)filter[2]), (Echo)filter[3]); } else { Debug.LogWarning("Error in parsing " + filterType + " filter"); } track++; } } while (!line[readLine].Contains ("*")); } while (readLine < line.Length); }
// Use this for initialization void Start() { Echo.Log(EchoConfig.Instance.MaxLogCount.ToString()); Echo.Log("Hello", "Nobody"); StackTrace st = new StackTrace(true); }