Ejemplo n.º 1
0
 public bool DoDataValidation(CellType in_cellType, List<Google2uRow> in_cells, WorkbookBase in_base)
 {
     switch (in_cellType)
     {
         case CellType.Null:
             return true;
         case CellType.ColumnHeader:
             return ValidateColumnHeader(in_cells);
         case CellType.RowHeader:
             return ValidateRowHeader(in_cells);
         case CellType.Type:
             return ValidateTypeValue();
         case CellType.Value:
             return ValidateValue(in_base);
     }
     return true;
 }
Ejemplo n.º 2
0
        private bool ValidateValue(WorkbookBase in_base)
        {
            var testType = MyType;
            if (RowNum == 1 || RowNum == 2)
                testType = SupportedType.String;

            Tooltip = string.Empty;
            switch (testType)
            {
                case SupportedType.GameObject:
                    try
                    {
                        Convert.ToString(CellValueString);
                    }
                    catch (Exception)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To GameObject";
                        return false;
                    }
                    break;
                case SupportedType.String:
                    try
                    {
                        Convert.ToString(CellValueString);
                    }
                    catch (Exception)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To String";
                        return false;
                    }
                    break;
                case SupportedType.Int:
                    try
                    {
                        Convert.ToInt32(CellValueString);
                    }
                    catch (Exception)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To Int";
                        return false;
                    }
                    break;
                case SupportedType.Float:
                    try
                    {
                        Convert.ToSingle(CellValueString);
                    }
                    catch (Exception)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To Float";
                        return false;
                    }
                    break;
                case SupportedType.Bool:
                    try
                    {
                        Convert.ToBoolean(CellValueString);
                    }
                    catch (Exception)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To Bool. You must use TRUE or FALSE";
                        return false;
                    }
                    break;
                case SupportedType.Byte:
                    try
                    {
                        Convert.ToByte(CellValueString);
                    }
                    catch (Exception)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To Byte";
                        return false;
                    }
                    break;
                case SupportedType.Vector2:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters] +
                                 " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (split.Length != 2)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To Vector2";
                        return false;
                    }
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToSingle(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Vector3";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.Vector3:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters] +
                                 " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (split.Length != 3)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To Vector3";
                        return false;
                    }
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToSingle(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Vector3";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.Color:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters] +
                                 " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (split.Length != 4)
                    {
                        if (split.Length != 3)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Color";
                            return false;
                        }
                        foreach (var s in split)
                        {
                            try
                            {
                                Convert.ToSingle(s);
                            }
                            catch (Exception)
                            {
                                Tooltip = "Unable to convert " + CellValueString + " To Color";
                                return false;
                            }
                        }
                    }
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToSingle(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Color";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.Color32:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters] +
                                 " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (split.Length != 4)
                    {
                        if (split.Length != 3)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Color32";
                            return false;
                        }
                        foreach (var s in split)
                        {
                            try
                            {
                                Convert.ToByte(s);
                            }
                            catch (Exception)
                            {
                                Tooltip = "Unable to convert " + CellValueString + " To Color32";
                                return false;
                            }
                        }
                    }
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToByte(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Color32";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.Quaternion:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters] +
                                 " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (split.Length != 4)
                    {
                        Tooltip = "Unable to convert " + CellValueString + " To Quaternion";
                        return false;
                    }
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToSingle(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Quaternion";
                            return false;
                        }
                    }
                }
                    break;

                case SupportedType.FloatArray:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ArrayDelimiters] + " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToSingle(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Float Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.IntArray:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ArrayDelimiters] + " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToInt32(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Int Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.BoolArray:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ArrayDelimiters] + " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToBoolean(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString +
                                      " To Bool Array. You must use TRUE or FALSE";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.ByteArray:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ArrayDelimiters] + " ";
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToByte(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Byte Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.StringArray:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.StringArrayDelimiters];
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            Convert.ToString(s);
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To String Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.Vector2Array:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexArrayDelimiters];
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            var innerdelims =
                                in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters];
                            var innersplit = s.Split(innerdelims.ToCharArray(),
                                StringSplitOptions.RemoveEmptyEntries);

                            if (innersplit.Length != 2)
                            {
                                Tooltip = "Unable to convert " + CellValueString + " To Vector2 Array";
                                return false;
                            }

                            foreach (var inners in innersplit)
                            {
                                Convert.ToSingle(inners);
                            }
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Vector2 Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.Vector3Array:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexArrayDelimiters];
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            var innerdelims =
                                in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters];
                            var innersplit = s.Split(innerdelims.ToCharArray(),
                                StringSplitOptions.RemoveEmptyEntries);

                            if (innersplit.Length != 3)
                            {
                                Tooltip = "Unable to convert " + CellValueString + " To Vector3 Array";
                                return false;
                            }

                            foreach (var inners in innersplit)
                            {
                                Convert.ToSingle(inners);
                            }
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Vector3 Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.ColorArray:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexArrayDelimiters];
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            var innerdelims =
                                in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters];
                            var innersplit = s.Split(innerdelims.ToCharArray(),
                                StringSplitOptions.RemoveEmptyEntries);

                            if (innersplit.Length != 4)
                            {
                                Tooltip = "Unable to convert " + CellValueString + " To Color Array";
                                return false;
                            }

                            foreach (var inners in innersplit)
                            {
                                Convert.ToSingle(inners);
                            }
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Color Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.Color32Array:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexArrayDelimiters];
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            var innerdelims =
                                in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters];
                            var innersplit = s.Split(innerdelims.ToCharArray(),
                                StringSplitOptions.RemoveEmptyEntries);

                            if (innersplit.Length != 4)
                            {
                                Tooltip = "Unable to convert " + CellValueString + " To Color32 Array";
                                return false;
                            }

                            foreach (var inners in innersplit)
                            {
                                Convert.ToByte(inners);
                            }
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Color32 Array";
                            return false;
                        }
                    }
                }
                    break;
                case SupportedType.QuaternionArray:
                {
                    var delims = in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexArrayDelimiters];
                    var split = CellValueString.Split(delims.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in split)
                    {
                        try
                        {
                            var innerdelims =
                                in_base.ExportOptions.DelimiterOptions[in_base.ExportOptions.ComplexTypeDelimiters];
                            var innersplit = s.Split(innerdelims.ToCharArray(),
                                StringSplitOptions.RemoveEmptyEntries);
                            if (innersplit.Length != 4)
                            {
                                Tooltip = "Unable to convert " + CellValueString + " To Quaternion Array";
                                return false;
                            }

                            foreach (var inners in innersplit)
                            {
                                Convert.ToSingle(inners);
                            }
                        }
                        catch (Exception)
                        {
                            Tooltip = "Unable to convert " + CellValueString + " To Quaternion Array";
                            return false;
                        }
                    }
                }
                    break;

                default:
                    return true;
            }

            return true;
        }
Ejemplo n.º 3
0
        public Google2uWorksheet(WorksheetEntry in_entry, Service in_service, WorkbookBase in_base)
        {
            WorksheetEntry = in_entry;
            MyWorkbook = in_base;
            WorksheetName = WorksheetEntry.Title.Text;
            Prefix = "worksheet" + WorksheetName.Replace(' ', '_');
            MyService = in_service;

            MyCleanupQuery = new CellQuery(in_entry.CellFeedLink);
            MyCellQuery = new CellQuery(in_entry.CellFeedLink) {ReturnEmpty = ReturnEmptyCells.yes};

            _ComboBoxList = new GUIContent[Convert.ToInt32(SupportedType.Unrecognized)];
            var iter = 0;
            foreach (var enumval in Enum.GetValues(typeof (SupportedType)))
            {
                if ((SupportedType) enumval == SupportedType.Unrecognized)
                    break;
                _ComboBoxList[iter] = new GUIContent(Convert.ToString(enumval));
                iter++;
            }
        }