Beispiel #1
0
        protected FieldWrapper GetField(string key)
        {
            key = key.ToLower();

            if (!Fields.Keys.Contains(key))
            {
                try
                {
                    var scField = Item.Fields[key];

                    switch (scField.Type.ToLower())
                    {
                    case "checkbox":
                        Fields[key] = new BooleanFieldWrapper(scField);
                        break;

                    case "image":
                        Fields[key] = new ImageFieldWrapper(scField);
                        break;

                    case "date":
                    case "datetime":
                        Fields[key] = new DateTimeFieldWrapper(scField);
                        break;

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

                    case "file":
                        Fields[key] = new FileFieldWrapper(scField);
                        break;

                    case "droplink":
                    case "droptree":
                        Fields[key] = new LinkFieldWrapper(scField);
                        break;

                    case "general link":
                        Fields[key] = new GeneralLinkFieldWrapper(scField);
                        break;

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

                    case "rich text":
                        Fields[key] = new RichTextFieldWrapper(scField);
                        break;

                    default:
                        Fields[key] = null;
                        break;
                    }
                }
                catch
                {
                    // Todo: Log error
                }
            }
            return((FieldWrapper)Fields[key]);
        }
        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);
            }
        }