static void CheckSetProperties(Dictionary <string, ClassInfo> classes, ClassInfo classInfo, FlowSourceObjectBase flowSource) { foreach (var name in classInfo.SetValues) { if (!flowSource.InPropertyNames.Contains(name)) { classInfo.AddError(String.Format("{0} is not defined", name)); errorFiles.Add(classInfo); } } foreach (var setterPropertyName in flowSource.InPropertyNames) { bool usedFound = false; var type = flowSource.GetType(); ClassInfo currentClassInfo = classInfo; while (type != null) { if (currentClassInfo.ContainsSetValue(setterPropertyName)) { usedFound = true; break; } type = type.BaseType; var className = type.FullName; if (type.IsGenericType) { className = GetGenericClassName(className); } if (!classes.TryGetValue(className, out currentClassInfo)) { break; } } if (!usedFound) { classInfo.AddError(String.Format("{0} is defined, but not used in SetValue()", setterPropertyName)); errorFiles.Add(classInfo); } } }
public void ChangeFlowSource(FlowDrawPanel flowDrawPanel, FlowSourceObjectBase source, Dictionary <string, string> data) { this.currentFlowDrawPanel = flowDrawPanel; try { while (dataGridView1.RowCount > 0) { if (dataGridView1[1, dataGridView1.RowCount - 1] is ExDataGridViewComboBoxCell exCell) { exCell.ResetEvent(); } dataGridView1.RowCount--; } if (flowDrawPanel != null && source != null && data != null) { foreach (CustomMemberInfo <PropertyInfo> propertyInfo in source.InProperties) { var row = new DataGridViewRow(); var cell = new DataGridViewTextBoxCell { Value = propertyInfo.MemberInfo.Name, ToolTipText = propertyInfo.ToolTipText }; row.Cells.Add(cell); var formatter = TypeFormatterManager.GetFormatter(propertyInfo.MemberInfo.PropertyType); DataGridViewCell cell2 = null; if (formatter != null) { if (formatter.AllowedPropertyString != null && formatter.AllowedPropertyString.Length > 0) { var exCell = new ExDataGridViewComboBoxCell(); cell2 = exCell; exCell.Items.AddRange(formatter.AllowedPropertyString); exCell.Value = formatter.AllowedPropertyString[0]; row.Cells.Add(cell2); this.dataGridView1.Rows.Add(row); exCell.SetEvent(); } else { if (CanValueButtonClick(source.Name, propertyInfo.MemberInfo.Name, propertyInfo.MemberInfo.PropertyType)) { var buttonCell = new ButtonCell(source.Name, propertyInfo.MemberInfo.Name, propertyInfo.MemberInfo.PropertyType); buttonCell.ButtonClick += buttonCell_ButtonClick; cell2 = buttonCell; } else { cell2 = new DataGridViewTextBoxCell(); } row.Cells.Add(cell2); this.dataGridView1.Rows.Add(row); } if (data.ContainsKey(propertyInfo.MemberInfo.Name)) { cell2.Value = data[propertyInfo.MemberInfo.Name]; } cell2.ReadOnly = false; cell2.Tag = formatter; } else { cell2 = new DataGridViewTextBoxCell(); row.Cells.Add(cell2); cell2.ReadOnly = true; this.dataGridView1.Rows.Add(row); } } } } catch (Exception) { } }
public FlowSourceDumper(FlowSourceObjectBase flowSourceObject, AssemblyAndType asmAndType) { this.flowSourceObject = flowSourceObject; this.asmAndType = asmAndType; }
public static string GetFastCode(FlowSourceObjectBase flowSource) { var ret = new StringBuilder(); var type = flowSource.GetType(); int level = 0; WriteData(ret, "//--------------------------------------------------------", level); WriteData(ret, "// This code is generated by AutoFastGenerator.", level); WriteData(ret, "// You should not modify the code.", level); WriteData(ret, "//--------------------------------------------------------", level); ret.AppendLine(); WriteData(ret, String.Format("namespace {0}", type.Namespace), level); WriteData(ret, "{", level); level++; WriteData(ret, String.Format("public partial class {0}", type.Name), level); WriteData(ret, "{", level); level++; if (flowSource.OutProperties.Count > 0) { WriteData(ret, "public override object GetPropertyValue(string propertyName)", level); WriteData(ret, "{", level); level++; WriteData(ret, "switch (propertyName)", level); WriteData(ret, "{", level); level++; foreach (CustomMemberInfo <PropertyInfo> propertyInfo in flowSource.OutProperties) { WriteData(ret, String.Format("case \"{0}\":", propertyInfo.MemberInfo.Name), level); foreach (var replacedName in propertyInfo.ReplacedNames) { WriteData(ret, String.Format("case \"{0}\":", replacedName), level); } level++; WriteData(ret, String.Format("return {0};", propertyInfo.MemberInfo.Name), level); level--; } WriteData(ret, "default:", level); level++; WriteData(ret, "return null;", level); level--; level--; WriteData(ret, "}", level); level--; WriteData(ret, "}", level); } ret.AppendLine(); if (flowSource.InProperties.Count > 0) { WriteData(ret, "protected override void SetPropertyValue(string propertyName, object value)", level); WriteData(ret, "{", level); level++; WriteData(ret, "switch (propertyName)", level); WriteData(ret, "{", level); level++; foreach (CustomMemberInfo <PropertyInfo> propertyInfo in flowSource.InProperties) { WriteData(ret, String.Format("case \"{0}\":", propertyInfo.MemberInfo.Name), level); foreach (var replacedName in propertyInfo.ReplacedNames) { WriteData(ret, String.Format("case \"{0}\":", replacedName), level); } level++; WriteData(ret, String.Format("{0} = ({1})value;", propertyInfo.MemberInfo.Name, GetClassName(propertyInfo.MemberInfo.PropertyType)), level); WriteData(ret, "break;", level); level--; } level--; WriteData(ret, "}", level); level--; WriteData(ret, "}", level); } ret.AppendLine(); if (flowSource.OutMethods.Count > 0) { WriteData(ret, "public override void ConnectEvent(string eventName, FlowScriptEngine.FlowEventHandler eventHandler)", level); WriteData(ret, "{", level); level++; WriteData(ret, "switch (eventName)", level); WriteData(ret, "{", level); level++; foreach (CustomMemberInfo <EventInfo> eventInfo in flowSource.OutMethods) { WriteData(ret, String.Format("case \"{0}\":", eventInfo.MemberInfo.Name), level); foreach (var replacedName in eventInfo.ReplacedNames) { WriteData(ret, String.Format("case \"{0}\":", replacedName), level); } level++; WriteData(ret, String.Format("{0} += new FlowScriptEngine.FlowEventHandler(eventHandler);", eventInfo.MemberInfo.Name), level); WriteData(ret, "break;", level); level--; } level--; WriteData(ret, "}", level); level--; WriteData(ret, "}", level); } level--; WriteData(ret, "}", level); level--; WriteData(ret, "}", level); return(ret.ToString()); }
internal FlowEventArgs(FlowSourceObjectBase source, bool isBreakUsed) { Source = source; IsBreakUsed = isBreakUsed; }