private void btnOK_Click(object sender, EventArgs e) { this.NewParameter = this.cboxNewName.SelectedItem as IParameter; this.OldParameter = this.cboxOldName.SelectedItem as IParameter; this.DialogResult = DialogResult.OK; this.Close(); }
public object[] Resolve(object requestParameters, IParameter[] targetParameters) { // Convert to array var parameters = ((IEnumerable) requestParameters).Cast<object>().ToArray(); // If length does not match, throw. if (parameters.Length != targetParameters.Length) { throw new ParameterLengthMismatchException(); } var result = new List<object>(); // Loop through and parse parameters for (var i = 0; i < parameters.Length; i++) { var request = parameters[i]; var target = targetParameters[i]; // If the target parameter is `object`, do not try to convert it. if (target.ParameterType == typeof (object)) { result.Add(request); } else { var serialized = _serializer.SerializeObject(request); var converted = _serializer.DeserializeObject(serialized, target.ParameterType); result.Add(converted); } } return result.ToArray(); }
protected virtual IPicoContainer WrapComponentInstances(Type decoratingComponentAdapterClass, IPicoContainer picoContainer, object[] wrapperDependencies) { Assert.IsTrue(typeof (DecoratingComponentAdapter).IsAssignableFrom(decoratingComponentAdapterClass)); IMutablePicoContainer mutablePicoContainer = new DefaultPicoContainer(); int size = (wrapperDependencies != null ? wrapperDependencies.Length : 0) + 1; ICollection allComponentAdapters = picoContainer.ComponentAdapters; foreach (object adapter in allComponentAdapters) { IParameter[] parameters = new IParameter[size]; parameters[0] = new ConstantParameter(adapter); for (int i = 1; i < parameters.Length; i++) { parameters[i] = new ConstantParameter(wrapperDependencies[i - 1]); } IMutablePicoContainer instantiatingPicoContainer = new DefaultPicoContainer(new ConstructorInjectionComponentAdapterFactory()); instantiatingPicoContainer.RegisterComponentImplementation("decorator", decoratingComponentAdapterClass, parameters); mutablePicoContainer.RegisterComponent( (IComponentAdapter) instantiatingPicoContainer.GetComponentInstance("decorator")); } return mutablePicoContainer; }
public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { DefaultReturnVector ret = new DefaultReturnVector(); int index = - 1; if (params_Renamed != null && params_Renamed.Length == 2) { Object first = params_Renamed[0].Value; Object[] second = (Object[]) params_Renamed[1].Value; for (int idx = 0; idx < second.Length; idx++) { if (first.Equals(second[idx])) { index = idx; break; } } } if (index > - 1) { DefaultReturnValue rv = new DefaultReturnValue(Constants.INTEGER_OBJECT, index); ret.addReturnValue(rv); } else { DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, false); ret.addReturnValue(rv); } return ret; }
public override IComponentAdapter CreateComponentAdapter(object componentKey, Type componentImplementation, IParameter[] parameters) { return new CachingComponentAdapter( base.CreateComponentAdapter(componentKey, componentImplementation, parameters)); }
public PendingBinaryStateOutputActuatorState WithParameter(IParameter parameter) { if (parameter == null) throw new ArgumentNullException(nameof(parameter)); Parameters.Add(parameter); return this; }
public int CreateSubmission(Dictionary<string, string> dataDictionary) { IParameter[] parameters = new IParameter[2]; parameters[0] = FormStorageCore.SqlHelper.CreateParameter("@DBformID", DBformID); parameters[1] = FormStorageCore.SqlHelper.CreateParameter("@ipAddress", FormStorageCore.GetUserIP()); //create submission int submissionID = FormStorageCore.SqlHelper.ExecuteScalar<int>("INSERT INTO FormStorageSubmissions (formID, IP, datetime) VALUES (@DBformID, @ipAddress, GETDATE());SELECT SCOPE_IDENTITY() AS submissionID;", parameters); //HttpContext.Current.Response.Write("Submission ID=>" + submissionID + "<br/>"); if (submissionID == 0) { throw new Exception("Could not create a record in table FormStorageSubmissions."); } parameters = new IParameter[3]; parameters[0] = FormStorageCore.SqlHelper.CreateParameter("@submissionID", submissionID); foreach (string formField in formFields) { try { parameters[1] = FormStorageCore.SqlHelper.CreateParameter("@fieldAlias", formField); parameters[2] = FormStorageCore.SqlHelper.CreateParameter("@value", HttpUtility.HtmlEncode(dataDictionary[formField])); int entryID = FormStorageCore.SqlHelper.ExecuteScalar<int>("INSERT INTO FormStorageEntries (submissionID, fieldAlias, value) VALUES (@submissionID, @fieldAlias, @value);SELECT SCOPE_IDENTITY() AS entryID;", parameters); } catch (Exception e2) { //HttpContext.Current.Response.Write(e2.Message); } } return submissionID; }
internal static CodeTypeReference GetParameterTypeReference(CodeTypeDeclaration classDeclaration, IParameter param) { Type underlyingType = GetParameterType(param); CodeTypeReference paramTypeRef = new CodeTypeReference(underlyingType); bool isValueType = underlyingType.IsValueType; // Check if we need to declare a custom type for this parameter. // If the parameter is an enum, try finding the matching enumeration in the current class if (!param.EnumValues.IsNullOrEmpty()) { // Naming scheme: MethodnameParametername CodeTypeReference enumReference = DecoratorUtil.FindFittingEnumeration( classDeclaration, param.EnumValues, param.EnumValueDescriptions); if (enumReference != null) { paramTypeRef = enumReference; isValueType = true; } } // Check if this is an optional value parameter. if (isValueType && !param.IsRequired) { paramTypeRef = new CodeTypeReference(typeof(Nullable<>)) { TypeArguments = { paramTypeRef.BaseType } }; // An optional value parameter has to be nullable. } return paramTypeRef; }
internal CodeTypeMemberCollection GenerateParameterProperty(IParameter parameter, IMethod method, CodeTypeDeclaration resourceClass, IEnumerable<string> usedNames) { // Get the name and return type of this parameter. string name = parameter.Name; CodeTypeReference returnType = ResourceBaseGenerator.GetParameterTypeReference( resourceClass, parameter); // Generate the property and field. CodeTypeMemberCollection newMembers = DecoratorUtil.CreateAutoProperty( name, parameter.Description, returnType, usedNames, parameter.IsRequired); // Add the KeyAttribute to the property. foreach (CodeTypeMember member in newMembers) { CodeMemberProperty property = member as CodeMemberProperty; if (property == null) { continue; } // Declare the RequestParameter attribute. CodeTypeReference attributeType = new CodeTypeReference(typeof(RequestParameterAttribute)); CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(attributeType); attribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(parameter.Name))); property.CustomAttributes.Add(attribute); } return newMembers; }
public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { if (params_Renamed != null && params_Renamed.Length > 0) { for (int idx = 0; idx < params_Renamed.Length; idx++) { if (params_Renamed[idx].StringValue.Equals("all")) { engine.Profile = ProfileType.PROFILE_ALL; } else if (params_Renamed[idx].StringValue.Equals("assert-fact")) { engine.Profile = ProfileType.PROFILE_ASSERT; } else if (params_Renamed[idx].StringValue.Equals("Add-activation")) { engine.Profile = ProfileType.PROFILE_ADD_ACTIVATION; } else if (params_Renamed[idx].StringValue.Equals("fire")) { engine.Profile = ProfileType.PROFILE_FIRE; } else if (params_Renamed[idx].StringValue.Equals("retract-fact")) { engine.Profile = ProfileType.PROFILE_RETRACT; } else if (params_Renamed[idx].StringValue.Equals("Remove-activation")) { engine.Profile = ProfileType.PROFILE_RM_ACTIVATION; } } } DefaultReturnVector ret = new DefaultReturnVector(); return ret; }
public AddToDate(IElementCreationContext context) : base(context, context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime)) { DateParameter = context.Owner.CreateParameter("date", context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime), "Date"); DateParameter.Postfix = " + "; AmountParameter = context.Owner.CreateParameter("amount", context.Owner.GetFloatType()); Parameters.Add(DateParameter); Parameters.Add(AmountParameter); _services = new OperationService[] { new OperationService(OperationType.Seconds, "Seconds", TimeSpan.FromSeconds), new OperationService(OperationType.Minutes, "Minutes", TimeSpan.FromMinutes), new OperationService(OperationType.Hours, "Hours", TimeSpan.FromHours), new OperationService(OperationType.Days, "Days", TimeSpan.FromDays), }; Operation = OperationType.Seconds; if (!string.IsNullOrWhiteSpace(context.Data)) { var data = JsonConvert.DeserializeObject<OperatorData>(context.Data); Operation = data.Operation; } foreach (var service in _services) { AddAction(new ElementAction(service.Text, () => Operation = service.Operation, () => Operation != service.Operation)); } }
private void ProcessParameter(IParameter parameter, int index, StringBuilder preMemberCodeBulider) { // Dispatch to the typed parameter handler method. Type key = parameter.GetType().GetInterfaces().First(t => t.Namespace == typeof(IParameter).Namespace && t.Name.StartsWith("I") && t.Name.EndsWith("Parameter")); Action<IParameter, int, StringBuilder> method = _parameterCodeGeneratorMethodMap[key]; method(parameter, index, preMemberCodeBulider); }
public void AddParameter(IParameter parameter) { if (parameter == null) throw new ArgumentNullException("parameter"); parameters.Add(parameter.Name, parameter.Value); }
/// <summary> the function will printout one or more templates. This implementation /// is slightly different than CLIPS in that it can take one or more /// template names. The definition in CLIPS beginners guide states the /// function does the following: (ppdeftemplate <deftemplate-name>) /// </summary> public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { GenericHashMap<object, object> filter = new GenericHashMap<object, object>(); if (params_Renamed != null && params_Renamed.Length > 0) { for (int idx = 0; idx < params_Renamed.Length; idx++) { if (params_Renamed[idx] is ValueParam) { Object df = ((ValueParam) params_Renamed[idx]).Value; filter.Put(df, df); } } } List<Object> templ = (List<Object>) engine.CurrentFocus.Templates; IEnumerator itr = templ.GetEnumerator(); while (itr.MoveNext()) { ITemplate tp = (ITemplate) itr.Current; if (filter.Get(tp.Name) != null) { engine.writeMessage(tp.toPPString() + "\r\n", "t"); } } return new DefaultReturnVector(); }
public ValueOrderSignature( string syntax, string description, ITrackingSpan trackingSpan, ISignatureHelpSession session) { _propertyName = "Syntax"; _syntax = syntax ?? string.Empty; _description = description; _trackingSpan = trackingSpan; _content = string.Format(CultureInfo.InvariantCulture, "{0}: {1}", _propertyName, _syntax); _nameParam = new CssPropertyNameParameter(this); _currentParam = _nameParam; _session = session; // In order to dismiss this tip at the appropriate time, I need to listen // to changes in the text buffer if (_trackingSpan != null && _session != null) { _session.Dismissed += OnSessionDismissed; _trackingSpan.TextBuffer.Changed += OnTextBufferChanged; } }
public ParameterCollection(IParameter[] parameters) { foreach (IParameter parameter in parameters) { AddParameter(parameter); } }
public override bool ParseParameterValue(IParameter parameter, string parameterValue) { bool returnValue = base.ParseParameterValue(parameter, parameterValue); if (returnValue) { switch (parameter.Name) { case _ParameterAlternateNameSource: case _ParameterNameSource: parameterValue = parameterValue.Trim(); if (Directory.Exists(parameterValue)) { ((Parameter<string>)parameter).Value = parameterValue; } else { returnValue = false; } break; } } return returnValue; }
public ConstructorInjectionComponentAdapter(object componentKey, Type componentImplementation, IParameter[] parameters, bool allowNonPublicClasses, IComponentMonitor componentMonitor) : base(componentKey, componentImplementation, parameters, allowNonPublicClasses) { this.componentMonitor = componentMonitor; }
public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { Decimal bdval = new Decimal(0); if (params_Renamed != null) { if (params_Renamed[0] is ValueParam) { ValueParam n = (ValueParam) params_Renamed[0]; bdval = n.BigDecimalValue; } else if (params_Renamed[0] is BoundParam) { BoundParam bp = (BoundParam) params_Renamed[0]; bdval = (Decimal) engine.getBinding(bp.VariableName); } else if (params_Renamed[0] is FunctionParam2) { FunctionParam2 n = (FunctionParam2) params_Renamed[0]; n.Engine = engine; n.lookUpFunction(); IReturnVector rval = (IReturnVector) n.Value; bdval = rval.firstReturnValue().BigDecimalValue; } double bdh = Decimal.ToDouble(bdval); bdval = Convert.ToDecimal(bdh/57.29578); } DefaultReturnVector ret = new DefaultReturnVector(); DefaultReturnValue rv = new DefaultReturnValue(Constants.BIG_DECIMAL, bdval); ret.addReturnValue(rv); return ret; }
public DefaultParameter(IParameter p) { this.name = p.Name; this.region = p.Region; this.modifier = p.Modifiers; this.returnType = p.ReturnType; }
public virtual String toPPString(IParameter[] params_Renamed, int indents) { if (params_Renamed != null && params_Renamed.Length >= 0) { StringBuilder buf = new StringBuilder(); buf.Append("(" + TRUE_Renamed); int idx = 0; if (params_Renamed[idx] is BoundParam) { BoundParam bp = (BoundParam) params_Renamed[idx]; buf.Append(" ?" + bp.VariableName); } else if (params_Renamed[idx] is ValueParam) { buf.Append(" " + params_Renamed[idx].StringValue); } else { buf.Append(" " + params_Renamed[idx].StringValue); } buf.Append(")"); return buf.ToString(); } else { return "(true)\n" + "Function description:\n" + "\tRepresentation of the boolean constant true."; } }
public IComponentAdapter CreateComponentAdapter(object componentKey, Type componentImplementation, IParameter[] parameters) { return new CachingComponentAdapter( new ConstructorInjectionComponentAdapter(componentKey, componentImplementation, parameters)); }
public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { DefaultReturnVector ret = new DefaultReturnVector(); DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, true); ret.addReturnValue(rv); return ret; }
public virtual String toPPString(IParameter[] params_Renamed, int indents) { if (params_Renamed != null && params_Renamed.Length > 0) { StringBuilder buf = new StringBuilder(); buf.Append("(instanceof"); for (int idx = 0; idx < params_Renamed.Length; idx++) { if (params_Renamed[idx] is BoundParam) { BoundParam bp = (BoundParam) params_Renamed[idx]; buf.Append(" ?" + bp.VariableName); } else if (params_Renamed[idx] is ValueParam) { buf.Append(" " + params_Renamed[idx].StringValue); } else { buf.Append(" " + params_Renamed[idx].StringValue); } } buf.Append(")"); return buf.ToString(); } else { return "(instanceof <Java-object> <class-name>)\n"; } }
public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { if (params_Renamed != null && params_Renamed.Length > 0) { FileInfo dir = new FileInfo(params_Renamed[0].StringValue); if (Directory.Exists(dir.FullName)) { FileInfo[] files = dir.Directory.GetFiles(); for (int idx = 0; idx < files.Length; idx++) { if (Directory.Exists(files[idx].FullName)) { engine.writeMessage("d " + files[idx] + Constants.LINEBREAK); } else { engine.writeMessage("- " + files[idx] + Constants.LINEBREAK); } } engine.writeMessage(files.Length + " files in the directory" + Constants.LINEBREAK, "t"); } else { } } DefaultReturnVector ret = new DefaultReturnVector(); return ret; }
public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { double dval = 0; if (params_Renamed != null) { if (params_Renamed.Length == 1) { if (params_Renamed[0] is ValueParam) { ValueParam n = (ValueParam) params_Renamed[0]; dval = n.DoubleValue; dval = System.Math.Cos(dval); } else if (params_Renamed[0] is BoundParam) { BoundParam bp = (BoundParam) params_Renamed[0]; dval = bp.DoubleValue; dval = System.Math.Cos(dval); } else if (params_Renamed[0] is FunctionParam2) { FunctionParam2 n = (FunctionParam2) params_Renamed[0]; n.Engine = engine; n.lookUpFunction(); IReturnVector rval = (IReturnVector) n.Value; dval = rval.firstReturnValue().DoubleValue; dval = System.Math.Cos(dval); } } } DefaultReturnVector ret = new DefaultReturnVector(); DefaultReturnValue rv = new DefaultReturnValue(Constants.DOUBLE_PRIM_TYPE, dval); ret.addReturnValue(rv); return ret; }
public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed) { bool eval = false; if (params_Renamed.Length == 2) { Object param1 = null; if (params_Renamed[0] is BoundParam && params_Renamed[1] is BoundParam) { param1 = ((BoundParam) params_Renamed[0]).ObjectRef; try { Type clazz = classnameResolver.resolveClass(((BoundParam) params_Renamed[1]).StringValue); eval = clazz.IsInstanceOfType(param1); } catch (Exception e) { throw new RuntimeException(e); } } } DefaultReturnVector ret = new DefaultReturnVector(); DefaultReturnValue rv = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, eval); ret.addReturnValue(rv); return ret; }
/// <summary> /// Validates a parameter. /// /// Checks to see if it is required, or if it needs regex validation. /// </summary> /// <param name="param"> /// A <see cref="IParameter"/> /// </param> /// <returns> /// A <see cref="System.Boolean"/> /// </returns> public bool ValidateParameter(IParameter param) { if (Parameters == null) { return false; } string currentParam; bool parameterPresent = Parameters.TryGetValue(param.Name, out currentParam); // If a required parameter is not present, fail. if (String.IsNullOrEmpty(currentParam) || !parameterPresent) { return !param.IsRequired; } // The parameter is present, validate the regex. bool isValidData = ValidateRegex(param, currentParam) && ValidateEnum(param, currentParam); if (isValidData == false) { return false; } return true; }
protected override IPresenter CreatePresenterInstance(Type presenterType, TypedPageData pageData, Type viewType, IEPiView view) { // Unfortunately, Ninject needs the bloody names of the parameters, // so we need to figure them out by reflecting. string pageDataParameterName = null; string viewParameterName = null; foreach (var constructor in presenterType.GetConstructors()) { var constructorParameters = constructor.GetParameters(); foreach (var parameter in constructorParameters) { if (parameter.ParameterType.IsAssignableFrom(pageData.GetType())) pageDataParameterName = parameter.Name; if (parameter.ParameterType.IsAssignableFrom(view.GetType())) viewParameterName = parameter.Name; } } var parameters = new IParameter[] { new ConstructorArgument(viewParameterName, view), new ConstructorArgument(pageDataParameterName, pageData) }; return (IPresenter)Kernel.Get(presenterType, parameters); }
/// <summary> /// Constructor /// </summary> /// <param name="componentKey">The component's key</param> /// <param name="componentImplementation">The component implementing type</param> /// <param name="parameters">Parameters used to initialize the component</param> /// <param name="allowNonPublicClasses">flag to allow instantiation of non-public classes.</param> public InstantiatingComponentAdapter(object componentKey, Type componentImplementation, IParameter[] parameters, bool allowNonPublicClasses) : base(componentKey, componentImplementation) { this.parameters = parameters; this.allowNonPublicClasses = allowNonPublicClasses; }
public static double GetPercentile(this IParameter parameter) { var distributedParameter = parameter as IDistributedParameter; return(distributedParameter?.Percentile ?? 0); }
public static void SetOffset(IParameter param, ref string lineToParse, ref int lengthToSum) { SetOffset(param, param.Value, ref lineToParse, ref lengthToSum); }
private UnityEventFunction GetEventFunctionFromParameter(IParameter parameter) { return(GetEventFunction(parameter?.ContainingParametersOwner)); }
private bool IsParameterForEventFunction(IParameter parameter) { return(GetEventFunctionFromParameter(parameter) != null); }
/// <summary> /// Initializes a new instance of the <see cref="AWSPartitionInput"/> class. /// </summary> /// <param name="stackParameter">The stack parameter.</param> public AWSPartitionInput(IParameter stackParameter) : base(stackParameter) { }
public virtual void Setup(IEvolutionState state, IParameter parm) /* Default implementation does nothing */ }
public void Visit(IParameter parameter) { CheckParameter(parameter); }
public ParameterHelper() { Parameter = MockRepository.GenerateStub <IParameter>(); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>True</c> if the objects are equal; otherwise <c>false</c></returns> public bool Equals(IParameter other) { return(other.GetType() == GetType() && other.Name.Equals(Name)); }
private ICommand withUpdatedValueOrigin(ICommand command, IParameter sourceParameter, IParameter targetParameter) { if (Equals(sourceParameter.ValueOrigin, targetParameter.ValueOrigin)) { return(command); } var updateValueOriginCommand = _parameterTask.SetParameterValueOrigin(targetParameter, sourceParameter.ValueOrigin); if (command == null) { return(updateValueOriginCommand); } var macroCommand = new PKSimMacroCommand { CommandType = command.CommandType, ObjectType = command.ObjectType, Description = command.Description }; macroCommand.Add(command); macroCommand.Add(updateValueOriginCommand); return(macroCommand); }
public ICommand SetParameterValueOrigin(IParameter parameter, ValueOrigin newValueOrigin) { return(setParameterValueOrigin(parameter, newValueOrigin, shouldChangeVersion: true)); }
public ICommand SetParameterValue(IParameter parameter, double value, ISimulation simulation) { return(SetParameterValue(parameter, value)); }
public ICommand UpdateParameterValueOrigin(IParameter parameter, ValueOrigin valueOrigin, ISimulation simulation) { return(SetParameterValueOrigin(parameter, valueOrigin)); }
/// <summary> /// Adds a custom parameter to the binding. /// </summary> /// <param name="parameter">The parameter.</param> public IBindingWithOrOnSyntax <T> WithParameter(IParameter parameter) { Binding.Parameters.Add(parameter); return(this); }
public ICommand SetParameterFomula(IParameter parameter, IFormula formula) { return(executeAndUpdatedDefaultStateAndValue(new SetParameterFormulaCommand(parameter, formula), parameter)); }
public ICommand SetCompoundType(IParameter compountTypeParameter, CompoundType newCompoundType) { return(executeAndUpdatedDefaultStateAndValue(new SetCompoundTypeParameterCommand(compountTypeParameter, newCompoundType), compountTypeParameter)); }
public string PathFor(IParameter parameter) => _entityPathResolver.PathFor(parameter);
private IParameter findNormParameterFor(IParameter relativeExpression) { return(relativeExpression.ParentContainer.Parameter(CoreConstants.Parameters.NormParameterFor(relativeExpression.Name))); }
public ICommand SetAdvancedParameterUnit(IParameter parameter, Unit displayUnit) { return(executeAndUpdatedDefaultStateAndValue(new SetAdvancedParameterUnitCommand(parameter, displayUnit), parameter)); }
public ICommand ResetParameter(IParameter parameter) { return(new ResetParameterCommand(parameter).Run(_executionContext)); }
public ICommand SetAdvancedParameterDisplayValue(IParameter parameter, double valueToSetInGuiUnit) { return(executeAndUpdatedDefaultStateAndValue(new SetAdvancedParameterValueCommand(parameter, parameter.ConvertToBaseUnit(valueToSetInGuiUnit)), parameter)); }
public void SetParameterFavorite(IParameter parameter, bool isFavorite) { _favoriteTask.SetParameterFavorite(parameter, isFavorite); }
public ICommand UpdateTableFormulaWithoutBuildingBlockChange(IParameter tableParameter, TableFormula tableFormula) { return(executeAndUpdatedDefaultStateAndValue(new UpdateParameterTableFormulaCommand(tableParameter, tableFormula), tableParameter, shouldChangeVersion: false)); }
public ICommand SetParameterUnitWithoutBuildingBlockChange(IParameter parameter, Unit displayUnit) { return(executeAndUpdatedDefaultStateAndValue(new SetParameterUnitCommand(parameter, displayUnit), parameter, shouldChangeVersion: false)); }
public ICommand UpdateTableFormula(IParameter tableParameter, TableFormula tableFormula) { return(executeAndUpdatedDefaultStateAndValue(new UpdateParameterTableFormulaCommand(tableParameter, tableFormula), tableParameter)); }
public ICommand SetParameterName(IParameter parameter, string name) { return(new RenameEntityCommand(parameter, name, _executionContext).Run(_executionContext)); }
public List <string> getAppropriateValuesAfterInversePreprocessing(int selectionId, int parameterId, List <string> appropriateValues) { PreprocessingViewModel.PreprocessingTemplate prepParameters = getPreprocessingParameters(selectionId); List <PreprocessingViewModel.SerializableList> info = prepParameters.info; List <view_models.Parameter> parametersWithPrepType = prepParameters.parameters; //находим нужный preprocessing list и нужное преобразование foreach (PreprocessingViewModel.SerializableList elem in info) { if (selectionId.Equals(elem.selectionId)) { List <int> parameterIdList = elem.parameterIds; int index = 0; foreach (int paramId in parameterIdList) { if (parameterId.Equals(paramId)) { IParameter p = elem.prepParameters[index]; foreach (view_models.Parameter prepParam in parametersWithPrepType) { if (parameterId.Equals(prepParam.Id)) { string prepType = prepParam.Type; List <string> results = new List <string>(); switch (prepType) { case "Линейная нормализация 1 (к float)": for (int i = 0; i < appropriateValues.Count; i++) { string apVal = p.GetFromLinearNormalized(Convert.ToSingle(appropriateValues[i].Replace(".", ","))); results.Add(apVal); } return(results); case "Нелинейная нормализация 2 (к float)": for (int i = 0; i < appropriateValues.Count; i++) { string apVal = p.GetFromNonlinearNormalized(Convert.ToSingle(appropriateValues[i].Replace(".", ","))); results.Add(apVal); } return(results); case "нормализация 3 (к int)": for (int i = 0; i < appropriateValues.Count; i++) { string apVal = p.GetFromNormalized(Convert.ToInt32(appropriateValues[i])); results.Add(apVal); } return(results); case "бинаризация": //добавить бинаризацию!!!! break; case "без предобработки": return(appropriateValues); } break; } } break; } index++; } break; } } return(null); }
public override void Setup(IEvolutionState state, IParameter paramBase) { base.Setup(state, paramBase); var def = DefaultBase; TossSecondParent = state.Parameters.GetBoolean(paramBase.Push(P_TOSS), def.Push(P_TOSS), false); MinChildSize = state.Parameters.GetIntWithDefault(paramBase.Push(P_MIN_CHILD_SIZE), def.Push(P_MIN_CHILD_SIZE), 0); NumTries = state.Parameters.GetIntWithDefault(paramBase.Push(P_NUM_TRIES), def.Push(P_NUM_TRIES), 1); MinCrossoverPercentage = state.Parameters.GetFloatWithDefault(paramBase.Push(P_MIN_CROSSOVER_PERCENT), def.Push(P_MIN_CROSSOVER_PERCENT), 0.0); MaxCrossoverPercentage = state.Parameters.GetFloatWithDefault(paramBase.Push(P_MAX_CROSSOVER_PERCENT), def.Push(P_MAX_CROSSOVER_PERCENT), 1.0); var crossoverTypeString = state.Parameters.GetStringWithDefault( paramBase.Push(VectorSpecies.P_CROSSOVERTYPE), def.Push(VectorSpecies.P_CROSSOVERTYPE), VectorSpecies.V_TWO_POINT); // determine the crossover method to use (only 1-point & 2-point currently supported) if (crossoverTypeString.ToUpper().Equals(VectorSpecies.V_ONE_POINT.ToUpper())) { CrossoverType = VectorSpecies.C_ONE_POINT; } else if (crossoverTypeString.ToUpper().Equals(VectorSpecies.V_TWO_POINT.ToUpper())) { CrossoverType = VectorSpecies.C_TWO_POINT; } else { state.Output.Error("ListCrossoverPipeline:\n:" + " Parameter crossover-type is currently set to: " + crossoverTypeString + "\n" + " Currently supported crossover types are \"one\" and \"two\" point.\n"); } // sanity check for crossover parameters if (MinChildSize < 0) { state.Output.Error("ListCrossoverPipeline:\n" + " Parameter min-child-size is currently equal to: " + MinChildSize + "\n" + " min-child-size must be a positive integer\n"); } if (NumTries < 1) { state.Output.Error("ListCrossoverPipeline:\n" + " Parameter tries is currently equal to: " + NumTries + "\n" + " tries must be greater than or equal to 1\n"); } if (MinCrossoverPercentage < 0.0 || MinCrossoverPercentage > 1.0) { state.Output.Error("ListCrossoverPipeline:\n" + " Parameter min-crossover-percent is currently equal to: " + MinCrossoverPercentage + "\n" + " min-crossover-percent must be either a real-value float between [0.0, 1.0] or left unspecified\n"); } if (MaxCrossoverPercentage < 0.0 || MaxCrossoverPercentage > 1.0) { state.Output.Error("ListCrossoverPipeline:\n" + " Parameter max-crossover-percent is currently equal to: " + MaxCrossoverPercentage + "\n" + " max-crossover-percent must be either a real-value float between [0.0, 1.0] or left unspecified\n"); } if (MinCrossoverPercentage > MaxCrossoverPercentage) { state.Output.Error("ListCrossoverPipeline:\n" + " Parameter min-crossover-percent must be less than max-crossover-percent\n"); } if (MinCrossoverPercentage == MaxCrossoverPercentage) { state.Output.Warning("ListCrossoverPipeline:\n" + " Parameter min-crossover-percent and max-crossover-percent are currently equal to: " + MinCrossoverPercentage + "\n" + " This effectively prevents any crossover from occurring\n"); } }
public List <bool> getValuesFromNormalized(List <string> appropriateValues, List <string> expectedValues, IParameter p) { List <bool> results = new List <bool>(); for (int i = 0; i < appropriateValues.Count; i++) { string apVal = p.GetFromNormalized(Convert.ToInt32(appropriateValues[i])); string exVal = p.GetFromNormalized(Convert.ToInt32(expectedValues[i])); if (!exVal.Equals("") && !apVal.Equals("") && exVal.Equals(apVal)) { results.Add(true); } else { results.Add(false); } } return(results); }
public ICommand SetParameterUnitAsStructuralChange(IParameter parameter, Unit displayUnit) { return(executeAndUpdatedDefaultStateAndValue(new SetParameterUnitStructureChangeCommand(parameter, displayUnit), parameter)); }