コード例 #1
0
        protected static MyNode FindNode(MyProject project, string nodeId)
        {
            var success = false;

            MyNode node = null;
            int parsedNodeId;
            if (int.TryParse(nodeId, out parsedNodeId))
            {
                node = project.GetNodeById(parsedNodeId);
                if (node != null)
                    success = true;
            }

            if (!success)
                throw new SerializationException("A dashboard property target node was not found");

            return node;
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        public override void RestoreTargetFromIdentifier(MyProject project)
        {
            if (TargetIdentifier == null)
                return;

            string[] split = TargetIdentifier.Split('#');
            if (split.Length != 2)
                return;

            MyWorkingNode node = (MyWorkingNode)project.GetNodeById(int.Parse(split[0]));

            if (node != null)
                Target = (MyMemoryBlock<float>)MyMemoryManager.Instance.GetMemoryBlockByName(node, split[1]);
        }
コード例 #4
0
        public override void Restore(MyProject project)
        {
            string[] idSplit = PropertyId.Split(SerializationIdSeparator.ToCharArray());

            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 dashboard property target node was not found");

            PropertyInfo = Node.GetType().GetProperty(idSplit[1]);

            if (PropertyInfo == null)
                throw new SerializationException("A dashboard property was not found on the node");
        }
コード例 #5
0
 public override void RestoreTargetFromIdentifier(MyProject project)
 {
     Target = (T)project.GetNodeById(int.Parse(TargetIdentifier));
 }