AmbulanceDemoCode.DriverFunctions.RemoveOptionalQuotes C# (CSharp) Метод

RemoveOptionalQuotes() публичный статический Метод

public static RemoveOptionalQuotes ( string s ) : string
s string
Результат string
        public static string RemoveOptionalQuotes(string s)
        {
            return (s.Length > 1 && s[0] == '"' && s[s.Length - 1] == '"') ? s.Substring(1, s.Length - 2).Replace("\"\"", "\"") : s;
        }

Usage Example

Пример #1
0
        // void OutputValueAtCol_I(string c, int i, IUpdatableRow outputrow)
        //
        // Helper function that takes the string value c and puts it into the column at position i in the output row.
        // The value will be cast to the expected type of the column.
        private void OutputValueAtCol_I(string c, int i, IUpdatableRow outputrow)
        {
            ISchema schema = outputrow.Schema;

            if (schema[i].Type == typeof(SqlMap <string, string>))
            {
                c = DriverFunctions.RemoveOptionalQuotes(c);
                SqlMap <string, string> scopeMap = String.IsNullOrEmpty(c) ? null : DriverFunctions.ReadStringMap(c, this._map_item_delim, this._map_kv_delim);
                outputrow.Set <SqlMap <string, string> >(i, scopeMap);
            }
            else if (schema[i].Type == typeof(SqlArray <int>))
            {
                c = DriverFunctions.RemoveOptionalQuotes(c);
                SqlArray <int> scopeArray = String.IsNullOrEmpty(c) ? null : DriverFunctions.ReadIntArray(c, this._array_item_delim);
                outputrow.Set <SqlArray <int> >(i, scopeArray);
            }
            else if (schema[i].Type == typeof(int))
            {
                int num = Convert.ToInt32(c);
                outputrow.Set <int>(i, num);
            }
            else if (schema[i].Type == typeof(int?))
            {
                int?num2 = (c == "") ? null : new int?(Convert.ToInt32(c));
                outputrow.Set <int?>(i, num2);
            }
            else if (schema[i].Type == typeof(long))
            {
                long num3 = Convert.ToInt64(c);
                outputrow.Set <long>(i, num3);
            }
            else if (schema[i].Type == typeof(long?))
            {
                long?num4 = (c == "") ? null : new long?(Convert.ToInt64(c));
                outputrow.Set <long?>(i, num4);
            }
            else if (schema[i].Type == typeof(DateTime))
            {
                DateTime dateTime = Convert.ToDateTime(c);
                outputrow.Set <DateTime>(i, dateTime);
            }
            else if (schema[i].Type == typeof(DateTime?))
            {
                DateTime?dateTime2 = (c == "") ? null : new DateTime?(Convert.ToDateTime(c));
                outputrow.Set <DateTime?>(i, dateTime2);
            }
            else if (schema[i].Type == typeof(string))
            {
                string text = DriverFunctions.RemoveOptionalQuotes(c);
                outputrow.Set <string>(i, text);
            }
            else
            {
                outputrow.Set <string>(i, c);
            }
        }