コード例 #1
0
ファイル: Main.cs プロジェクト: dexeb21/MyExport
///////////////////////////////////////////////////////////////////////////////////////////////////
        // Проверяет значение поля на null
        // Если значение поля невалидно, то при любом обращении к
        // нему(даже при проверке на null) может возникнуть исключение
        private bool IsNullFieldValue(IExportField field)
        {
            try
            {
                return(field.Value == null);
            }
            catch (Exception e)
            {
                return(true);
            }
        }
コード例 #2
0
        // Getting the specified field
        private void getField(IExportField field, IExportDocument docRef, string fieldName)
        {
            // saving the field name

            if (field.Children != null)
            {
                getFields(field.Children, docRef, fieldName);
            }

            else if (field.Items != null)
            {
                getFields(field.Items, docRef, fieldName);
            }
            else if (field.Value != null)
            {
                if (field.IsExportable == true && field.Name == fieldName)
                {
                    fieldValue = field.Value.ToString();
                    //MessageBox.Show(field.Value.ToString(), fieldValue.ToString());
                }
            }
        }
コード例 #3
0
        // Checks if the field value is null
        // If the field value is invalid, any attempt to access this field (even
        // to check if it is null) may cause an exception
        private bool IsNullFieldValue(IExportField field)
        {
            try
            {
                return (field.Value == null);
            }

            catch (Exception e)
            {
                return true;
            }
        }
コード例 #4
0
        // Exporting the specified field
        private void exportField(IExportField field, IExportDocument docRef, StreamWriter sw)
        {
            // saving the field value it can be accessed
            if (IsNullFieldValue(field))
            {
                sw.WriteLine();
                //fieldvalue = "";
            }
            else
            {
                //sw.WriteLine("    " + field.Text);
                //fieldvalue = field.Text;
            }

            if (field.Children != null)
            {
                // exporting child fields
                //exportFields(field.Children, docRef, indent + "    ");
                exportFields(field.Children, docRef, sw);
            }

            else
            {
                if (field.Items != null)
                {
                    // exporting field instances
                    //exportFields(field.Items, docRef, indent + "    ");
                    exportFields(field.Items, docRef, sw);
                }
                else
                {
                    if (field.IsExportable == true)
                    {
                       // fLayer.DataSource.Add(field);
                        sw.Write(" " + field.Name);
                        sw.WriteLine("    " + field.Text);
                    }
                }
            }
        }