예제 #1
0
        protected FieldWrapper GetField(string key, string type)
        {
            key = key.ToLower();
            if (!_fields.Keys.Contains(key))
            {
                try
                {
                    switch (type)
                    {
                    case "checkbox":
                        _fields[key] = new BooleanFieldWrapper(paramters[key]);
                        break;

                    case "checklist":
                    case "treelist":
                    case "treelistex":
                    case "multilist":
                        _fields[key] = new ListFieldWrapper(paramters[key]);
                        break;

                    case "droplink":
                    case "droptree":
                    case "general link":
                        _fields[key] = new LinkFieldWrapper(paramters[key]);
                        break;

                    case "single-line text":
                    case "multi-line text":
                    case "rich text":
                    case "droplist":
                    case "number":
                        _fields[key] = new TextFieldWrapper(paramters[key]);
                        break;

                    default:
                        _fields[key] = new FieldWrapper(paramters[key]);
                        break;
                    }
                }
                catch
                {
                    // Todo: Log error
                }
            }

            return((FieldWrapper)_fields[key]);
        }
        protected FieldWrapper GetField(string key, string type)
        {
            key = key.ToLower();
            if (!_fields.Keys.Contains(key))
            {
                try
                {
                    switch (type)
                    {
                        case "checkbox":
                            _fields[key] = new BooleanFieldWrapper(paramters[key]);
                            break;
                        case "checklist":
                        case "treelist":
                        case "treelistex":
                        case "multilist":
                            _fields[key] = new ListFieldWrapper(paramters[key]);
                            break;
                        case "droplink":
                        case "droptree":
                        case "general link":
                            _fields[key] = new LinkFieldWrapper(paramters[key]);
                            break;
                        case "single-line text":
                        case "multi-line text":
                        case "rich text":
                        case "droplist":
                        case "number":
                            _fields[key] = new TextFieldWrapper(paramters[key]);
                            break;
                        default:
                            _fields[key] = new FieldWrapper(paramters[key]);
                            break;
                    }
                }
                catch
                {
                    // Todo: Log error
                }
            }

            return (FieldWrapper)_fields[key];
        }
예제 #3
0
        protected IFieldWrapper GetField(string key, string type)
        {
            if (!_fields.ContainsKey(key))
            {
                var parameterValue = string.Empty;

                _parameters.TryGetValue(key, out parameterValue);

                try
                {
                    switch (type)
                    {
                        case "checkbox":
                            _fields[key] = new BooleanFieldWrapper(parameterValue, SpawnProvider);
                            break;
                        case "checklist":
                        case "treelist":
                        case "treelist with search":
                        case "treelistex":
                        case "multilist":
                        case "multilist with search":
                        case "tags":
                            _fields[key] = new ListFieldWrapper(parameterValue, SpawnProvider);
                            break;
                        case "droplink":
                        case "droptree":
                        case "general link":
                        case "general link with search":
                            _fields[key] = new LinkFieldWrapper(parameterValue, SpawnProvider);
                            break;
                        case "single-line text":
                        case "multi-line text":
                        case "rich text":
                        case "droplist":
                        case "number":
                            _fields[key] = new TextFieldWrapper(parameterValue, SpawnProvider);
                            break;
                        case "integer":
                            _fields[key] = new IntegerFieldWrapper(parameterValue, SpawnProvider);
                            break;
                        default:
                            _fields[key] = new FieldWrapper(parameterValue, SpawnProvider);
                            break;
                    }
                }
                catch (Exception ex)
                {
                    var paramKeys = new StringBuilder();

                    foreach (var param in _parameters)
                    {
                        paramKeys.AppendLine(param.Key);
                    }

                    throw new Exception("Fortis: An error occurred while mapping the field with key " + key
                                        + Environment.NewLine
                                        + Environment.NewLine
                                        + "Available parameters: "
                                        + Environment.NewLine
                                        + paramKeys.ToString(), ex);
                }
            }

            try
            {
                return (FieldWrapper)_fields[key];
            }
            catch (Exception ex)
            {
                throw new Exception("Fortis: An error occurred while mppaing the field with key " + key, ex);
            }
        }