public bool Compare(IValueType leftTerm, IValueType rightTerm) { if (leftTerm.GetType() != typeof(BaseType) || rightTerm.GetType() != typeof(BaseType)) { return(false); } return((BaseType)leftTerm < (BaseType)rightTerm); }
public static string[] ParseValueInstance(IValueType ivt, IEnumerable <string> strings) { var stringsList = strings.ToList(); if (!stringsList.Any()) { throw new RuntimeException("Error: Internal failure."); } var returns = new string[2]; var str = stringsList.FirstOrDefault(); var words = ivt.GetType().GetAttributeValue((KeywordAttribute itm) => itm.Words); var word = words.FirstOrDefault(); var reg = str.IndexOf(word, StringComparison.InvariantCulture); str = str.Remove(reg, word.Length); if (string.IsNullOrWhiteSpace(str)) { throw new RuntimeException("ERROR: Expected an instance name"); } if (str.Contains('=')) { try { var split = str.Split('=', 2); var inst = split[0].Trim(); CheckValidName(inst, returns); var val = split[1].Trim(); val = CheckValForOtherInst(val, word); if (string.IsNullOrWhiteSpace(val)) { throw new RuntimeException("ERROR: Expected Value"); } returns[1] = val; } catch (RuntimeException) { throw; } catch (Exception) { throw new RuntimeException("ERROR: Expected Value"); } } else { var instanceName = str.Trim(); if (!instanceName.ValidNewInstanceName()) { throw new RuntimeException($"ERROR: {instanceName} is an invalid instance name"); } returns[0] = instanceName; } return(returns); }
public virtual bool CanHandle(ITypedValue value) { if (value.Type != null && !valueType.GetType() .IsAssignableFrom(value.Type.GetType())) { return(false); } return(CanWriteValue(value)); }
public void SetData(IValueType value) { // Do type checking if (Data?.GetType() != value.GetType()) { throw new ArgumentException( string.Format("Type mismatch when trying to assign '{0}' to Variable '{2}' of type '{1}'", value.GetType().Name, Data?.GetType().Name, Key) ); } if (!m_Data.Get().Equals(value.Get())) { Events.OnDataValueChanged.Invoke(Data, value); } m_Data = value; }
public bool Compare(IValueType leftTerm, IValueType rightTerm) { if (!(leftTerm is BaseType)) { throw new Exception($"Can't cast {leftTerm.GetType().Name} to BaseType"); } if (!(rightTerm is ListType)) { throw new Exception($"Can't cast {rightTerm.GetType().Name} to ListType"); } return(((ListType)rightTerm).Between(leftTerm)); }