// -------- Start -------- public GPPresentation(GProperty property) { PropertyID = property.GetBoundProperty().ID; Property = property.GetBoundProperty() as Property; PropertyType = property.Type; }
// 생성자 public PropertyBlock(GCommand command) { InitializeComponent(); _GCommand = command; _GProperty = new GProperty(command); _GObjectList = new List <GBase> { GObject }; PropertyName.Text = command.FriendlyName; InitializeBlock(); }
// -------- Deleting and Breaking Connections -------- private void DeleteItem_Click(object sender, RoutedEventArgs e) { IPanel iPanel = (sender as MenuItem).Tag as IPanel; bool removedIsStatement = iPanel is GStatement; GProperty gProperty = null; if (!removedIsStatement) { gProperty = iPanel as GProperty; for (int n = Connections.Count - 1; n >= 0; n--) { if (gProperty.Type == PropertyType.Condition) { ((Connections[n].First as GStatement).GetBoundProperty() as Statement).Conditions.Remove(gProperty.GetBoundProperty()); ((Connections[n].First as GStatement).GetBoundProperty() as Statement).NegatedConditions.Remove(gProperty.GetBoundProperty().ID); } else { ((Connections[n].First as GStatement).GetBoundProperty() as Statement).Events.Remove(gProperty.GetBoundProperty()); } if (Connections[n].First.Equals(iPanel) || Connections[n].Second.Equals(iPanel)) { Connections[n].Delete(); Connections.RemoveAt(n); } } } else { for (int n = Connections.Count - 1; n >= 0; n--) { if (Connections[n].First.Equals(iPanel) || Connections[n].Second.Equals(iPanel)) { Connections[n].Delete(); Connections.RemoveAt(n); } } conversation.BreakConnectionsWithStatement((iPanel.GetBoundProperty() as Statement)); conversation.RemoveStatement(iPanel.GetBoundProperty() as Statement); UpdateStartStatementsSequence(); } Workspace.Children.Remove(iPanel as Control); }
public GPPresentation GetPropertyPresentation(GProperty gProperty) { double gPropertyX = Canvas.GetLeft(gProperty); double gPropertyY = Canvas.GetTop(gProperty); foreach (GPPresentation presentation in Properties) { if (presentation.PointPresentation.X == gPropertyX && presentation.PointPresentation.Y == gPropertyY) { return(presentation); } } return(null); }
private void AddPropertyPanel(Point point, PropertyType type, Property property = null) { GProperty gProperty = new GProperty(type, property); Panel.SetZIndex(gProperty, 10); gProperty.DeleteItem.Click += DeleteItem_Click; gProperty.MouseDown += Control_MouseDown; gProperty.MouseDown += Control_Connection_MouseDown; gProperty.MouseMove += Control_MouseMove; gProperty.MouseUp += Control_MouseUp; Canvas.SetTop(gProperty, point.Y); Canvas.SetLeft(gProperty, point.X); Workspace.Children.Add(gProperty); }
public static IGClass AddTConstructorAutoPropertyGroup(this IGClass gClass, IPhilote <IGMethod> gMethodId, string gAutoPropertyName, string gType, IPhilote <IGPropertyGroup> gPropertyGroupId = default, string?gAccessors = "{ get;}", string?gVisibility = default) { var gProperty = new GProperty(gAutoPropertyName.ToUpperFirstChar(), gType, gAccessors, gVisibility); if (gClass.GPropertyGroups != null && gClass.GPropertyGroups.ContainsKey(gPropertyGroupId)) { gClass.GPropertyGroups[gPropertyGroupId].GPropertys[gProperty.Philote] = gProperty; } else { throw new Exception(string.Format("{0} not found in the PropertyGroups of {1}", gPropertyGroupId.ID.ToString(), gClass.GName)); } IGMethod gMethod = default; if (gClass.GMethods != null && gClass.GMethods.ContainsKey(gMethodId)) { gMethod = gClass.GMethods[gMethodId]; } else if (gClass.GMethodGroups != null) { foreach (var kvp in gClass.GMethodGroups) { if (kvp.Value.GMethods.ContainsKey(gMethodId)) { var gMethodGroup = kvp.Value; gMethod = gMethodGroup.GMethods[gMethodId]; } } } if (gMethod == null) { throw new Exception(string.Format("{0} not found in the Methods or MethodGroups of {1}", gMethodId.ID.ToString(), gClass.GName)); } GArgument gArgument = new GArgument(gAutoPropertyName.ToLowerFirstChar(), gType); gMethod.GDeclaration.GArguments[gArgument.Philote] = gArgument; gMethod.GBody.GStatements.Add($"{gAutoPropertyName.ToUpperFirstChar()} = {gAutoPropertyName.ToLowerFirstChar()} ?? throw new ArgumentNullException(nameof({gAutoPropertyName.ToLowerFirstChar()}));"); return(gClass); }
/*******************************************************************************/ /*******************************************************************************/ static IGClass MCreateStateConfigurationClass(string gVisibility = "public") { //var gMethodArgumentList = new List<IGArgument>() { // new GArgument("requestorPhilote", "object"), // new GArgument("callback", "object"), // new GArgument("timerSignil", "object"), // new GArgument("ct", "CancellationTokenFromCaller?") //}; //var gMethodArguments = new Dictionary<IPhilote<IGArgument>, IGArgument>(); //foreach (var o in gMethodArgumentList) { // gMethodArguments.Add(o.Philote, o); //} var gClass = new GClass("StateConfiguration", gVisibility: gVisibility); var gProperty = new GProperty("State", "State", "{get;}", "public"); gClass.GPropertys.Add(gProperty.Philote, gProperty); gProperty = new GProperty("Trigger", "Trigger", "{get;}", "public"); gClass.GPropertys.Add(gProperty.Philote, gProperty); gProperty = new GProperty("NextState", "State", "{get;}", "public"); gClass.GPropertys.Add(gProperty.Philote, gProperty); var gMethodArguments = new Dictionary <IPhilote <IGArgument>, IGArgument>(); foreach (var o in new List <IGArgument>() { new GArgument("state", "State"), new GArgument("trigger", "Trigger"), new GArgument("nextState", "State"), }) { gMethodArguments.Add(o.Philote, o); } var gMethodDeclaration = new GMethodDeclaration(gName: "StateConfiguration", gVisibility: "public", isConstructor: true, gArguments: gMethodArguments); var gBody = new GBody( gStatements: new List <string>() { "State=state;", "Trigger=trigger;", "NextState=nextState;", }); var gMethod = new GMethod(gMethodDeclaration, gBody); gClass.GMethods.Add(gMethod.Philote, gMethod); return(gClass); }
public static IGClass AddTLocalizerConstructorAutoPropertyGroup(this IGClass gClass, IPhilote <IGMethod> gMethodId, string gAutoPropertyName, string assemblyUnitName, IPhilote <IGPropertyGroup> gPropertyGroupId = default, string?gAccessors = "{ get; }", string?gVisibility = default) { IGMethod gMethod = default; if (gClass.GMethods != null && gClass.GMethods.ContainsKey(gMethodId)) { gMethod = gClass.GMethods[gMethodId]; } else if (gClass.GMethodGroups != null) { foreach (var kvp in gClass.GMethodGroups) { if (kvp.Value.GMethods.ContainsKey(gMethodId)) { //GMethodGroup gMethodGroup = kvp.Value; gMethod = kvp.Value.GMethods[gMethodId]; } } } if (gMethod == null) { throw new Exception(string.Format("{0} not found in the Constructors, Methods or MethodGroups of {1}", gMethodId.ID.ToString(), gClass.GName)); } var gMethodDeclaration = gMethod.GDeclaration; string gName = gMethodDeclaration.GName; GProperty gProperty = new GProperty(gName: $"{gAutoPropertyName}", gType: $"IStringLocalizer", gAccessors: gAccessors); if (gClass.GPropertyGroups != null && gClass.GPropertyGroups.ContainsKey(gPropertyGroupId)) { gClass.GPropertyGroups[gPropertyGroupId].GPropertys[gProperty.Philote] = gProperty; } else { throw new Exception(string.Format("{0} not found in the PropertyGroups of {1}", gPropertyGroupId.ID.ToString(), gClass.GName)); } //gMethod.GBody.StatementList.Add($"{gAutoPropertyName} = StringLocalizerFactory.Create(nameof({assemblyUnitName}.Resources), \"{assemblyUnitName}\");"); gMethod.GBody.GStatements.Add($"{gAutoPropertyName} = StringLocalizerFactory.Create(nameof(Resources), \"{assemblyUnitName}\");"); return(gClass); }
public static IGClass AddTLoggerConstructorAutoPropertyGroup(this IGClass gClass, IPhilote <IGMethod> gMethodId, IPhilote <IGPropertyGroup> gPropertyGroupId = default, string?gAccessors = "{ get; }", string?gVisibility = default) { IGMethod gMethod = default; if (gClass.GMethods != null && gClass.GMethods.ContainsKey(gMethodId)) { gMethod = gClass.GMethods[gMethodId]; } else if (gClass.GMethodGroups != null) { foreach (var kvp in gClass.GMethodGroups) { if (kvp.Value.GMethods.ContainsKey(gMethodId)) { var gMethodGroup = kvp.Value; gMethod = gMethodGroup.GMethods[gMethodId]; } } } if (gMethod == null) { throw new Exception(string.Format("{0} not found in the Constructors, Methods or MethodGroups of {1}", gMethodId.ID.ToString(), gClass.GName)); } var gMethodDeclaration = gMethod.GDeclaration; string gName = gMethodDeclaration.GName; GProperty gProperty = new GProperty(gName: $"Logger", gType: $"ILogger<{gName}>", gAccessors: gAccessors); if (gClass.GPropertyGroups != null && gClass.GPropertyGroups.ContainsKey(gPropertyGroupId)) { gClass.GPropertyGroups[gPropertyGroupId].GPropertys[gProperty.Philote] = gProperty; } else { throw new Exception(string.Format("{0} not found in the PropertyGroups of {1}", gPropertyGroupId.ID.ToString(), gClass.GName)); } gMethod.GBody.GStatements.Add($"Logger = LoggerFactory.CreateLogger<{gName}>();"); return(gClass); }
// -------- Access -------- private void HookProperties() { foreach (UIElement element in Workspace.Children) { if (element is GStatement) { GStatement gStatement = element as GStatement; GSPresentation statement = new GSPresentation(gStatement); statement.PointPresentation = new PointPresentation(Canvas.GetLeft(element as GStatement), Canvas.GetTop(element as GStatement)); Statements.Add(statement); } else if (element is GProperty) { GProperty gProperty = element as GProperty; GPPresentation property = new GPPresentation(gProperty); property.PointPresentation = new PointPresentation(Canvas.GetLeft(element as GProperty), Canvas.GetTop(element as GProperty)); Properties.Add(property); } } }
public static void MStateMachineConstructor( IGCompilationUnit gCompilationUnit = default, IGNamespace gNamespace = default, IGClass gClass = default, IGMethod gConstructor = default, IList <string> initialDiGraphList = default) { #region UsingGroup var gUsingGroup = MUsingGroupForStatelessStateMachine(); gCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote, gUsingGroup); #endregion #region Delegates var gDelegates = new Dictionary <IPhilote <IGDelegate>, IGDelegate>(); var UnhandledTriggerDelegateArguments = new Dictionary <IPhilote <IGArgument>, IGArgument>(); foreach (var o in new List <IGArgument>() { new GArgument("state", "State"), new GArgument("trigger", "Trigger"), }) { UnhandledTriggerDelegateArguments.Add(o.Philote, o); } foreach (var o in new List <IGDelegate>() { new GDelegate(new GDelegateDeclaration("UnHandledTriggerDelegate", gType: "void", gVisibility: "public", gArguments: UnhandledTriggerDelegateArguments)), new GDelegate(new GDelegateDeclaration(gName: "EntryExitDelegate", gType: "void", gVisibility: "public")), new GDelegate(new GDelegateDeclaration(gName: "GuardClauseDelegate", gType: "void", gVisibility: "public")), }) { gDelegates.Add(o.Philote, o); } gNamespace.AddDelegate(gDelegates); #endregion #region StateMachine GPropertyGroup and its properties var gPropertyGroup = new GPropertyGroup(gName: "StateMachine Properties"); // StateMachine Property var gProperty = new GProperty(gName: "StateMachine", gType: "StateMachine<State,Trigger>", gAccessors: "{get;}"); gPropertyGroup.GPropertys.Add(gProperty.Philote, gProperty); // StateConfigurations property //gProperty = new GProperty(gName: "StateConfigurations", gType: "List<StateConfiguration>", gAccessors: "{get;}"); //gPropertyGroup.GPropertys.Add(gProperty.Philote, gProperty); // Add the PropertyGroup to the gClass gClass.GPropertyGroups.Add(gPropertyGroup.Philote, gPropertyGroup); #endregion // Add initialization statements for the properties in the the StateMachine Properties Property Group to the constructor body gConstructor.GBody.GStatements.AddRange(new List <string>() { "StateMachine = new StateMachine<State, Trigger>(State.WaitingForInitialization);", "//StateConfigurations = stateConfigurations;", "ConfigureStateMachine();", }); //// StateConfiguration Class for the provided namespace //// Define the properties for the StateConfiguration class //// ToDo: Move this type into ATAP.Utilities.StateMachine //var gPropertys = new Dictionary<IPhilote<IGProperty>, GIProperty>(); //gProperty = new GProperty("State", "State", gAccessors: "{get;}", gVisibility: "public"); //gPropertys.Add(gProperty.Philote, gProperty); //gProperty = new GProperty("Trigger", "Trigger", gAccessors: "{get;}", gVisibility: "public"); //gPropertys.Add(gProperty.Philote, gProperty); //gProperty = new GProperty("NextState", "State", gAccessors: "{get;}", gVisibility: "public"); //gPropertys.Add(gProperty.Philote, gProperty); //var stateConfigurationClass = new GClass(gName: "StateConfiguration", gPropertys: gPropertys); //var gMethodArguments = new Dictionary<IPhilote<IGArgument>, IGArgument>(); //foreach (var o in new List<IGArgument>() { // new GArgument("state", "State"), new GArgument("trigger", "Trigger"), new GArgument("nextState", "State"), //}) { // gMethodArguments.Add(o.Philote, o); //} //gConstructor = new GMethod( // new GMethodDeclaration(gName: "StateConfiguration", isConstructor: true, gType: "IDisposable", // gVisibility: "public", gAccessModifier: "", // gArguments: gMethodArguments), // gBody: // new GBody(new List<string>() {"State=state;", "Trigger=trigger;", "NextState=nextState;",}), // new GComment(new List<string>() { // "/// <summary>", "/// builds one state instance", "/// </summary>", "/// <returns></returns>", // })); //stateConfigurationClass.GMethods.Add(gConstructor.Philote, gConstructor); //gNamespace.GClasss.Add(stateConfigurationClass.Philote, stateConfigurationClass); }
private void Control_Connection_MouseDown(object sender, MouseButtonEventArgs e) { if (!creatingConnection || selected == null) { return; } Control connecting = sender as Control; IPanel selectedPanel = sender as IPanel; IPanel connectingPanel = connecting as IPanel; PanelConnection panelConnection = null; if (connecting is GStatement) { GStatement connectingGStatement = connecting as GStatement; panelConnection = new PanelConnection(selected, connecting, true, BreakConnectionItem_Click); if (selected.StatementType == connectingGStatement.StatementType) { Console.WriteLine("Cannot connect two statements with same type!"); creatingConnection = false; selected = null; return; } (selected.GetBoundProperty() as Statement).NextStatements.Add(connectingGStatement.GetBoundProperty() as Statement); } else if (connecting is GProperty) { GProperty connectingGProperty = connecting as GProperty; if (connectingGProperty.GetBoundProperty() == null) { Console.WriteLine("GProperty property is not defined!"); creatingConnection = false; selected = null; return; } panelConnection = new PanelConnection(selected, connecting, false, BreakConnectionItem_Click); Statement statement = selected.GetBoundProperty() as Statement; Property property = connectingGProperty.GetBoundProperty() as Property; if (connectingGProperty.Type == PropertyType.Condition) { statement.Conditions.Add(property); if (connectingGProperty.Negated) { statement.NegatedConditions.Add(property.ID); } } else if (connectingGProperty.Type == PropertyType.Event) { statement.Events.Add(property); } } Connections.Add(panelConnection); creatingConnection = false; selected = null; HideTopInformationBar(); }
public static IGAssemblyGroup MConsoleSinkGHS(string gAssemblyGroupName, string subDirectoryForGeneratedFiles = default, string baseNamespaceName = default, bool hasInterfaces = true, GPatternReplacement gPatternReplacement = default) { GPatternReplacement _gPatternReplacement = gPatternReplacement == default ? new GPatternReplacement() : gPatternReplacement; var mCreateAssemblyGroupResult = MAssemblyGroupGHHSConstructor(gAssemblyGroupName, subDirectoryForGeneratedFiles, baseNamespaceName, hasInterfaces, _gPatternReplacement); #region Initial StateMachine Configuration mCreateAssemblyGroupResult.GPrimaryConstructorBase.GStateConfiguration.GDOTGraphStatements.Add( @" WaitingForInitialization -> WaitingForRequestToWriteSomething [label = ""InitializationCompleteReceived""] WaitingForRequestToWriteSomething -> WaitingForWriteToComplete [label = ""WriteStarted""] WaitingForWriteToComplete -> WaitingForRequestToWriteSomething [label = ""WriteFinished""] WaitingForWriteToComplete -> WaitingForRequestToWriteSomething [label = ""CancellationTokenActivated""] WaitingForRequestToWriteSomething -> ServiceFaulted [label = ""ExceptionCaught""] WaitingForWriteToComplete ->ServiceFaulted [label = ""ExceptionCaught""] WaitingForRequestToWriteSomething ->ShutdownStarted [label = ""CancellationTokenActivated""] WaitingForRequestToWriteSomething ->ShutdownStarted [label = ""StopAsyncActivated""] WaitingForWriteToComplete ->ShutdownStarted [label = ""StopAsyncActivated""] ShutdownStarted ->ShutdownComplete [label = ""ShutdownCompleted""] " ); #endregion var s1 = new List <string>() { @"StateMachine.Configure(State.WaitingForInitialization)", //$" .OnEntry(() => {{ if (OnWaitingForInitializationEntry!= null) OnWaitingForInitializationEntry(); }})", //$" .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})", $" .Permit(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething)", $";", @"StateMachine.Configure(State.WaitingForRequestToWriteSomething)", //$" .OnEntry(() => {{ if (OnWaitingForInitializationEntry!= null) OnWaitingForInitializationEntry(); }})", // $" .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})", $" .Permit(Trigger.WriteStarted, State.WaitingForWriteToComplete)", $" .Permit(Trigger.StopAsyncActivated, State.ShutdownStarted)", // $" .PermitReentryIf(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething, () => {{ if (GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived!= null) return GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived(); return true; }})", $";", @"StateMachine.Configure(State.WaitingForWriteToComplete)", $" .OnEntry((string mesg) => {{Console.Write(mesg);}})", // $" .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})", $" .Permit(Trigger.WriteFinished, State.WaitingForRequestToWriteSomething)", $" .Permit(Trigger.StopAsyncActivated, State.ShutdownStarted)", // $" .PermitReentryIf(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething, () => {{ if (GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived!= null) return GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived(); return true; }})", $";", @"StateMachine.Configure(State.ShutdownStarted)", //$" .OnEntry(() => {{ if (OnWaitingForInitializationEntry!= null) OnWaitingForInitializationEntry(); }})", // $" .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})", $" .Permit(Trigger.ShutdownCompleted, State.ShutdownComplete)", // $" .PermitReentryIf(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething, () => {{ if (GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived!= null) return GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived(); return true; }})", $";", @"StateMachine.Configure(State.ShutdownComplete);", }; #region Add UsingGroups to the Titular Derived and Titular Base CompilationUnits #region Add UsingGroups common to both the Titular Derived and Titular Base CompilationUnits #endregion #region Add UsingGroups specific to the Titular Base CompilationUnit #endregion #endregion #region Injected PropertyGroup For ConsoleSinkAndConsoleSource #endregion #region Additional Properties needed by the Base class var lclPropertyGroup = new GPropertyGroup($"Private Properties part of {mCreateAssemblyGroupResult.GClassBase.GName}"); var mesgProperty = new GProperty(gName: "Mesg", gType: "string", gVisibility: "private"); lclPropertyGroup.GPropertys.Add(mesgProperty.Philote, mesgProperty); mCreateAssemblyGroupResult.GClassBase.GPropertyGroups.Add(lclPropertyGroup.Philote, lclPropertyGroup); #endregion #region Add the MethodGroup containing new methods provided by this library to the Titular Base CompilationUnit var gMethodGroup = new GMethodGroup( gName: $"MethodGroup specific to {mCreateAssemblyGroupResult.GClassBase.GName}"); foreach (var gMethod in MCreateWriteMethodInConsoleSink()) { gMethodGroup.GMethods.Add(gMethod.Philote, gMethod); } mCreateAssemblyGroupResult.GClassBase.AddMethodGroup(gMethodGroup); #endregion #region Add additional classes provided by this library to the Titular Base CompilationUnit #endregion #region Add References used by the Titular Derived and Titular Base CompilationUnits to the ProjectUnit #region Add References used by both the Titular Derived and Titular Base CompilationUnits #endregion #region Add References unique to the Titular Base CompilationUnit #endregion #endregion /*******************************************************************************/ #region Update the Interface Assembly for this service #region Add UsingGroups for the Titular Derived Interface and Titular Base Interface #region Add UsingGroups common to both the Titular Derived Interface and the Titular Base Interface #endregion #region Add UsingGroups specific to the Titular Base Interface #endregion #endregion #region Add References for the Titular Interface ProjectUnit #region Add References common to both the Titular Derived Interface and Titular Base Interface #endregion #region Add References unique to the Titular Base Interface CompilationUnit #endregion #endregion #endregion #region Finalize the GHHS GAssemblyGroupGHHSFinalizer(mCreateAssemblyGroupResult); #endregion #region Populate the ConfigureStateMachine method mCreateAssemblyGroupResult.GClassBase.CombinedMethods() .Where(x => x.GDeclaration.GName == "ConfigureStateMachine").First().GBody.GStatements.AddRange(s1); // mCreateAssemblyGroupResult.GPrimaryConstructorBase.GBody.GStatements.AddRange(s1); #endregion return(mCreateAssemblyGroupResult.GAssemblyGroup); }