public void Subscribe(Persist type, object id, HubCallerContext connection) { if(!this.subscriptions.ContainsKey(this.GetKey(type, id))) { this.subscriptions.Add(this.GetKey(type, id), new List<HubCallerContext>()); } this.subscriptions[this.GetKey(type, id)].Add(connection); }
public void Notify(Persist type, object id, object o) { if (subscriptions.ContainsKey(this.GetKey(type, id))) { var context = GlobalHost.ConnectionManager.GetHubContext<GameHub>(); foreach (var clientContext in subscriptions[this.GetKey(type, id)]) { context.Clients.Client(clientContext.ConnectionId).propertyUpdated(this.GetKey(type, id), o); } } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); } else { instance = this; DontDestroyOnLoad(this.gameObject); } }
void Awake() { if (!_instance) { _instance = this; DontDestroyOnLoad(this.gameObject); } else if (this.gameObject != _instance.gameObject) { Destroy(this.gameObject); } }
protected void Copy() { if (canvasController.SelectedElements.Any()) { string copyBuffer = Persist.Serialize(canvasController.SelectedElements); Clipboard.SetData("FlowSharp", copyBuffer); } else { MessageBox.Show("Please select one or more shape(s).", "Nothing to copy.", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public virtual void OnPreviousPress() { if (Persist != null) { Persist.Close(); Persist = null; } if (OwnerState != null && OwnerState.DialogStateManager != null) { OwnerState.DialogStateManager.FireAction(DialogAction.Previous); } }
void Awake() { if (!singleton) { singleton = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
// Use this for initialization void Awake() { if (!p) { p = this; DontDestroyOnLoad(this.gameObject); } else { DestroyImmediate(this.gameObject); } }
// Now there can be only one of void Awake() { if (control == null) { DontDestroyOnLoad(gameObject); control = this; } else if (control != this) { Destroy(gameObject); } }
public void RemoveContactProcess() { string input; if (manager.GetContacts().Count != 0) { Console.Clear(); int tempNum; for (int i = 0; i < manager.GetContacts().Count; i++) { tempNum = i + 1; Console.WriteLine("{0}) {1}", tempNum, manager.GetContacts()[i].FullName); } while (true) { tempNum = 1; tempNum = tempNum + manager.GetContacts().Count; Console.Write("\nEnter the number of the contact you wish to remove: "); input = Console.ReadLine(); if (int.TryParse(input, out int selection)) { if (selection < 1 || selection >= tempNum) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nThe selection {0} is out of range, please try again.\n", selection); Console.ResetColor(); continue; } else { manager.RemoveContact(selection = selection - 1); if (Program.UsePersistance) { Persist.WriteContacts(manager.GetContacts()); } break; } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n{0} is not a valid whole number, please use numbers only.\n", input); Console.ResetColor(); } } } else { Utilities.ConsoleShowErrorMsg("You have no contacts that you can remove."); } }
public void RemoveAllContactsProcess() { if (manager.GetContacts().Count != 0) { manager.RemoveAllContacts(); Persist.DeleteSaveData(); } else { Utilities.ConsoleShowErrorMsg("You have no contacts that you can remove."); } }
public static string readStringFromFile(string filename) { // Get the path to the file to save to string path = Persist.pathForDocumentsFile(filename); StreamReader sr = new StreamReader(path); string str = sr.ReadToEnd(); sr.Close(); return(str); }
public async Task PersistDataTestFail() { var model = TenantData.GetSecond(); model.Id = string.Empty; var persist = new Persist <Tenant> { Model = model }; await persist.Execute(); persist.Confirm.Success.Should().BeFalse(); }
public void ParamsTest() { string persistString = string.Empty; // TODO: 初始化为适当的值 Persist target = new Persist(persistString); // TODO: 初始化为适当的值 string[] actual; actual = target.Params; if (actual.Length != 1) { Assert.Fail(); } }
private void P(Persist p) { var sub = 0; PersistAll(p.Messages, e => { Sender.Tell(new Done(p.Id, ++sub)); if (!Behavior(e)) { DoNothing(); } }); }
public async Task <IActionResult> Get(string id) { var loader = new NotesByRefId { Id = id }; await DataHandler.Execute(loader); if (loader.ResultNotable != null) { var model = loader.Result; if (model == null) { model = new Notes { RefId = loader.ResultNotable.Id, TenantId = CurrentUser.TenantId, TenantName = CurrentUser.TenantName, AuthorId = CurrentUser.Id, AuthorName = CurrentUser.Name, Name = loader.ResultNotable.Name, RegionKey = CurrentUser.RegionKey, IsActive = true }; var persist = new Persist <Notes> { Model = model }; await DataHandler.Execute(persist); loader.ResultNotable.NotesId = persist.Model.Id; var persistNotable = new Persist <INotable>() { Model = loader.ResultNotable }; await DataHandler.Execute(persistNotable); await DataHandler.Commit(); model = persist.Model; } return(Ok(new NotableViewModel() { Notable = Mapper.Map <ResultOwned>(loader.ResultNotable), Notes = model })); } return(NotFound()); }
/// <summary> /// Remove all of the user's contacts. /// </summary> public void RemoveAllContactsProcess() { // If the user has any contacts. if (manager.GetContacts().Count != 0) { manager.RemoveAllContacts(); Persist.DeleteSaveData(); } // If the user has no contacts display a message stating such. else { Utilities.ConsoleShowErrorMsg("You have no contacts that you can remove."); } }
protected async Task <ConfirmViewModel> Save(T model) { if (AuthoriseWrite(model)) { var persist = new Persist <T> { Model = model }; await DataHandler.Execute(persist); return(ConfirmViewModel.CreateSuccess(persist.Model)); } return(ConfirmViewModel.CreateFailure("Failed Authorisation on " + model.GetType().Name)); }
public static object deserializeObjectFromFile(string filename, Type type) { // Get the path to the file to save to string path = Persist.pathForDocumentsFile(filename); object obj; StreamReader sr = new StreamReader(path); XmlSerializer serializer = new XmlSerializer(type); obj = serializer.Deserialize(sr); sr.Close(); return(obj); }
public async Task <IActionResult> TwoFactor([FromBody] TwoFactorViewModel viewModel) { var query = new UserById { Id = viewModel.Id }; await DataHandler.Execute(query); if (query.Result != null && query.Result.IsActive && (query.ResultTenant == null || query.ResultTenant.IsActive)) { var config = query.ResultConfig; if (config.TwoFactorAuth == viewModel.Auth && config.IsTwoFactorActive && config.IsTwoFactor) { config.IsTwoFactorActive = false; config.TwoFactorAuth = string.Empty; var persist = new Persist <UserConfig>() { Model = config }; await DataHandler.Execute(persist); if (persist.Confirm.Success) { await DataHandler.Commit(); } var logic = new SigninAuth { Login = query.Result, Config = query.ResultConfig, Tenant = query.ResultTenant, Settings = CloudHandler.Settings }; await LogicHandler.Execute(logic); return(Ok(logic.Result)); } return(Ok(new FailViewModel { Message = "Code does not match" })); } return(Ok(new FailViewModel { Message = "Identity not found" })); }
public async Task PersistDataTestInsert() { using var store = GetDocumentStore(); using var session = store.OpenAsyncSession(); var model = TenantData.GetSecond(); model.Id = string.Empty; var persist = new Persist <Tenant> { Session = session, Model = model }; await persist.Execute(); persist.Confirm.Success.Should().BeTrue(); }
protected void LoadFileIntoCanvas(string filename, string canvasName, BaseController canvasController) { canvasController.Filename = filename; // set now, in case of relative image files, etc... canvasController.CanvasName = canvasName; string data = File.ReadAllText(filename); List <GraphicElement> els = Persist.Deserialize(canvasController.Canvas, data); canvasController.Clear(); canvasController.UndoStack.ClearStacks(); ElementCache.Instance.ClearCache(); ServiceManager.Get <IFlowSharpMouseControllerService>().ClearState(); canvasController.AddElements(els); canvasController.Elements.ForEach(el => el.UpdatePath()); canvasController.Canvas.Invalidate(); }
/// <summary> /// Criar Persist para o Select de parametro tipo string /// </summary> /// <param name="o"></param> /// <returns></returns> public List <Persist> CriarPersist(String o) { String[] vet = o.ToUpper().Substring(o.ToUpper().IndexOf("SELECT") + 6, (o.ToUpper().IndexOf("FROM")) - 6).Split(','); List <Persist> p = new List <Persist>(); Persist pst; for (int i = 0; i < vet.Length; i++) { pst = new Persist(); pst.DscNome = vet[i].Trim(); pst.ObjValor = null; p.Add(pst); } return(p); }
void Awake() { // Singleton Game Manager if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); SS = false; }
public List <Persist> CriarPersistPuro(Object o) { List <Persist> lst = new List <Persist>(); Persist obj = new Persist(); if (o != null) { Dictionary <string, object> propertyValues = new Dictionary <string, object>(); Type ObjectType = o.GetType(); System.Reflection.PropertyInfo[] properties = Ordenar(ObjectType.GetProperties()); foreach (System.Reflection.PropertyInfo property in properties) { obj = new Persist(); if (property.PropertyType.IsClass && !property.PropertyType.Name.ToUpper().Equals("STRING")) { if (property.GetValue(o, null) == null) { obj.ObjValor = property.PropertyType; obj.DscNome = property.Name; obj.FlgFlag = VerificarAnnotation(obj, property, ObjectType); obj.Type = property.PropertyType; } else { obj = CriarPersistOriginal(property.GetValue(o, null))[0]; obj.Type = property.GetValue(o, null).GetType(); obj.ObjValor = property.GetValue(o, null); } lst.Add(obj); } else { obj.DscNome = property.Name; obj.ObjValor = property.GetValue(o, null); obj.FlgFlag = VerificarAnnotation(obj, property, ObjectType); obj.Type = property.PropertyType.Name.ToUpper().Equals("STRING") ? property.PropertyType : property.PropertyType.GetGenericArguments()[0]; lst.Add(obj); } } } else { obj = null; lst.Add(obj); } return(lst); }
static void Main(string[] args) { //Console.WriteLine(Kata.HighAndLow("1 2 3 4 5")); //Console.WriteLine(Kata.HighAndLow("1 9 -3 4 5")); //Console.WriteLine(Kata.FindShort("bitcoin take over thea world maybe whoa knows perhaps")); //Console.WriteLine(Kata.DescendingOrder(841267)); //Console.WriteLine(Kata.find_it(new[] { 20, 1, -1, 2, -2, -2, -2, 3, 3, 5, 5, 1, 2, 4, 20, 4, -1, -2, 5 })); //Console.WriteLine(Kata.find_it(new[] { 1})); Console.WriteLine(Persist.Persistence(999)); Console.ReadKey(); }
public List <string> GetModulesWithEnoughQuestionWarningAsList() { var tmpModuleList = new List <string>(module); var allModuls = Persist.GetModuleFiles(); for (var index = 0; index < allModuls.Count; index++) { var modul = allModuls[index]; var loadedModuleFile = Persist.Load <ModuleQuestions>("Modules\\" + modul); if (!loadedModuleFile.HasEnoughQuestions()) { tmpModuleList[index] += " (" + loadedModuleFile.GetCombinedNumberOfQuestions() + "/90 Fragen)"; } } return(tmpModuleList); }
public Menu() { List <Contact> contacts; if (Program.UsePersistance) { contacts = Persist.ReadContacts(); manager = new Manager(contacts); } else { contacts = new List <Contact>(); manager = new Manager(contacts); } tasks = new Tasks(manager); }
// Start is called before the first frame update void Start() { if (!TheOne) { if (ToPersist == null) { ToPersist = this; TheOne = true; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } } }
public void PersistConstructorTest() { string persistString = typeof(Persist).ToString() + "," + "param1,param2,param3,param4"; // TODO: 初始化为适当的值 Persist target = new Persist(persistString); Assert.AreEqual(typeof(Persist).ToString(), target.TypeName); string[] param = new string[] { "param1", "param2", "param3", "param4" }; for (int i = 0; i < param.Length; i++) { if (param[i] != target.Params[i]) { Assert.Fail(); } } }
protected bool SaveOrSaveAs(bool forceSaveAs = false) { bool ret = true; if (String.IsNullOrEmpty(filename) || forceSaveAs) { ret = SaveAs(); } else { string data = Persist.Serialize(canvasController.Elements); File.WriteAllText(filename, data); } return(ret); }
private string GetKey(Persist type, object name) { return type.ToString() + "-" + name.ToString(); }
public async Task<object> Remove(Persist type, object id) { return HttpRuntime.Cache.Remove(this.GetKey(type, id)); }
public object Get(Persist type, object id) { return HttpRuntime.Cache.Get(this.GetKey(type, id)); }
public void Store(Persist type, object id, object o) { HttpRuntime.Cache.Add(this.GetKey(type, id), o, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(60), System.Web.Caching.CacheItemPriority.Normal, null); this.Notify(type, id, o); }
void Start() { persist = GameObject.Find("Persist").GetComponent<Persist>(); sound = GameObject.Find("SoundManager").GetComponent<SoundManager>(); }