Exemple #1
0
        public override XElement SerializeItem(object item, object parentItem)
        {
            VirtualLeitchRouterOutput output = item as VirtualLeitchRouterOutput;

            if (output == null)
            {
                return(null);
            }
            XElement serializedOutput = base.SerializeItem(item, parentItem);

            serializedOutput.SetAttributeValue(ATTRIBUTE_ASSOCIATED_INPUT, output.CurrentInput?.Index ?? 0);
            serializedOutput.SetAttributeValue(ATTRIBUTE_LOCK_STATUS, output.LockStatusCode);
            serializedOutput.SetAttributeValue(ATTRIBUTE_LOCK_OWNER_PANEL_ID, output.LockOwnerPanelId);
            return(serializedOutput);
        }
Exemple #2
0
        public override object DeserializeItem(XmlNode serializedItem, object parentItem)
        {
            VirtualLeitchRouterOutput restoredOutput = base.DeserializeItem(serializedItem, parentItem) as VirtualLeitchRouterOutput;

            if (!int.TryParse(serializedItem.Attributes[ATTRIBUTE_ASSOCIATED_INPUT]?.Value, out int associatedInput))
            {
                associatedInput = 0;
            }
            restoredOutput._associatedInputIndex = associatedInput;
            if (!int.TryParse(serializedItem.Attributes[ATTRIBUTE_LOCK_STATUS]?.Value, out int lockStatus))
            {
                lockStatus = 0;
            }
            if (!int.TryParse(serializedItem.Attributes[ATTRIBUTE_LOCK_OWNER_PANEL_ID]?.Value, out int lockOwnerPanelId))
            {
                lockOwnerPanelId = -1;
            }
            restoredOutput.SetLock(lockStatus, lockOwnerPanelId);
            return(restoredOutput);
        }