Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        mxThis  = this.transform;
        xCamera = this.GetComponent <Camera>();

        NFrame.NFIClass xLogicClass = NFrame.NFCKernelModule.Instance.GetLogicClassModule().GetElement("Scene");
        List <string>   xList       = xLogicClass.GetConfigNameList();

        for (int i = 0; i < xList.Count; ++i)
        {
            string strName = (string)xList[i];

            string strCamOffestPos = NFrame.NFCKernelModule.Instance.GetElementModule().QueryPropertyString(strName, "CamOffestPos");
            string strCamOffestRot = NFrame.NFCKernelModule.Instance.GetElementModule().QueryPropertyString(strName, "CamOffestRot");

            NFrame.NFDataList xCamOffestPosList = new NFrame.NFDataList(strCamOffestPos, ',');
            NFrame.NFDataList xCamOffestRotList = new NFrame.NFDataList(strCamOffestRot, ',');
            if (xCamOffestPosList.Count() == 3 && xCamOffestRotList.Count() == 2)
            {
                OffestPos xOffestPos = new OffestPos();
                xOffestPos.offsetX = float.Parse(xCamOffestPosList.StringVal(0));
                xOffestPos.offsetY = float.Parse(xCamOffestPosList.StringVal(1));
                xOffestPos.offsetZ = float.Parse(xCamOffestPosList.StringVal(2));

                xOffestPos.XRot = float.Parse(xCamOffestRotList.StringVal(0));
                xOffestPos.YRot = float.Parse(xCamOffestRotList.StringVal(1));

                mxOffestPosList[int.Parse(strName)] = xOffestPos;
            }
        }
    }
Exemplo n.º 2
0
        private void OnClassPlayerEventHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
        {
            if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH)
            {
                NFIClass           classObject     = mClassModule.GetElement(strClassName);
                NFIPropertyManager propertyManager = classObject.GetPropertyManager();
                NFIRecordManager   recordManager   = classObject.GetRecordManager();

                NFDataList propertyList = propertyManager.GetPropertyList();
                NFDataList recordList   = recordManager.GetRecordList();

                for (int i = 0; i < propertyList.Count(); ++i)
                {
                    NFIProperty propertyObject = propertyManager.GetProperty(propertyList.StringVal(i));
                    if (propertyObject.GetUpload())
                    {
                        mKernelModule.RegisterPropertyCallback(self, propertyObject.GetKey(), OnPropertyDataHandler);
                    }
                }

                for (int i = 0; i < recordList.Count(); ++i)
                {
                    NFIRecord recordObject = recordManager.GetRecord(recordList.StringVal(i));
                    if (recordObject.GetUpload())
                    {
                        mKernelModule.RegisterRecordCallback(self, recordObject.GetName(), RecordEventHandler);
                    }
                }
            }
        }
Exemplo n.º 3
0
        void AddBasePropertyFormOther(string strName, string strOther)
        {
            NFIClass xOtherClass = GetElement(strOther);
            NFIClass xLogicClass = GetElement(strName);

            if (null != xLogicClass && null != xOtherClass)
            {
                NFDataList xValue = xOtherClass.GetPropertyManager().GetPropertyList();
                for (int i = 0; i < xValue.Count(); ++i)
                {
                    NFIProperty xProperty = xOtherClass.GetPropertyManager().GetProperty(xValue.StringVal(i));
                    xLogicClass.GetPropertyManager().AddProperty(xValue.StringVal(i), xProperty.GetData());
                }
            }
        }
Exemplo n.º 4
0
        void InitRecord(NFGUID self, string strClassName)
        {
            NFIClass   xLogicClass = mxLogicClassModule.GetElement(strClassName);
            NFDataList xDataList   = xLogicClass.GetRecordManager().GetRecordList();

            for (int i = 0; i < xDataList.Count(); ++i)
            {
                string    strRecordyName = xDataList.StringVal(i);
                NFIRecord xRecord        = xLogicClass.GetRecordManager().GetRecord(strRecordyName);

                NFIObject        xObject        = GetObject(self);
                NFIRecordManager xRecordManager = xObject.GetRecordManager();

                NFIRecord record = xRecordManager.AddRecord(strRecordyName, xRecord.GetRows(), xRecord.GetColsData());
                if (record != null)
                {
                    record.SetUpload(xRecord.GetUpload());
                }
            }
        }
Exemplo n.º 5
0
        void InitProperty(NFGUID self, string strClassName)
        {
            NFIClass   xLogicClass = mxLogicClassModule.GetElement(strClassName);
            NFDataList xDataList   = xLogicClass.GetPropertyManager().GetPropertyList();

            for (int i = 0; i < xDataList.Count(); ++i)
            {
                string      strPropertyName = xDataList.StringVal(i);
                NFIProperty xProperty       = xLogicClass.GetPropertyManager().GetProperty(strPropertyName);

                NFIObject          xObject          = GetObject(self);
                NFIPropertyManager xPropertyManager = xObject.GetPropertyManager();

                NFIProperty property = xPropertyManager.AddProperty(strPropertyName, xProperty.GetData());
                //if property==null ,means this property alreay exist in manager
                if (property != null)
                {
                    property.SetUpload(xProperty.GetUpload());
                }
            }
        }
Exemplo n.º 6
0
        private void LoadLogicClassRecord(string strName)
        {
            NFIClass xLogicClass = GetElement(strName);

            if (null != xLogicClass)
            {
                string strLogicPath = mstrPath + xLogicClass.GetPath();

                XmlDocument xmldoc = new XmlDocument();

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

                    byte[] data = Convert.FromBase64String(strContent);
                    string res  = System.Text.ASCIIEncoding.Default.GetString(data);

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

                XmlNode xRoot          = xmldoc.SelectSingleNode("XML");
                XmlNode xNodePropertys = xRoot.SelectSingleNode("Records");
                if (null != xNodePropertys)
                {
                    XmlNodeList xNodeList = xNodePropertys.SelectNodes("Record");
                    if (null != xNodeList)
                    {
                        for (int i = 0; i < xNodeList.Count; ++i)
                        {
                            XmlNode xRecordNode = xNodeList.Item(i);

                            string     strID     = xRecordNode.Attributes["Id"].Value;
                            string     strRow    = xRecordNode.Attributes["Row"].Value;
                            string     strUpload = xRecordNode.Attributes["Upload"].Value;
                            bool       bUpload   = strUpload.Equals("1");
                            NFDataList xValue    = new NFDataList();

                            XmlNodeList xTagNodeList = xRecordNode.SelectNodes("Col");
                            for (int j = 0; j < xTagNodeList.Count; ++j)
                            {
                                XmlNode xColTagNode = xTagNodeList.Item(j);

                                XmlAttribute strTagID   = xColTagNode.Attributes["Tag"];
                                XmlAttribute strTagType = xColTagNode.Attributes["Type"];


                                switch (strTagType.Value)
                                {
                                case "int":
                                {
                                    xValue.AddInt(0);
                                }
                                break;

                                case "float":
                                {
                                    xValue.AddFloat(0.0);
                                }
                                break;

                                case "string":
                                {
                                    xValue.AddString("");
                                }
                                break;

                                case "object":
                                {
                                    xValue.AddObject(new NFGUID(0, 0));
                                }
                                break;

                                case "vector2":
                                {
                                    xValue.AddVector2(NFVector2.Zero());
                                }
                                break;

                                case "vector3":
                                {
                                    xValue.AddVector3(NFVector3.Zero());
                                }
                                break;

                                default:
                                    break;
                                }
                            }
                            NFIRecord xRecord = xLogicClass.GetRecordManager().AddRecord(strID, int.Parse(strRow), xValue);
                            xRecord.SetUpload(bUpload);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void LoadLogicClassProperty(string strName)
        {
            NFIClass xLogicClass = GetElement(strName);

            if (null != xLogicClass)
            {
                string strLogicPath = mstrPath + xLogicClass.GetPath();

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

                    byte[] data = Convert.FromBase64String(strContent);
                    string res  = System.Text.ASCIIEncoding.Default.GetString(data);

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

                XmlNode     xRoot          = xmldoc.SelectSingleNode("XML");
                XmlNode     xNodePropertys = xRoot.SelectSingleNode("Propertys");
                XmlNodeList xNodeList      = xNodePropertys.SelectNodes("Property");
                for (int i = 0; i < xNodeList.Count; ++i)
                {
                    XmlNode      xPropertyNode = xNodeList.Item(i);
                    XmlAttribute strID         = xPropertyNode.Attributes["Id"];
                    XmlAttribute strType       = xPropertyNode.Attributes["Type"];
                    XmlAttribute strUpload     = xPropertyNode.Attributes["Upload"];
                    bool         bUpload       = strUpload.Value.Equals("1");

                    switch (strType.Value)
                    {
                    case "int":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddInt(0);
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "float":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddFloat(0.0);
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "string":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddString("");
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "object":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddObject(new NFGUID(0, 0));
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct)
        {
            NFIObject go = mKernelModule.GetObject(self);

            if (go == null)
            {
                Debug.LogError("error id" + self);
                return;
            }

            NFIRecordManager xRecordManager = go.GetRecordManager();

            Hashtable recordVecDesc = new Hashtable();
            Hashtable recordVecData = new Hashtable();

            for (int k = 0; k < xAddStruct.RecordIntList.Count; ++k)
            {
                NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.RecordIntList[k];

                if (addIntStruct.Col >= 0)
                {
                    recordVecDesc[addIntStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_INT;
                    recordVecData[addIntStruct.Col] = addIntStruct.Data;
                }
            }

            for (int k = 0; k < xAddStruct.RecordFloatList.Count; ++k)
            {
                NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.RecordFloatList[k];

                if (addFloatStruct.Col >= 0)
                {
                    recordVecDesc[addFloatStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_FLOAT;
                    recordVecData[addFloatStruct.Col] = addFloatStruct.Data;
                }
            }

            for (int k = 0; k < xAddStruct.RecordStringList.Count; ++k)
            {
                NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.RecordStringList[k];

                if (addStringStruct.Col >= 0)
                {
                    recordVecDesc[addStringStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_STRING;
                    if (addStringStruct.Data != null)
                    {
                        recordVecData[addStringStruct.Col] = addStringStruct.Data.ToStringUtf8();
                    }
                    else
                    {
                        recordVecData[addStringStruct.Col] = "";
                    }
                }
            }

            for (int k = 0; k < xAddStruct.RecordObjectList.Count; ++k)
            {
                NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.RecordObjectList[k];

                if (addObjectStruct.Col >= 0)
                {
                    recordVecDesc[addObjectStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_OBJECT;
                    recordVecData[addObjectStruct.Col] = mHelpModule.PBToNF(addObjectStruct.Data);
                }
            }

            for (int k = 0; k < xAddStruct.RecordVector2List.Count; ++k)
            {
                NFMsg.RecordVector2 addObjectStruct = (NFMsg.RecordVector2)xAddStruct.RecordVector2List[k];

                if (addObjectStruct.Col >= 0)
                {
                    recordVecDesc[addObjectStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR2;
                    recordVecData[addObjectStruct.Col] = mHelpModule.PBToNF(addObjectStruct.Data);
                }
            }

            for (int k = 0; k < xAddStruct.RecordVector3List.Count; ++k)
            {
                NFMsg.RecordVector3 addObjectStruct = (NFMsg.RecordVector3)xAddStruct.RecordVector3List[k];

                if (addObjectStruct.Col >= 0)
                {
                    recordVecDesc[addObjectStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR3;
                    recordVecData[addObjectStruct.Col] = mHelpModule.PBToNF(addObjectStruct.Data);
                }
            }

            NFDataList varListDesc = new NFDataList();
            NFDataList varListData = new NFDataList();

            for (int m = 0; m < recordVecDesc.Count; m++)
            {
                if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m))
                {
                    NFDataList.VARIANT_TYPE nType = (NFDataList.VARIANT_TYPE)recordVecDesc[m];
                    switch (nType)
                    {
                    case NFDataList.VARIANT_TYPE.VTYPE_INT:
                    {
                        varListDesc.AddInt(0);
                        varListData.AddInt((Int64)recordVecData[m]);
                    }

                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_FLOAT:
                    {
                        varListDesc.AddFloat(0.0f);
                        varListData.AddFloat((float)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                    {
                        varListDesc.AddString("");
                        varListData.AddString((string)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_OBJECT:
                    {
                        varListDesc.AddObject(new NFGUID());
                        varListData.AddObject((NFGUID)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2:
                    {
                        varListDesc.AddVector2(new NFVector2());
                        varListData.AddVector2((NFVector2)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3:
                    {
                        varListDesc.AddVector3(new NFVector3());
                        varListData.AddVector3((NFVector3)recordVecData[m]);
                    }
                    break;

                    default:
                        break;
                    }
                }
                else
                {
                    //����
                    //Debug.LogException(i);
                }
            }

            NFIRecord xRecord = xRecordManager.GetRecord(strRecordName);

            if (null == xRecord)
            {
                Debug.Log("Empty record:" + strRecordName);
                string    strClassName  = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName);
                NFIClass  xLogicClass   = mClassModule.GetElement(strClassName);
                NFIRecord xStaticRecord = xLogicClass.GetRecordManager().GetRecord(strRecordName);

                xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc, xStaticRecord.GetTagData());
            }

            xRecord.AddRow(xAddStruct.Row, varListData);
        }
Exemplo n.º 9
0
        private void LoadInstanceElement(NFIClass xLogicClass)
        {
            string strLogicPath = mstrRootPath;

            strLogicPath += xLogicClass.GetInstance();

            strLogicPath = strLogicPath.Replace(".xml", "");

            TextAsset textAsset = (TextAsset)Resources.Load(strLogicPath);

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(textAsset.text);
            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)
                        {
                            NFDataList.VARIANT_TYPE eType = xProperty.GetType();
                            switch (eType)
                            {
                            case NFDataList.VARIANT_TYPE.VTYPE_INT:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddInt(int.Parse(xAttribute.Value));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFDataList.VARIANT_TYPE.VTYPE_FLOAT:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddFloat(float.Parse(xAttribute.Value));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddString(xAttribute.Value);
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFDataList.VARIANT_TYPE.VTYPE_OBJECT:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddObject(new NFGUID(0, int.Parse(xAttribute.Value)));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void LoadLogicClassRecord(string strName)
        {
            NFIClass xLogicClass = GetElement(strName);

            if (null != xLogicClass)
            {
                string strLogicPath = mstrPath + xLogicClass.GetPath();
                strLogicPath = strLogicPath.Replace(".xml", "");

                TextAsset textAsset = (TextAsset)Resources.Load(strLogicPath);

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(textAsset.text);
                XmlNode xRoot = xmldoc.SelectSingleNode("XML");

                XmlNode xNodePropertys = xRoot.SelectSingleNode("Records");
                if (null != xNodePropertys)
                {
                    XmlNodeList xNodeList = xNodePropertys.SelectNodes("Record");
                    if (null != xNodeList)
                    {
                        for (int i = 0; i < xNodeList.Count; ++i)
                        {
                            XmlNode xRecordNode = xNodeList.Item(i);

                            string     strID     = xRecordNode.Attributes["Id"].Value;
                            string     strRow    = xRecordNode.Attributes["Row"].Value;
                            string     strUpload = xRecordNode.Attributes["Upload"].Value;
                            bool       bUpload   = strUpload.Equals("1");
                            NFDataList xValue    = new NFDataList();

                            XmlNodeList xTagNodeList = xRecordNode.SelectNodes("Col");
                            for (int j = 0; j < xTagNodeList.Count; ++j)
                            {
                                XmlNode xColTagNode = xTagNodeList.Item(j);

                                XmlAttribute strTagID   = xColTagNode.Attributes["Tag"];
                                XmlAttribute strTagType = xColTagNode.Attributes["Type"];


                                switch (strTagType.Value)
                                {
                                case "int":
                                {
                                    xValue.AddInt(0);
                                }
                                break;

                                case "float":
                                {
                                    xValue.AddFloat(0.0);
                                }
                                break;

                                case "string":
                                {
                                    xValue.AddString("");
                                }
                                break;

                                case "object":
                                {
                                    xValue.AddObject(new NFGUID(0, 0));
                                }
                                break;

                                case "vector2":
                                {
                                    xValue.AddVector2(NFVector2.Zero());
                                }
                                break;

                                case "vector3":
                                {
                                    xValue.AddVector3(NFVector3.Zero());
                                }
                                break;

                                default:
                                    break;
                                }
                            }
                            NFIRecord xRecord = xLogicClass.GetRecordManager().AddRecord(strID, int.Parse(strRow), xValue);
                            xRecord.SetUpload(bUpload);
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        private void LoadLogicClassProperty(string strName)
        {
            NFIClass xLogicClass = GetElement(strName);

            if (null != xLogicClass)
            {
                string strLogicPath = mstrPath + xLogicClass.GetPath();

                strLogicPath = strLogicPath.Replace(".xml", "");

                TextAsset textAsset = (TextAsset)Resources.Load(strLogicPath);

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(textAsset.text);
                XmlNode xRoot = xmldoc.SelectSingleNode("XML");

                XmlNode     xNodePropertys = xRoot.SelectSingleNode("Propertys");
                XmlNodeList xNodeList      = xNodePropertys.SelectNodes("Property");
                for (int i = 0; i < xNodeList.Count; ++i)
                {
                    XmlNode      xPropertyNode = xNodeList.Item(i);
                    XmlAttribute strID         = xPropertyNode.Attributes["Id"];
                    XmlAttribute strType       = xPropertyNode.Attributes["Type"];
                    XmlAttribute strUpload     = xPropertyNode.Attributes["Upload"];
                    bool         bUpload       = strUpload.Value.Equals("1");

                    switch (strType.Value)
                    {
                    case "int":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddInt(0);
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "float":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddFloat(0.0);
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "string":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddString("");
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "object":
                    {
                        NFDataList xValue = new NFDataList();
                        xValue.AddObject(new NFGUID(0, 0));
                        NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
Exemplo n.º 12
0
        private void LoadInstanceElement(NFIClass xLogicClass)
        {
            string strLogicPath = mstrRootPath;

            strLogicPath += xLogicClass.GetInstance();

            XmlDocument xmldoc = new XmlDocument();

            if (xLogicClass.GetEncrypt())
            {
                ///////////////////////////////////////////////////////////////////////////////////////
                StreamReader cepherReader = new StreamReader(strLogicPath);;
                string       strContent   = cepherReader.ReadToEnd();
                cepherReader.Close();

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

                string res = System.Text.ASCIIEncoding.Default.GetString(data);

                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)
                        {
                            NFDataList.VARIANT_TYPE eType = xProperty.GetType();
                            switch (eType)
                            {
                            case NFDataList.VARIANT_TYPE.VTYPE_INT:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddInt(int.Parse(xAttribute.Value));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFDataList.VARIANT_TYPE.VTYPE_FLOAT:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddFloat(float.Parse(xAttribute.Value));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddString(xAttribute.Value);
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFDataList.VARIANT_TYPE.VTYPE_OBJECT:
                            {
                                NFDataList xValue = new NFDataList();
                                xValue.AddObject(new NFGUID(0, int.Parse(xAttribute.Value)));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }