protected virtual void WriteValue(TagDictionary value) { foreach (ITag item in value) { this.WriteTag(item, WriteTagOptions.None); } }
public override TagDictionary ReadDictionary(TagCompound owner) { TagDictionary value; value = new TagDictionary(owner); this.LoadChildren(value, this.Options, TagType.None); return value; }
protected TagsManager(IntPtr handle) { Handle = handle; IsAvailable = true; TagDictionary = new TagDictionary(this); TagList = new ExTagList(this); APETagList = new SimpleTagList(this, TagType.APEv2); FLACTagList = new SimpleTagList(this, TagType.Flac); ID3v1TagList = new SimpleTagList(this, TagType.ID3v1); OpusVorbisList = new SimpleTagList(this, TagType.OpusVorbis); WMATagList = new SimpleTagList(this, TagType.WMA); WAVTagList = new SimpleTagList(this, TagType.WAV); ID3v2TagList = new ID3v2TagList(this); }
private static TagDictionary BuildTagDictionary(string instanceName, string fixedPath, TagDictionary fallbackDictionary) { TagDictionary tags; if (File.Exists(fixedPath)) { Logging.Log("Loading xml config from file {0}", Path.GetFullPath(fixedPath)); var configXml = Retry.Do(() => File.ReadAllText(fixedPath), TimeSpan.FromSeconds(5)); Logging.Log((fallbackDictionary != null ? "Re-" : "") + "Building Tag Dictionary (Using config file)"); tags = new TagDictionary(instanceName, configXml); Logging.Log((fallbackDictionary != null ? "Re-" : "") + "Built Tag Dictionary (Using config file)"); } else { Logging.Log("No structure file found at: {0}", Path.GetFullPath(fixedPath)); tags = fallbackDictionary ?? BuildTagDictionary(); } return(tags); }
public void DbLoginNamesAreSubstituted() { var sut = TagDictionary.FromXml("ident", XmlData); Assert.AreEqual(string.Format("{0}-{1}-AUDIT", Environment.GetEnvironmentVariable("ClientCode"), Environment.GetEnvironmentVariable("Environment")), GetDbLoginValue(sut, "AUDIT", "Username")); }
public void DbLoginConnectionStringLoaded() { var sut = TagDictionary.FromXml("ident", XmlData); Assert.AreEqual("Actual ConnectionString", GetDbLoginValue(sut, "ConnectionString", "ConnectionString")); }
public void LoadEmptyXmlData() { Assert.DoesNotThrow(() => TagDictionary.FromSources("ident", new Dictionary <TagSource, string> { { TagSource.XmlData, "" } })); }
public void TestDefaultLoader(string expected, string key) { var loader = TagDictionary.FromXml("myId", XmlData); Assert.AreEqual(expected, loader[key]); }
public void LoadFromEnvironment() { var loader = new TagDictionary("ident", Tuple.Create("", TagSource.Environment)); Assert.AreEqual(IsSys, loader[IsSys]); }
internal override void UpdateLayoutTransitionCore(FrameworkElement child, FrameworkElement root, object tag, TagData newTagData) { TagData tagData; Rect previousRect; bool parentChange = false; bool usingBeforeLoaded = false; object initialTag = GetInitialIdentityTag(child); // Locate the previous tag, and the parent-relative previous rect. The previous rect is computed using the app-relative rect if switching parents. // Note that we do not use the app-relative rect all time time, because when the parent itself moves, it accounts for all the motion and we do not have to. bool gotData = TagDictionary.TryGetValue(tag, out tagData); // if spawn point has changed then throw away the old one if (gotData && tagData.InitialTag != initialTag) { gotData = false; TagDictionary.Remove(tag); } if (!gotData) { TagData spawnData; if (initialTag != null && TagDictionary.TryGetValue(initialTag, out spawnData)) { previousRect = TranslateRect(spawnData.AppRect, root, newTagData.Parent); parentChange = true; usingBeforeLoaded = true; } else { previousRect = Rect.Empty; } tagData = new TagData() { ParentRect = Rect.Empty, AppRect = Rect.Empty, Parent = newTagData.Parent, Child = child, Timestamp = DateTime.Now, InitialTag = initialTag }; TagDictionary.Add(tag, tagData); } else if (tagData.Parent != VisualTreeHelper.GetParent(child)) { previousRect = TranslateRect(tagData.AppRect, root, newTagData.Parent); parentChange = true; } else { previousRect = tagData.ParentRect; } FrameworkElement originalChild = child; if ((!FluidMoveBehavior.IsEmptyRect(previousRect) && !FluidMoveBehavior.IsEmptyRect(newTagData.ParentRect)) && (!IsClose(previousRect.Left, newTagData.ParentRect.Left) || !IsClose(previousRect.Top, newTagData.ParentRect.Top)) || (child != tagData.Child && transitionStoryboardDictionary.ContainsKey(tag))) { Rect currentRect = previousRect; bool forceFloatAbove = false; // If this element was animating before, append its current transform to the start position and kill the old animation. // Note that in an overlay scenario, the animation is on the image in the overlay. Storyboard oldTransitionStoryboard = null; if (transitionStoryboardDictionary.TryGetValue(tag, out oldTransitionStoryboard)) { object tagOverlay = GetOverlay(tagData.Child); AdornerContainer adornerContainer = (AdornerContainer)tagOverlay; forceFloatAbove = (tagOverlay != null); // if floating before, we need to keep floating FrameworkElement elementWithTransform = tagData.Child; if (tagOverlay != null) { Canvas overlayCanvas = adornerContainer.Child as Canvas; if (overlayCanvas != null) { elementWithTransform = overlayCanvas.Children[0] as FrameworkElement; } } // if we're picking a specific starting point, don't append this transform if (!usingBeforeLoaded) { Transform transform = GetTransform(elementWithTransform); currentRect = transform.TransformBounds(currentRect); } transitionStoryboardDictionary.Remove(tag); oldTransitionStoryboard.Stop(); oldTransitionStoryboard = null; RemoveTransform(elementWithTransform); if (tagOverlay != null) { System.Windows.Documents.AdornerLayer.GetAdornerLayer(root).Remove(adornerContainer); TransferLocalValue(tagData.Child, FluidMoveBehavior.cacheDuringOverlayProperty, FrameworkElement.RenderTransformProperty); SetOverlay(tagData.Child, null); } } object overlay = null; // If we need to float this element, then we have to: // 1. Take a picture of it // 2. Put that picture in an Image in a popup // 3. Hide the original element (opacity=0 so we do not disturb layout) // 4. Animate the image // 5. Keep track of all the info we need to unwind this later if (forceFloatAbove || (parentChange && this.FloatAbove)) { Canvas canvas = new Canvas() { Width = newTagData.ParentRect.Width, Height = newTagData.ParentRect.Height, IsHitTestVisible = false }; Rectangle rectangle = new Rectangle() { Width = newTagData.ParentRect.Width, Height = newTagData.ParentRect.Height, IsHitTestVisible = false }; rectangle.Fill = new VisualBrush(child); canvas.Children.Add(rectangle); AdornerContainer adornerContainer = new AdornerContainer(child) { Child = canvas }; overlay = adornerContainer; // remember this overlay so we can get info from it SetOverlay(originalChild, overlay); System.Windows.Documents.AdornerLayer adorners = System.Windows.Documents.AdornerLayer.GetAdornerLayer(root); adorners.Add(adornerContainer); // Note: Not using this approach currently because the bitmap is not ready yet // To remove use of VisualBrush, have to fill in bitmap after a render //RenderTargetBitmap bitmap = new RenderTargetBitmap((int)child.ActualWidth, (int)child.ActualHeight, 96, 96, PixelFormats.Pbgra32); //bitmap.Render(parent); //image.Source = bitmap; // can't animate this or it will flash, have to set the value outright TransferLocalValue(child, FrameworkElement.RenderTransformProperty, FluidMoveBehavior.cacheDuringOverlayProperty); child.RenderTransform = new TranslateTransform(-10000, -10000); canvas.RenderTransform = new TranslateTransform(10000, 10000); // change value here so that the animations will be applied to the image child = rectangle; } // OK, now build the actual animation Rect parentRect = newTagData.ParentRect; Storyboard transitionStoryboard = CreateTransitionStoryboard(child, usingBeforeLoaded, ref parentRect, ref currentRect); // Put this storyboard in the running dictionary so we can detect reentrancy transitionStoryboardDictionary.Add(tag, transitionStoryboard); transitionStoryboard.Completed += delegate(object sender, EventArgs e) { Storyboard currentlyRunningStoryboard; if (transitionStoryboardDictionary.TryGetValue(tag, out currentlyRunningStoryboard) && currentlyRunningStoryboard == transitionStoryboard) { transitionStoryboardDictionary.Remove(tag); transitionStoryboard.Stop(); RemoveTransform(child); child.InvalidateMeasure(); if (overlay != null) { System.Windows.Documents.AdornerLayer.GetAdornerLayer(root).Remove((AdornerContainer)overlay); TransferLocalValue(originalChild, FluidMoveBehavior.cacheDuringOverlayProperty, FrameworkElement.RenderTransformProperty); SetOverlay(originalChild, null); } } }; transitionStoryboard.Begin(); } // Store current tag status tagData.ParentRect = newTagData.ParentRect; tagData.AppRect = newTagData.AppRect; tagData.Parent = newTagData.Parent; tagData.Child = newTagData.Child; tagData.Timestamp = newTagData.Timestamp; }
public override TagDictionary ReadDictionary(TagCompound owner) { TagDictionary results; ITag tag; results = new TagDictionary(owner); tag = this.Read(); while (tag.Type != TagType.End) { results.Add(tag); tag = this.Read(); } return results; }
public void AccessByGroupType() { var sut = new TagDictionary("ident", Tuple.Create(XmlData, TagSource.XmlData)); Assert.AreEqual("SYS", "{{ GDS.myId.IsSys }}".RenderTemplate(sut)); }
public Slider() { TagDictionary.Add(BexisUITagType.input, new Dictionary <string, object>()); addAttribute(BexisUITagType.input, "type", "text"); }
public TagDictionaryTests() { TestObject = new TagDictionary <string, string>(); }
public override void run(string format, string[] args) { base.run(format, args); mlParams = CmdLineUtil.loadTrainingParameters(@params.Params, true); if (mlParams != null && !TrainUtil.isValid(mlParams.Settings)) { throw new TerminateToolException(1, "Training parameters file '" + @params.Params + "' is invalid!"); } if (mlParams == null) { mlParams = ModelUtil.createTrainingParameters(@params.Iterations.Value, @params.Cutoff.Value); mlParams.put(TrainingParameters.ALGORITHM_PARAM, getModelType(@params.Type).ToString()); } File modelOutFile = @params.Model; CmdLineUtil.checkOutputFile("pos tagger model", modelOutFile); Dictionary ngramDict = null; int?ngramCutoff = @params.Ngram; if (ngramCutoff != null) { Console.Error.Write("Building ngram dictionary ... "); try { ngramDict = POSTaggerME.buildNGramDictionary(sampleStream, ngramCutoff.Value); sampleStream.reset(); } catch (IOException e) { throw new TerminateToolException(-1, "IO error while building NGram Dictionary: " + e.Message, e); } Console.Error.WriteLine("done"); } POSTaggerFactory postaggerFactory = null; try { postaggerFactory = POSTaggerFactory.create(@params.Factory, ngramDict, null); } catch (InvalidFormatException e) { throw new TerminateToolException(-1, e.Message, e); } if (@params.Dict != null) { try { postaggerFactory.TagDictionary = postaggerFactory.createTagDictionary(@params.Dict); } catch (IOException e) { throw new TerminateToolException(-1, "IO error while loading POS Dictionary: " + e.Message, e); } } if (@params.TagDictCutoff != null) { try { TagDictionary dict = postaggerFactory.TagDictionary; if (dict == null) { dict = postaggerFactory.createEmptyTagDictionary(); postaggerFactory.TagDictionary = dict; } if (dict is MutableTagDictionary) { POSTaggerME.populatePOSDictionary(sampleStream, (MutableTagDictionary)dict, @params.TagDictCutoff.Value); } else { throw new System.ArgumentException("Can't extend a POSDictionary that does not implement MutableTagDictionary."); } sampleStream.reset(); } catch (IOException e) { throw new TerminateToolException(-1, "IO error while creating/extending POS Dictionary: " + e.Message, e); } } POSModel model; try { model = POSTaggerME.train(@params.Lang, sampleStream, mlParams, postaggerFactory); } catch (IOException e) { throw new TerminateToolException(-1, "IO error while reading training data or indexing data: " + e.Message, e); } finally { try { sampleStream.close(); } catch (IOException) { // sorry that this can fail } } CmdLineUtil.writeModel("pos tagger", modelOutFile, model); }
public void LoadLabelledGroups() { var sut = TagDictionary.FromXml("ident", XmlData); Assert.IsTrue(sut.ContainsKey("GDS")); }
public void PropertyAndLabelWithSameNameThrowException() { Environment.SetEnvironmentVariable("GDS", "This shouldn't be here"); Assert.Throws <InvalidDataException>(() => TagDictionary.FromXml("ident", XmlData)); Environment.SetEnvironmentVariable("GDS", null); }
/// <summary> /// Writes an unnamed tag entry for a <see cref="T:TagDictionary" /> value. /// </summary> /// <param name="value">The <see cref="T:TagDictionary" /> value to write.</param> public void WriteTag(TagDictionary value) { this.WriteTag(string.Empty, value); }
public void LoadFromXmlFileName() { var loader = new TagDictionary("ident", Tuple.Create(XMLFilename, TagSource.XmlFileName)); Assert.AreEqual("SomeUserName", loader["DbUser"]); }
public void AccessFirstInLabel() { var sut = new TagDictionary("ident", Tuple.Create(XmlData, TagSource.XmlData)); Assert.AreEqual("SYS", "{% with GDS|first as instance %}{{ instance.IsSys }}{% endwith %}".RenderTemplate(sut)); }
public void LoadEnvironmentOnlyWithInvalidXMLFile() { var sut = new TagDictionary("ident", Tuple.Create("", TagSource.Environment), Tuple.Create("incorrectStructure.xml", TagSource.XmlFileName)); Assert.AreEqual(EnvClientCode, sut["ClientCode"]); }
public void LoadFlatLabelledGroups() { var sut = new TagDictionary("ident", XmlData); Assert.IsTrue(sut.ContainsKey("FlatGroup")); }
public void IdValueTakesPrecidenceEvenFromLaterSource() { var loader = new TagDictionary("myId", Tuple.Create(XmlData, TagSource.XmlData), Tuple.Create("structure.xml", TagSource.XmlFileName)); Assert.AreEqual(Idvalue, loader[Avalue]); }
public override string ToString() { return(string.Format("({0},{1}) : {2}", Group, Element, TagDictionary.GetDescription(this))); }
public void DbPasswordAccessibleViaDictionaryWithoutPrefix() { var sut = new TagDictionary("myId", Tuple.Create(XmlData, TagSource.XmlData), Tuple.Create("structure.xml", TagSource.XmlFileName)); Assert.AreEqual("Some high entrophy random text", sut.DbLogins["AUDIT"].Password); }
public void LoadEnvironmentOnlyWithInvalidXML() { var sut = TagDictionary.FromXml("ident", "ThisIsNotXML"); Assert.AreEqual(EnvClientCode, sut["ClientCode"]); }
public void TestTagsInPropertiesAreSubstituted(string expected, string key) { var tagDict = new TagDictionary("myId", Tuple.Create(XmlData, TagSource.XmlData), Tuple.Create("structure.xml", TagSource.XmlFileName)); Assert.IsTrue(tagDict[key].ToString().Contains(expected)); }
public void DbLoginsGenerated() { var sut = TagDictionary.FromXml("ident", XmlData); Assert.AreEqual("This isn't a password either", GetDbLoginValue(sut, "config", "Password")); }
public void SuccessfullyGetDbPassword() { var loader = new TagDictionary("ident", Tuple.Create(XMLFilename, TagSource.XmlFileName)); Assert.AreEqual("NoPasswordsRoundHere", loader.GetDbPassword("config")); }
public void DbLoginDefaultDbsAreSubstituted() { var sut = TagDictionary.FromXml("ident", XmlData); Assert.AreEqual("FAA-LOC-AUDIT", GetDbLoginValue(sut, "AUDIT", "DefaultDb")); }
public void DbLoginsGenerated() { var sut = new TagDictionary("ident", XmlData); Assert.AreEqual("This isn't a password either", sut.DbLogins.Values.First(login => login.Username == "config").Password); }
public void ValueTest() { // arrange TagCompound target; TagDictionary expected; target = new TagCompound(); expected = new TagDictionary(); // act target.Value = expected; // assert Assert.AreEqual(expected, target.Value); Assert.AreSame(target, expected.Owner); }
public void DbLoginNamesAreSubstituted() { var sut = new TagDictionary("ident", XmlData); Assert.IsTrue(sut.DbLogins.Values.Select(login => login.Username).Contains(string.Format("{0}-{1}-AUDIT", Environment.GetEnvironmentVariable("ClientCode"), Environment.GetEnvironmentVariable("Environment")))); }
public virtual void Write(TagDictionary value) { foreach (ITag item in value) this.Write(item, NbtOptions.Header); this.WriteEnd(); }
public void DbLoginDefaultDbsAreSubstituted() { var sut = new TagDictionary("ident", XmlData); Assert.IsTrue(sut.DbLogins.Values.Select(login => login.DefaultDb).Contains("FAA-LOC-AUDIT")); }
public void ForLoopWorks() { var sut = new TagDictionary("ident", Tuple.Create(XmlData, TagSource.XmlData)); Assert.AreEqual("myIdmyId2", "{% for instance in GDS %}{{ instance.identity }}{% endfor %}".RenderTemplate(sut)); }
public virtual TagDictionary ReadDictionary(TagCompound owner) { TagDictionary value; value = new TagDictionary(owner); _reader.Read(); this.ReadChildValues(value, ReadTagOptions.None, TagType.None); return value; }