コード例 #1
0
 protected virtual void WriteValue(TagDictionary value)
 {
   foreach (ITag item in value)
   {
     this.WriteTag(item, WriteTagOptions.None);
   }
 }
コード例 #2
0
ファイル: XmlTagReader.cs プロジェクト: Craiel/CarbonProjects
        public override TagDictionary ReadDictionary(TagCompound owner)
        {
            TagDictionary value;

              value = new TagDictionary(owner);

              this.LoadChildren(value, this.Options, TagType.None);

              return value;
        }
コード例 #3
0
ファイル: TagsManager.cs プロジェクト: higankanshi/xZune.Bass
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
        public void DbLoginConnectionStringLoaded()
        {
            var sut = TagDictionary.FromXml("ident", XmlData);

            Assert.AreEqual("Actual ConnectionString", GetDbLoginValue(sut, "ConnectionString", "ConnectionString"));
        }
コード例 #7
0
 public void LoadEmptyXmlData()
 {
     Assert.DoesNotThrow(() => TagDictionary.FromSources("ident", new Dictionary <TagSource, string> {
         { TagSource.XmlData, "" }
     }));
 }
コード例 #8
0
        public void TestDefaultLoader(string expected, string key)
        {
            var loader = TagDictionary.FromXml("myId", XmlData);

            Assert.AreEqual(expected, loader[key]);
        }
コード例 #9
0
        public void LoadFromEnvironment()
        {
            var loader = new TagDictionary("ident", Tuple.Create("", TagSource.Environment));

            Assert.AreEqual(IsSys, loader[IsSys]);
        }
コード例 #10
0
        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;
        }
コード例 #11
0
    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;
    }
コード例 #12
0
        public void AccessByGroupType()
        {
            var sut = new TagDictionary("ident", Tuple.Create(XmlData, TagSource.XmlData));

            Assert.AreEqual("SYS", "{{ GDS.myId.IsSys }}".RenderTemplate(sut));
        }
コード例 #13
0
ファイル: BexisUIHelper.cs プロジェクト: payamad/Core
 public Slider()
 {
     TagDictionary.Add(BexisUITagType.input, new Dictionary <string, object>());
     addAttribute(BexisUITagType.input, "type", "text");
 }
コード例 #14
0
 public TagDictionaryTests()
 {
     TestObject = new TagDictionary <string, string>();
 }
コード例 #15
0
        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);
        }
コード例 #16
0
        public void LoadLabelledGroups()
        {
            var sut = TagDictionary.FromXml("ident", XmlData);

            Assert.IsTrue(sut.ContainsKey("GDS"));
        }
コード例 #17
0
 public void PropertyAndLabelWithSameNameThrowException()
 {
     Environment.SetEnvironmentVariable("GDS", "This shouldn't be here");
     Assert.Throws <InvalidDataException>(() => TagDictionary.FromXml("ident", XmlData));
     Environment.SetEnvironmentVariable("GDS", null);
 }
コード例 #18
0
 /// <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);
 }
コード例 #19
0
        public void LoadFromXmlFileName()
        {
            var loader = new TagDictionary("ident", Tuple.Create(XMLFilename, TagSource.XmlFileName));

            Assert.AreEqual("SomeUserName", loader["DbUser"]);
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        public void LoadEnvironmentOnlyWithInvalidXMLFile()
        {
            var sut = new TagDictionary("ident", Tuple.Create("", TagSource.Environment), Tuple.Create("incorrectStructure.xml", TagSource.XmlFileName));

            Assert.AreEqual(EnvClientCode, sut["ClientCode"]);
        }
コード例 #22
0
        public void LoadFlatLabelledGroups()
        {
            var sut = new TagDictionary("ident", XmlData);

            Assert.IsTrue(sut.ContainsKey("FlatGroup"));
        }
コード例 #23
0
        public void IdValueTakesPrecidenceEvenFromLaterSource()
        {
            var loader = new TagDictionary("myId", Tuple.Create(XmlData, TagSource.XmlData), Tuple.Create("structure.xml", TagSource.XmlFileName));

            Assert.AreEqual(Idvalue, loader[Avalue]);
        }
コード例 #24
0
ファイル: Tag.cs プロジェクト: zzti/Evil-DICOM
 public override string ToString()
 {
     return(string.Format("({0},{1}) : {2}", Group, Element, TagDictionary.GetDescription(this)));
 }
コード例 #25
0
        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);
        }
コード例 #26
0
        public void LoadEnvironmentOnlyWithInvalidXML()
        {
            var sut = TagDictionary.FromXml("ident", "ThisIsNotXML");

            Assert.AreEqual(EnvClientCode, sut["ClientCode"]);
        }
コード例 #27
0
        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));
        }
コード例 #28
0
        public void DbLoginsGenerated()
        {
            var sut = TagDictionary.FromXml("ident", XmlData);

            Assert.AreEqual("This isn't a password either", GetDbLoginValue(sut, "config", "Password"));
        }
コード例 #29
0
        public void SuccessfullyGetDbPassword()
        {
            var loader = new TagDictionary("ident", Tuple.Create(XMLFilename, TagSource.XmlFileName));

            Assert.AreEqual("NoPasswordsRoundHere", loader.GetDbPassword("config"));
        }
コード例 #30
0
        public void DbLoginDefaultDbsAreSubstituted()
        {
            var sut = TagDictionary.FromXml("ident", XmlData);

            Assert.AreEqual("FAA-LOC-AUDIT", GetDbLoginValue(sut, "AUDIT", "DefaultDb"));
        }
コード例 #31
0
        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);
        }
コード例 #32
0
    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);
    }
コード例 #33
0
        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"))));
        }
コード例 #34
0
    public virtual void Write(TagDictionary value)
    {
      foreach (ITag item in value)
        this.Write(item, NbtOptions.Header);

      this.WriteEnd();
    }
コード例 #35
0
        public void DbLoginDefaultDbsAreSubstituted()
        {
            var sut = new TagDictionary("ident", XmlData);

            Assert.IsTrue(sut.DbLogins.Values.Select(login => login.DefaultDb).Contains("FAA-LOC-AUDIT"));
        }
コード例 #36
0
        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));
        }
コード例 #37
0
    public virtual TagDictionary ReadDictionary(TagCompound owner)
    {
      TagDictionary value;

      value = new TagDictionary(owner);

      _reader.Read();

      this.ReadChildValues(value, ReadTagOptions.None, TagType.None);

      return value;
    }