예제 #1
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Button        editButton = (Button)sender;
            GlossaryEntry entry      = (GlossaryEntry)editButton.DataContext;

            ViewModel.DeleteEntry(entry);
        }
예제 #2
0
        public void CreateNewEntry()
        {
            GlossaryEntry entry = new GlossaryEntry();

            ctx.GlossaryEntries.Add(entry);
            CurrentEntry = entry;
        }
예제 #3
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            Button        editButton = (Button)sender;
            GlossaryEntry entry      = (GlossaryEntry)editButton.DataContext;

            ViewModel.EditEntry(entry);
            SwivelToBackStoryboard.Begin();
        }
예제 #4
0
 public void DeleteGlossaryEntry(GlossaryEntry glossaryEntry)
 {
     if ((glossaryEntry.EntityState == EntityState.Detached))
     {
         this.ObjectContext.GlossaryEntries.Attach(glossaryEntry);
     }
     this.ObjectContext.GlossaryEntries.DeleteObject(glossaryEntry);
 }
예제 #5
0
        /// <summary>
        /// Demonstrates how to store <see cref="Glossary"/> data in a <see cref="Unit"/> element.
        /// </summary>
        public static void StoreGlossary()
        {
            GlossaryEntry entry;
            MarkedSpan    span;
            Segment       segment;
            Translation   translation;
            Unit          unit;

            // Create a unit to hold the glossary.
            unit            = new Unit("id");
            unit.Glossary   = new Glossary();
            entry           = new GlossaryEntry();
            entry.Reference = "#m1";
            unit.Glossary.Entries.Add(entry);

            // Create a term that looks like: <gls:term source="publicTermbase">TAB key</gls:term>
            entry.Term.Source = "publicTermbase";
            entry.Term.Text   = "TAB key";

            // Create a translation that looks like: <gls:translation id="1" source="myTermbase">Tabstopptaste</gls:translation>
            translation        = new Translation("1");
            translation.Source = "myTermbase";
            translation.Text   = "Tabstopptaste";
            entry.Translations.Add(translation);

            // Create a translation that looks like: <gls:translation ref="#m2" source="myTermbase">TAB-TASTE</gls:translation>
            translation           = new Translation();
            translation.Reference = "#m1";
            translation.Source    = "myTermbase";
            translation.Text      = "TAB-TASTE";
            entry.Translations.Add(translation);

            // Create a definition that looks like:
            //  <gls:definition source="publicTermbase">A keyboard key that is traditionally used to insert tab"
            //      characters into a document.</gls:definition>
            entry.Definition        = new Definition();
            entry.Definition.Source = "publicTermbase";
            entry.Definition.Text   = "A keyboard key that is traditionally used to insert tab characters into a document.";

            // Create a segment to which the glossary refers.
            segment        = new Segment();
            segment.Source = new Source();
            segment.Source.Text.Add(new PlainText("Press the "));
            span      = new MarkedSpan("m1");
            span.Type = "term";
            span.Text.Add(new PlainText("TAB key"));
            segment.Source.Text.Add(span);

            segment.Target = new Target();
            segment.Target.Text.Add(new PlainText("Drücken Sie die "));
            span      = new MarkedSpan("m1");
            span.Type = "term";
            span.Text.Add(new PlainText("TAB-TASTE"));
            segment.Target.Text.Add(span);

            unit.Resources.Add(segment);
        }
예제 #6
0
 public void InsertGlossaryEntry(GlossaryEntry glossaryEntry)
 {
     if ((glossaryEntry.EntityState != EntityState.Detached))
     {
         this.ObjectContext.ObjectStateManager.ChangeObjectState(glossaryEntry, EntityState.Added);
     }
     else
     {
         this.ObjectContext.GlossaryEntries.AddObject(glossaryEntry);
     }
 }
        public void GlossaryDefaultValue_GlossaryEntry()
        {
            GlossaryEntry entry;

            entry = new GlossaryEntry();
            Assert.IsNull(entry.Definition, "Definition is incorrect.");
            Assert.IsNull(entry.Id, "Id is incorrect.");
            Assert.IsNull(entry.Reference, "Reference is incorrect.");
            Assert.IsNotNull(entry.Term, "Term is incorrect.");
            Assert.AreEqual(0, entry.Translations.Count, "Translations count is incorrect.");

            entry = new GlossaryEntry("id");
            Assert.IsNull(entry.Definition, "Definition is incorrect.");
            Assert.AreEqual("id", entry.Id, "Id is incorrect.");
            Assert.IsNull(entry.Reference, "Reference is incorrect.");
            Assert.IsNotNull(entry.Term, "Term is incorrect.");
            Assert.AreEqual(0, entry.Translations.Count, "Translations count is incorrect.");
        }
 public void TestInitialize()
 {
     this.element  = new GlossaryEntry();
     this.provider = this.element;
 }
예제 #9
0
 public void EditEntry(GlossaryEntry entry)
 {
     CurrentEntry = entry;
 }
예제 #10
0
 public void DeleteEntry(GlossaryEntry entry)
 {
     ctx.GlossaryEntries.Remove(entry);
     ctx.SubmitChanges(DeleteCallback, null);
 }
예제 #11
0
 public void UpdateGlossaryEntry(GlossaryEntry currentGlossaryEntry)
 {
     this.ObjectContext.GlossaryEntries.AttachAsModified(currentGlossaryEntry, this.ChangeSet.GetOriginal(currentGlossaryEntry));
 }
예제 #12
0
        public void RoundtripExample4()
        {
            var u1 = new Unit("u1");

            var te1 = new TextElement("Press the ");
            var te2 = new SmElement("m1");
            var te3 = new TextElement("TAB key");
            var te4 = new EmElement();
            var te5 = new TextElement(".");

            var te6  = new TextElement("Drücken Sie die ");
            var te7  = new SmElement("m2");
            var te8  = new TextElement("TAB-TASTE");
            var te9  = new EcElement();
            var te10 = new TextElement(".");

            var s1 = new Segment();

            s1.Source.Add(te1);
            s1.Source.Add(te2);
            s1.Source.Add(te3);
            s1.Source.Add(te4);
            s1.Source.Add(te5);
            s1.Target.Add(te6);
            s1.Target.Add(te7);
            s1.Target.Add(te8);
            s1.Target.Add(te9);
            s1.Target.Add(te10);

            var unit1 = new Unit("u1");

            unit1.Subunits.Add(s1);

            var gloss = new GlossaryEntry();
            var def   = new Definition();

            def.Source       = "publicTermbase";
            def.Text         = "A keyboard key that is traditionally used to insert tab characters into a document.";
            gloss.Definition = def;


            var t1 = new Translation("1", "myTermbase", "Tabstopptaste");
            var t2 = new Translation("2", "myTermbase", "TAB-TASTE");

            gloss.Translations.Add(t1);
            gloss.Translations.Add(t2);

            unit1.Glossary.Add(gloss);

            var model = new JliffDocument("en", "de");

            model.Files.Add(new Localization.Jliff.Graph.File("f1"));
            model.Files[0].Subfiles = new List <ISubfile>
            {
                unit1
            };

            var dllPath    = Assembly.GetAssembly(typeof(ModelTests)).Location;
            var dllName    = Assembly.GetAssembly(typeof(ModelTests)).GetName().Name;
            var outputPath = dllPath.Replace(dllName + ".dll", "");


            Converter.Serialize(Path.Combine(outputPath, "example4.json"), model);

            Converter.Deserialize(new FileInfo(Path.Combine(outputPath, "example4.json")));

            JsonSchema schema  = JsonSchema.Parse(schemaDef);
            var        obGraph = JObject.FromObject(model);

            Assert.IsTrue(obGraph.IsValid(schema));
        }