public void Create(Dictionary <string, string> inValues) { foreach (KeyValuePair <string, string> item in inValues) { fieldList.Add(new ItemField(item.Value, item.Key, "", MemberAttributes.Public)); } toBytes = new ItemMethod("ToBytes", MemberAttributes.Public | MemberAttributes.Override, new List <string>() { }); toBytes.SetReturn("System.byte[]"); toBytes.Method.Statements.Add(Line("ByteArray bytes", "new ByteArray()")); toStream = new ItemMethod("ToStream", MemberAttributes.Public | MemberAttributes.Static, new List <string>() { "System.byte[]" }); toStream.SetReturn("Stream"); toStream.Method.Statements.Add(Line(className + " stream", "new " + className + "()")); toStream.Method.Statements.Add(Line("ByteArray data", "new ByteArray(inArg0)")); GetItems(inValues).ForEach(i => HandleItem(i)); toBytes.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("bytes.ToBytes()"))); toStream.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("stream"))); methodList.Add(toBytes); methodList.Add(toStream); Create(); }
/// <summary> /// 商品情報一覧取得 /// </summary> /// <returns></returns> async Task GetItemList() { // 商品情報一覧を取得 var targetItemList = await ItemMethod.GetItemListAsync(true); // 初期化 ItemList.Clear(); ProductPoint = string.Empty; TotalSales = string.Empty; // 取得した商品を画面表示用のコレクションに追加&合計金額を取得 decimal totalSales = 0; foreach (var item in targetItemList) { totalSales += Convert.ToDecimal(item.SalePrice); ItemList.Add(item); } // 商品点数を設定 ProductPoint = ItemList.Count.ToString(); // 合計金額を設定 TotalSales = DisplayUtil.convertNumToDisplay(totalSales.ToString()); }
//preset private void MethodMenuOpenButton_Click(object sender, RoutedEventArgs e) { var openDialog = new OpenFileDialog() { Title = "Save Preset", DefaultExt = "pre", Filter = "My preset files (*.pre)|*.pre", CheckFileExists = true, CheckPathExists = true }; if (openDialog.ShowDialog() == true) { Preset preset = null; try { preset = new Preset(openDialog.FileName, _prototypes); } catch (Exception ex) { MessageBox.Show("Error: File corupted" + ex.ToString()); return; } _presetList.Clear(); foreach (var item in preset.List) { var method = new ItemMethod(item); _presetList.Add(method); } MyAppItem.ReloadList(_seclectingListView, methodListBox); } }
public void Create(Dictionary<string, string> inValues) { foreach (KeyValuePair<string, string> item in inValues) { fieldList.Add(new ItemField(item.Value, item.Key, "", MemberAttributes.Public)); } toBytes = new ItemMethod("ToBytes", MemberAttributes.Public | MemberAttributes.Override, new List<string>() { }); toBytes.SetReturn("System.byte[]"); toBytes.Method.Statements.Add(Line("ByteArray bytes", "new ByteArray()")); toStream = new ItemMethod("ToStream", MemberAttributes.Public | MemberAttributes.Static, new List<string>() { "System.byte[]" }); toStream.SetReturn("Stream"); toStream.Method.Statements.Add(Line(className + " stream", "new " + className + "()")); toStream.Method.Statements.Add(Line("ByteArray data", "new ByteArray(inArg0)")); GetItems(inValues).ForEach(i => HandleItem(i)); toBytes.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("bytes.ToBytes()"))); toStream.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("stream"))); methodList.Add(toBytes); methodList.Add(toStream); Create(); }
/// <summary> /// 商品削除 /// </summary> /// <param name="id"></param> public async void DeleteItem(string id) { // IDをに該当する商品を、内部で保持している商品情報から削除 var ret = await ItemMethod.DeleteItemAsync(id); // 削除後の商品情報一覧を取得 await GetItemList(); }
/// <summary> /// スキャン処理 /// </summary> public async void ScanExcute() { // PluCodeを元にDBから商品情報を取得し、内部で保持している商品情報一覧に追加 var ret = await ItemMethod.GetItemInfoAsync(""); // 内部で保持している商品情報一覧を取得 await GetItemList(); }
private void MenuMethod_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { TextBlock prototypeBlock = sender as TextBlock; ItemMethod instance = new ItemMethod(prototypeBlock.Text, _prototypes); _methodList.Add(instance); if (instance.Item.Name != "Name Normalize String Action" && instance.Item.Name != "GUID String Action") { instance.Item.ShowEditDialog(_seclectingListView, methodListBox); } }
public void use(string objectName) { ItemMethod _im = GameObject.Find("Item Manager").GetComponent <ItemMethod>(); foreach (Objet objet in _objets.Keys) { if (objet._name.Equals(objectName) && _objets[objet] > 0) { _im._effects[objectName](gameObject); _objets[objet]--; break; } } }
//Item Format [METHOD: ITEM] public ItemTransfer(string RawItem, int line) { string[] parts = RawItem.Split(':'); Method = (ItemMethod)Enum.Parse(typeof(ItemMethod), (parts[0].TrimStart('['))); Item = parts[1].Trim().TrimEnd(']').Trim(); //Will be item grabbing method eventually LinePreceeding = line-1; }
/// <summary> /// 内部で保持している商品情報をクリア /// </summary> public async void ItemListClear() { var ret = await ItemMethod.ItemListClearAsync(); }
/// <summary> /// /// </summary> /// <param name="inPath"></param> /// <param name="outPath"></param> private void ForGen(string inPath, string outPath) { List <string> listClassNames = new List <string>(); Assist.ClearDirFiles(outPath); DirectoryInfo folder = new DirectoryInfo(inPath); FileSystemInfo[] files = folder.GetFileSystemInfos(); int length = files.Length; for (int index = 0; index < length; index++) { if (files[index] is DirectoryInfo) { //this.ForGen(files[index].FullName); } else { if (files[index].Name.EndsWith(".xlsx")) { //DataSet mResultSet = Assist.ExcelToDataSet(files[index].FullName); FileStream stream = File.Open(files[index].FullName, FileMode.Open, FileAccess.Read); IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); DataSet mResultSet = excelReader.AsDataSet(); //判断Excel文件中是否存在数据表 if (mResultSet.Tables.Count < 1) { return; } //默认读取第一个数据表 DataTable mSheet = mResultSet.Tables[0]; string tableName = mSheet.TableName; string csName = m_itemHeader + Stringer.FirstLetterUp(tableName); listClassNames.Add(csName); CreateCSItemData csItemData = new CreateCSItemData(m_nameSpace, csName, m_outPath); //读取数据表行数和列数 int rowCount = mSheet.Rows.Count; int colCount = mSheet.Columns.Count; List <string> mainKeyList = new List <string>(); for (int j = 0; j < colCount; j++)//列 { string key = mSheet.Rows[titleIndex][j].ToString(); if (key == "") { Assist.Log("下标" + "(" + titleIndex + "," + j + ")" + "不能为空"); return; } string strData = mSheet.Rows[typeIndex][j].ToString(); string[] strs = strData.Split('+'); string keyType = strs[0]; int isMainkey = int.Parse(strs[1]); string linkTableName = strs[2]; ItemField itemField = new ItemField(key, keyType, MemberAttributes.Private); csItemData.AddFieldValue(itemField); ItemProperty itemProperty = new ItemProperty(key); itemProperty.SetGetName(); itemProperty.SetSetName(); itemProperty.SetComment(mSheet.Rows[summary][j].ToString()); itemProperty.SetValueType(keyType); itemProperty.SetModifier(MemberAttributes.Public | MemberAttributes.Final); itemProperty.SetField("ProtoMember", (j + 1).ToString()); csItemData.AddPropertyValue(itemProperty); //是主键,或者是合成主键的一部分字段 if (isMainkey == 1) { mainKeyList.Add(key); } //有链接的表 if (linkTableName != "0") { linkTableName = m_itemHeader + Stringer.FirstLetterUp(linkTableName); string subClassname = linkTableName; ItemMethod mis = new ItemMethod("Get" + subClassname, MemberAttributes.Final | MemberAttributes.Public, new List <string>() { "System.String" }); csItemData.SetComment("获取" + subClassname, mis.Method); mis.Method.ReturnType = new CodeTypeReference(subClassname); mis.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("CfgData.Instance.m_PBData." + subClassname + "Dic[inArg0]"))); csItemData.AddMethodValue(mis); } } //最多由3个字段组成主键 string MainKey = ""; if (mainKeyList.Count == 1) { MainKey = mainKeyList[0] + ".ToString()"; } else if (mainKeyList.Count == 2) { MainKey = mainKeyList[0] + ".ToString() + \"_\" + this.m_" + mainKeyList[1] + ".ToString()"; } else if (mainKeyList.Count == 3) { MainKey = mainKeyList[0] + ".ToString() + \"_\" + this.m_" + mainKeyList[1] + ".ToString() + \"_\" + this.m_" + mainKeyList[2] + ".ToString()"; } ItemProperty itemProperty2 = new ItemProperty("MainKey"); itemProperty2.SetGetName(MainKey); itemProperty2.SetComment("主键"); itemProperty2.SetValueType("string"); itemProperty2.SetModifier(MemberAttributes.Public | MemberAttributes.Final); csItemData.AddPropertyValue(itemProperty2); csItemData.Create(); } } } CreatePBData final = new CreatePBData(m_nameSpace, m_PBData, m_outPath); final.SetValue(listClassNames); final.Create(); List <string> dyncUsingList = new List <string>(); dyncUsingList.Add("protobuf-net.dll"); dyncUsingList.Add("mscorlib.dll"); List <string> dyncCsFilesName = Assist.GetObjPaths(".cs", m_outPath); string csDataPoolPath = Path.Combine(Environment.CurrentDirectory, "CfgData.cs"); dyncCsFilesName.Add(csDataPoolPath); for (int i = 0; i < dyncCsFilesName.Count; i++) { dyncCsFilesName[i] = dyncCsFilesName[i].Replace("/", "\\"); } string dyncDllPath = Path.Combine(m_outPath, "CfgData.dll"); CompilerResults cr = DyncLibTool.CompileCSharpCode(dyncCsFilesName, dyncDllPath, dyncUsingList); //Assembly assembly = cr.CompiledAssembly; Assist.Log("Gen OK"); }
public void AddMethodValue(ItemMethod itemMethod) { methodList.Add(itemMethod); }
/// <summary> /// IAnalyzeItemインスタンス作成 /// </summary> /// <param name="node">対象Node</param> /// <param name="semanticModel">対象ソースのsemanticModel</param> /// <param name="container">イベントコンテナ</param> /// <param name="parent">親IAnalyzeItemインスタンス(デフォルトはnull)</param> /// <returns>IAnalyzeItemインスタンス</returns> public static IAnalyzeItem Create(SyntaxNode node, SemanticModel semanticModel, EventContainer container, IAnalyzeItem parent = null) { IAnalyzeItem result = null; // nodeの種類によって取得メソッドを実行 switch (node) { // クラス定義 case ClassDeclarationSyntax targetNode: result = new ItemClass(targetNode, semanticModel, parent, container); break; // インターフェース case InterfaceDeclarationSyntax targetNode: result = new ItemInterface(targetNode, semanticModel, parent, container); break; // クラス要素定義 case PropertyDeclarationSyntax targetNode: result = new ItemProperty(targetNode, semanticModel, parent, container); break; case FieldDeclarationSyntax targetNode: result = new ItemField(targetNode, semanticModel, parent, container); break; case MethodDeclarationSyntax targetNode: result = new ItemMethod(targetNode, semanticModel, parent, container); break; case ConstructorDeclarationSyntax targetNode: result = new ItemConstructor(targetNode, semanticModel, parent, container); break; case EnumDeclarationSyntax targetNode: result = new ItemEnum(targetNode, semanticModel, parent, container); break; // ラムダ式 case ArrowExpressionClauseSyntax targetNode: if (parent is ItemProperty) { result = new ItemAccessor(targetNode, semanticModel, parent, container); } else { var op = semanticModel.GetOperation(targetNode).Children.First(); switch (op) { case Microsoft.CodeAnalysis.Operations.IReturnOperation operation: result = new ItemReturn(op.Syntax, semanticModel, parent, container); break; case Microsoft.CodeAnalysis.Operations.IExpressionStatementOperation operation: result = new ItemStatementExpression(op.Syntax, semanticModel, parent, container); break; } } break; // ローカル定義 case LocalFunctionStatementSyntax targetNode: result = new ItemLocalFunction(targetNode, semanticModel, parent, container); break; case LocalDeclarationStatementSyntax targetNode: result = new ItemStatementLocalDeclaration(targetNode, semanticModel, parent, container); break; case ExpressionStatementSyntax targetNode: result = new ItemStatementExpression(targetNode, semanticModel, parent, container); break; case AccessorDeclarationSyntax targetNode: result = new ItemAccessor(targetNode, semanticModel, parent, container); break; // 分岐処理 case IfStatementSyntax targetNode: result = new ItemIf(targetNode, semanticModel, parent, container); break; case ElseClauseSyntax targetNode: result = new ItemElseClause(targetNode, semanticModel, parent, container); break; case SwitchStatementSyntax targetNode: result = new ItemSwitch(targetNode, semanticModel, parent, container); break; case SwitchSectionSyntax targetNode: result = new ItemSwitchCase(targetNode, semanticModel, parent, container); break; // ループ処理 case WhileStatementSyntax targetNode: result = new ItemWhile(targetNode, semanticModel, parent, container); break; case DoStatementSyntax targetNode: result = new ItemDo(targetNode, semanticModel, parent, container); break; case ForEachStatementSyntax targetNode: result = new ItemForEach(targetNode, semanticModel, parent, container); break; case ForStatementSyntax targetNode: result = new ItemFor(targetNode, semanticModel, parent, container); break; // その他 case ReturnStatementSyntax targetNode: result = new ItemReturn(targetNode, semanticModel, parent, container); break; case BreakStatementSyntax targetNode: result = new ItemBreak(targetNode, semanticModel, parent, container); break; case ContinueStatementSyntax targetNode: result = new ItemContinue(targetNode, semanticModel, parent, container); break; } return(result); }
/// <summary> /// <para>0: 字段名</para> /// <para>1: a+i+0 指明类型及是否为Key值</para> /// <para>2: 注释</para> /// </summary> /// <param name="inList">0: 字段名</param> public void SetValue(List <string[]> inList) { ItemMethod mi = new ItemMethod("Set", MemberAttributes.Final | MemberAttributes.Public, new List <string>() { "List<string>" }); classer.CustomAttributes.Add(new CodeAttributeDeclaration("ProtoContract")); List <string> keyList = new List <string>();// key 值 for (int i = 0; i < inList.Count; i++) { string[] ss = inList[i][1].Split('+'); string typeString = ss[1]; CustumType ct = Stringer.StrToEnum <CustumType>(typeString, CustumType.None); if (ct != CustumType.None) // 基本类型或自定义类型 { //AddField(inList[i][0], inList[i][1], MemberAttributes.Private); fieldList.Add(new ItemField(inList[i][0], inList[i][1], MemberAttributes.Private)); ItemProperty item = new ItemProperty(inList[i][0]); item.SetGetName(); item.SetSetName(); item.SetComment(inList[i][2]); item.SetValueType(inList[i][1]); item.SetModifier(MemberAttributes.Public | MemberAttributes.Final); item.SetField("ProtoMember", (i + 1).ToString()); propertyList.Add(item); if (ss[2] == "1")// 如果该属性是类的Key值,则加入列表 { keyList.Add(inList[i][0]); } Type vType = Stringer.ToType(inList[i][1]); string left = "_" + Stringer.FirstLetterLower(inList[i][0]); CodeVariableReferenceExpression right = new CodeVariableReferenceExpression(); if (vType == typeof(System.String)) { right.VariableName = "inArg0[" + i + "]"; } else if (vType == typeof(System.UInt32)) { right.VariableName = "uint.Parse(inArg0[" + i + "])"; } else if (vType == typeof(System.Single)) { right.VariableName = "float.Parse(inArg0[" + i + "])"; } else { right.VariableName = "new " + vType.ToString() + "(inArg0[" + i + "])"; } CodeAssignStatement ass = new CodeAssignStatement(new CodeVariableReferenceExpression(left), right); mi.Method.Statements.Add(ass); } else // 从属表 { string subclassname = Stringer.FirstLetterUp(typeString); ItemMethod mis = new ItemMethod("Get" + subclassname, MemberAttributes.Final | MemberAttributes.Public, new List <string>() { "System.String", "PBData" }); SetComment("获取" + inList[i][2], mis.Method); mis.Method.ReturnType = new CodeTypeReference(subclassname); mis.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("inArg1." + subclassname + "Dic[this.key + \"_\" + inArg0]"))); methodList.Add(mis); } } // Key 属性 ItemProperty keyPropertyItem = new ItemProperty("key"); if (keyList.Count == 1) { keyPropertyItem.SetGetName(keyList[0] + ".ToString()"); } else if (keyList.Count == 2) { keyPropertyItem.SetGetName(keyList[0] + ".ToString() + \"_\" +" + keyList[1] + ".ToString()"); } else if (keyList.Count == 3) { keyPropertyItem.SetGetName(keyList[0] + ".ToString() + \"_\" +" + keyList[1] + ".ToString() + \"_\" +" + keyList[2] + ".ToString()"); } keyPropertyItem.SetValueType(); keyPropertyItem.SetModifier(MemberAttributes.Public | MemberAttributes.Final); keyPropertyItem.SetComment("类的Key值"); propertyList.Add(keyPropertyItem); methodList.Add(mi); Create(); }
/// <summary> /// <para>0: 字段名</para> /// <para>1: a+i+0 指明类型及是否为Key值</para> /// <para>2: 注释</para> /// </summary> /// <param name="inList">0: 字段名</param> public void SetValue(List<string[]> inList) { ItemMethod mi = new ItemMethod("Set", MemberAttributes.Final | MemberAttributes.Public, new List<string>(){"List<string>"}); classer.CustomAttributes.Add(new CodeAttributeDeclaration("ProtoContract")); List<string> keyList = new List<string>();// key 值 for (int i = 0; i < inList.Count; i++) { string[] ss = inList[i][1].Split('+'); string typeString = ss[1]; CustumType ct = Stringer.StrToEnum<CustumType>(typeString, CustumType.None); if (ct != CustumType.None) // 基本类型或自定义类型 { //AddField(inList[i][0], inList[i][1], MemberAttributes.Private); fieldList.Add(new ItemField(inList[i][0], inList[i][1], MemberAttributes.Private)); ItemProperty item = new ItemProperty(inList[i][0]); item.SetGetName(); item.SetSetName(); item.SetComment(inList[i][2]); item.SetValueType(inList[i][1]); item.SetModifier(MemberAttributes.Public | MemberAttributes.Final); item.SetField("ProtoMember", (i + 1).ToString()); propertyList.Add(item); if (ss[2] == "1")// 如果该属性是类的Key值,则加入列表 { keyList.Add(inList[i][0]); } Type vType = Stringer.ToType(inList[i][1]); string left = "_" + Stringer.FirstLetterLower(inList[i][0]); CodeVariableReferenceExpression right = new CodeVariableReferenceExpression(); if (vType == typeof(System.String)) { right.VariableName = "inArg0[" + i + "]"; } else if (vType == typeof(System.UInt32)) { right.VariableName = "uint.Parse(inArg0[" + i + "])"; } else if (vType == typeof(System.Single)) { right.VariableName = "float.Parse(inArg0[" + i + "])"; } else { right.VariableName = "new " + vType.ToString() + "(inArg0[" + i + "])"; } CodeAssignStatement ass = new CodeAssignStatement(new CodeVariableReferenceExpression(left), right); mi.Method.Statements.Add(ass); } else // 从属表 { string subclassname = Stringer.FirstLetterUp(typeString); ItemMethod mis = new ItemMethod("Get" + subclassname, MemberAttributes.Final | MemberAttributes.Public, new List<string>() { "System.String" , "PBData"}); SetComment("获取" + inList[i][2], mis.Method); mis.Method.ReturnType = new CodeTypeReference(subclassname); mis.Method.Statements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("inArg1." + subclassname + "Dic[this.key + \"_\" + inArg0]"))); methodList.Add(mis); } } // Key 属性 ItemProperty keyPropertyItem = new ItemProperty("key"); if (keyList.Count == 1) { keyPropertyItem.SetGetName(keyList[0] + ".ToString()"); } else if (keyList.Count == 2) { keyPropertyItem.SetGetName(keyList[0] + ".ToString() + \"_\" +" + keyList[1] + ".ToString()"); } else if (keyList.Count == 3) { keyPropertyItem.SetGetName(keyList[0] + ".ToString() + \"_\" +" + keyList[1] + ".ToString() + \"_\" +" + keyList[2] + ".ToString()"); } keyPropertyItem.SetValueType(); keyPropertyItem.SetModifier(MemberAttributes.Public | MemberAttributes.Final); keyPropertyItem.SetComment("类的Key值"); propertyList.Add(keyPropertyItem); methodList.Add(mi); Create(); }
/// <summary> /// スキャン処理(連続用) /// </summary> public async void ScanContinuousExcute(string plucode) { // PluCodeを元にDBから商品情報を取得し、内部で保持している商品情報一覧に追加 var ret = await ItemMethod.GetItemInfoAsync(plucode); }