public override bool SetPropertyDouble(string strPropertyName, double dwValue) { NFIProperty property = mPropertyManager.GetProperty(strPropertyName); if (null == property) { NFIDataList valueList = new NFCDataList(); valueList.AddDouble(0); property = mPropertyManager.AddProperty(strPropertyName, valueList); } property.SetDouble(dwValue); return(true); }
public override NFIObject CreateObject(NFGUID self, int nContainerID, int nGroupID, string strClassName, string strConfigIndex, NFIDataList arg) { if (!mhtObject.ContainsKey(self)) { NFIObject xNewObject = new NFCObject(self, nContainerID, nGroupID, strClassName, strConfigIndex); mhtObject.Add(self, xNewObject); NFCDataList varConfigID = new NFCDataList(); varConfigID.AddString(strConfigIndex); xNewObject.GetPropertyManager().AddProperty("ConfigID", varConfigID); NFCDataList varConfigClass = new NFCDataList(); varConfigClass.AddString(strClassName); xNewObject.GetPropertyManager().AddProperty("ClassName", varConfigClass); if (arg.Count() % 2 == 0) { for (int i = 0; i < arg.Count() - 1; i += 2) { string strPropertyName = arg.StringVal(i); NFIDataList.VARIANT_TYPE eType = arg.GetType(i + 1); switch (eType) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddInt(arg.IntVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddFloat(arg.FloatVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE: { NFIDataList xDataList = new NFCDataList(); xDataList.AddDouble(arg.DoubleVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { NFIDataList xDataList = new NFCDataList(); xDataList.AddString(arg.StringVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddObject(arg.ObjectVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; default: break; } } } InitProperty(self, strClassName); InitRecord(self, strClassName); ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName]; if (null != xHandleDel && null != xHandleDel.GetHandler()) { NFIObject.ClassEventHandler xHandlerList = xHandleDel.GetHandler(); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_LOADDATA, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH, strClassName, strConfigIndex); } //NFCLog.Instance.Log(NFCLog.LOG_LEVEL.DEBUG, "Create object: " + self.ToString() + " ClassName: " + strClassName + " SceneID: " + nContainerID + " GroupID: " + nGroupID); return(xNewObject); } return(null); }
public override bool SetDouble(int nRow, int nCol, double value) { if(nRow >= 0 && nRow < mnRow) { if (!mhtRecordVec.ContainsKey(nRow)) { AddRow(nRow); } NFIDataList valueList = (NFIDataList)mhtRecordVec[nRow]; if (valueList.GetType(nCol) == NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE) { if (valueList.DoubleVal(nCol) - value > 0.01f || valueList.DoubleVal(nCol) - value < -0.01f) { NFCDataList oldValue = new NFCDataList(); oldValue.AddDouble(valueList.DoubleVal(nCol)); valueList.SetDouble(nCol, value); NFCDataList newValue = new NFCDataList(); newValue.AddDouble(valueList.DoubleVal(nCol)); if (null != doHandleDel) { doHandleDel(mSelf, mstrRecordName, eRecordOptype.Updata, nRow, nCol, oldValue, newValue); } } } return true; } return false; }
public override bool SetPropertyDouble(string strPropertyName, double dwValue) { NFIProperty property = mPropertyManager.GetProperty(strPropertyName); if (null == property) { NFIDataList valueList = new NFCDataList(); valueList.AddDouble(0); property = mPropertyManager.AddProperty(strPropertyName, valueList); } property.SetDouble(dwValue); return true; }
public override NFIObject CreateObject(NFGUID self, int nContainerID, int nGroupID, string strClassName, string strConfigIndex, NFIDataList arg) { if (!mhtObject.ContainsKey(self)) { NFIObject xNewObject = new NFCObject(self, nContainerID, nGroupID, strClassName, strConfigIndex); mhtObject.Add(self, xNewObject); NFCDataList varConfigID = new NFCDataList(); varConfigID.AddString(strConfigIndex); xNewObject.GetPropertyManager().AddProperty("ConfigID", varConfigID); NFCDataList varConfigClass = new NFCDataList(); varConfigClass.AddString(strClassName); xNewObject.GetPropertyManager().AddProperty("ClassName", varConfigClass); if (arg.Count() % 2 == 0) { for (int i = 0; i < arg.Count() - 1; i += 2) { string strPropertyName = arg.StringVal(i); NFIDataList.VARIANT_TYPE eType = arg.GetType(i + 1); switch (eType) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddInt(arg.IntVal(i+1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddFloat(arg.FloatVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE: { NFIDataList xDataList = new NFCDataList(); xDataList.AddDouble(arg.DoubleVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { NFIDataList xDataList = new NFCDataList(); xDataList.AddString(arg.StringVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddObject(arg.ObjectVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; default: break; } } } InitProperty(self, strClassName); InitRecord(self, strClassName); ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName]; if (null != xHandleDel && null != xHandleDel.GetHandler()) { NFIObject.ClassEventHandler xHandlerList = xHandleDel.GetHandler(); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_LOADDATA, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH, strClassName, strConfigIndex); } //NFCLog.Instance.Log(NFCLog.LOG_LEVEL.DEBUG, "Create object: " + self.ToString() + " ClassName: " + strClassName + " SceneID: " + nContainerID + " GroupID: " + nGroupID); return xNewObject; } return null; }
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(); string res = System.Text.ASCIIEncoding.Default.GetString(data); 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 NFGUID(0, int.Parse(xAttribute.Value))); xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); } break; default: break; } } } } } }
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(); string res = System.Text.ASCIIEncoding.Default.GetString(data); 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 NFGUID(0, int.Parse(xAttribute.Value))); xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); } break; default: break; } } } } } }
private void LoadLogicClassRecord(string strName) { NFILogicClass xLogicClass = GetElement(strName); if (null != xLogicClass) { string strLogicPath = xLogicClass.GetPath(); 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"); 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; NFIDataList xValue = new NFCDataList(); 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.0f); } break; case "double": { xValue.AddDouble(0.0f); } break; case "string": { xValue.AddString(""); } break; case "object": { xValue.AddObject(new NFIDENTID(0, 0)); } break; default: break; } } xLogicClass.GetRecordManager().AddRecord(strID, int.Parse(strRow), xValue); } } } } }
private void LoadLogicClassRecord(string strName) { NFILogicClass xLogicClass = GetElement(strName); if (null != xLogicClass) { string strLogicPath = mstrPath + xLogicClass.GetPath(); 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(); string res = System.Text.ASCIIEncoding.Default.GetString(data); xmldoc.LoadXml(res); ///////////////////////////////////////////////////////////////// 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; NFIDataList xValue = new NFCDataList(); 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.0f); } break; case "double": { xValue.AddDouble(0.0f); } break; case "string": { xValue.AddString(""); } break; case "object": { xValue.AddObject(new NFGUID(0, 0)); } break; default: break; } } xLogicClass.GetRecordManager().AddRecord(strID, int.Parse(strRow), xValue); } } } } }
private void LoadLogicClassProperty(string strName) { NFILogicClass xLogicClass = GetElement(strName); if (null != xLogicClass) { string strLogicPath = mstrPath + xLogicClass.GetPath(); 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(); string res = System.Text.ASCIIEncoding.Default.GetString(data); xmldoc.LoadXml(res); ///////////////////////////////////////////////////////////////// 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"]; switch (strType.Value) { case "int": { NFIDataList xValue = new NFCDataList(); xValue.AddInt(0); xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); } break; case "float": { NFIDataList xValue = new NFCDataList(); xValue.AddFloat(0.0f); xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); } break; case "double": { NFIDataList xValue = new NFCDataList(); xValue.AddDouble(0.0f); xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); } break; case "string": { NFIDataList xValue = new NFCDataList(); xValue.AddString(""); xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); } break; case "object": { NFIDataList xValue = new NFCDataList(); xValue.AddObject(new NFGUID(0, 0)); xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); } break; default: break; } } } }