Esempio n. 1
0
        /// <summary>
        /// Searches the entire area within control of the country and finds the closest
        /// and highest priority job for this worker.
        /// </summary>
        /// <returns>A <see cref="WorkerActionInfo"/> object with information regarding
        /// the location and type of work to perform.  For more inforation, see the
        /// <see cref="WorkerActionInfo"/> object.</returns>
        protected virtual WorkerActionInfo FindCellToImprove()
        {
            City             next        = this.parentCity;
            GameRoot         root        = GameRoot.Instance;
            GridCell         currentCell = root.Grid.GetCell(this.Coordinates);
            WorkerActionInfo info        = new WorkerActionInfo(WorkerAction.None, currentCell);

            if (next == null)
            {
                next = currentCell.FindClosestDomesticCity(ParentCountry);
            }
            else
            {
                NamedObjectCollection <City> exceptions = new NamedObjectCollection <City>();
                bool found = false;
                while (!found)
                {
                    info = next.RetrieveWorkItem();
                    if (info.WorkerAction != WorkerAction.None)
                    {
                        found = true;
                        break;
                    }
                    else
                    {
                        exceptions.Add(next);
                    }

                    next = currentCell.FindClosestDomesticCity(ParentCountry, exceptions);
                }
            }

            return(info);
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Theme"/> class.
 /// </summary>
 public Theme()
 {
     Cursors = new NamedObjectCollection<ThemeCursor>();
       Fonts = new NamedObjectCollection<ThemeFont>();
       Textures = new NamedObjectCollection<ThemeTexture>();
       Styles = new NamedObjectCollection<ThemeStyle>();
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Theme"/> class.
 /// </summary>
 public Theme()
 {
     Cursors  = new NamedObjectCollection <ThemeCursor>();
     Fonts    = new NamedObjectCollection <ThemeFont>();
     Textures = new NamedObjectCollection <ThemeTexture>();
     Styles   = new NamedObjectCollection <ThemeStyle>();
 }
Esempio n. 4
0
        protected ShaderIntelliSense()
        {
            EffectStateValues  = new NamedObjectCollection <NamedCompletionData>();
            SamplerStates10    = new NamedObjectCollection <NamedCompletionData>();
            SamplerStates      = new NamedObjectCollection <NamedCompletionData>();
            RasterizerStates   = new NamedObjectCollection <NamedCompletionData>();
            DepthStencilStates = new NamedObjectCollection <NamedCompletionData>();
            BlendStates        = new NamedObjectCollection <NamedCompletionData>();
            EffectStates       = new NamedObjectCollection <NamedCompletionData>();
            EffectFunctions    = new NamedObjectCollection <NamedCompletionData>();
            Methods            = new NamedObjectCollection <NamedCompletionData>();
            Functions          = new NamedObjectCollection <NamedCompletionData>();
            Macros             = new NamedObjectCollection <NamedCompletionData>();
            Constants          = new List <NamedCompletionData>();
            EffectTypes        = new NamedObjectCollection <NamedCompletionData>();
            SpecialTypes       = new NamedObjectCollection <NamedCompletionData>();
            ScalarTypes        = new NamedObjectCollection <NamedCompletionData>();
            Types    = new NamedObjectCollection <NamedCompletionData>();
            Keywords = new NamedObjectCollection <NamedCompletionData>();
            PreprocessorDirectives = new List <NamedCompletionData>();
            Snippets = new Dictionary <string, SnippetCompletionData>();

            // Initialize IntelliSense info that is identical in HLSL and Cg here.
            InitializeSnippets();
            InitializePreprocessorDirectives();
            InitializeKeywords();
            InitializeTypes();
            InitializeConstants();

            // Create shader parser
            _parser = new ShaderParser(this);
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GridCell"/> class.
 /// </summary>
 public GridCell()
 {
     exploredCountries = new NamedObjectCollection <CountryBase>();
     InitializeUnitCollection();
     this.roadLayout  = GridCellItemDirection.None;
     this.riverLayout = GridCellItemDirection.None;
 }
Esempio n. 6
0
        //--------------------------------------------------------------
        protected ShaderIntelliSense()
        {
            EffectStateValues = new NamedObjectCollection<NamedCompletionData>();
            SamplerStates10 = new NamedObjectCollection<NamedCompletionData>();
            SamplerStates = new NamedObjectCollection<NamedCompletionData>();
            RasterizerStates = new NamedObjectCollection<NamedCompletionData>();
            DepthStencilStates = new NamedObjectCollection<NamedCompletionData>();
            BlendStates = new NamedObjectCollection<NamedCompletionData>();
            EffectStates = new NamedObjectCollection<NamedCompletionData>();
            EffectFunctions = new NamedObjectCollection<NamedCompletionData>();
            Methods = new NamedObjectCollection<NamedCompletionData>();
            Functions = new NamedObjectCollection<NamedCompletionData>();
            Macros = new NamedObjectCollection<NamedCompletionData>();
            Constants = new List<NamedCompletionData>();
            EffectTypes = new NamedObjectCollection<NamedCompletionData>();
            SpecialTypes = new NamedObjectCollection<NamedCompletionData>();
            ScalarTypes = new NamedObjectCollection<NamedCompletionData>();
            Types = new NamedObjectCollection<NamedCompletionData>();
            Keywords = new NamedObjectCollection<NamedCompletionData>();
            PreprocessorDirectives = new List<NamedCompletionData>();
            Snippets = new Dictionary<string, SnippetCompletionData>();

            // Initialize IntelliSense info that is identical in HLSL and Cg here.
            InitializeSnippets();
            InitializePreprocessorDirectives();
            InitializeKeywords();
            InitializeTypes();
            InitializeConstants();

            // Create shader parser
            _parser = new ShaderParser(this);
        }
        public void TestConstructorWithComparer()
        {
            var collection = new NamedObjectCollection <NamedTestObject>(StringComparer.InvariantCultureIgnoreCase);

            collection.Add(new NamedTestObject("foo1", 1));
            Assert.IsTrue(collection.Contains("FOO1"));
        }
Esempio n. 8
0
        public void ExceptionTest()
        {
            NamedObjectCollection <NamedTestObject> collection = new NamedObjectCollection <NamedTestObject>();

            collection.Add(new NamedTestObject("foo1", 1));
            collection.Add(new NamedTestObject("foo1", 2));
        }
Esempio n. 9
0
        private NamedObjectCollection <Field> ConvertToLowerInvariant(NamedObjectCollection <Field> columnNames)
        {
            if (columnNames != null)
            {
                NamedObjectCollection <Field> columnNamesInLower = new NamedObjectCollection <Field>();
                columnNamesInLower = columnNames;

                int         selectedIndex = 1;
                DataRowView item;
                string[]    selectedViewFields = new string[lbxFields.SelectedItems.Count + 1];
                selectedViewFields[0] = fieldName;
                for (int i = 0; i < lbxFields.Items.Count; i++)
                {
                    item = (DataRowView)lbxFields.Items[i];
                    if (lbxFields.GetSelected(i))
                    {
                        selectedViewFields[selectedIndex] = item[lbxFields.DisplayMember].ToString();
                        DataRow selectRow = item.Row;
                        selectedFields.Add(page.GetView().GetFieldById(int.Parse((selectRow[ColumnNames.FIELD_ID].ToString()))));
                        selectedIndex++;
                    }
                }
                return(columnNamesInLower);
            }
            return(columnNames);
        }
        public void ExceptionTest()
        {
            NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();

              collection.Add(new NamedTestObject("foo1", 1));
              collection.Add(new NamedTestObject("foo1", 2));
        }
Esempio n. 11
0
        /// <summary>
        /// Determines whether or not the <see cref="Worker"/> can build a railroad on the current
        /// square.
        /// </summary>
        /// <returns></returns>
        public bool CanBuildRailroad()
        {
            GameRoot root        = GameRoot.Instance;
            GridCell currentCell = root.Grid.GetCell(this.Coordinates);
            NamedObjectCollection <Resource> resources = root.Ruleset.Resources;
            bool hasResources = true;

            foreach (Resource resource in resources)
            {
                if (resource.RailroadPrerequisite)
                {
                    foreach (City city in this.ParentCountry.Cities)
                    {
                        if (!city.HasAccessToResource(resource))
                        {
                            hasResources = false;
                            break;
                        }
                    }
                }
            }

            if (hasResources)
            {
                //if the resources are available, we can build as long
                //as there is already a road here.
                return(currentCell.HasRoad);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
        public void TryGetValueTest()
        {
            NamedObjectCollection <NamedTestObject> collection = new NamedObjectCollection <NamedTestObject>();

            collection.Add(new NamedTestObject("foo1", 1));
            collection.Add(new NamedTestObject("foo2", 2));

            NamedTestObject namedObject;

            Assert.IsTrue(collection.TryGet("foo2", out namedObject));
            Assert.AreEqual(2, namedObject.Value);

            Assert.IsFalse(collection.TryGet("not existing", out namedObject));
            Assert.IsNull(namedObject);

            // Test with other comparer and without internal Dictionary.
            collection = new NamedObjectCollection <NamedTestObject>(StringComparer.InvariantCultureIgnoreCase, 5);
            Assert.IsFalse(collection.TryGet("notExisting", out namedObject));

            collection.Add(new NamedTestObject("foo1", 1));
            collection.Add(new NamedTestObject("foo2", 2));
            Assert.IsTrue(collection.TryGet("foo2", out namedObject));
            Assert.AreEqual(2, namedObject.Value);
            Assert.IsFalse(collection.TryGet("notExisting", out namedObject));
        }
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="page">The current page</param>
 public CodesFieldDefinition(MainForm frm, Page page)
     : base(frm)
 {
     InitializeComponent();
     this.mode      = FormMode.Create;
     this.page      = page;
     selectedFields = new NamedObjectCollection <Field>();
 }
Esempio n. 14
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="page">The current page</param>
 public CodesFieldDefinition(MainForm frm, Page page)
     : base(frm)
 {
     InitializeComponent();
     this.mode = FormMode.Create;
     this.page = page;
     selectedFields = new NamedObjectCollection<Field>();
 }
Esempio n. 15
0
        /// <summary>
        /// Handles the click event for the "..." data source button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void btnDataSource_Click(object sender, EventArgs e)
        {
            if (ValidateToAddDataSource())
            {
                NamedObjectCollection <Field> columnNamesInLower = new NamedObjectCollection <Field>();
                int         selectedIndex = 1;
                DataRowView item;
                string[]    selectedViewFields = new string[lbxLinkedFields.SelectedItems.Count + 1];
                selectedViewFields[0] = field.Name;
                for (int i = 0; i < lbxLinkedFields.Items.Count; i++)
                {
                    item = (DataRowView)lbxLinkedFields.Items[i];
                    if (lbxLinkedFields.GetSelected(i))
                    {
                        selectedViewFields[selectedIndex] = item[lbxLinkedFields.DisplayMember].ToString();
                        DataRow selectRow       = item.Row;
                        string  fieldColumnName = (selectRow[ColumnNames.NAME].ToString());
                        string  fieldStringID   = (selectRow[ColumnNames.FIELD_ID].ToString());
                        if (DoesFieldNameExistInCollection(fieldColumnName, selectedFields) == false)
                        {
                            selectedFields.Add(page.GetView().GetFieldById(int.Parse(fieldStringID)));
                        }
                        selectedIndex++;
                    }
                }

                ListDialog   codesDialog = new ListDialog((TableBasedDropDownField)this.Field, this.MainForm, txtFieldName.Text, this.page, selectedFields);
                DialogResult result      = codesDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (!((string.IsNullOrEmpty(codesDialog.SourceTableName) && string.IsNullOrEmpty(codesDialog.TextColumnName))))
                    {
                        txtDataSource.Text      = codesDialog.SourceTableName + " :: " + codesDialog.TextColumnName;
                        lbxLinkedFields.Enabled = false;
                        lblSelectFields.Enabled = false;
                        txtFieldName.Enabled    = false;
                    }
                    else
                    {
                        //if code table has not been set - set these to empty
                        txtDataSource.Text      = string.Empty;
                        field.SourceTableName   = string.Empty;
                        field.TextColumnName    = string.Empty;
                        lbxLinkedFields.Enabled = true;
                        lblSelectFields.Enabled = true;
                    }

                    this.sourceTableName = codesDialog.SourceTableName;
                    this.textColumnName  = codesDialog.TextColumnName;
                    btnOk.Enabled        = true;
                }
                btnOk.Enabled = true;
            }
            else
            {
                ShowErrorMessages();
            }
        }
Esempio n. 16
0
        private void InitializeCommands()
        {
            NamedObjectCollection <Command> commands = ClientApplication.Instance.Commands;

            this.btnLoadGame.Tag = commands["LoadGameCommand"];
            this.btnNewGame.Tag  = commands["StartNewGameCommand"];
            this.btnOptions.Tag  = commands["GameOptionsCommand"];
            this.btnQuit.Tag     = commands["QuitGameCommand"];
        }
Esempio n. 17
0
        //Initializes the command pattern objects tied to the menu commands.
        private void InitializeCommands()
        {
            NamedObjectCollection <Command> commands = ClientApplication.Instance.Commands;

            this.loadGameLabel.Tag = commands["LoadGameCommand"];
            this.newGameLabel.Tag  = commands["StartNewGameCommand"];
            this.optionsLabel.Tag  = commands["GameOptionsCommand"];
            this.exitLabel.Tag     = commands["ExitGameCommand"];
        }
        public void Add_should_add_using_full_type_name()
        {
            var t    = new NamedObjectCollection <UriParser>();
            var item = new HttpStyleUriParser();

            t.Add(item);

            Assert.Same(item, t["System.HttpStyleUriParser"]);
        }
Esempio n. 19
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="page">The current page</param>
 public ListFieldDefinition(MainForm frm, Page page)
     : base(frm)
 {
     InitializeComponent();
     this.Text = "List Field";
     this.mode = FormMode.Create;
     this.page = page;
     selectedFields = new NamedObjectCollection<Field>();
     btnOk.Enabled = true;
 }
Esempio n. 20
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="field">The fied to be edited</param>
 public CodesFieldDefinition(MainForm frm, DDLFieldOfCodes field)
     : base(frm)
 {
     InitializeComponent();
     this.mode = FormMode.Edit;
     this.field = field;
     this.page = field.Page;
     selectedFields = new NamedObjectCollection<Field>();
     LoadFormData();
 }
Esempio n. 21
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="page">The current page</param>
 public ListFieldDefinition(MainForm frm, Page page)
     : base(frm)
 {
     InitializeComponent();
     this.Text      = "List Field";
     this.mode      = FormMode.Create;
     this.page      = page;
     selectedFields = new NamedObjectCollection <Field>();
     btnOk.Enabled  = true;
 }
        public void Add_should_add_using_implicit_and_explicit_names()
        {
            var t    = new NamedObjectCollection <UriParser>();
            var item = new HttpStyleUriParser();

            t.Add("http", item);

            Assert.Same(item, t["System.HttpStyleUriParser"]);
            Assert.Same(item, t["http"]);
        }
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="field">The fied to be edited</param>
 public CodesFieldDefinition(MainForm frm, DDLFieldOfCodes field)
     : base(frm)
 {
     InitializeComponent();
     this.mode      = FormMode.Edit;
     this.field     = field;
     this.page      = field.Page;
     selectedFields = new NamedObjectCollection <Field>();
     LoadFormData();
 }
        public void Add_should_allow_multiple_with_same_implicit_name()
        {
            var t     = new NamedObjectCollection <UriParser>();
            var item1 = new HttpStyleUriParser();
            var item2 = new HttpStyleUriParser();

            t.Add(item1);
            t.Add(item2);

            Assert.HasCount(2, t);
        }
        public void BasicsTest()
        {
            NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();
              collection.Add(new NamedTestObject("foo1", 1));
              collection.Add(new NamedTestObject("foo2", 2));

              Assert.AreEqual(1, collection["foo1"].Value);
              Assert.AreEqual(2, collection["foo2"].Value);
              Assert.AreEqual(1, collection[0].Value);
              Assert.AreEqual(2, collection[1].Value);
        }
Esempio n. 26
0
        public void BasicsTest()
        {
            NamedObjectCollection <NamedTestObject> collection = new NamedObjectCollection <NamedTestObject>();

            collection.Add(new NamedTestObject("foo1", 1));
            collection.Add(new NamedTestObject("foo2", 2));

            Assert.AreEqual(1, collection["foo1"].Value);
            Assert.AreEqual(2, collection["foo2"].Value);
            Assert.AreEqual(1, collection[0].Value);
            Assert.AreEqual(2, collection[1].Value);
        }
        public void Add_should_not_use_implicit_name_on_second_instance()
        {
            var t     = new NamedObjectCollection <UriParser>();
            var item1 = new HttpStyleUriParser();
            var item2 = new HttpStyleUriParser();

            t.Add(item1);
            t.Add(item2);

            Assert.Equal(new [] { "System.HttpStyleUriParser" }, t.GetNames(item1));
            Assert.Empty(t.GetNames(item2));
        }
Esempio n. 28
0
 /// <summary>
 /// Constructor of the Codes dialog
 /// </summary>
 /// <param name="frm">The main form</param>
 /// <param name="name">The field's name</param>
 /// <param name="currentPage">The current page</param>
 public ListDialog(MainForm frm, string name, Page currentPage)
     : base(frm, name, currentPage)
 {
     InitializeComponent();
     fieldName      = name;
     page           = currentPage;
     ddlField       = new DDListField(page);
     ddlField.Name  = fieldName;
     selectedFields = new NamedObjectCollection <Field>();
     SetDataSource(ddlField);
     SetDgCodes(dgCodes, fieldName);
 }
Esempio n. 29
0
 /// <summary>
 /// Constructor of the Codes dialog
 /// </summary>
 /// <param name="frm">The main form</param>
 /// <param name="name">The field's name</param>
 /// <param name="currentPage">The current page</param>
 public ListDialog(MainForm frm, string name, Page currentPage)
     : base(frm, name, currentPage)
 {
     InitializeComponent();
     fieldName = name;
     page = currentPage;
     ddlField = new DDListField(page);
     ddlField.Name = fieldName;
     selectedFields = new NamedObjectCollection<Field>();
     SetDataSource(ddlField);
     SetDgCodes(dgCodes, fieldName);
 }
Esempio n. 30
0
        /// <summary>
        /// Identifies the source code region at the given offset and collect all identifiers up to this
        /// offset.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="targetOffset">The target offset where the region shall be evaluated.</param>
        /// <param name="collectedIdentifiers">The collected identifiers.</param>
        /// <param name="collectedFields">The collected field identifiers.</param>
        /// <returns>The identified source code region.</returns>
        /// <remarks>
        /// The method returns the identified source code region. While parsing the source code up to
        /// <paramref name="targetOffset"/> it collects all unknown identifiers in
        /// <paramref name="collectedIdentifiers"/> and all identifiers that look like fields of structs
        /// in <paramref name="collectedFields"/>.
        /// </remarks>
        public ShaderRegion IdentifyRegion(ITextSource document, int targetOffset, out IList <NamedCompletionData> collectedIdentifiers, out IList <NamedCompletionData> collectedFields)
        {
            NamedObjectCollection <NamedCompletionData> identifiers = new NamedObjectCollection <NamedCompletionData>();
            NamedObjectCollection <NamedCompletionData> fields      = new NamedObjectCollection <NamedCompletionData>();

            // Parse file from start (offset == 0).
            ShaderRegion region = IdentifyRegion(document, 0, targetOffset, identifiers, fields);

            collectedIdentifiers = identifiers;
            collectedFields      = fields;
            return((region == ShaderRegion.Default) ? ShaderRegion.Global : region);
        }
Esempio n. 31
0
 /// <summary>
 /// Contructor of the CodesDialog
 /// </summary>
 /// <param name="field">The field</param>
 /// <param name="frm">The main form</param>
 /// <param name="name">The field name</param>
 /// <param name="currentPage">The current page</param>
 /// <param name="selectedItems">The names of the fields from the Code Field Definition dialog</param>
 public CodesDialog(TableBasedDropDownField field, MainForm frm, string name, Page currentPage, NamedObjectCollection <Field> selectedItems)
     : base(field, frm, name, currentPage)
 {
     InitializeComponent();
     fieldName      = name;
     page           = currentPage;
     ddlField       = (DDLFieldOfCodes)field;
     selectedFields = selectedItems;
     SetDataSource(ddlField);
     SetDgCodes(dgCodes, fieldName);
     dgCodes.Visible = true;
     relateCondition = ddlField.RelateConditionString;
 }
Esempio n. 32
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="ParticleParameterCollection"/> class.
        /// </summary>
        /// <param name="particleSystem">The particle system that owns this collection.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="particleSystem"/> is <see langword="null"/>.
        /// </exception>
        internal ParticleParameterCollection(ParticleSystem particleSystem)
        {
            if (particleSystem == null)
            {
                throw new ArgumentNullException("particleSystem");
            }

            ParticleSystem = particleSystem;

            _collection = new NamedObjectCollection <IParticleParameter>(
                StringComparer.Ordinal,
                8); // TODO: Choose appropriate threshold for lookup-table.
        }
        private void HandleResultChosen(object sender, System.EventArgs e)
        {
            INewGameControl ctl = (INewGameControl)sender;

            this.playerColor  = ctl.PlayerColor;
            this.civilization = ctl.ChosenCivilization;
            this.opponents    = ctl.ChosenOpponents;
            this.leaderName   = ctl.LeaderName;
            GameRoot root = ClientApplication.Instance.ServerInstance;

            root.StartServer(ctl.WorldSize, ctl.Age, ctl.Temperature, ctl.Climate, ctl.Landmass, ctl.WaterCoverage, ctl.BarbarianAggressiveness, ctl.Difficulty, ctl.Rules);
            OnInvoked();
        }
        public void Clear_should_remove_names()
        {
            NamedObjectCollection <ImplicityNamed> t = new NamedObjectCollection <ImplicityNamed>();
            var item = new ImplicityNamed {
                Name = "a"
            };

            t.Add(item);
            t.Clear();

            Assert.Equal(0, t.Count);
            Assert.Null(t["a"]);
        }
        public void Add_should_add_by_implicit_name_nominal()
        {
            NamedObjectCollection <ImplicityNamed> t = new NamedObjectCollection <ImplicityNamed>();
            var item = new ImplicityNamed {
                Name = "a"
            };

            t.Add(item);

            Assert.Same(item, t["a"]);
            Assert.True(t.Contains("a"));
            Assert.True(t.Contains(item));
        }
Esempio n. 36
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="frm">The parent form</param>
        /// <param name="field">The fied to be edited</param>
        public ListFieldDefinition(MainForm frm, DDListField field)
            : base(frm)
        {
            InitializeComponent();
            this.Text      = "List Field";
            this.mode      = FormMode.Edit;
            this.field     = field;
            this.page      = field.Page;
            selectedFields = new NamedObjectCollection <Field>();

            LoadFormData();
            btnOk.Enabled = true;
        }
        private bool DoesFieldNameExistInCollection(string fieldname, NamedObjectCollection <Field> collection)
        {
            bool matchFound = false;

            foreach (string name in collection.Names)
            {
                if (fieldname.Equals(name))
                {
                    matchFound = true;
                }
            }
            return(matchFound);
        }
Esempio n. 38
0
 /// <summary>
 /// Contructor of the CodesDialog
 /// </summary>
 /// <param name="field">The field</param>
 /// <param name="frm">The main form</param>
 /// <param name="name">The field name</param>
 /// <param name="currentPage">The current page</param>
 /// <param name="selectedItems">The names of the fields from the Code Field Definition dialog</param>
 public CodesDialog(TableBasedDropDownField field, MainForm frm, string name, Page currentPage, NamedObjectCollection<Field> selectedItems)
     : base(field, frm, name, currentPage)
 {
     InitializeComponent();
     fieldName = name;
     page = currentPage;
     ddlField = (DDLFieldOfCodes)field;
     selectedFields = selectedItems;
     SetDataSource(ddlField);
     SetDgCodes(dgCodes, fieldName);
     dgCodes.Visible = true;
     relateCondition = ddlField.RelateConditionString;
 }
Esempio n. 39
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="frm">The parent form</param>
        /// <param name="field">The fied to be edited</param>
        public ListFieldDefinition(MainForm frm, DDListField field)
            : base(frm)
        {
            InitializeComponent();
            this.Text = "List Field";
            this.mode = FormMode.Edit;
            this.field = field;
            this.page = field.Page;
            selectedFields = new NamedObjectCollection<Field>();

            LoadFormData();
            btnOk.Enabled = true;
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="ConsoleCommandInterpreter"/> class.
    /// </summary>
    /// <param name="console">The <see cref="IConsole"/>.</param>
    /// <exception cref="ArgumentNullException">
    /// <paramref name="console"/> is <see langword="null"/>.
    /// </exception>
    public ConsoleCommandInterpreter(IConsole console)
    {
      if (console == null)
        throw new ArgumentNullException("console");

      Console = console;
      Commands = new NamedObjectCollection<ConsoleCommand>();

      // Add default built-in commands.
      //Commands.Add(new ConsoleCommand("add", "Prints the sum of two variables: add <value1> <value2>.", Add));
      Commands.Add(new ConsoleCommand("clear", "Clears the console.", Clear));
      Commands.Add(new ConsoleCommand("gc", "Forces a full garbage collection.", CollectGarbage));
      Commands.Add(new ConsoleCommand("parse", "Prints the command and its arguments (for debugging the console).", ParseCommand));
    }
        public void AddRange()
        {
            NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();
              collection.AddRange(new[]
              {
            new NamedTestObject("foo1", 1),
            new NamedTestObject("foo2", 2)
              });

              Assert.AreEqual(1, collection["foo1"].Value);
              Assert.AreEqual(2, collection["foo2"].Value);
              Assert.AreEqual(1, collection[0].Value);
              Assert.AreEqual(2, collection[1].Value);
        }
Esempio n. 42
0
        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ConsoleCommandInterpreter"/> class.
        /// </summary>
        /// <param name="console">The <see cref="IConsole"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="console"/> is <see langword="null"/>.
        /// </exception>
        public ConsoleCommandInterpreter(IConsole console)
        {
            if (console == null)
            throw new ArgumentNullException("console");

              Console = console;
              Commands = new NamedObjectCollection<ConsoleCommand>();

              // Add default built-in commands.
              //Commands.Add(new ConsoleCommand("add", "Prints the sum of two variables: add <value1> <value2>.", Add));
              Commands.Add(new ConsoleCommand("clear", "Clears the console.", Clear));
              Commands.Add(new ConsoleCommand("gc", "Forces a full garbage collection.", CollectGarbage));
              Commands.Add(new ConsoleCommand("parse", "Prints the command and its arguments (for debugging the console).", ParseCommand));
        }
        public void GenericTryGetValueTest()
        {
            NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();
              collection.Add(new NamedTestObject("foo1", 1));
              collection.Add(new NamedTestObject("foo2", 2));
              collection.Add(new DerivedNamedTestObject("foo3", 3));

              NamedTestObject namedObject;
              Assert.IsTrue(collection.TryGet<NamedTestObject>("foo2", out namedObject));
              Assert.AreEqual(2, namedObject.Value);

              Assert.IsTrue(collection.TryGet<NamedTestObject>("foo3", out namedObject));
              Assert.AreEqual(3, namedObject.Value);

              DerivedNamedTestObject derivedObject;
              Assert.IsFalse(collection.TryGet<DerivedNamedTestObject>("not existing", out derivedObject));
              Assert.IsNull(derivedObject);

              Assert.IsFalse(collection.TryGet<DerivedNamedTestObject>("foo2", out derivedObject));
              Assert.IsNull(derivedObject);

              Assert.IsTrue(collection.TryGet<DerivedNamedTestObject>("foo3", out derivedObject));
              Assert.AreEqual(3, derivedObject.Value);

              // Test with other comparer and without internal Dictionary.
              collection = new NamedObjectCollection<NamedTestObject>(StringComparer.InvariantCultureIgnoreCase, 5);
              collection.Add(new NamedTestObject("foo1", 1));
              collection.Add(new NamedTestObject("foo2", 2));
              collection.Add(new DerivedNamedTestObject("foo3", 3));

              Assert.IsFalse(collection.TryGet<DerivedNamedTestObject>("not existing", out derivedObject));
              Assert.IsNull(derivedObject);

              Assert.IsFalse(collection.TryGet<DerivedNamedTestObject>("foo2", out derivedObject));
              Assert.IsNull(derivedObject);

              Assert.IsTrue(collection.TryGet<DerivedNamedTestObject>("foo3", out derivedObject));
              Assert.AreEqual(3, derivedObject.Value);
        }
Esempio n. 44
0
        /// <summary>
        /// Builds the completion data from the given list.
        /// </summary>
        /// <param name="keywordCategories">The keyword categories.</param>
        /// <param name="stateCategories">The state categories.</param>
        /// <param name="includeConstants"><c>true</c> to include constant in the completion data.</param>
        /// <param name="includeSnippets"><c>true</c> to include snippets in the completion data.</param>
        /// <returns></returns>
        private ICompletionData[] BuildCompletionData(IEnumerable<IEnumerable<NamedCompletionData>> keywordCategories, IEnumerable<IEnumerable<NamedCompletionData>> stateCategories, bool includeConstants, bool includeSnippets)
        {
            List<ICompletionData> completionData = new List<ICompletionData>();

            if (includeSnippets)
            {
                // Add Snippets
                foreach (SnippetCompletionData snippet in Snippets.Values)
                    completionData.Add(new SnippetCompletionData(snippet.Text, snippet.Description, MultiColorGlyphs.Snippet, snippet.Snippet));
            }

            // Add Keywords
            foreach (IEnumerable<NamedCompletionData> keywords in keywordCategories)
                foreach (NamedCompletionData keyword in keywords)
                    completionData.Add(keyword);

            // Add Effect States:
            // Different state groups can have the same states.
            // Merge them into a single NamedObjectCollection first, to avoid duplications.
            NamedObjectCollection<NamedCompletionData> stateCompletionData = new NamedObjectCollection<NamedCompletionData>();
            foreach (IEnumerable<NamedCompletionData> states in stateCategories)
                foreach (NamedCompletionData state in states)
                    if (!stateCompletionData.Contains(state.Name))
                        stateCompletionData.Add(state);

            foreach (NamedCompletionData state in stateCompletionData)
                completionData.Add(state);

            // Merge constants and state values
            NamedObjectCollection<NamedCompletionData> constants = new NamedObjectCollection<NamedCompletionData>();
            if (includeConstants)
                foreach (ConstantCompletionData constant in Constants)
                    constants.Add(constant);

            foreach (StateCompletionData state in stateCompletionData)
                foreach (string stateValue in state.AllowedValues)
                    if (!constants.Contains(stateValue))
                        constants.Add(EffectStateValues[stateValue]);

            foreach (NamedCompletionData constant in constants)
                completionData.Add(constant);

            return completionData.ToArray();
        }
Esempio n. 45
0
 private bool DoesFieldNameExistInCollection(string fieldname, NamedObjectCollection<Field> collection)
 {
     bool matchFound = false;
     foreach (string name in collection.Names)
     {
         if (fieldname.Equals(name))
         {
             matchFound = true;
         }
     }
     return matchFound;
 }
Esempio n. 46
0
        /// <summary>
        /// Handles the click event for the "..." data source button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void btnDataSource_Click(object sender, EventArgs e)
        {
            if (ValidateToAddDataSource())
            {
                NamedObjectCollection<Field> columnNamesInLower = new NamedObjectCollection<Field>();
                int selectedIndex = 1;
                DataRowView item;
                string[] selectedViewFields = new string[lbxLinkedFields.SelectedItems.Count + 1];
                selectedViewFields[0] = field.Name;
                for (int i = 0; i < lbxLinkedFields.Items.Count; i++)
                {
                    item = (DataRowView)lbxLinkedFields.Items[i];
                    if (lbxLinkedFields.GetSelected(i))
                    {
                        selectedViewFields[selectedIndex] = item[lbxLinkedFields.DisplayMember].ToString();
                        DataRow selectRow = item.Row;
                        string fieldColumnName = (selectRow[ColumnNames.NAME].ToString());
                        string fieldStringID = (selectRow[ColumnNames.FIELD_ID].ToString());
                        if (DoesFieldNameExistInCollection(fieldColumnName, selectedFields) == false)
                        {
                            selectedFields.Add(page.GetView().GetFieldById(int.Parse(fieldStringID)));
                        }
                        selectedIndex++;
                    }
                }

                ListDialog codesDialog = new ListDialog((TableBasedDropDownField)this.Field, this.MainForm, txtFieldName.Text, this.page, selectedFields);
                DialogResult result = codesDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (!((string.IsNullOrEmpty(codesDialog.SourceTableName) && string.IsNullOrEmpty(codesDialog.TextColumnName))))
                    {
                        txtDataSource.Text = codesDialog.SourceTableName + " :: " + codesDialog.TextColumnName;
                        lbxLinkedFields.Enabled = false;
                        lblSelectFields.Enabled = false;
                        txtFieldName.Enabled = false;
                    }
                    else
                    {
                        //if code table has not been set - set these to empty
                        txtDataSource.Text = string.Empty;
                        field.SourceTableName = string.Empty;
                        field.TextColumnName = string.Empty;
                        lbxLinkedFields.Enabled = true;
                        lblSelectFields.Enabled = true;
                    }

                    this.sourceTableName = codesDialog.SourceTableName;
                    this.textColumnName = codesDialog.TextColumnName;
                    btnOk.Enabled = true;
                }
                btnOk.Enabled = true;
            }
            else
            {
                ShowErrorMessages();
            }
        }
Esempio n. 47
0
 /// <summary>
 /// Gets a collection of renderable <see cref="Epi.Fields"/> on an <see cref="Epi.Page"/>
 /// </summary>
 /// <param name="page"><see cref="Epi.Page"/></param>
 /// <returns>A named object collection of renderable <see cref="Epi.Fields"/>.</returns>
 public NamedObjectCollection<Field> GetFieldsOnPage(Page page)
 {
     NamedObjectCollection<Field> pageFields = new NamedObjectCollection<Field>();
     foreach (Field field in page.Fields)
     {
         if (field is RenderableField)
         {
             RenderableField renderableField = field as RenderableField;
             if (renderableField.Page.Id == page.Id)
             {
                 pageFields.Add(renderableField);
             }
         }
     }
     return pageFields;
 }
 public void TestConstructorWithComparer()
 {
     var collection = new NamedObjectCollection<NamedTestObject>(StringComparer.InvariantCultureIgnoreCase);
       collection.Add(new NamedTestObject("foo1", 1));
       Assert.IsTrue(collection.Contains("FOO1"));
 }
 public void AddRangeShouldThrowWhenNull()
 {
     NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();
       collection.AddRange(null);
 }
Esempio n. 50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThemeStyle"/> class.
 /// </summary>
 public ThemeStyle()
 {
     Attributes = new NamedObjectCollection<ThemeAttribute>();
       States = new NamedObjectCollection<ThemeState>();
 }
Esempio n. 51
0
        /// <summary>
        /// Get all groups on a given page as a NamedObjectCollection
        /// </summary>
        /// <param name="page">The page the field group belongs to</param>
        /// <returns>FieldGroup</returns>
        public NamedObjectCollection<GroupField> GetGroupFields(Page page)
        {
            NamedObjectCollection<GroupField> groups = new NamedObjectCollection<GroupField>();
            try
            {
                DataTable table = GetGroupsForPage(page.Id);
                foreach (DataRow row in table.Rows)
                {
                    groups.Add(new GroupField(row, page));
                }

            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not retrieve field groups", ex);
            }
            return (groups);
        }
Esempio n. 52
0
        /// <summary>
        /// Handles the click event for the "..." data source button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void btnDataSource_Click(object sender, EventArgs e)
        {
            if (ValidateToAddDataSource())
            {
                NamedObjectCollection<Field> columnNamesInLower = new NamedObjectCollection<Field>();
                int selectedIndex = 1;
                DataRowView item;
                string[] selectedFieldNames = new string[lbxLinkedFields.SelectedItems.Count];

                for (int i = 0; i < lbxLinkedFields.Items.Count; i++)
                {
                    item = (DataRowView)lbxLinkedFields.Items[i];
                    if (lbxLinkedFields.GetSelected(i))
                    {
                        selectedFieldNames[selectedIndex - 1] = item[lbxLinkedFields.DisplayMember].ToString();
                        DataRow selectRow = item.Row;
                        string fieldColumnName = (selectRow[ColumnNames.NAME].ToString());
                        string fieldStringID = (selectRow[ColumnNames.FIELD_ID].ToString());

                        if (DoesFieldNameExistInCollection(fieldColumnName, selectedFields) == false)
                        {
                            selectedFields.Add(page.GetView().GetFieldById(int.Parse(fieldStringID)));
                        }
                        selectedIndex++;
                    }
                }

                CodesDialog codesDialog = new CodesDialog((TableBasedDropDownField)this.Field, this.MainForm, txtFieldName.Text, this.page, selectedFields);

                DialogResult result = codesDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    if (!((string.IsNullOrEmpty(codesDialog.SourceTableName) && string.IsNullOrEmpty(codesDialog.TextColumnName))))
                    {
                        txtDataSource.Text = codesDialog.SourceTableName + " :: " + codesDialog.TextColumnName;
                        lbxLinkedFields.Enabled = true;
                        lblSelectFields.Enabled = true;
                        txtFieldName.Enabled = false;

                        string dialogRelateCondition = codesDialog.relateCondition;
                        if (string.IsNullOrEmpty(dialogRelateCondition))
                        {
                            ((DDLFieldOfCodes)field).AssociatedFieldInformation = ((DDLFieldOfCodes)field).RelateConditionString;
                        }
                        else
                        {
                            ((DDLFieldOfCodes)field).AssociatedFieldInformation = dialogRelateCondition;
                        }

                        ((DDLFieldOfCodes)field).ShouldSort = codesDialog.ShouldSort;
                    }
                    else
                    {
                        txtDataSource.Text = string.Empty;
                        field.SourceTableName = string.Empty;
                        field.TextColumnName = string.Empty;

                        lbxLinkedFields.Enabled = true;
                        lbxLinkedFields.Visible = true;
                        lblSelectFields.Enabled = true;
                        lblSelectFields.Visible = true;

                        ((DDLFieldOfCodes)field).AssociatedFieldInformation = string.Empty;
                    }

                    this.sourceTableName = codesDialog.SourceTableName;
                    this.textColumnName = codesDialog.TextColumnName;
                    btnOk.Enabled = true;
                }
            }
            else
            {
                ShowErrorMessages();
            }
        }
        public void Move()
        {
            NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();
              collection.Add(new NamedTestObject("foo1", 1));
              collection.Add(new NamedTestObject("foo2", 2));
              collection.Add(new DerivedNamedTestObject("foo3", 3));

              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(-1, 1));
              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(1, -1));
              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(3, 1));
              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(1, 3));

              collection.Move(1, 1);
              Assert.AreEqual(2, collection[1].Value);

              collection.Move(0, 2);
              Assert.AreEqual(2, collection[0].Value);
              Assert.AreEqual(3, collection[1].Value);
              Assert.AreEqual(1, collection[2].Value);
        }
Esempio n. 54
0
 /// <summary>
 /// Contructor of the CodesDialog
 /// </summary>
 /// <param name="field">The field</param>
 /// <param name="frm">The main form</param>
 /// <param name="name">The field name</param>
 /// <param name="currentPage">The current page</param>
 /// <param name="selectedItems">The names of the fields from the Code Field Definition dialog</param>
 public ListDialog(TableBasedDropDownField field, MainForm frm, string name, Page currentPage, NamedObjectCollection<Field> selectedItems)
     : base(frm, name, currentPage)
 {
     InitializeComponent();
     fieldName = name;
     page = currentPage;
     ddlField = (DDListField)field;
     this.Text = "List Field";
     //if (!(string.IsNullOrEmpty(sourceTableName)))
     //{
     //    codeTable = ddlField.GetSourceData();
     //}
     selectedFields = selectedItems;
     SetDataSource(ddlField);
     SetDgCodes(dgCodes, fieldName);
 }
Esempio n. 55
0
        /// <summary>
        /// Identifies the source code region at the given offset and collect all identifiers up to this 
        /// offset.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="targetOffset">The target offset where the region shall be evaluated.</param>
        /// <param name="collectedIdentifiers">The collected identifiers.</param>
        /// <param name="collectedFields">The collected field identifiers.</param>
        /// <returns>The identified source code region.</returns>
        /// <remarks>
        /// The method returns the identified source code region. While parsing the source code up to 
        /// <paramref name="targetOffset"/> it collects all unknown identifiers in 
        /// <paramref name="collectedIdentifiers"/> and all identifiers that look like fields of structs 
        /// in <paramref name="collectedFields"/>.
        /// </remarks>
        public ShaderRegion IdentifyRegion(ITextSource document, int targetOffset, out IList<NamedCompletionData> collectedIdentifiers, out IList<NamedCompletionData> collectedFields)
        {
            NamedObjectCollection<NamedCompletionData> identifiers = new NamedObjectCollection<NamedCompletionData>();
            NamedObjectCollection<NamedCompletionData> fields = new NamedObjectCollection<NamedCompletionData>();

            // Parse file from start (offset == 0).
            ShaderRegion region = IdentifyRegion(document, 0, targetOffset, identifiers, fields);
            collectedIdentifiers = identifiers;
            collectedFields = fields;
            return (region == ShaderRegion.Default) ? ShaderRegion.Global : region;
        }
Esempio n. 56
0
        private NamedObjectCollection<Field> ConvertToLower(NamedObjectCollection<Field> columnNames)
        {
            if (columnNames != null)
            {
                NamedObjectCollection<Field> columnNamesInLower = new NamedObjectCollection<Field>();
                columnNamesInLower = columnNames;

                int selectedIndex = 1;
                DataRowView item;
                string[] selectedViewFields = new string[lbxFields.SelectedItems.Count + 1];
                selectedViewFields[0] = fieldName;
                for (int i = 0; i < lbxFields.Items.Count; i++)
                {
                    item = (DataRowView)lbxFields.Items[i];
                    if (lbxFields.GetSelected(i))
                    {
                        selectedViewFields[selectedIndex] = item[lbxFields.DisplayMember].ToString();
                        DataRow selectRow = item.Row;
                        selectedFields.Add(page.GetView().GetFieldById(int.Parse((selectRow[ColumnNames.FIELD_ID].ToString()))));
                        selectedIndex++;
                    }
                }
                return columnNamesInLower;
            }
            return columnNames;
        }
Esempio n. 57
0
        /// <summary>
        /// Identifies the source code region at the given offset.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="startOffset">The start offset where to start the search.</param>
        /// <param name="targetOffset">The target offset where the region shall be evaluated.</param>
        /// <param name="identifiers">The collected identifiers.</param>
        /// <param name="fields">The collected field identifiers.</param>
        /// <returns>
        /// The method returns the identified source code region.
        /// </returns>
        /// <remarks>
        /// <para>
        /// If there is no region at <paramref name="targetOffset"/> the method returns
        /// <see cref="ShaderRegion.Default"/>. In this the caller needs to decide what region it
        /// actually is. (When <see cref="IdentifyRegion(ITextSource,int,int,NamedObjectCollection{NamedCompletionData},NamedObjectCollection{NamedCompletionData})"/>
        /// is called with a <paramref name="startOffset"/> of 0 then it is <see cref="ShaderRegion.Global"/>.)
        /// </para>
        /// <para>
        /// This method calls itself recursively. First identifies the outermost region, then it
        /// recursively refines the search and returns the innermost region.
        /// </para>
        /// </remarks>
        private ShaderRegion IdentifyRegion(ITextSource document, int startOffset, int targetOffset, NamedObjectCollection<NamedCompletionData> identifiers, NamedObjectCollection<NamedCompletionData> fields)
        {
            int offset = startOffset;
            bool collectIdentifiers = (identifiers != null);

            while (offset < document.TextLength && offset < targetOffset)
            {
                char c = document.GetCharAt(offset);
                switch (c)
                {
                    case '/':
                        // Skip comments
                        if (offset + 1 < document.TextLength)
                        {
                            char nextChar = document.GetCharAt(offset + 1);
                            if (nextChar == '/')
                            {
                                // Line comment
                                offset = SkipLineComment(document, offset + 2);
                                if (targetOffset <= offset)
                                    return ShaderRegion.LineComment;
                            }
                            else if (nextChar == '*')
                            {
                                // Block comment
                                offset = SkipBlockComment(document, offset + 2);
                                if (targetOffset < offset)
                                    return ShaderRegion.BlockComment;
                            }
                            else
                            {
                                // No comment
                                ++offset;
                            }
                        }
                        else
                        {
                            // End of file -> Skip past end to terminate algorithm.
                            ++offset;
                        }
                        break;
                    case '"':
                        // Skip strings
                        offset = SkipString(document, offset + 1);
                        if (targetOffset < offset)
                            return ShaderRegion.String;
                        break;
                    case '\'':
                        // Skip character literals
                        offset = SkipCharacterLiteral(document, offset + 1);
                        if (targetOffset < offset)
                            return ShaderRegion.CharacterLiteral;
                        break;
                    case '{':
                        // Identify the current block
                        int startOffsetOfBlock = offset;
                        ShaderRegion region = IdentifyBlockAt(document, offset);
                        offset = TextUtilities.FindClosingBracket(document, offset + 1, '{', '}');
                        if (offset == -1 || targetOffset < offset)
                        {
                            // Let's identify the region inside this block. (Recursion!)
                            ShaderRegion innerRegion = IdentifyRegion(document, startOffsetOfBlock + 1, targetOffset, identifiers, fields);
                            if (region == ShaderRegion.TechniqueOrPass10 && innerRegion == ShaderRegion.TechniqueOrPass)
                            {
                                // Return the more specific
                                return ShaderRegion.TechniqueOrPass10;
                            }
                            if (innerRegion == ShaderRegion.Default || innerRegion == ShaderRegion.Unknown)
                            {
                                // The inner region is unknown or same as outer region
                                return region;
                            }
                            // Return the more specific inner region.
                            return innerRegion;
                        }
                        ++offset;
                        break;
                    case '<':
                        // Check whether this is an annotation
                        if (IsStartOfAnnotation(document, offset))
                        {
                            int startOffsetOfAnnotation = offset;
                            offset = TextUtilities.FindClosingBracket(document, offset + 1, '<', '>');
                            if (offset == -1 || targetOffset <= offset)
                            {
                                // Let's identify the region inside the annotation. (Recursion!)
                                ShaderRegion innerRegion = IdentifyRegion(document, startOffsetOfAnnotation + 1, targetOffset, identifiers, fields);
                                if (innerRegion == ShaderRegion.Default || innerRegion == ShaderRegion.Unknown)
                                {
                                    // The inner region is unknown or same as outer region
                                    return ShaderRegion.Annotation;
                                }

                                // Return the more specific inner region.
                                return innerRegion;
                            }
                            ++offset;
                        }
                        else
                        {
                            ++offset;
                        }
                        break;
                    default:
                        if (Char.IsLetter(c) || c == '_')
                        {
                            if (collectIdentifiers)
                            {
                                string identifier = TextUtilities.GetIdentifierAt(document, offset);
                                if (!String.IsNullOrEmpty(identifier) && !_intelliSense.FullLookupTable.Contains(identifier))
                                {
                                    if (offset > 0 && document.GetCharAt(offset - 1) == '.')
                                    {
                                        if (!fields.Contains(identifier))
                                            fields.Add(new GuessCompletionData(identifier));
                                    }
                                    else
                                    {
                                        if (!identifiers.Contains(identifier))
                                            identifiers.Add(new GuessCompletionData(identifier));
                                    }
                                }
                            }
                            offset = SkipIdentifier(document, offset);
                        }
                        else if (Char.IsDigit(c))
                        {
                            offset = SkipNumber(document, offset);
                            if (targetOffset <= offset)
                            {
                                return ShaderRegion.Default;
                            }
                        }
                        else
                        {
                            ++offset;
                        }
                        break;
                }
            }
            return ShaderRegion.Default;
        }
Esempio n. 58
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThemeStyle"/> class.
 /// </summary>
 public ThemeStyleContent()
 {
     Attributes = new NamedObjectCollection<ThemeAttributeContent>();
       States = new NamedObjectCollection<ThemeStateContent>();
 }
        public void GetEnumerator()
        {
            NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();
              collection.Add(new NamedTestObject("foo1", 1));
              collection.Add(new NamedTestObject("foo2", 2));

              int i = 0;
              foreach(var item in collection)
              {
            i++;
            Assert.AreEqual(i, item.Value);
              }
        }
Esempio n. 60
0
        //--------------------------------------------------------------
        #region Creation and Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="CommandLineParser"/> class.
        /// </summary>
        public CommandLineParser()
        {
            Arguments = new NamedObjectCollection<Argument>(StringComparer.OrdinalIgnoreCase);
        }