Beispiel #1
0
        private void OkBTN_Click(object sender, EventArgs e)
        {
            try
            {
                // parse the array dimensions.
                string     text       = ArrayDimensionsTB.Text.Trim();
                List <int> dimensions = new List <int>();

                if (!String.IsNullOrEmpty(text))
                {
                    int          dimension = 0;
                    const string digits    = "0123456789";

                    for (int ii = 0; ii < text.Length; ii++)
                    {
                        if (Char.IsWhiteSpace(text, ii))
                        {
                            continue;
                        }

                        if (text[ii] == ',')
                        {
                            dimensions.Add(dimension);
                            dimension = 0;
                            continue;
                        }

                        if (!Char.IsDigit(text, ii))
                        {
                            throw new FormatException("Invalid character in array index. Use numbers seperated by commas.");
                        }

                        dimension *= 10;
                        dimension += digits.IndexOf(text[ii]);
                    }

                    dimensions.Add(dimension);
                }

                // save the result.
                int valueRank = (dimensions.Count < 1) ? ValueRanks.Scalar : dimensions.Count;

                m_result                   = new SetTypeResult();
                m_result.TypeInfo          = new TypeInfo(m_typeInfo.BuiltInType, valueRank);
                m_result.ArrayDimensions   = dimensions.ToArray();
                m_result.UseDefaultOnError = ErrorHandlingCB.SelectedIndex == 0;

                if (m_typeInfo.BuiltInType == BuiltInType.ExtensionObject)
                {
                    m_result.DataTypeId = StructureTypeBTN.SelectedNode;
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Beispiel #2
0
        private void OkBTN_Click(object sender, EventArgs e)
        {
            try
            {
                // parse the array dimensions.
                string text = ArrayDimensionsTB.Text.Trim();
                List<int> dimensions = new List<int>();

                if (!String.IsNullOrEmpty(text))
                {
                    int dimension = 0;
                    const string digits = "0123456789";

                    for (int ii = 0; ii < text.Length; ii++)
                    {
                        if (Char.IsWhiteSpace(text, ii))
                        {
                            continue;
                        }

                        if (text[ii] == ',')
                        {
                            dimensions.Add(dimension);
                            dimension = 0;
                            continue;
                        }

                        if (!Char.IsDigit(text, ii))
                        {
                            throw new FormatException("Invalid character in array index. Use numbers seperated by commas.");
                        }

                        dimension *= 10;
                        dimension += digits.IndexOf(text[ii]);
                    }

                    dimensions.Add(dimension);
                }
                
                // save the result.
                int valueRank = (dimensions.Count < 1) ? ValueRanks.Scalar : dimensions.Count;

                m_result = new SetTypeResult();
                m_result.TypeInfo = new TypeInfo(m_typeInfo.BuiltInType, valueRank);
                m_result.ArrayDimensions = dimensions.ToArray();
                m_result.UseDefaultOnError = ErrorHandlingCB.SelectedIndex == 0;

                if (m_typeInfo.BuiltInType == BuiltInType.ExtensionObject)
                {
                    m_result.DataTypeId = StructureTypeBTN.SelectedNode;
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }