public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as Issue;
            var root   = new Dictionary <string, object>();
            var result = new Dictionary <string, object>();

            if (entity != null)
            {
                result.Add("subject", entity.Subject);
                result.Add("description", entity.Description);
                result.Add("notes", entity.Notes);
                result.WriteIdIfNotNull(entity.Project, "project_id");
                result.WriteIdIfNotNull(entity.Priority, "priority_id");
                result.WriteIdIfNotNull(entity.Status, "status_id");
                result.WriteIdIfNotNull(entity.Category, "category_id");
                result.WriteIdIfNotNull(entity.Tracker, "tracker_id");
                result.WriteIdIfNotNull(entity.AssignedTo, "assigned_to_id");
                result.WriteIdIfNotNull(entity.FixedVersion, "fixed_version_id");
                result.WriteIdIfNotNull(entity.ParentIssue, "parent_issue_id");
                result.WriteIfNotDefaultOrNull(entity.EstimatedHours, "estimated_hours");

                if (entity.StartDate != null)
                {
                    result.Add("start_date", entity.StartDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
                }
                if (entity.DueDate != null)
                {
                    result.Add("due_date", entity.DueDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
                }

                result.WriteIfNotDefaultOrNull(entity.DoneRatio, "done_ratio");

                if (entity.Uploads != null)
                {
                    result.Add("uploads", entity.Uploads.ToArray());
                }

                if (entity.CustomFields != null)
                {
                    serializer.RegisterConverters(new[] { new CustomFieldConverter() });
                    result.Add("custom_fields", entity.CustomFields.ToArray());
                }

                if (entity.Watchers != null)
                {
                    serializer.RegisterConverters(new[] { new WatcherConverter() });
                    result.Add("watchers", entity.Watchers.ToArray());
                }

                root["issue"] = result;
                return(root);
            }

            return(result);
        }
Exemplo n.º 2
0
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as User;
            var root = new Dictionary<string, object>();
            var result = new Dictionary<string, object>();

            if (entity != null)
            {
                result.Add("login", entity.Login);
                result.Add("firstname", entity.FirstName);
                result.Add("lastname", entity.LastName);
                result.Add("mail", entity.Email);
                result.Add("password", entity.Password);
                result.Add("must_change_passwd", entity.MustChangePassword);
                result.WriteIfNotDefaultOrNull(entity.AuthenticationModeId, "auth_source_id");

                if (entity.CustomFields != null)
                {
                    serializer.RegisterConverters(new[] { new IssueCustomFieldConverter() });
                    result.Add("custom_fields", entity.CustomFields.ToArray());
                }

                root["user"] = result;
                return root;
            }
            return result;
        }
Exemplo n.º 3
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as User;
            var root   = new Dictionary <string, object>();
            var result = new Dictionary <string, object>();

            if (entity != null)
            {
                result.Add("login", entity.Login);
                result.Add("firstname", entity.FirstName);
                result.Add("lastname", entity.LastName);
                result.Add("mail", entity.Email);
                result.Add("password", entity.Password);
                result.Add("must_change_passwd", entity.MustChangePassword);
                result.WriteIfNotDefaultOrNull(entity.AuthenticationModeId, "auth_source_id");

                if (entity.CustomFields != null)
                {
                    serializer.RegisterConverters(new[] { new IssueCustomFieldConverter() });
                    result.Add("custom_fields", entity.CustomFields.ToArray());
                }

                root["user"] = result;
                return(root);
            }
            return(result);
        }
Exemplo n.º 4
0
        public override IDictionary <string, object> Serialize(
            object obj,
            JavaScriptSerializer serializer)
        {
            var entity = obj as WikiPage;
            var root   = new Dictionary <string, object>();
            var result = new Dictionary <string, object>();

            if (entity != null)
            {
                result.Add("text", entity.Text);
                result.Add("comments", entity.Comments);
                result.WriteIfNotDefaultOrNull <int>(entity.Version, "version");
                root["wiki_page"] = result;
                return(root);
            }
            return(result);
        }
Exemplo n.º 5
0
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as WikiPage;
            var root = new Dictionary<string, object>();
            var result = new Dictionary<string, object>();

            if (entity != null)
            {
                result.Add("text", entity.Text);
                result.Add("comments", entity.Comments);
                result.WriteIfNotDefaultOrNull<int>(entity.Version, "version");

                root["wiki_page"] = result;
                return root;
            }

            return result;
        }
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as IssueRelation;
            var root = new Dictionary<string, object>();
            var result = new Dictionary<string, object>();

            if (entity != null)
            {
                result.Add("issue_to_id", entity.IssueToId);
                result.Add("relation_type", entity.Type.ToString());
                if (entity.Type == IssueRelationType.precedes || entity.Type == IssueRelationType.follows)
                    result.WriteIfNotDefaultOrNull(entity.Delay, "delay");

                root["relation"] = result;
                return root;
            }

            return result;
        }
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as Version;
            var root = new Dictionary<string, object>();
            var result = new Dictionary<string, object>();

            if (entity != null)
            {
                result.Add("name", entity.Name);
                result.Add("status", entity.Status.ToString());
                result.Add("sharing", entity.Sharing.ToString());
                result.Add("description", entity.Description);
                result.WriteIfNotDefaultOrNull(entity.DueDate, "due_date");

                root["version"] = result;
                return root;
            }

            return result;
        }
Exemplo n.º 8
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as User;
            var root   = new Dictionary <string, object>();
            var result = new Dictionary <string, object>();

            if (entity != null)
            {
                result.Add("login", entity.Login);
                result.Add("firstname", entity.FirstName);
                result.Add("lastname", entity.LastName);
                result.Add("mail", entity.Email);
                result.Add("password", entity.Password);
                result.WriteIfNotDefaultOrNull(entity.AuthenticationModeId, "auth_source_id");

                root["user"] = result;
                return(root);
            }
            return(result);
        }
Exemplo n.º 9
0
        public override IDictionary <string, object> Serialize(
            object obj,
            JavaScriptSerializer serializer)
        {
            var entity = obj as Version;
            var root   = new Dictionary <string, object>();
            var result = new Dictionary <string, object>();

            if (entity != null)
            {
                result.Add("name", entity.Name);
                result.Add("status", entity.Status.ToString());
                result.Add("sharing", entity.Sharing.ToString());
                result.Add("description", entity.Description);
                result.WriteIfNotDefaultOrNull(entity.DueDate, "due_date");
                root["version"] = result;
                return(root);
            }
            return(result);
        }
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as IssueRelation;
            var root   = new Dictionary <string, object>();
            var result = new Dictionary <string, object>();

            if (entity != null)
            {
                result.Add("issue_to_id", entity.IssueToId);
                result.Add("relation_type", entity.Type.ToString());
                if (entity.Type == IssueRelationType.precedes || entity.Type == IssueRelationType.follows)
                {
                    result.WriteIfNotDefaultOrNull(entity.Delay, "delay");
                }

                root["relation"] = result;
                return(root);
            }

            return(result);
        }
Exemplo n.º 11
0
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var entity = obj as Issue;
            var root = new Dictionary<string, object>();
            var result = new Dictionary<string, object>();

            if (entity != null)
            {
                result.Add("subject", entity.Subject);
                result.Add("description", entity.Description);
                result.Add("notes", entity.Notes);
                result.WriteIdIfNotNull(entity.Project, "project_id");
                result.WriteIdIfNotNull(entity.Priority, "priority_id");
                result.WriteIdIfNotNull(entity.Status, "status_id");
                result.WriteIdIfNotNull(entity.Category, "category_id");
                result.WriteIdIfNotNull(entity.Tracker, "tracker_id");
                result.WriteIdIfNotNull(entity.AssignedTo, "assigned_to_id");
                result.WriteIdIfNotNull(entity.FixedVersion, "fixed_version_id");
               // result.WriteIdIfNotNull(entity.ParentIssue, "parent_issue_id");
                result.WriteIfNotDefaultOrNull(entity.EstimatedHours, "estimated_hours");

                if(entity.ParentIssue == null)
                    result.Add("parent_issue_id", null);
                else
                {
                    result.Add("parent_issue_id", entity.ParentIssue.Id);
                }
                if (entity.StartDate != null)
                    result.Add("start_date", entity.StartDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
                if (entity.DueDate != null)
                    result.Add("due_date", entity.DueDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));

                result.WriteIfNotDefaultOrNull(entity.DoneRatio, "done_ratio");

                if (entity.Uploads != null) result.Add("uploads", entity.Uploads.ToArray());

                if (entity.CustomFields != null)
                {
                    serializer.RegisterConverters(new[] { new IssueCustomFieldConverter() });
                    result.Add("custom_fields", entity.CustomFields.ToArray());
                }

                if (entity.Watchers != null)
                {
                    serializer.RegisterConverters(new[] { new WatcherConverter()  });
                    result.Add("watcher_user_ids", entity.Watchers.ToArray());
                }

                root["issue"] = result;
                return root;
            }

            return result;
        }