public void ReloadItem(Int32 tid) { mAllItems.Remove(tid); var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ""); string tempPath = System.IO.Path.Combine(path, GetFilePath()); var cType = typeof(ItemT); var atts = cType.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true); string suffix = ""; if (atts.Length > 0) { ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute; suffix = dea.m_strFileExt.Substring(1); } string itemname = tid.ToString() + "." + suffix; string fullPathname = System.IO.Path.Combine(tempPath, itemname); ItemT item = new ItemT(); if (ServerFrame.Config.IConfigurator.FillProperty(item, fullPathname)) { var templateid = tid; mAllItems.Add(templateid, item); OnLoadedItem(item, templateid); } }
public void LoadAllTemplate(string tPath) { try { mAllItems.Clear(); var files = System.IO.Directory.GetFiles(System.IO.Path.Combine(tPath, GetFilePath())); var cType = typeof(ItemT); var atts = cType.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true); string suffix = ""; if (atts.Length > 0) { ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute; suffix = dea.m_strFileExt.Substring(1); } foreach (var i in files) { if (i.Contains("meta")) { continue; } string[] strs = i.Substring(i.LastIndexOf("\\") + 1).Split('.'); if (strs.Length < 2) { continue; } if (strs[1] == suffix) { string fullPathname = i; ItemT item = new ItemT(); if (ServerFrame.Config.IConfigurator.FillProperty(item, fullPathname)) { var templateid = int.Parse(strs[0]); mAllItems.Add(templateid, item); OnLoadedItem(item, templateid); } } } } catch (System.Exception ex) { } }
public Form1() { InitializeComponent(); mInst = this; string fullPathname = ServerCommon.IServer.Instance.ExePath + "TemplateConfig.cfg"; if (false == ServerFrame.Config.IConfigurator.FillProperty(mConfig, fullPathname)) { //System.Windows.Forms.MessageBox.Show("请检查服务器配置文件"); ServerFrame.Config.IConfigurator.SaveProperty(mConfig, "TemplateConfig", fullPathname); } propertyGrid1.SelectedObject = mConfig; ApplyConfig(); string dir = System.AppDomain.CurrentDomain.BaseDirectory + "CodeLinker.dll"; m_UIEditorAssembly = System.Reflection.Assembly.LoadFile(dir); var aTypes = m_UIEditorAssembly.GetTypes(); //foreach (var type in aTypes) //{ // var atts = type.GetCustomAttributes(typeof(Device.CDataEditorAttribute), true); // if (atts.Length > 0) // { // Device.CDataEditorAttribute dea = atts[0] as Device.CDataEditorAttribute; // CComboBoxItem item = new CComboBoxItem() // { // m_Type = type, // m_strExt = dea.m_strFileExt // }; // comboBox_Templates.Items.Add(item); // } //} dir = System.AppDomain.CurrentDomain.BaseDirectory + "ServerCommon.dll"; //var dir = System.IO.Directory.GetCurrentDirectory() + "\\ServerCommon.dll"; m_ServerCommonAssembly = System.Reflection.Assembly.LoadFile(dir); aTypes = m_ServerCommonAssembly.GetTypes(); foreach (var type in aTypes) { var atts = type.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true); if (atts.Length > 0) { ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute; CComboBoxItem item = new CComboBoxItem() { m_Type = type, m_strExt = dea.m_strFileExt }; comboBox_Templates.Items.Add(item); } } dir = System.AppDomain.CurrentDomain.BaseDirectory + "CSCommon.dll"; //var dir = System.IO.Directory.GetCurrentDirectory() + "\\ServerCommon.dll"; m_CSCommonAssembly = System.Reflection.Assembly.LoadFile(dir); aTypes = m_CSCommonAssembly.GetTypes(); foreach (var type in aTypes) { var atts = type.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true); if (atts.Length > 0) { ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute; CComboBoxItem item = new CComboBoxItem() { m_Type = type, m_strExt = dea.m_strFileExt }; comboBox_Templates.Items.Add(item); } } comboBox_Templates.SelectedIndex = 0; }
private DataSet _CreateDateSetFromFile(string suffix, IEnumerable <string> files, out Type curType) { // var aTypes = Form1.Inst.m_ServerCommonAssembly.GetTypes(); // curType = null; // foreach (var type in aTypes) // { // var atts = type.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true); // // if (atts.Length > 0) // { // ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute; // if (dea.m_strFileExt == suffix) // { // curType = type; // break; // } // } // } curType = null; var aTypes = Form1.Inst.m_CSCommonAssembly.GetTypes(); foreach (var type in aTypes) { var atts = type.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true); if (atts.Length > 0) { ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute; if (dea.m_strFileExt == suffix) { curType = type; break; } } } mDataset = new DataSet(); mExportFileName = suffix.Substring(1); var rootTable = new DataTable("@_root"); mDataset.Tables.Add(rootTable); mTableNameToTypeName[rootTable.TableName] = curType.ToString(); if (curType == null) { return(mDataset); } var column = new DataColumn(); column.DataType = typeof(string); column.ColumnName = "@filename"; column.Caption = "文件名"; column.ReadOnly = false; column.Unique = false; rootTable.Columns.Add(column); _InitColumn(curType, rootTable, null); var keys = new Stack <ParentKeysInfo>(); var props = curType.GetProperties(); foreach (var file in files) { var dotIdx = file.LastIndexOf('.'); if (dotIdx < 0) { continue; } if (file.Substring(dotIdx) != suffix) { continue; } var obj = Form1.Inst.m_CSCommonAssembly.CreateInstance(curType.ToString()); ServerFrame.Config.IConfigurator.FillProperty(obj, file); var row = rootTable.NewRow(); row["@filename"] = file.Substring(file.LastIndexOf('\\') + 1); //mCurFileName = row["@filename"].ToString(); ParentKeysInfo key = new ParentKeysInfo(); key.KeyName = "@filename"; key.Descrip = "文件名"; key.value = row["@filename"]; keys.Push(key); _FillRow(obj, row, props, -1, keys, null); rootTable.Rows.Add(row); keys.Pop(); } return(mDataset); }