Beispiel #1
0
        public void Configuration_CanAdd_Editable_ToDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement {
                Name = "DefinitionTextPage"
            };

            definitionElement.Containers.Add(new ContainableElement {
                Name = "X", Type = typeof(EditableCheckBoxAttribute).AssemblyQualifiedName
            });
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions        = builder.GetDefinitions();
            var textPageDefinition = definitions
                                     .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                              .Where(e => e.GetType() == typeof(EditableCheckBoxAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(1));
        }
Beispiel #2
0
        public void Configuration_CanAdd_Editable_ToExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection {
                DefineUnattributedTypes = true
            };

            definitionCollection.Add(new DefinitionElement
            {
                Name      = "DefinitionTextPage",
                Editables = new ContainableCollection {
                    new ContainableElement {
                        Name  = "MetaTitle",
                        Title = "Page title",
                        Type  = typeof(N2.Details.EditableTextAttribute).AssemblyQualifiedName
                    }
                }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase <IUniquelyNamed> [0], new EngineSection {
                Definitions = definitionCollection
            });

            var definitions    = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Name == "MetaTitle"));
        }
Beispiel #3
0
        public void Configuration_CanChange_Editable_OnExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(new DefinitionElement
            {
                Name      = "DefinitionTextPage",
                Editables = new ContainableCollection {
                    new ContainableElement {
                        Name  = "Title",
                        Title = "Page title in navigation",
                        Type  = typeof(EditableTextAttribute).AssemblyQualifiedName
                    }
                }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions    = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Title == "Page title in navigation" && e.GetType() == typeof(EditableTextAttribute)));
            Assert.That(textDefinition.Editables.Any(e => e.Title == "Title" || e.GetType() == typeof(WithEditableTitleAttribute)), Is.False);
        }
Beispiel #4
0
        private static void LoadDff()
        {
            using (new Timing("Loading DFFs into scene"))
                using (new MemoryCounter()) {
                    var itemDefinitions   = new DefinitionCollection();
                    var modelCollection   = new ModelCollection();
                    var textureCollection = new TextureCollection(true);

                    foreach (var obj in Selection.objects)
                    {
                        var objPath = AssetDatabase.GetAssetPath(obj);

                        if (objPath.EndsWith(".dff", StringComparison.OrdinalIgnoreCase))
                        {
                            var dff = new DffFile(objPath);

                            modelCollection.Add(dff);
                            itemDefinitions.Add(new ItemDefinition(dff.FileNameWithoutExtension));
                        }
                        else if (objPath.EndsWith(".txd", StringComparison.OrdinalIgnoreCase))
                        {
                            textureCollection.Add(new TxdFile(objPath));
                        }
                    }

                    using (new Loader(itemDefinitions, modelCollection, textureCollection))
                        foreach (var definition in itemDefinitions)
                        {
                            definition.GetObject(true);
                        }
                }
        }
Beispiel #5
0
        public void Configuration_CanRemove_Editable_FromDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement {
                Name = "DefinitionTextPage"
            };

            definitionElement.Containers.Remove(new ContainableElement {
                Name = "Text"
            });
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions        = builder.GetDefinitions();
            var textPageDefinition = definitions
                                     .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                              .Where(e => e.GetType() == typeof(EditableFreeTextAreaAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(0));
        }
Beispiel #6
0
        private void SetupVoid()
        {
            Definition definition = new Definition(new NowhereLocation(), new Set <string>(), new Modifiers(new NowhereLocation()));

            definition.SetName(new Identifier(new NowhereLocation(), "void"));
            definition.Complete();
            store.Add(definition);
        }
        public void Configuration_CanAdd_Definition()
        {
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(new DefinitionElement { Name = "DefinitionUndefined", Type = typeof(DefinitionUndefined).AssemblyQualifiedName });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var undefinedDefinition = definitions
                .Single(d => d.ItemType == typeof(DefinitionUndefined));

            Assert.That(undefinedDefinition.IsDefined, Is.True);
        }
        /// <summary>
        /// This is an internal helper which looks up a term/expression, parses it and
        /// returns as a list for convenience.
        /// </summary>
        private DefinitionCollection InternalGetDefinitions(string text, string database)
        {
            if (database == null || database.Length == 0)
            {
                database = "*";
            }

            string command = string.Concat("DEFINE ", database, " \"", text, "\"");

            string[]             responses      = reDefinitions.Split(ExecuteCommand(command));
            DefinitionCollection definitionList = new DefinitionCollection();


            for (int i = 0; i < responses.Length; i++)
            {
                // Split occasionally produces empty strings
                if (responses[i].Trim().Length == 0)
                {
                    continue;
                }

                StringReader rdr = new StringReader(responses[i]);

                try
                {
                    string statusLine = rdr.ReadLine();

                    // --------------------------------------------------------------------------
                    // The status line would look similar to this:
                    // "Shortcake" web1913 "Webster's Revised Unabridged Dictionary (1913)"
                    //
                    // We need to pull out the dictionary name where it was found.
                    // --------------------------------------------------------------------------
                    Match  m = reDatabase.Match(statusLine);
                    string dbName = null, dbDescription = null;
                    string termDescription = null;

                    dbName          = m.Groups[1].Value;
                    dbDescription   = m.Groups[2].Value;
                    termDescription = rdr.ReadToEnd().ToString();

                    definitionList.Add(new Definition(termDescription, new Database(dbName, dbDescription)));
                }
                finally
                {
                    rdr.Close();
                }
            }

            return(definitionList);
        }
Beispiel #9
0
        public void Configuration_CanAdd_Definition()
        {
            var definitionCollection = new DefinitionCollection();

            definitionCollection.Add(new DefinitionElement {
                Name = "DefinitionUndefined", Type = typeof(DefinitionUndefined).AssemblyQualifiedName
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection {
                Definitions = definitionCollection
            });

            var definitions         = builder.GetDefinitions();
            var undefinedDefinition = definitions
                                      .Single(d => d.ItemType == typeof(DefinitionUndefined));

            Assert.That(undefinedDefinition.IsDefined, Is.True);
        }
        public void Configuration_CanAdd_Editable_ToDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement { Name = "DefinitionTextPage" };
            definitionElement.Containers.Add(new ContainableElement { Name = "X", Type = typeof(EditableCheckBoxAttribute).AssemblyQualifiedName });
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textPageDefinition = definitions
                .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                .Where(e => e.GetType() == typeof(EditableCheckBoxAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(1));
        }
        public void Configuration_CanAdd_Editable_ToExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(new DefinitionElement
            {
                Name = "DefinitionTextPage",
                Editables = new ContainableCollection { new ContainableElement {
                    Name = "MetaTitle",
                    Title = "Page title",
                    Type = typeof(N2.Details.EditableTextAttribute).AssemblyQualifiedName } }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Name == "MetaTitle"));
        }
        public void Configuration_CanRemove_Editable_FromDefinition()
        {
            DefinitionElement definitionElement = new DefinitionElement { Name = "DefinitionTextPage" };
            definitionElement.Containers.Remove(new ContainableElement { Name = "Text" });
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(definitionElement);

            DefinitionBuilder builder = new DefinitionBuilder(typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textPageDefinition = definitions
                .Single(d => d.ItemType == typeof(DefinitionTextPage));

            var textEditors = textPageDefinition.Editables
                .Where(e => e.GetType() == typeof(EditableFreeTextAreaAttribute));

            Assert.That(textEditors.Count(), Is.EqualTo(0));
        }
        public void Configuration_CanChange_Editable_OnExistingDefinition()
        {
            var definitionCollection = new DefinitionCollection();
            definitionCollection.Add(new DefinitionElement
            {
                Name = "DefinitionTextPage",
                Editables = new ContainableCollection { new ContainableElement {
                    Name = "Title",
                    Title = "Page title in navigation",
                    Type = typeof(EditableTextAttribute).AssemblyQualifiedName } }
            });
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection { Definitions = definitionCollection });

            var definitions = builder.GetDefinitions();
            var textDefinition = definitions.Single(d => d.ItemType == typeof(DefinitionTextPage));

            Assert.That(textDefinition.Editables.Any(e => e.Title == "Page title in navigation" && e.GetType() == typeof(EditableTextAttribute)));
            Assert.That(textDefinition.Editables.Any(e => e.Title == "Title" || e.GetType() == typeof(WithEditableTitleAttribute)), Is.False);
        }
Beispiel #14
0
 public void AddGlobalFromAnywhere(Definition def)
 {
     _anywhereGlobalDefs.Add(def);
 }
        /// <summary>
        /// This is an internal helper which looks up a term/expression, parses it and 
        /// returns as a list for convenience.
        /// </summary>
        private DefinitionCollection InternalGetDefinitions(string text, string database)
        {
            if (database == null || database.Length == 0)
                database = "*";

            string                  command = string.Concat ("DEFINE ", database, " \"", text, "\"");
            string[]                responses = reDefinitions.Split(ExecuteCommand (command));
            DefinitionCollection    definitionList = new DefinitionCollection ();

            for (int i=0; i<responses.Length; i++)
            {
                // Split occasionally produces empty strings
                if (responses[i].Trim().Length == 0)
                    continue;

                StringReader rdr = new StringReader (responses[i]);

                try
                {
                    string statusLine = rdr.ReadLine ();

                    // --------------------------------------------------------------------------
                    // The status line would look similar to this:
                    // "Shortcake" web1913 "Webster's Revised Unabridged Dictionary (1913)"
                    //
                    // We need to pull out the dictionary name where it was found.
                    // --------------------------------------------------------------------------
                    Match       m = reDatabase.Match (statusLine);
                    string      dbName = null, dbDescription = null;
                    string      termDescription = null;

                    dbName              = m.Groups[1].Value;
                    dbDescription       = m.Groups[2].Value;
                    termDescription     = rdr.ReadToEnd ().ToString ();

                    definitionList.Add (new Definition (termDescription, new Database (dbName, dbDescription)));
                }
                finally
                {
                    rdr.Close ();
                }
            }

            return definitionList;
        }
Beispiel #16
0
 public void AddDefinition(Definition def)
 {
     _defs.Add(def);
 }
Beispiel #17
0
 public void AddGlobalFromFile(Definition def)
 {
     _fileGlobalDefs.Add(def);
 }