示例#1
0
        /// <summary>
        /// Creates an event object from a node object.
        /// </summary>
        /// <param name="Node">Node added.</param>
        /// <param name="Language">Language</param>
        /// <param name="Caller">Original caller.</param>
        /// <param name="OldId">Old Node ID, if differrent from previous NodeId.</param>
        public static async Task <NodeUpdated> FromNode(INode Node, Language Language, RequestOrigin Caller, string OldId)
        {
            List <Parameter> Parameters = new List <Parameter>();

            foreach (Parameter P in await Node.GetDisplayableParametersAsync(Language, Caller))
            {
                Parameters.Add(P);
            }

            return(new NodeUpdated()
            {
                OldId = OldId,
                Parameters = Parameters.ToArray(),
                HasChildren = Node.HasChildren,
                ChildrenOrdered = Node.ChildrenOrdered,
                IsReadable = Node.IsReadable,
                IsControllable = Node.IsControllable,
                HasCommands = Node.HasCommands,
                ParentId = Node.Parent?.NodeId ?? string.Empty,
                ParentPartition = Node.Parent?.Partition ?? string.Empty,
                Updated = DateTime.Now,
                State = Node.State,
                NodeId = Node.NodeId,
                Partition = Node.Partition,
                LogId = NodeAdded.EmptyIfSame(Node.LogId, Node.NodeId),
                LocalId = NodeAdded.EmptyIfSame(Node.LocalId, Node.NodeId),
                SourceId = Node.SourceId,
                Timestamp = DateTime.Now
            });
        }
示例#2
0
 /// <summary>
 /// Creates an event object from a node object.
 /// </summary>
 /// <param name="Node">Node removed.</param>
 public static NodeRemoved FromNode(INode Node)
 {
     return(new NodeRemoved()
     {
         NodeId = Node.NodeId,
         Partition = Node.Partition,
         LogId = NodeAdded.EmptyIfSame(Node.LogId, Node.NodeId),
         LocalId = NodeAdded.EmptyIfSame(Node.LocalId, Node.NodeId),
         SourceId = Node.SourceId,
         Timestamp = DateTime.Now
     });
 }