private void txtFile_TextChanged(object sender, EventArgs e) { string text = txtFile.Text; if (!String.IsNullOrWhiteSpace(text) && File.Exists(text)) { workbook = WorkbookFactory.Create(text); int sheetsCount = workbook.NumberOfSheets; BindItem item; items.Clear(); for (int i = 0; i < sheetsCount; i++) { item = new BindItem(); item.Text = workbook.GetSheetName(i); item.Value = i.ToString(); items.Add(item); } cmbSheets.DataSource = null; cmbSheets.DataSource = items; cmbSheets.DisplayMember = "Text"; cmbSheets.ValueMember = "Value"; if (cmbSheets.Items.Count > 0) { cmbSheets.SelectedIndex = -1; cmbSheets.SelectedIndex = 0; } } }
static System.Collections.Generic.List <BindItem> TryGetBind(System.Type entityType) { string key = entityType.AssemblyQualifiedName; var list = _list_key.GetOrAdd(key, (p) => { if (entityType.IsValueType || entityType == typeof(string) || entityType == typeof(object) || TypeExtensions.IsNullableType(entityType)) { return(null); } var cache = new System.Collections.Generic.List <BindItem>(); foreach (System.Reflection.PropertyInfo propertyInfo in entityType.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.SetProperty)) { var binder = AttributeExtensions.GetCustomAttribute <DataBinderAttribute>(propertyInfo); if (binder == null) { continue; } BindItem bindItem = new BindItem() { propertyInfo = propertyInfo, binder = binder, bindAction = binder.Bind, }; cache.Add(bindItem); } return(cache); }); return(list); }
public ListViewAdapter(RectTransform container, GameObject listItem, BindItem bindItem) { this.container = container; this.bindItem = bindItem; this.listItem = listItem; this.itemHeight = listItem.GetComponent <RectTransform>().rect.height; }
/// <summary> /// 把拆分好的变量设置到luabehaviour里面 /// </summary> /// <param name="Obj"></param> /// <param name="buildPath"></param> static private void SetLuaBehaviour(UnityEngine.GameObject Obj, string buildPath) { if (Obj != null) { LuaBehaviour luaBehaviour = Obj.transform.GetComponent <LuaBehaviour>(); if (luaBehaviour == null) { luaBehaviour = Obj.AddComponent <LuaBehaviour>(); } if (luaBehaviour != null) { List <BindItem> lst = new List <BindItem>(); if (luaBehaviourDefine != null) { foreach (KeyValuePair <string, UnityEngine.Object> pair in luaBehaviourDefine) { string name = pair.Key; UnityEngine.Object obj = pair.Value; BindItem bItem = new BindItem(); bItem.name = name; bItem.obj = obj; lst.Add(bItem); } string luaFilePath = buildPath.Replace(constLuaPath, ""); luaBehaviour.SetInitInfo(luaFilePath, lst); } } } }
public WxUserResult Bind(BindItem item) { string error = ""; dp2WeiXinService.Instance.WriteDebug("走进bind API"); if (item.bindLibraryCode == null) { item.bindLibraryCode = ""; } // 返回对象 WxUserResult result = new WxUserResult(); // 前端有时传上来是这个值 if (item.prefix == "null") { item.prefix = ""; } WxUserItem userItem = null; int nRet = dp2WeiXinService.Instance.Bind(item.libId, item.bindLibraryCode, item.prefix, item.word, item.password, item.weixinId, out userItem, out error); if (nRet == -1) { result.errorCode = -1; result.errorInfo = error; return(result); } result.users = new List <WxUserItem>(); result.users.Add(userItem); // 将绑定的帐户设为当前帐户 nRet = ApiHelper.ActiveUser(userItem, out error); if (nRet == -1) { result.errorCode = -1; result.errorInfo = error; return(result); } return(result); }
/// <summary> /// 逐行分析!@#definestart到!@#defineend的详细内容 /// </summary> /// <param name="ln"></param> /// <param name="luaBehaviour"></param> void parseField(string ln, LuaBehaviour luaBehaviour) { int pos = ln.IndexOf("--"); if (pos == 0) { fieldType = ln.Substring(2); return; } pos = ln.IndexOf("="); if (pos > 0) { string field = ln.Substring(0, pos).Trim(); object value = null; BindItem item = null; if (luaBehaviour.bindObjs != null) { for (int i = 0; i < luaBehaviour.bindObjs.Count; i++) { if (luaBehaviour.bindObjs[i].name == field) { item = luaBehaviour.bindObjs[i]; value = luaBehaviour.bindObjs[i].obj; break; } } } if (fieldType == "") { fieldType = "GameObject"; } Type type = getType(fieldType); UnityEngine.Object go = EditorGUILayout.ObjectField(field, (item == null ? null : item.obj as UnityEngine.Object), type, true); if (item != null) { item.obj = go; } else if (go != null) { item = new BindItem(); item.obj = go; item.name = field; if (luaBehaviour.bindObjs == null) { luaBehaviour.bindObjs = new List <BindItem>(); } luaBehaviour.bindObjs.Add(item); } fieldType = ""; } }
private void UpdateUI(string inputFile) { treeLoaded.Nodes.Clear(); var item = new BindItem(FileUtils.GetFileNameOnly(inputFile), inputFile); treeLoaded.Nodes.Add(new TreeNode { Text = item.Name, Tag = item }); if (_processAssembly == null) { return; } if (_processAssembly.Value == false) // process rules { inputFile = FileUtils.Copy(inputFile); lstResources.Items.Add(inputFile); } else // process assembly { try { string assemblyPath = FileUtils.Copy(inputFile); // load assembly in memory _assemblyResolver = new AssemblyResolver(assemblyPath); _assemblyResolver.OnAssemblyLoaded += AssemblyResolverOnAssemblyLoaded; _assemblyResolver.Load(); } catch (ArgumentNullException argumentException) { MessageBox.Show(@"Some technical error occured : " + argumentException.Message); } catch (InvalidOperationException loadException) { MessageBox.Show(loadException.Message); } catch (Exception ex) { MessageBox.Show(@"Unknown error occured : " + ex.Message); } } }
private void dgvRules_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { if (dgvRules.Rows.Count > e.RowIndex) { DataGridViewRow row = dgvRules.Rows[e.RowIndex]; LoadControlData(row); if (items.Count > 0) { BindItem[] itemArr = new BindItem[items.Count]; items.CopyTo(itemArr); DataGridViewComboBoxCell cell = row.Cells["Field"] as DataGridViewComboBoxCell; if (cell != null) { cell.DataSource = itemArr; cell.DisplayMember = "Text"; cell.ValueMember = "Value"; cell.Value = itemArr[0].Value; } } } }
static System.Collections.Generic.List <BindItem> TryGetBind(System.Type entityType) { string key = entityType.AssemblyQualifiedName; System.Collections.Generic.List <BindItem> list; if (!_list_key.TryGetValue(key, out list)) { ThreadHelper.Block(_list_key, () => { if (!_list_key.TryGetValue(key, out list)) { if (entityType.IsValueType || entityType == typeof(string) || entityType == typeof(object) || TypeExtensions.IsNullableType(entityType)) { _list_key.TryAdd(key, null); return; } list = new System.Collections.Generic.List <BindItem>(); foreach (System.Reflection.PropertyInfo propertyInfo in entityType.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.SetProperty)) { var binder = AttributeExtensions.GetCustomAttribute <DataBinderAttribute>(propertyInfo); if (binder == null) { continue; } BindItem bindItem = new BindItem() { propertyInfo = propertyInfo, binder = binder, bindAction = binder.Bind, }; list.Add(bindItem); } _list_key.TryAdd(key, list.Count == 0 ? null : list); } }); } return(list); }
private void txtFilePath_TextChanged(object sender, EventArgs e) { string text = txtFilePath.Text; if (!String.IsNullOrWhiteSpace(text) && File.Exists(text)) { try { workbook = WorkbookFactory.Create(text); } catch (Exception ex) { MessageBox.Show("文件:" + text + "文件已经打开!"); return; } List <BindItem> items = new List <BindItem>(); int sheetsCount = workbook.NumberOfSheets; BindItem item; for (int i = 0; i < sheetsCount; i++) { item = new BindItem(); item.Text = workbook.GetSheetName(i); item.Value = i.ToString(); items.Add(item); } cmbSheets.DataSource = items; cmbSheets.DisplayMember = "Text"; cmbSheets.ValueMember = "Value"; if (cmbSheets.Items.Count > 0) { cmbSheets.SelectedIndex = -1; cmbSheets.SelectedIndex = 0; } } }
private void LoadModuleData() { cbxDataName.Items.Clear(); if (cbxDataType.Items.Count <= 0) { return; } if (cbxDataType.SelectedIndex <= 0) { foreach (ISysDesign dc in _modules.Values) { //载入模块提供的数据项名称 foreach (KeyValuePair <string, string> dn in dc.ProvideDatas) { BindItem bi = new BindItem(dn.Key, dn.Value); cbxDataName.Items.Add(bi); } } } else { foreach (ISysDesign dc in _modules.ParentWindowBizModules.Values) { //载入模块提供的数据项名称 foreach (KeyValuePair <string, string> dn in dc.ProvideDatas) { BindItem bi = new BindItem(dn.Key, dn.Value); cbxDataName.Items.Add(bi); } } } }
List <BindItem> GetIisCertBindings(Dictionary <string, Tuple <Certificate, bool> > certs) { List <BindItem> bindItems = new List <BindItem>(); // サーバーに存在するすべての証明書バインディングを取得 foreach (var site in Svr.Sites.Where(x => x.Name._IsFilled()).OrderBy(x => x.Name)) { foreach (var bind in site.Bindings.Where(x => x.BindingInformation._IsFilled()).OrderBy(x => x.BindingInformation)) { if (bind.Protocol._IsSamei("https")) { if (bind.CertificateHash != null && bind.CertificateHash.Length >= 1) { string hash = bind.CertificateHash._GetHexString(); if (certs.TryGetValue(hash, out Tuple <Certificate, bool>?certTuple)) { var cert = certTuple.Item1; BindItem item = new BindItem { BindingInfo = bind.BindingInformation, Cert = cert, SiteName = site.Name, HostName = bind.Host._NormalizeFqdn()._NonNullTrim(), HasPrivateKey = certTuple.Item2, }; bindItems.Add(item); } } } else if (bind.Protocol._IsSamei("ftp")) { var ftpServer = site.GetChildElement("ftpServer"); if (ftpServer != null) { var security = ftpServer.GetChildElement("security"); if (security != null) { var ssl = security.GetChildElement("ssl"); if (ssl != null) { string hash = (string)ssl.Attributes["serverCertHash"].Value; if (hash._IsFilled()) { hash = hash._NormalizeHexString(); if (certs.TryGetValue(hash, out Tuple <Certificate, bool>?certTuple)) { var cert = certTuple.Item1; BindItem item = new BindItem { BindingInfo = "ftp", Cert = cert, SiteName = site.Name, HasPrivateKey = certTuple.Item2, }; bindItems.Add(item); } } } } } } } } return(bindItems); }
private bool ShowDetailRow(BindItem item) { return(item.Complete); }
public WxUserResult Bind(BindItem item) { string error = ""; dp2WeiXinService.Instance.WriteLog1("!!!走进bind API"); if (item.bindLibraryCode == null) { item.bindLibraryCode = ""; } // 返回对象 WxUserResult result = new WxUserResult(); if (HttpContext.Current.Session[WeiXinConst.C_Session_sessioninfo] == null) { error = "session失效。"; goto ERROR1; } SessionInfo sessionInfo = (SessionInfo)HttpContext.Current.Session[WeiXinConst.C_Session_sessioninfo]; if (sessionInfo == null) { error = "session失效2。"; goto ERROR1; } // 前端有时传上来是这个值 if (item.prefix == "null") { item.prefix = ""; } WxUserItem userItem = null; int nRet = dp2WeiXinService.Instance.Bind(item.libId, item.bindLibraryCode, item.prefix, item.word, item.password, item.weixinId, out userItem, out error); if (nRet == -1) { goto ERROR1; } result.users = new List <WxUserItem>(); result.users.Add(userItem); if (sessionInfo.Active != null) { dp2WeiXinService.Instance.WriteLog1("原来session中的user对象id=[" + sessionInfo.Active.id + "],weixinid=[" + sessionInfo.WeixinId + "]"); } else { dp2WeiXinService.Instance.WriteLog1("原来session中无user对象"); } dp2WeiXinService.Instance.WriteUserInfo(item.weixinId, "bind返回后"); //更新session信息 nRet = sessionInfo.Init1(item.weixinId, out error); if (nRet == -1) { goto ERROR1; } dp2WeiXinService.Instance.WriteUserInfo(item.weixinId, "session.init后"); return(result); ERROR1: result.errorCode = -1; result.errorInfo = error; return(result); }
private void cmbSheets_SelectedIndexChanged(object sender, EventArgs e) { object selectedValue = cmbSheets.SelectedValue; if (selectedValue != null) { string sIndex = selectedValue as string; int index; if (!String.IsNullOrWhiteSpace(sIndex) && int.TryParse(sIndex, out index)) { ISheet sheet = workbook.GetSheetAt(index); int lastRowNum = sheet.LastRowNum; if (lastRowNum > 0) { IRow excelRow = sheet.GetRow(0); if (excelRow != null) { ICell excelCell; items.Clear(); BindItem item; for (int i = excelRow.FirstCellNum; i < excelRow.LastCellNum; i++) { item = new BindItem(); excelCell = excelRow.GetCell(i); if (excelCell != null) { try { item.Text = excelCell.StringCellValue; item.Value = i.ToString(); items.Add(item); } catch { } } } if (items.Count > 0) { DataGridViewComboBoxCell cell; BindItem[] itemArr; foreach (DataGridViewRow row in dgvRules.Rows) { itemArr = new BindItem[items.Count]; items.CopyTo(itemArr); cell = row.Cells["Field"] as DataGridViewComboBoxCell; if (cell != null) { cell.DataSource = itemArr; cell.DisplayMember = "Text"; cell.ValueMember = "Value"; cell.Value = itemArr[0].Value; } } //foreach (DataGridViewRow orderRow in dgvOrderRules.Rows) //{ // itemArr = new BindItem[items.Count]; // items.CopyTo(itemArr); // cell = orderRow.Cells[0] as DataGridViewComboBoxCell; // if (cell != null) // { // cell.DataSource = itemArr; // cell.DisplayMember = "Text"; // cell.ValueMember = "Value"; // cell.Value = itemArr[0].Value; // } //} } } } } } }
private void cmbSheets_SelectedIndexChanged(object sender, EventArgs e) { object selectedValue = cmbSheets.SelectedValue; if (selectedValue != null) { string sIndex = selectedValue as string; int index; if (!String.IsNullOrWhiteSpace(sIndex) && int.TryParse(sIndex, out index)) { ISheet sheet = workbook.GetSheetAt(index); int lastRowNum = sheet.LastRowNum; if (lastRowNum > 0) { IRow row = sheet.GetRow(0); if (row != null) { ICell cell; string cellValue, sI; List <BindItem> items = new List <BindItem>(), pageItems = new List <BindItem>(); BindItem item; for (int i = row.FirstCellNum; i < row.LastCellNum; i++) { item = new BindItem(); cell = row.GetCell(i); if (cell != null) { try { cellValue = cell.StringCellValue; item.Text = cellValue; sI = i.ToString(); item.Value = sI; items.Add(item); item = new BindItem(); item.Text = cellValue; item.Value = sI; pageItems.Add(item); } catch { } } } cmbArchiveIdField.DataSource = items; cmbArchiveIdField.DisplayMember = "Text"; cmbArchiveIdField.ValueMember = "Value"; cmbPageField.DataSource = pageItems; cmbPageField.DisplayMember = "Text"; cmbPageField.ValueMember = "Value"; if (cmbArchiveIdField.Items.Count > 0) { cmbArchiveIdField.SelectedIndex = -1; cmbArchiveIdField.SelectedIndex = 0; } if (cmbPageField.Items.Count > 0) { cmbPageField.SelectedIndex = -1; cmbPageField.SelectedIndex = 0; } } } } } }
private static void LoadTarget() { try { var path = AppDomain.CurrentDomain.BaseDirectory + "descriptors.txt"; if (File.Exists(path)) { var descriptors = File.ReadAllText(path, Encoding.UTF8); foreach (var assemblyName in descriptors.Split(';')) { var files = Directory.GetFiles(Environment.CurrentDirectory, assemblyName); if (files.Length <= 0) { continue; } //assembly var assemblyTarget = new MonoAssemblyResolver(assemblyName); var text = Path.GetFileName(assemblyName); var tag = new BindItem { Assembly = assemblyTarget, Method = null }; //class List <TypeDefinition> types = assemblyTarget.FindClasses(); for (int i = 0; i < types.Count; i++) { if (types[i].HasMethods) { //method var methodDefinitions = types[i].GetMethods(false); for (int j = 0; j < methodDefinitions.Count; j++) { Type type = null; if (types[i].Name == "Program" && methodDefinitions[j].Name == "Main") { type = _injectTypeDict["Startup"]; } else { type = _injectTypeDict["ObjectValueInject"]; } _mapping.Add(new InjectionMapping(assemblyTarget, methodDefinitions[j], type)); } } } } } else { Console.WriteLine($"{path}文件不存在"); } } catch (Exception ex) { throw ex; } }