public bool TryDeserialize(XElement serializedObject, IXmlSerializer xmlSerializer, out object deserializedObject) { if (serializedObject == null) { throw new ArgumentNullException("serializedObject"); } deserializedObject = null; if (serializedObject.Name.LocalName != "BaseRuntimeTreeNode") { return(false); } XElement valueElement = serializedObject.Element("Value"); if (valueElement != null) { if (valueElement.Elements().Count() != 1) { return(false); } deserializedObject = FunctionFacade.BuildTree(valueElement.Elements().Single()); } return(true); }
public bool TryDeserialize(XElement serializedObject, IXmlSerializer xmlSerializer, out object deserializedObject) { if (serializedObject == null) { throw new ArgumentNullException("serializedObject"); } if (xmlSerializer == null) { throw new ArgumentNullException("xmlSerializer"); } deserializedObject = null; if (serializedObject.Name.LocalName != "NamedFunctionCall") { return(false); } NamedFunctionCall namedFunctionCall = new NamedFunctionCall(null, null); XElement nameElement = serializedObject.Element("Name"); if (nameElement != null) { if (nameElement.Elements().Count() != 1) { return(false); } namedFunctionCall.Name = (string)xmlSerializer.Deserialize(nameElement.Elements().Single()); } XElement valueElement = serializedObject.Element("Value"); if (valueElement != null) { if (valueElement.Elements().Count() != 1) { return(false); } object result; try { result = FunctionFacade.BuildTree(valueElement.Elements().Single()); } catch (Exception) { return(false); } if ((result is BaseFunctionRuntimeTreeNode) == false) { return(false); } namedFunctionCall.FunctionCall = (BaseFunctionRuntimeTreeNode)result; } deserializedObject = namedFunctionCall; return(true); }
private void EnsureWidgetFunction() { lock (_lock) { if (_widgetFunction == null && _serializedWidgetFunction != null) { WidgetFunctionRuntimeTreeNode functionNode = (WidgetFunctionRuntimeTreeNode)FunctionFacade.BuildTree(_serializedWidgetFunction); _setParameters = functionNode.GetSetParameters().ToList(); _widgetFunction = functionNode.GetWidgetFunction(); } } }