void IAsyncDebuggerClient.OnWatchesUpdated(WatchType watchType) { if (watchType == WatchType.CallStack) { m_Variables.Clear(); } }
private void Watch(HttpListenerContext context, WatchType watchType) { var name = GetPayload(context); if (String.IsNullOrWhiteSpace(name)) { SendTextResponse(context, Error.InvalidName.ToMessage()); return; } Error result; switch (watchType) { case WatchType.File: result = Watcher.WatchFile(name); break; case WatchType.Directory: result = Watcher.WatchDirectory(name); break; default: result = Error.FailedToWatch; break; } SendTextResponse(context, result.ToMessage()); }
private void Watch(HttpListenerContext context, WatchType watchType) { var name = GetPayload(context); if (String.IsNullOrWhiteSpace(name)) { SendTextResponse(context, Error.InvalidName.ToMessage()); return; } Error result; switch (watchType) { case WatchType.File: result = Watcher.WatchFile(name); break; case WatchType.Directory: result = Watcher.WatchDirectory(name); break; default: result = Error.FailedToWatch; break; } SendTextResponse(context, result.ToMessage()); }
public void TestFixtureSetUp() { // Enable test mode ReflectionTool.TestMode = true; // This call is necessary for NUnit to load the type var someType = new WatchType(); Effort.Provider.EffortProviderConfiguration.RegisterProvider(); // prepare inmemory products db _factory = new UnitOfWorkFactory <ProductsContext>(new InMemoryDbContextManager("ProductStorageTest")); // prepare empty workplan var workplan = new Workplan { Name = "TestWorkplan" }; workplan.AddConnector("Start", NodeClassification.Start); workplan.AddConnector("End", NodeClassification.End); using (var uow = _factory.Create()) { var entity = RecipeStorage.SaveWorkplan(uow, workplan); uow.SaveChanges(); _workplanId = entity.Id; } }
public void InstantiateProduct() { var watch = new WatchType() { Identity = new ProductIdentity("1277125", 01), Watchface = new ProductPartLink <WatchfaceType> { Product = new WatchfaceType { Identity = new ProductIdentity("512380125", 01) } } }; for (int i = 1; i <= 4; i++) { watch.Needles.Add(new NeedlePartLink { Role = (NeedleRole)i - 1, Product = new NeedleType { Identity = new ProductIdentity("12641" + i, (short)(i % 4)) } }); } // Create instance var watchInstance = (WatchInstance)watch.CreateInstance(); // Assert Assert.AreEqual(watch, watchInstance.Type, "Wrong watch product"); Assert.AreEqual(watch.Watchface.Product, watchInstance.Watchface.Type, "Wrong watchface product"); Assert.AreEqual(NeedleRole.Hours, watch.Needles.ElementAt(0).Role, "Role not set on instance"); }
/// <summary> /// Called when the view is loading. Load any settings saved in the xml document. /// </summary> /// <param name="xmlIn"></param> public void LoadFromXML(XmlReader xmlIn) { try { xmlIn.MoveToContent(); _graphicElements.loadFromXML(xmlIn); xmlIn.Read(); do { if (xmlIn.NodeType == XmlNodeType.EndElement) { break; } if (xmlIn.NodeType == XmlNodeType.Element && xmlIn.Name == "WatchItem") { string label = xmlIn.GetAttribute("Label"); WatchType wt = (WatchType)Enum.Parse(typeof(WatchType), xmlIn.GetAttribute("WatchType"), true); bool signed = bool.Parse(xmlIn.GetAttribute("Signed")); bool displayHex = bool.Parse(xmlIn.GetAttribute("DisplayHex")); _loadedEntries.Add(new WatchEntry(label, wt, signed, displayHex, _JM)); } xmlIn.Skip(); } while (!xmlIn.EOF); } catch (Exception ex) { ARMPluginInterfaces.Utils.OutputDebugString(ex.Message); this.defaultSettings(); } }//LoadFromXML
public void Update(WatchType watchType, IEnumerable <WatchItem> items) { if (watchType != WatchType.CallStack && watchType != WatchType.Watches) { return; } int watchIdx = (int)watchType; string watchHash = string.Join("|", items.Select(l => l.ToString()).ToArray()); if (m_CachedWatches[watchIdx] == null || m_CachedWatches[watchIdx] != watchHash) { m_CachedWatches[watchIdx] = watchHash; Send(xw => { using (xw.Element(watchType.ToString().ToLowerInvariant())) { foreach (WatchItem wi in items) { using (xw.Element("item")) { if (wi.Name == null) { if (watchType == WatchType.CallStack) { xw.Attribute("name", ((wi.RetAddress < 0) ? "<chunk-root>" : "<??unknown??>")); } else { xw.Attribute("name", "(null name ??)"); } } else { xw.Attribute("name", wi.Name); } if (wi.Value != null) { xw.Attribute("value", wi.Value.ToString()); xw.Attribute("type", wi.IsError ? "error" : wi.Value.Type.ToLuaDebuggerString()); } xw.Attribute("address", wi.Address.ToString("X8")); xw.Attribute("baseptr", wi.BasePtr.ToString("X8")); xw.Attribute("lvalue", wi.LValue); xw.Attribute("retaddress", wi.RetAddress.ToString("X8")); } } } }); } }
public void DuplicateProduct(bool crossTypeIdentifier, bool revisionTaken) { // Arrange var productMgr = new ProductManager { Factory = _factory, Storage = _storage }; productMgr.TypeChanged += (sender, product) => { }; var watch = SetupProduct("Jaques Lemans", "321"); _storage.SaveType(watch); var recipe = new WatchProductRecipe { Product = watch, Classification = RecipeClassification.Default, Name = "TestRecipe", Workplan = new Workplan { Id = _workplanId } }; _storage.SaveRecipe(recipe); // Act (& Assert) WatchType duplicate = null; if (crossTypeIdentifier | revisionTaken) { var newIdentity = crossTypeIdentifier ? new ProductIdentity("3214711", 7) : new ProductIdentity("321" + WatchMaterial, 5); var ex = Assert.Throws <IdentityConflictException>(() => { duplicate = (WatchType)productMgr.Duplicate(watch.Id, newIdentity); }); Assert.AreEqual(crossTypeIdentifier, ex.InvalidTemplate); return; } Assert.DoesNotThrow(() => { duplicate = (WatchType)productMgr.Duplicate(watch.Id, new ProductIdentity("654" + WatchMaterial, 1)); }); var recipeDuplicates = _storage.LoadRecipes(duplicate.Id, RecipeClassification.Unset); // Assert Assert.AreEqual(watch.Watchface.Product.Id, duplicate.Watchface.Product.Id); Assert.AreEqual(watch.Needles.Sum(n => n.Product.Id), duplicate.Needles.Sum(n => n.Product.Id)); Assert.Greater(recipeDuplicates.Count, 0); Assert.AreNotEqual(recipe.Id, recipeDuplicates[0].Id); Assert.AreEqual(recipe.Name, recipeDuplicates[0].Name); Assert.AreEqual(recipe.Classification, recipeDuplicates[0].Classification); }
public Watch(string name, WatchType type, long pollInterval, double leaseInterval, SynchronizationContext synchronizationContext, UpdateUIHandler updateUIHandler, LogHandler logMessage, HttpManager httpManager) { this.name = name; this.type = type; this.pollInterval = pollInterval; this.leaseInterval = leaseInterval; this.synchronizationContext = synchronizationContext; this.updateUIHandler = updateUIHandler; this.logMessage = logMessage; this.httpManager = httpManager; }
public MovementType(WatchType type, Descriptions description) { Type = type; if (Type == WatchType.Electronic && (int)description > 4 || Type == WatchType.Mechanical && (int)description < 4) { Description = Descriptions.BalanceWheel; } else { Description = description; } }
protected static ManagementEventWatcher WatchImpl <T>(int Interval, string NS, string CN, WatchType Type, Action <T> onEvent, Func <ManagementBaseObject, T> factory) { var ret = new ManagementEventWatcher(NS, WatchQueryCreate(Interval, Type, CN)); ret.EventArrived += (x, e) => onEvent(factory(e.NewEvent.Properties["TargetInstance"].Value as ManagementBaseObject)); ret.Start(); return(ret); }
void IDebugger.Update(WatchType watchType, IEnumerable <WatchItem> items) { var list = m_WatchItems[(int)watchType]; list.Clear(); list.AddRange(items); lock (m_Lock) if (Client != null) { Client.OnWatchesUpdated(watchType); } }
void IDebugger.Update(WatchType watchType, IEnumerable <WatchItem> items) { if (watchType == WatchType.CallStack) { m_Ctx.Post(UpdateCallStack, items); } if (watchType == WatchType.Watches) { m_Ctx.Post(UpdateWatches, items); } if (watchType == WatchType.VStack) { m_Ctx.Post(UpdateVStack, items); } }
private static void CheckProduct(WatchType watch, ProductTypeEntity watchProductTypeEntity, IProductTypeEntityRepository productTypeEntityRepo, long savedWatchId) { var watchNeedlesCount = watch.Needles.Count; var watchEntityNeedlesCount = watchProductTypeEntity.Parts.Count(p => p.Child.TypeName.Equals(nameof(NeedleType))); Assert.AreEqual(watchNeedlesCount, watchEntityNeedlesCount, "Different number of needles"); var watchfaceEntity = watchProductTypeEntity.Parts.First(p => p.Child.TypeName.Equals(nameof(WatchfaceType))).Child; Assert.NotNull(watchfaceEntity, "There is no watchface"); var identity = (ProductIdentity)watch.Identity; var byIdentifier = productTypeEntityRepo.GetByIdentity(identity.Identifier, identity.Revision); Assert.NotNull(byIdentifier, "New version of watch not found by identifier "); Assert.AreEqual(savedWatchId, byIdentifier.Id, "Different id´s"); }
public void CreateWatch(UIComponent parent, string name, WatchType type, int index, UITextureAtlas atlas, string spriteName, string toolTip) { try { Name = name; Type = type; if (Type == WatchType.Aspect) { CreateAsAspect(parent, ModConfig.Instance.VerticalLayout, ModConfig.Instance.DoubleRibbonLayout, index, atlas, spriteName, toolTip); } else if (Type == WatchType.Pillar) { CreateAsPillar(parent, ModConfig.Instance.VerticalLayout, ModConfig.Instance.DoubleRibbonLayout, index, atlas, spriteName, toolTip); } _button.eventClick += (component, eventParam) => { SetInfoMode(name); }; if (ModConfig.Instance.ShowNumericalDigits == 2 || ModConfig.Instance.ShowNumericalDigits == 3) { CreateNumericalDigits(_button, ModConfig.Instance.NumericalDigitsAnchor, ModConfig.Instance.VerticalLayout, ModConfig.Instance.DoubleRibbonLayout, index); if (ModConfig.Instance.ShowNumericalDigits == 2) { _label.isVisible = false; _button.eventMouseEnter += (component, eventParam) => { _label.isVisible = true; }; _button.eventMouseLeave += (component, eventParam) => { _label.isVisible = false; }; } } } catch (Exception e) { Debug.Log("[Watch It!] Watch:CreateWatch -> Exception: " + e.Message); } }
public void LoadRecipesByClassification() { // Arrange var watch = new WatchType { Name = "Test", Identity = new ProductIdentity("8899665", 1), }; _storage.SaveType(watch); CreateRecipe(RecipeClassification.Default); CreateRecipe(RecipeClassification.Alternative); CreateRecipe(RecipeClassification.Alternative); CreateRecipe(RecipeClassification.Part); // Act var defaults = _storage.LoadRecipes(watch.Id, RecipeClassification.Default); var alternatives = _storage.LoadRecipes(watch.Id, RecipeClassification.Alternative); var defaultsAndAlternatives = _storage.LoadRecipes(watch.Id, RecipeClassification.Default | RecipeClassification.Alternative); var parts = _storage.LoadRecipes(watch.Id, RecipeClassification.Part); var all = _storage.LoadRecipes(watch.Id, RecipeClassification.CloneFilter); // Assert Assert.AreEqual(1, defaults.Count); Assert.AreEqual(2, alternatives.Count); Assert.AreEqual(3, defaultsAndAlternatives.Count); Assert.AreEqual(1, parts.Count); Assert.AreEqual(4, all.Count); void CreateRecipe(RecipeClassification classification) { var recipe = new WatchProductRecipe { Product = watch, Classification = classification, Name = classification + ": TestRecipe", Workplan = new Workplan { Id = _workplanId } }; _storage.SaveRecipe(recipe); } }
private static WatchType SetupProduct(string watchName, string identifierPrefix, short revision = 5) { var watchface = new WatchfaceType { Name = "Black water resistant for " + watchName, Identity = new ProductIdentity(identifierPrefix + "4711", revision), Numbers = new[] { 3, 6, 9, 12 } }; var needles = new List <NeedlePartLink> { new NeedlePartLink { Product = new NeedleType { Name = "Hours needle", Identity = new ProductIdentity(identifierPrefix + "24", 1) } }, new NeedlePartLink { Product = new NeedleType { Name = "Minutes needle", Identity = new ProductIdentity(identifierPrefix + "1440", 2) } }, new NeedlePartLink { Product = new NeedleType { Name = "Seconds needle", Identity = new ProductIdentity(identifierPrefix + "B86400", 3) } } }; var watch = new WatchType { Name = watchName, Identity = new ProductIdentity(identifierPrefix + WatchMaterial, revision), Watchface = new ProductPartLink <WatchfaceType> { Product = watchface }, Needles = needles, Weight = 123.45 }; return(watch); }
public async Task AddToUserWatchlistAsync(string userId, string mediaId, WatchType watchType) { var watcher = this.watchRepository.All() .FirstOrDefault(x => x.UserId == userId && x.MediaId == mediaId); if (watcher == null) { watcher = new MediaWatcher() { UserId = userId, MediaId = mediaId, }; await this.watchRepository.AddAsync(watcher); } watcher.WatchType = watchType; await this.watchRepository.SaveChangesAsync(); }
public void PartLinksWithTheSameIdentifierAreOnlySavedOnce() { //Arrange var watch = new WatchType { Name = "watch", Identity = new ProductIdentity("223", 1), Needles = new List <NeedlePartLink> { new NeedlePartLink { Role = NeedleRole.Minutes, Product = new NeedleType { Identity = new ProductIdentity("222", 0), Name = "name" } }, new NeedlePartLink { Role = NeedleRole.Seconds, Product = new NeedleType { Identity = new ProductIdentity("222", 0), Name = "name" } } } }; //Act _storage.SaveType(watch); var minuteNeedle = watch.Needles.Find(t => t.Role == NeedleRole.Minutes); var secondsNeedle = watch.Needles.Find(t => t.Role == NeedleRole.Seconds); //Assert Assert.AreNotEqual(minuteNeedle.Product.Id, 0, "Id of Needle for minutes was 0"); Assert.AreNotEqual(secondsNeedle.Product.Id, 0, "Id of Needle for seconds was 0"); Assert.AreEqual(secondsNeedle.Product.Id, minuteNeedle.Product.Id, "Both needles must have the same Id since they are the same product"); }
private static string WatchQueryCreate(int Interval, WatchType Type, string ClassName) { string from = ""; switch (Type) { case WatchType.Creation: from = "__InstanceCreationEvent"; break; case WatchType.Deletion: from = "__InstanceDeletionEvent"; break; case WatchType.Modification: from = "__InstanceModificationEvent"; break; } return(string.Format("SELECT * FROM {0} WITHIN {1} WHERE TargetInstance ISA '{2}'", from, Interval, ClassName)); }
public Watch(WatchType type) { this.type = type; }
public void Update(WatchType watchType, IEnumerable<WatchItem> items) { }
void IDebugger.Update(WatchType watchType, IEnumerable<WatchItem> items) { var list = m_WatchItems[(int)watchType]; list.Clear(); list.AddRange(items); lock (m_Lock) if (Client != null) Client.OnWatchesUpdated(watchType); }
public List<WatchItem> GetWatches(WatchType watchType) { return m_WatchItems[(int)watchType]; }
void IAsyncDebuggerClient.OnWatchesUpdated(WatchType watchType) { if (watchType == WatchType.CallStack) m_Variables.Clear(); }
public override void CompileTimeInitialize(LocationInfo targetLocation, AspectInfo aspectInfo) { m_Trace = false; if (targetLocation.LocationKind == LocationKind.Field) { m_Trace = !targetLocation.FieldInfo.IsSpecialName; } else if (targetLocation.LocationKind == LocationKind.Property) { m_Trace = true; } if (m_Trace) { if (m_IncludeType) { m_Name = targetLocation.DeclaringType.Name + "." + targetLocation.Name; } else { m_Name = targetLocation.Name; } m_FormattedSessionName = FormatSessionName(targetLocation); m_WatchType = GetWatchType(targetLocation); if (m_IncludeInstance) { m_IncludeInstance = !targetLocation.IsStatic; } } base.CompileTimeInitialize(targetLocation, aspectInfo); }
private static bool Add(Dictionary <string, WatchedChannel> dict, ulong discordChannelId, string youtubeChannelId, string channelName, WatchType wType) { WatchedChannel wc; if (dict.ContainsKey(youtubeChannelId)) { if (dict[youtubeChannelId].ChannelsThatAreSubbed.Contains(discordChannelId)) { return(false); } dict[youtubeChannelId].ChannelsThatAreSubbed.Add(discordChannelId); return(true); } dict.Add(youtubeChannelId, wc = new WatchedChannel { ChannelId = youtubeChannelId, ChannelName = channelName, ChannelsThatAreSubbed = new List <ulong> { discordChannelId }, WatchedType = wType }); AddToQueue(wc); return(true); }
public void Update(WatchType watchType, IEnumerable <WatchItem> items) { }
public override void CompileTimeInitialize(FieldInfo field) { if (m_IncludeType) { m_Name = field.DeclaringType.Name + "." + field.Name; } else { m_Name = field.Name; } m_FormattedSessionName = FormatSessionName(field); m_WatchType = GetWatchType(field); if (m_IncludeInstance) { m_IncludeInstance = !field.IsStatic; } base.CompileTimeInitialize(field); }
public List <WatchItem> GetWatches(WatchType watchType) { return(m_WatchItems[(int)watchType]); }
public void Update(WatchType watchType, IEnumerable<WatchItem> items) { if (watchType != WatchType.CallStack && watchType != WatchType.Watches) return; int watchIdx = (int)watchType; string watchHash = string.Join("|", items.Select(l => l.ToString()).ToArray()); if (m_CachedWatches[watchIdx] == null || m_CachedWatches[watchIdx] != watchHash) { m_CachedWatches[watchIdx] = watchHash; Send(xw => { using (xw.Element(watchType.ToString().ToLowerInvariant())) { foreach (WatchItem wi in items) { using (xw.Element("item")) { if (wi.Name == null) { if (watchType == WatchType.CallStack) { xw.Attribute("name", ((wi.RetAddress < 0) ? "<chunk-root>" : "<??unknown??>")); } else { xw.Attribute("name", "(null name ??)"); } } else { xw.Attribute("name", wi.Name); } if (wi.Value != null) { xw.Attribute("value", wi.Value.ToString()); xw.Attribute("type", wi.IsError ? "error" : wi.Value.Type.ToLuaDebuggerString()); } xw.Attribute("address", wi.Address.ToString("X8")); xw.Attribute("baseptr", wi.BasePtr.ToString("X8")); xw.Attribute("lvalue", wi.LValue); xw.Attribute("retaddress", wi.RetAddress.ToString("X8")); } } } }); } }
void IDebugger.Update(WatchType watchType, IEnumerable<WatchItem> items) { if (watchType == WatchType.CallStack) m_Ctx.Post(UpdateCallStack, items); if (watchType == WatchType.Watches) m_Ctx.Post(UpdateWatches, items); if (watchType == WatchType.VStack) m_Ctx.Post(UpdateVStack, items); }
public void Update(WatchType watchType, IEnumerable <WatchItem> items) { if (items != null && watchType == WatchType.Locals) { lock (this.varsLock) { this.vars = new Dictionary <string, string>(); foreach (WatchItem watchItem in items) { if (!string.IsNullOrEmpty(watchItem.Name) && null != watchItem.Value) { switch (watchItem.Value.Type) { case DataType.Tuple: for (int i = 0; i < watchItem.Value.Tuple.Length; i++) { this.vars.Add(watchItem.Value + "[" + i.ToString() + "]", (watchItem.Value.Tuple[i] ?? DynValue.Void).ToDebugPrintString()); } break; case DataType.Function: break; case DataType.Table: foreach (TablePair p in watchItem.Value.Table.Pairs) { switch (p.Value.Type) { case DataType.Tuple: case DataType.Function: case DataType.Table: case DataType.UserData: case DataType.Thread: case DataType.ClrFunction: case DataType.TailCallRequest: case DataType.YieldRequest: break; case DataType.Nil: case DataType.Void: case DataType.Boolean: case DataType.Number: case DataType.String: this.vars.Add(watchItem.Name + "[" + p.Key.ToDebugPrintString() + "]", p.Value.ToDebugPrintString()); break; } } break; case DataType.UserData: case DataType.Thread: case DataType.ClrFunction: case DataType.TailCallRequest: case DataType.YieldRequest: break; case DataType.Nil: case DataType.Void: case DataType.Boolean: case DataType.Number: case DataType.String: default: if (watchItem.Name != "...") { this.vars.Add(watchItem.Name.ToString(), (watchItem.Value ?? DynValue.Void).ToDebugPrintString()); } break; } } } } } }
internal static bool TryAdd(ulong discordChannelId, string youtubeChannelId, string channelName, WatchType wType) { if (!_initialized) { return(false); } bool wasAdded; switch (wType) { case WatchType.Livestream: wasAdded = Add(LivestreamChannels, discordChannelId, youtubeChannelId, channelName, wType); if (wasAdded) { File.WriteAllText(WatchLivestreamPath, JsonConvert.SerializeObject(LivestreamChannels)); } return(wasAdded); case WatchType.Video: wasAdded = Add(VideoChannels, discordChannelId, youtubeChannelId, channelName, wType); if (wasAdded) { File.WriteAllText(WatchVideoPath, JsonConvert.SerializeObject(VideoChannels)); } return(wasAdded); } return(false); }
/// <summary> /// Watch all the creation/deletion/modification of this object /// </summary> /// <param name="Interval">Interval</param> /// <param name="Type">Type of watch</param> /// <param name="onEvent">Action you want to be performed on event</param> /// <returns>Handle to watcher</returns> public static ManagementEventWatcher Watch(int Interval, WatchType Type, Action <Win32_Process> onEvent) { return(WatchImpl(Interval, Namespace, ClassName, Type, onEvent, p => new Win32_Process(p))); }
internal static bool TryRemove(ulong discordChannelId, string channelIdOrName, WatchType wType) { if (!_initialized) { return(false); } switch (wType) { case WatchType.Livestream: return(Remove(LivestreamChannels, discordChannelId, channelIdOrName)); case WatchType.Video: return(Remove(VideoChannels, discordChannelId, channelIdOrName)); } return(false); }
public async Task <IEnumerable <T> > GetUserWatchListAsync <T>(string userId, int page, WatchType watchType) { int pagination = (page - 1) * MediaPerPage; var watches = await this.watchRepository.AllAsNoTracking() .Where(x => x.UserId == userId && x.WatchType == watchType) .Skip(pagination) .Take(MediaPerPage) .To <T>().ToListAsync(); return(watches); }