コード例 #1
0
ファイル: OrderAction.cs プロジェクト: cristianoferr/minefort
        public static OrderAction Deserialize(XmlReader xmlReader)
        {
            if (orderActionTypes == null)
            {
                orderActionTypes = FindOrderActionsInAssembly();
            }

            string orderActionType = xmlReader.GetAttribute("type");

            if (orderActionTypes.ContainsKey(orderActionType))
            {
                xmlReader = xmlReader.ReadSubtree();
                Type          t           = orderActionTypes[orderActionType];
                XmlSerializer serializer  = new XmlSerializer(t);
                OrderAction   orderAction = (OrderAction)serializer.Deserialize(xmlReader);
                //// need to set name explicitly (not part of deserialization as it's passed in)
                orderAction.Initialize(orderActionType);
                return(orderAction);
            }
            else
            {
                UnityDebugger.Debugger.Log(OrderActionsLogChannel, string.Format("There is no deserializer for OrderAction '{0}'", orderActionType));
                return(null);
            }
        }