Exemplo n.º 1
0
        public IUiWorkflowTask Create(IWorkflowTask task, IUiPoint point)
        {
            var t = task.GetType();


            var entityUi = (IWorkflowTaskEntityUi)WorkflowEntityUiResolver.Instance.Resolve(task);

            var cssClass = entityUi.UiAttributes.ContainsKey("class") ? entityUi.UiAttributes["class"] : string.Empty;

            var w = new UiWorkflowTask
            {
                Top                  = point.Top,
                Left                 = point.Left,
                Description          = task.Description,
                AvailableTransitions = task.AvailableTransitions,
                Id          = task.Id,
                Name        = task.Name,
                Transitions = task.Transitions,
                TypeName    = t.FullName,
                AssemblyQualifiedTypeName = t.AssemblyQualifiedName,
                Class                  = cssClass,
                IsStartTask            = task.IsStartTask,
                TransitionDescriptions = new Dictionary <string, string>(),
                CustomProperties       = new Dictionary <string, object>()
            };

            foreach (var transition in task.AvailableTransitions)
            {
                w.TransitionDescriptions.Add(transition, entityUi.TransitionDescriptions[transition]);
            }

            foreach (var p in t.GetProperties())
            {
                if (p.Name == "Name" || p.Name == "Description" || p.Name == "IsStartTask")
                {
                    continue;
                }
                if (
                    p.PropertyType != typeof(string) &&
                    p.PropertyType != typeof(int) &&
                    p.PropertyType != typeof(Boolean) &&
                    p.PropertyType != typeof(IList <string>) &&
                    p.PropertyType != typeof(IList <int>)
                    )
                {
                    continue;
                }



                w.CustomProperties.Add(p.Name, p.GetValue(task, null));
            }

            return(w);
        }
        public IUiWorkflowTask Create(IWorkflowTask task, IUiPoint point)
        {
            var t = task.GetType();


            var entityUi = (IWorkflowTaskEntityUi)WorkflowEntityUiResolver.Instance.Resolve(task);

            var cssClass = entityUi.UiAttributes.ContainsKey("class") ? entityUi.UiAttributes["class"] : string.Empty;

            var w = new UiWorkflowTask
                        {
                            Top = point.Top,
                            Left = point.Left,
                            Description = task.Description,
                            AvailableTransitions = task.AvailableTransitions,
                            Id = task.Id,
                            Name = task.Name,
                            Transitions = task.Transitions,
                            TypeName = t.FullName,
                            AssemblyQualifiedTypeName = t.AssemblyQualifiedName,
                            Class = cssClass,
                            IsStartTask = task.IsStartTask,
                            TransitionDescriptions = new Dictionary<string, string>(),
                            CustomProperties = new Dictionary<string, object>()
                        };

            foreach (var transition in task.AvailableTransitions)
            {
                w.TransitionDescriptions.Add(transition, entityUi.TransitionDescriptions[transition]);
            }
            
            foreach(var p in t.GetProperties())
            {

                if (p.Name == "Name" || p.Name == "Description" || p.Name == "IsStartTask") continue;
                if (
                    p.PropertyType != typeof(string) && 
                    p.PropertyType != typeof(int) &&
                    p.PropertyType != typeof(Boolean) && 
                    p.PropertyType != typeof(IList<string>) &&
                    p.PropertyType != typeof(IList<int>)
                ) continue;



                w.CustomProperties.Add(p.Name,  p.GetValue(task, null));
            }

            return w;
        }