Exemplo n.º 1
0
        private void LoadInstanceElement(NFILogicClass xLogicClass)
        {
            string strLogicPath = mstrRootPath;

            strLogicPath += xLogicClass.GetInstance();

            XmlDocument xmldoc = new XmlDocument();

            ///////////////////////////////////////////////////////////////////////////////////////
            if (NFCLogicClassManager.Instance.GetCepher())
            {
                StreamReader cepherReader = new StreamReader(strLogicPath);;
                string       strContent   = cepherReader.ReadToEnd();
                cepherReader.Close();

                byte[] data = Convert.FromBase64String(strContent);

                MemoryStream stream = new MemoryStream(data);
                XmlReader    x      = XmlReader.Create(stream);
                x.MoveToContent();
                string res = x.ReadOuterXml();

                xmldoc.LoadXml(res);
            }
            else
            {
                xmldoc.Load(strLogicPath);
            }
            /////////////////////////////////////////////////////////////////

            XmlNode xRoot = xmldoc.SelectSingleNode("XML");

            XmlNodeList xNodeList = xRoot.SelectNodes("Object");

            for (int i = 0; i < xNodeList.Count; ++i)
            {
                //NFCLog.Instance.Log("Class:" + xLogicClass.GetName());

                XmlNode      xNodeClass = xNodeList.Item(i);
                XmlAttribute strID      = xNodeClass.Attributes["Id"];

                //NFCLog.Instance.Log("ClassID:" + strID.Value);

                NFIElement xElement = GetElement(strID.Value);
                if (null == xElement)
                {
                    xElement = new NFCElement();
                    AddElement(strID.Value, xElement);
                    xLogicClass.AddConfigName(strID.Value);

                    XmlAttributeCollection xCollection = xNodeClass.Attributes;
                    for (int j = 0; j < xCollection.Count; ++j)
                    {
                        XmlAttribute xAttribute = xCollection[j];
                        NFIProperty  xProperty  = xLogicClass.GetPropertyManager().GetProperty(xAttribute.Name);
                        if (null != xProperty)
                        {
                            NFIDataList.VARIANT_TYPE eType = xProperty.GetType();
                            switch (eType)
                            {
                            case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddInt(int.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddFloat(float.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddDouble(double.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddString(xAttribute.Value);
                                NFIProperty xTestProperty = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddObject(new NFIDENTID(0, int.Parse(xAttribute.Value)));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void LoadInstanceElement(NFILogicClass xLogicClass)
        {
            string strLogicPath = mstrRootPath;
            strLogicPath += xLogicClass.GetInstance();

            XmlDocument xmldoc = new XmlDocument();
            //xmldoc.Load(strLogicPath);
            ///////////////////////////////////////////////////////////////////////////////////////
            StreamReader cepherReader = new StreamReader(strLogicPath); ;
            string strContent = cepherReader.ReadToEnd();
            cepherReader.Close();

            byte[] data = Convert.FromBase64String(strContent);

            MemoryStream stream = new MemoryStream(data);
            XmlReader x = XmlReader.Create(stream);
            x.MoveToContent();
            string res = x.ReadOuterXml();

            xmldoc.LoadXml(res);
            /////////////////////////////////////////////////////////////////

            XmlNode xRoot = xmldoc.SelectSingleNode("XML");

            XmlNodeList xNodeList = xRoot.SelectNodes("Object");
            for (int i = 0; i < xNodeList.Count; ++i)
            {
                //NFCLog.Instance.Log("Class:" + xLogicClass.GetName());

                XmlNode xNodeClass = xNodeList.Item(i);
                XmlAttribute strID = xNodeClass.Attributes["ID"];

                //NFCLog.Instance.Log("ClassID:" + strID.Value);

                NFIElement xElement = GetElement(strID.Value);
                if (null == xElement)
                {
                    xElement = new NFCElement();
                    AddElement(strID.Value, xElement);
                    xLogicClass.AddConfigName(strID.Value);

                    XmlAttributeCollection xCollection = xNodeClass.Attributes;
                    for (int j = 0; j < xCollection.Count; ++j)
                    {
                        XmlAttribute xAttribute = xCollection[j];
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().GetProperty(xAttribute.Name);
                        if (null != xProperty)
                        {
                            NFIDataList.VARIANT_TYPE eType = xProperty.GetType();
                            switch (eType)
                            {
                                case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                                    {
                                        NFIDataList xValue = new NFCDataList();
                                        xValue.AddInt(int.Parse(xAttribute.Value));
                                        xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                    }
                                    break;
                                case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                                    {
                                        NFIDataList xValue = new NFCDataList();
                                        xValue.AddFloat(float.Parse(xAttribute.Value));
                                        xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                    }
                                    break;
                                case NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE:
                                    {
                                        NFIDataList xValue = new NFCDataList();
                                        xValue.AddDouble(double.Parse(xAttribute.Value));
                                        xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                    }
                                    break;
                                case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                                    {
                                        NFIDataList xValue = new NFCDataList();
                                        xValue.AddString(xAttribute.Value);
                                        NFIProperty xTestProperty = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                    }
                                    break;
                                case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                                    {
                                        NFIDataList xValue = new NFCDataList();
                                        xValue.AddObject(new NFIDENTID(0, int.Parse(xAttribute.Value)));
                                        xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void LoadInstanceElement(NFILogicClass xLogicClass)
        {
            string strLogicPath = mstrRootPath;

            strLogicPath += xLogicClass.GetInstance();

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(strLogicPath);

            XmlNode xRoot = xmldoc.SelectSingleNode("XML");

            XmlNodeList xNodeList = xRoot.SelectNodes("Object");

            for (int i = 0; i < xNodeList.Count; ++i)
            {
                //NFCLog.Instance.Log("Class:" + xLogicClass.GetName());

                XmlNode      xNodeClass = xNodeList.Item(i);
                XmlAttribute strID      = xNodeClass.Attributes["ID"];

                //NFCLog.Instance.Log("ClassID:" + strID.Value);

                NFIElement xElement = GetElement(strID.Value);
                if (null == xElement)
                {
                    xElement = new NFCElement();
                    AddElement(strID.Value, xElement);
                    xLogicClass.AddConfigName(strID.Value);

                    XmlAttributeCollection xCollection = xNodeClass.Attributes;
                    for (int j = 0; j < xCollection.Count; ++j)
                    {
                        XmlAttribute xAttribute = xCollection[j];
                        NFIProperty  xProperty  = xLogicClass.GetPropertyManager().GetProperty(xAttribute.Name);
                        if (null != xProperty)
                        {
                            NFIDataList.VARIANT_TYPE eType = xProperty.GetType();
                            switch (eType)
                            {
                            case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddInt(int.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddFloat(float.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddDouble(double.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddString(xAttribute.Value);
                                NFIProperty xTestProperty = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddObject(new NFIDENTID(0, int.Parse(xAttribute.Value)));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }