public IEnumerable <IConceptInfo> CreateNewConcepts(CodeTableInfo conceptInfo, IDslModel existingConcepts) { var codePropertyInfo = new ShortStringPropertyInfo { DataStructure = conceptInfo.Entity, Name = "Code" }; var autoCode = new AutoCodePropertyInfo { Property = codePropertyInfo }; var namePropertyInfo = new ShortStringPropertyInfo { DataStructure = conceptInfo.Entity, Name = "Name" }; var requiredInfo = new RequiredPropertyInfo { Property = namePropertyInfo }; return(new IConceptInfo[] { codePropertyInfo, autoCode, namePropertyInfo, requiredInfo }); }
public PluginPipelineUser(RequiredPropertyInfo demand, ArgumentValueUIArgs args, object demanderInstance) : base(new Type[] { }) //makes it a design time use case { Getter = () => { var p = (Pipeline)args.InitialValue; return(p); }; Setter = v => args.Setter(v); var pipeDemander = demanderInstance as IDemandToUseAPipeline; if (pipeDemander == null) { throw new NotSupportedException("Class " + demanderInstance.GetType().Name + " does not implement interface IDemandToUseAPipeline despite having a property which is a Pipeline"); } _useCase = pipeDemander.GetDesignTimePipelineUseCase(demand); ExplicitSource = _useCase.ExplicitSource; ExplicitDestination = _useCase.ExplicitDestination; foreach (var o in _useCase.GetInitializationObjects()) { AddInitializationObject(o); } GenerateContext(); }
public PipelineSelectionUIFactory(ICatalogueRepository repository, RequiredPropertyInfo requirement, ArgumentValueUIArgs args, object demanderInstance) { _repository = repository; var pluginUserAndCase = new PluginPipelineUser(requirement, args, demanderInstance); _user = pluginUserAndCase; _useCase = pluginUserAndCase; }
private static string ValidatorsCodeSnippet(RequiredPropertyInfo info) { string result = string.Format( @"{{Validator :Validators.required, ErrorCode: 'required', ErrorMessage: ""{0} is required"" }}, ", info.Property.Name); return(result); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { if (conceptInfo is RequiredPropertyInfo) { RequiredPropertyInfo info = (RequiredPropertyInfo)conceptInfo; if (DataStructureCodeGenerator.IsTypeSupported(info.Property.DataStructure)) { codeBuilder.InsertCode(ImplementationCodeSnippet((RequiredPropertyInfo)info), MvcPropertyHelper.AttributeTag, info.Property); } } }
private string CheckDataSnippet(RequiredPropertyInfo info) { return(string.Format( @" {{ var invalid = insertedNew.Concat(updatedNew).FirstOrDefault(item => string.IsNullOrWhiteSpace(item.{2})); if (invalid != null) throw new Rhetos.UserException(""It is not allowed to enter {0}.{1} because the required property {2} is not set."", ""DataStructure:{0}.{1},ID:"" + invalid.ID.ToString() + "",Property:{2}""); }} ", info.Property.DataStructure.Module.Name, info.Property.DataStructure.Name, info.Property.Name)); }
private string CheckDataSnippet(RequiredPropertyInfo info) { string dataStructureFullName = info.Property.DataStructure.Module.Name + "." + info.Property.DataStructure.Name; return (@"{ var invalid = insertedNew.Concat(updatedNew).FirstOrDefault(item => item." + CsPropertyName(info.Property) + @" == null " + OrCondition.Evaluate(info) + @"); if (invalid != null) throw new Rhetos.UserException(""It is not allowed to enter {0} because the required property {1} is not set."", new[] { """ + dataStructureFullName + @""", """ + info.Property.Name + @""" }, ""DataStructure:" + dataStructureFullName + @",ID:"" + invalid.ID.ToString() + "",Property:" + CsPropertyName(info.Property) + @""", null); } "); }
private void CreateLine(IArgumentHost parent, IArgument argument, RequiredPropertyInfo required, float maxArgNameWidth) { Label name = new Label(); HelpIcon helpIcon = new HelpIcon(); helpIcon.SetHelpText(GetSystemTypeName(argument.GetSystemType()) ?? "Unrecognised Type:" + argument.Type, required.Demand.Description); helpIcon.Dock = DockStyle.Right; string spaceSeparatedArgumentName = UsefulStuff.PascalCaseStringToHumanReadable(argument.Name); name.Height = helpIcon.Height; name.Text = spaceSeparatedArgumentName; name.TextAlign = ContentAlignment.MiddleLeft; name.Dock = DockStyle.Left; name.Width = (int)maxArgNameWidth + 3 /*padding*/; RAGSmiley ragSmiley = new RAGSmiley(); if (required.Demand.Mandatory && string.IsNullOrWhiteSpace(argument.Value)) { ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory")); } var args = new ArgumentValueUIArgs(); args.Parent = parent; args.Type = argument.GetSystemType(); args.ContextText = required.Demand.ContextText; try { args.InitialValue = argument.GetValueAsSystemType(); } catch (Exception e) { //add the text value value and report the error if (_valueUisFactory.CanHandleInvalidStringData(args.Type)) { args.InitialValue = argument.Value; } else { args.InitialValue = null; } ragSmiley.Fatal(e); } args.Required = required; args.CatalogueRepository = (ICatalogueRepository)argument.Repository; args.Setter = (v) => { ragSmiley.Reset(); try { argument.SetValue(v); argument.SaveToDatabase(); argument.GetValueAsSystemType(); if (required.Demand.Mandatory && (v == null || string.IsNullOrWhiteSpace(v.ToString()))) { ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory")); } } catch (Exception ex) { ragSmiley.OnCheckPerformed(new CheckEventArgs("Failed to set property properly", CheckResult.Fail, ex)); } }; args.Fatal = ragSmiley.Fatal; var valueui = (Control)_valueUisFactory.Create(_activator, args); valueui.Dock = DockStyle.Fill; Panel p = new Panel(); p.Height = Math.Max(Math.Max(lblClassName.Height, helpIcon.Height), valueui.Height); p.Dock = DockStyle.Top; name.Location = new Point(0, 0); p.Controls.Add(name); helpIcon.Left = name.Right; p.Controls.Add(helpIcon); ragSmiley.Dock = DockStyle.Right; p.Controls.Add(ragSmiley); p.Controls.Add(valueui); name.Height = p.Height; Label hr = new Label(); hr.AutoSize = false; hr.BorderStyle = BorderStyle.FixedSingle; hr.Height = 1; hr.Dock = DockStyle.Bottom; p.Controls.Add(hr); valueui.BringToFront(); pArguments.Controls.Add(p); }
private void CreateLine(IArgumentHost parent, IArgument argument, RequiredPropertyInfo required) { Label name = new Label(); HelpIcon helpIcon = new HelpIcon(); helpIcon.SetHelpText(GetSystemTypeName(argument.GetSystemType()) ?? "Unrecognised Type:" + argument.Type, required.Demand.Description); helpIcon.Anchor = AnchorStyles.Top | AnchorStyles.Left; string spaceSeparatedArgumentName = UsefulStuff.PascalCaseStringToHumanReadable(argument.Name); name.Height = helpIcon.Height; name.Text = spaceSeparatedArgumentName; name.TextAlign = ContentAlignment.MiddleLeft; name.AutoSize = true; name.Anchor = AnchorStyles.Top | AnchorStyles.Left; RAGSmiley ragSmiley = new RAGSmiley(); if (required.Demand.Mandatory && string.IsNullOrWhiteSpace(argument.Value)) { ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory")); } var args = new ArgumentValueUIArgs(); args.Parent = parent; args.Type = argument.GetSystemType(); try { args.InitialValue = argument.GetValueAsSystemType(); } catch (Exception e) { //add the text value value and report the error if (_valueUisFactory.CanHandleInvalidStringData(args.Type)) { args.InitialValue = argument.Value; } else { args.InitialValue = null; } ragSmiley.Fatal(e); } args.Required = required; args.CatalogueRepository = (ICatalogueRepository)argument.Repository; args.Setter = (v) => { ragSmiley.Reset(); try { argument.SetValue(v); argument.SaveToDatabase(); argument.GetValueAsSystemType(); if (required.Demand.Mandatory && (v == null || string.IsNullOrWhiteSpace(v.ToString()))) { ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory")); } } catch (Exception ex) { ragSmiley.OnCheckPerformed(new CheckEventArgs("Failed to set property properly", CheckResult.Fail, ex)); } }; args.Fatal = ragSmiley.Fatal; var valueui = (Control)_valueUisFactory.Create(args); valueui.Anchor = name.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; _valueUIs.Add(valueui); Panel p = new Panel(); p.Height = Math.Max(Math.Max(lblClassName.Height, helpIcon.Height), valueui.Height); p.Width = pArguments.ClientRectangle.Width; p.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; p.BorderStyle = BorderStyle.FixedSingle; p.Location = new Point(0, _currentY); _currentY += p.Height; name.Location = new Point(0, 0); p.Controls.Add(name); helpIcon.Left = name.Right; p.Controls.Add(helpIcon); ragSmiley.Left = p.Width - ragSmiley.Width; ragSmiley.Anchor = AnchorStyles.Right | AnchorStyles.Top; p.Controls.Add(ragSmiley); valueui.Left = helpIcon.Right; valueui.Width = p.Width - (helpIcon.Right + ragSmiley.Left); _maxValueUILeft = Math.Max(_maxValueUILeft, valueui.Left); p.Controls.Add(valueui); p.MinimumSize = new Size(ragSmiley.Right, p.Height); name.Height = p.Height; pArguments.Controls.Add(p); }
public IPipelineUseCase GetDesignTimePipelineUseCase(RequiredPropertyInfo property) { return(AutoRoutingAttacherPipelineUseCase.GetDesignTimeUseCase(this)); }
private static string ImplementationCodeSnippet(RequiredPropertyInfo info) { return(string.Format(@"[Required] ")); }
public IPipelineUseCase GetDesignTimePipelineUseCase(RequiredPropertyInfo property) { return(new KVPAttacherPipelineUseCase(this, new FlatFileToLoad(null))); }