public ModbusClientNode(INodeContext context) { context.ThrowIfNull("context"); ITypeService typeService = context.GetService <ITypeService>(); this.TimeSpan = typeService.CreateInt(PortTypes.Integer, "Abfrageinterval", 60); this.ModbusHost = typeService.CreateString(PortTypes.String, "Modbus TCP Host"); this.ModbusPort = typeService.CreateInt(PortTypes.Integer, "Port", 502); this.ModbusID = typeService.CreateInt(PortTypes.Integer, "Geräte ID", 1); this.ModbusID.MinValue = 1; this.ModbusID.MaxValue = 256; // --------------------------------------------------------------------------------------- // this.ModbusAddress1 = typeService.CreateInt(PortTypes.Integer, "Register Addresse", 1); this.ModbusAddress1.MinValue = 1; this.ModbusAddress1.MaxValue = 65535; this.FunctionCode = typeService.CreateEnum("ModbusFunction", "Funktion", FunctionCodeEnum.VALUES, FunctionCodeEnum.FC_03); this.DataType = typeService.CreateEnum("ModbusDataType", "Datentyp", DataTypeEnum.VALUES, DataTypeEnum.INT32); this.RegisterOrder = typeService.CreateEnum("ModbusRegisterOrder", "Register Reihenfolge", ByteOrderEnum.VALUES, ByteOrderEnum.LOW_HIGH); this.OutputValue1 = typeService.CreateDouble(PortTypes.Number, "Register Wert"); this.ErrorMessage = typeService.CreateString(PortTypes.String, "RAW / Error"); SchedulerService = context.GetService <ISchedulerService>(); }
protected override ValidationResult validateTemplate(StringValueObject template, string language, bool doFullCheck) { // Call base class checks first ValidationResult result = base.validateTemplate(template, language, doFullCheck); if (result.HasError) { return(result); } // Do our own checking if (doFullCheck && hasAssignment(template.Value)) { return(new ValidationResult { HasError = true, Message = Localize(language, template.Name) + ": " + Localize(language, "HasAssignment") }); } return(new ValidationResult { HasError = false }); }
private ValidationResult validateInternal(StringValueObject template, ref List <TokenBase> templateTokens, ref int binCount, ref int intCount, ref int numCount, ref int strCount, string language, bool doFullCheck) { System.Diagnostics.Trace.Assert(template.HasValue && (template.Value.Length > 0)); splitTokens(template, ref templateTokens); ValidationResult result = validateTotalNumberOfTokens(template.Name, ref templateTokens, language); if (result.HasError) { return(result); } result = countTokenTypes(template.Name, ref templateTokens, ref binCount, ref intCount, ref numCount, ref strCount, language); if (result.HasError) { return(result); } result = validateTokens(template.Name, ref templateTokens, language, doFullCheck); return(result); }
public static AuthCredentials FromNodeParameters( EnumValueObject authType, StringValueObject token, StringValueObject userName, StringValueObject password) { if (authType.HasValue && authType.Value == AuthType.BasicAuth.ToString()) { return(new AuthCredentials { Type = AuthType.BasicAuth, Username = userName.HasValue ? userName.Value : string.Empty, Password = password.HasValue ? password.Value : string.Empty }); } else if (authType.HasValue && authType.Value == AuthType.BearerToken.ToString()) { return(new AuthCredentials { Type = AuthType.BearerToken, Token = token.HasValue ? token.Value : string.Empty }); } else { return(new AuthCredentials { Type = AuthType.NoAuth }); } }
/// <summary> /// Initializes a new instance of the <see cref="UnifiPresenceDetectionNode"/> class. /// </summary> /// <param name="context">The node context.</param> public UnifiPresenceDetectionNode(INodeContext context) : base(context) { context.ThrowIfNull("context"); // Get the TypeService from the context this.TypeService = context.GetService <ITypeService>(); this.Trigger = this.TypeService.CreateBool(PortTypes.Bool, "Trigger", false); this.BaseUrl = this.TypeService.CreateString(PortTypes.String, "BaseURL", "https://127.0.0.1:8443"); this.SiteId = this.TypeService.CreateString(PortTypes.String, "UniFi Site", "default"); this.Username = this.TypeService.CreateString(PortTypes.String, "Username", ""); this.Password = this.TypeService.CreateString(PortTypes.String, "Password", ""); this.DeviceAmount = this.TypeService.CreateInt(PortTypes.Integer, "Anzahl Geräte", 1); this.DeviceAmount.MinValue = 1; this.DeviceAmount.MaxValue = 15; this.Devices = new List <IValueObject>(); this.DeviceAmount.ValueSet += this.GenerateDevicePorts; this.ConnectedAmount = this.TypeService.CreateInt(PortTypes.Integer, "Anzahl angemeldete Clients", 0); this.IsOneConnected = this.TypeService.CreateBool(PortTypes.Bool, "Mindestens ein Device angemeldet", false); this.IsAllConnected = this.TypeService.CreateBool(PortTypes.Bool, "Alle Devices angemeldet", false); this.ConnectedPersons = this.TypeService.CreateString(PortTypes.String, "Angemeldete Personen", ""); this.Error = this.TypeService.CreateString(PortTypes.String, "Fehlermeldung", ""); this.DeviceAmount.Value = 1; this.DefinedDevicesAndPersons = new Dictionary <string, string>(); }
public void ToStringWhenValueIsNull_ShouldReturnEmptyString() { var vo = new StringValueObject(null); var result = vo.ToString(); Assert.AreEqual("", result); }
public bool Equals(StringValueObject valueObject) { if (this.GetValue().Equals(valueObject.GetValue())) { return(true); } return(false); }
public void SingleValueObjectWithSameNullValues_ShouldBeEqual() { var valueObject = new StringValueObject(null); var sameValuesVO = new StringValueObject(null); Assert.AreEqual(valueObject, sameValuesVO); Assert.IsTrue(valueObject == sameValuesVO); Assert.IsFalse(valueObject != sameValuesVO); }
public void ValueObject_Equals_NotSameType() { var i1 = new IntValueObject { Prop = 1 }; var s2 = new StringValueObject { Prop = "1" }; object.ReferenceEquals(i1, s2).Should().BeFalse(); i1.Equals(s2).Should().BeFalse(); }
public SendMail(INodeContext context) : base(context) { context.ThrowIfNull("context"); ITypeService typeService = context.GetService <ITypeService>(); this.SendTrigger = typeService.CreateBool(PortTypes.Bool, "Trigger"); this.To = typeService.CreateString(PortTypes.String, "Empfängeradresse"); this.From = typeService.CreateString(PortTypes.String, "Senderadresse"); this.SmtpHost = typeService.CreateString(PortTypes.String, "SMTP Server"); this.SmtpPort = typeService.CreateInt(PortTypes.Integer, "SMTP Port"); this.ErrorMessage = typeService.CreateString(PortTypes.String, "Fehlertext"); this.Encryption = typeService.CreateEnum("SmtpEncryption", "Verschlüsselung", EncryptionTypes.VALUES); this.SmtpUser = typeService.CreateString(PortTypes.String, "SMTP Benutzer"); this.SmtpPassword = typeService.CreateString(PortTypes.String, "SMTP Kennwort"); }
public Write(INodeContext context) : base(context) { context.ThrowIfNull("context"); ITypeService typeService = context.GetService <ITypeService>(); this.InfluxDbHost = typeService.CreateString(PortTypes.String, "Influx DB host"); this.InfluxDbPort = typeService.CreateInt(PortTypes.Integer, "Influx DB Port", 8086); this.InfluxDbName = typeService.CreateString(PortTypes.String, "Influx DB name"); this.InfluxMeasureName = typeService.CreateString(PortTypes.String, "Measure name"); this.InfluxDbMeasureTags = typeService.CreateString(PortTypes.String, "Measure tags"); this.InfluxDbMeasureFieldName1 = typeService.CreateString(PortTypes.String, "Measure field name 1"); this.InfluxDbMeasureFieldValue1 = typeService.CreateDouble(PortTypes.Float, "Measure value 1"); this.InfluxDbMeasureFieldName2 = typeService.CreateString(PortTypes.String, "Measure field name 2"); this.InfluxDbMeasureFieldValue2 = typeService.CreateDouble(PortTypes.Float, "Measure value 2"); this.ErrorCode = typeService.CreateInt(PortTypes.Integer, "HTTP status-code"); this.ErrorMessage = typeService.CreateString(PortTypes.String, "SMTP Benutzer"); }
protected virtual ValidationResult validateTemplate(StringValueObject template, string language, bool doFullCheck) { if ((!template.HasValue) || (template.Value.Length <= 0)) { return(new ValidationResult { HasError = true, Message = Localize(language, template.Name) + Localize(language, getEmptyTemplateError()) }); } return(new ValidationResult { HasError = false }); }
private void splitTokens(StringValueObject template, ref List <TokenBase> templateTokens) { TemplateTokenFactory ttf = TemplateTokenFactory.Instance; List <SplitElement> splitElements = SplitNonTokenizedElements(template.Value); foreach (SplitElement elem in splitElements) { if (elem.isFixedToken) { // Treat fixed tokens like constant strings between placeholders templateTokens.Add(ttf.createConstStringToken(elem.text)); } else { for (int curPos = 0; curPos < elem.text.Length;) { Match curMatch = PLACEHOLDER_REGEX.Match(elem.text, curPos); if (curMatch.Success && (curMatch.Length >= 2)) { // Constant string before placeholder templateTokens.Add(ttf.createConstStringToken( elem.text.Substring(curPos, curMatch.Index - curPos))); // Placeholder string between delimiters templateTokens.Add( ttf.createPlaceholderToken( elem.text.Substring(curMatch.Index + 1, curMatch.Length - 2), getGroupSeparator(), getDecimalSeparator() ) ); curPos = curMatch.Index + curMatch.Length; } else { // Constant string after last placeholder templateTokens.Add(ttf.createConstStringToken( elem.text.Substring(curPos))); curPos = elem.text.Length; } } } } }
public ModbusClientNode(INodeContext context) { context.ThrowIfNull("context"); ITypeService typeService = context.GetService <ITypeService>(); this.ModbusHost = typeService.CreateString(PortTypes.String, "Modbus TCP Server"); this.ModbusPort = typeService.CreateInt(PortTypes.Integer, "Port", 502); this.ModbusAddress = typeService.CreateInt(PortTypes.Integer, "Modbus Addresse"); this.ModbusAddress.MinValue = 0; this.ModbusAddress.MaxValue = 65535; this.ReadCount = typeService.CreateInt(PortTypes.Integer, "Anzahl bytes"); this.ReadCount.MinValue = 1; this.ReadCount.MaxValue = 2; this.OutputValue = typeService.CreateDouble(PortTypes.Float, "Wert"); this.ErrorMessage = typeService.CreateString(PortTypes.String, "Error"); SchedulerService = context.GetService <ISchedulerService>(); }
private void UpdateBodyAndContentTypeInputVisibility(object sender, ValueChangedEventArgs e) { StringValueObject createBody() { if (this.Body != null) { return(this.Body); } else { StringValueObject result = this.TypeService.CreateString(PortTypes.String, "Body", string.Empty); result.ValueSet += RefreshVariables; return(result); } } EnumValueObject createContentType() { if (this.ContentType != null) { return(this.ContentType); } else { return(this.TypeService.CreateEnum("HttpContentType", "ContentType", new string[] { "ContentType.Empty", "text/plain", "application/json", "application/xml", "application/x-www-form-urlencoded" }, "ContentType.Empty")); } } var method = this.Method.HasValue ? this.Method.Value : string.Empty; this.Body = method != "GET" ? createBody() : null; this.ContentType = method != "GET" ? createContentType() : null; }
public ModbusClientNode(INodeContext context) { context.ThrowIfNull("context"); ITypeService typeService = context.GetService <ITypeService>(); this.TimeSpan = typeService.CreateInt(PortTypes.Integer, "Restart (Sek.)", 60); this.ModbusHost = typeService.CreateString(PortTypes.String, "Modbus TCP Server"); this.ModbusPort = typeService.CreateInt(PortTypes.Integer, "Port", 502); this.ModbusID = typeService.CreateInt(PortTypes.Integer, "Modbus ID", 3); // --------------------------------------------------------------------------------------- // this.ModbusAddress1 = typeService.CreateInt(PortTypes.Integer, "Modbus Addresse", 0); this.ModbusAddress1.MinValue = 0; this.ModbusAddress1.MaxValue = 65535; this.ReadCount1 = typeService.CreateInt(PortTypes.Integer, "Anzahl words", 2); this.ReadCount1.MinValue = 1; this.ReadCount1.MaxValue = 2; this.OutputValue1 = typeService.CreateDouble(PortTypes.Number, "Register Wert"); this.ErrorMessage = typeService.CreateString(PortTypes.String, "RAW / Error"); SchedulerService = context.GetService <ISchedulerService>(); }
public virtual List <TEntity> Find(Criteria criteria) { using (var scope = ScopeFactory.CreateScope()) { var dbContext = scope.ServiceProvider.GetRequiredService <ELearningContext>(); IQueryable <TEntity> query = dbContext.Set <TEntity>(); foreach (Criterion criterion in criteria.Criterion) { query = query.Where(x => (Reflection.GetObjectProperty(Reflection.GetObjectProperty(x, StringValueObject.UppercaseFirst(criterion.Field.Value)), "Value")).ToString() == criterion.Value.Value); } query = query .Skip((criteria.Limit.Value - 1) * criteria.Offset.Value) .Take(criteria.Offset.Value); return(query.ToList()); } }
private ValidationResult validateInternal(StringValueObject template, ref List <TokenBase> templateTokens, ref int binCount, ref int intCount, ref int numCount, ref int strCount, string language) { if ((!template.HasValue) || (template.Value.Length <= 0)) { return(new ValidationResult { HasError = true, Message = Localize(language, "EmptyTemplate") }); } TemplateTokenFactory ttf = TemplateTokenFactory.Instance; for (int curPos = 0; curPos < template.Value.Length;) { Match curMatch = PLACEHOLDER_REGEX.Match(template.Value, curPos); if (curMatch.Success && (curMatch.Length >= 2)) { // constant string before placeholder templateTokens.Add(ttf.createConstStringToken( template.Value.Substring(curPos, curMatch.Index - curPos))); // placeholder string between delimiters templateTokens.Add(ttf.createPlaceholderToken( template.Value.Substring(curMatch.Index + 1, curMatch.Length - 2))); curPos = curMatch.Index + curMatch.Length; } else { // constant string after last placeholder templateTokens.Add(ttf.createConstStringToken( template.Value.Substring(curPos))); curPos = template.Value.Length; } } ValidationResult result = validateNumberOfTokens(language, ref templateTokens); if (result.HasError) { return(result); } foreach (TokenBase token in templateTokens) { switch (token.getType()) { case TokenType.ConstString: case TokenType.VarReference: // nothing to do break; case TokenType.VarBoolean: binCount++; break; case TokenType.VarInteger: intCount++; break; case TokenType.VarNumber: numCount++; break; case TokenType.VarString: strCount++; break; case TokenType.Error: default: return(createTokenError(language, template.Name, token)); } } if (binCount > MAX_INPUTS) { return(new ValidationResult { HasError = true, Message = Localize(language, "TooManyBinPlaceholders") }); } if (intCount > MAX_INPUTS) { return(new ValidationResult { HasError = true, Message = Localize(language, "TooManyIntPlaceholders") }); } if (numCount > MAX_INPUTS) { return(new ValidationResult { HasError = true, Message = Localize(language, "TooManyNumPlaceholders") }); } if (strCount > MAX_INPUTS) { return(new ValidationResult { HasError = true, Message = Localize(language, "TooManyStrPlaceholders") }); } return(validateTokens(language, template.Name, ref templateTokens)); }
protected bool Equals(StringValueObject other) { return(Value == other.Value); }