public static DashboardTaskProperty CreateTaskProperty(MyTask task, string propertyName)
        {
            if (propertyName == null)
                propertyName = "Enabled";

            return new DashboardTaskProperty(task, task.GetType().GetProperty(propertyName));
        }
Exemple #2
0
 public MyDebugTaskNode(MyTask task)
     : base(task)
 {
     Icon = Properties.Resources.gears;
     OwnerName = task.GetType().Name;
 }
        public override void Restore(MyProject project)
        {
            string[] idSplit = PropertyId.Split(new[] { SerializationIdSeparator }, StringSplitOptions.RemoveEmptyEntries);

            Node = FindNode(project, idSplit[0]);

            var workingNode = Node as MyWorkingNode;
            if (workingNode == null)
                throw new SerializationException("A task dashboard property found a node without tasks");

            Task = workingNode.GetTaskByPropertyName(idSplit[1]);

            if (Task == null)
                throw new SerializationException("A task dashboard property did not find the target task");

            PropertyInfo = Task.GetType().GetProperty(idSplit[2]);

            if (PropertyInfo == null)
                throw new SerializationException("A task dashboard property was not found on the task");
        }
 public DashboardTaskProperty(MyTask task, PropertyInfo propertyInfo)
     : base(task.GenericOwner, propertyInfo)
 {
     Task = task;
 }
        public override void Restore(MyProject project)
        {
            string[] idSplit = PropertyId.Split(new [] {SerializationIdSeparator}, StringSplitOptions.RemoveEmptyEntries);

            var success = false;

            int nodeId;
            if (int.TryParse(idSplit[0], out nodeId))
            {
                Node = project.GetNodeById(nodeId);
                if (Node != null)
                    success = true;
            }

            if (!success)
                throw new SerializationException("A task dashboard property did not find the specified node");

            var workingNode = Node as MyWorkingNode;
            if (workingNode == null)
                throw new SerializationException("A task dashboard property found a node without tasks");

            Task = workingNode.GetTaskByPropertyName(idSplit[1]);

            if (Task == null)
                throw new SerializationException("A task dashboard property did not find the target task");

            PropertyInfo = Task.GetType().GetProperty(idSplit[2]);

            if (PropertyInfo == null)
                throw new SerializationException("A task dashboard property was not found on the task");
        }