Beispiel #1
0
    public static object DeSerializeXmlToObject(string _filePath, Type _type, Type[] _extraTypes)
    {
        object _result = default(object);

        if (File.Exists(_filePath))
        {
            using (StreamReader _reader = new StreamReader(_filePath))
            {
                try
                {
                    System.Xml.Serialization.XmlSerializer _xmlSerializer = new System.Xml.Serialization.XmlSerializer(_type, _extraTypes);

                    _result = _xmlSerializer.Deserialize(_reader);
                }
                catch (Exception _error)
                {
                    ExtendLib.DLog("DXMLSerializer", _error);
                }
                finally
                {
                    _reader.Close();
                }

                return(_result);
            }
        }


        return(default(object));
    }
Beispiel #2
0
    public static void SerializeObjectToXml <T>(string _filePath, T _obj, Type[] _extraTypes, bool _apend = true)
    {
        if (!_apend && File.Exists(_filePath))
        {
            File.Delete(_filePath);
        }

        if (_obj != null)
        {
            using (StreamWriter _writer = new StreamWriter(_filePath, false))
            {
                try
                {
                    System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T), _extraTypes);

                    xmlSerializer.Serialize(_writer, _obj);
                }
                catch (Exception _error)
                {
                    ExtendLib.DLog("DXMLSerializer", _error);
                }
                finally
                {
                    _writer.Close();
                }
            }
        }
    }
Beispiel #3
0
        public TBWindowRightClickMenu(TBWindow _window) : base(_window)
        {
            _menu = new GenericMenu();

            if (_menuContentTable.Keys == null)
            {
                ExtendLib.DLog("TaskEditor RightClick Menu", "Null Table");
            }

            _handleEnumerator = _menuContentTable.Keys.GetEnumerator();

            while (_handleEnumerator.MoveNext())
            {
                AddMenuItem(_handleEnumerator.Current);
            }
        }
Beispiel #4
0
        protected override void OnMenuSelected(string _message, Vector2 _mousePoint)
        {
            DBaseNodeEditor _node;

            try
            {
                _node = (DBaseNodeEditor)Activator.CreateInstance(_menuContentTable[_message]);
            }
            catch (Exception)
            {
                ExtendLib.DLog("TaskEditor", "Wrong Node Type");
                return;
            }

            _node.NodeRect = new Rect(_mousePoint, DTaskEditorConst.NodeWindowSize);
            TBWindow.NodesRouter.Add(_node);
        }