Ejemplo n.º 1
0
        static bool RunBetween(IEnumerable <DataStorage.WarewolfAtom> warewolfAtoms, IEnumerable <DataStorage.WarewolfAtom> tovals, DataStorage.WarewolfAtom a)
        {
            WarewolfListIterator iterator = new WarewolfListIterator();
            var from = new WarewolfAtomIterator(warewolfAtoms);
            var to   = new WarewolfAtomIterator(tovals);

            iterator.AddVariableToIterateOn(@from);
            iterator.AddVariableToIterateOn(to);
            while (iterator.HasMoreData())
            {
                var fromval = iterator.FetchNextValue(@from);
                var toVal   = iterator.FetchNextValue(to);

                DateTime fromDt;
                if (DateTime.TryParse(fromval, out fromDt))
                {
                    DateTime toDt;
                    if (!DateTime.TryParse(toVal, out toDt))
                    {
                        throw new InvalidDataException(ErrorResource.IsBetweenDataTypeMismatch);
                    }
                    DateTime recDateTime;
                    if (DateTime.TryParse(a.ToString(), out recDateTime))
                    {
                        if (recDateTime > fromDt && recDateTime < toDt)
                        {
                            return(true);
                        }
                    }
                }
                double fromNum;
                if (double.TryParse(fromval, out fromNum))
                {
                    double toNum;
                    if (!double.TryParse(toVal, out toNum))
                    {
                        return(false);
                    }
                    double recNum;
                    if (!double.TryParse(a.ToString(), out recNum))
                    {
                        continue;
                    }
                    if (recNum > fromNum && recNum < toNum)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
#pragma warning disable S1541 // Methods and properties should not be too complex
#pragma warning disable S3776 // Cognitive Complexity of methods should not be too high
        static bool RunBetween(IEnumerable <DataStorage.WarewolfAtom> warewolfAtoms, IEnumerable <DataStorage.WarewolfAtom> tovals, DataStorage.WarewolfAtom a)
#pragma warning restore S3776 // Cognitive Complexity of methods should not be too high
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            var iterator = new WarewolfListIterator();
            var from     = new WarewolfAtomIterator(warewolfAtoms);
            var to       = new WarewolfAtomIterator(tovals);

            iterator.AddVariableToIterateOn(@from);
            iterator.AddVariableToIterateOn(to);
            while (iterator.HasMoreData())
            {
                var fromval = iterator.FetchNextValue(@from);
                var toVal   = iterator.FetchNextValue(to);

                if (DateTime.TryParse(fromval, out DateTime fromDt))
                {
                    if (!DateTime.TryParse(toVal, out DateTime toDt))
                    {
                        throw new InvalidDataException(ErrorResource.IsBetweenDataTypeMismatch);
                    }
                    if (DateTime.TryParse(a.ToString(), out DateTime recDateTime) && recDateTime > fromDt && recDateTime < toDt)
                    {
                        return(true);
                    }
                }
                if (double.TryParse(fromval, out double fromNum))
                {
                    if (!double.TryParse(toVal, out double toNum))
                    {
                        return(false);
                    }
                    if (!double.TryParse(a.ToString(), out double recNum))
                    {
                        continue;
                    }
                    if (recNum > fromNum && recNum < toNum)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 public static string WarewolfAtomToStringErrorIfNull(DataStorage.WarewolfAtom a)
 {
     if (a == null)
     {
         return(string.Empty);
     }
     if (a.IsNothing)
     {
         throw new NullValueInVariableException(ErrorResource.VariableIsNull, string.Empty);
     }
     return(a.ToString());
 }
Ejemplo n.º 4
0
        private static KeyValuePair <string, WarewolfAtomList <DataStorage.WarewolfAtom> > CreateDataItem(JArray newArray, KeyValuePair <string, WarewolfAtomList <DataStorage.WarewolfAtom> > dataItem, JObject jObjForArray, int i, DataStorage.WarewolfAtom warewolfAtom)
        {
            if (newArray.Count < i + 1 || newArray.Count == 0)
            {
                newArray.Add(jObjForArray);
            }
            else
            {
                var jToken = newArray[i] as JObject;
                jToken?.Add(new JProperty(dataItem.Key, warewolfAtom.ToString()));
            }

            return(dataItem);
        }
Ejemplo n.º 5
0
 static void ParseDataItemToOutputs(JObject jObject, string key, DataStorage.WarewolfAtom warewolfAtom)
 {
     if (warewolfAtom is DataStorage.WarewolfAtom.DataString stringResult)
     {
         jObject.Add(key, stringResult.Item);
     }
     else if (warewolfAtom is DataStorage.WarewolfAtom.Int intResult)
     {
         jObject.Add(key, intResult.Item);
     }
     else if (warewolfAtom is DataStorage.WarewolfAtom.Float floatResult)
     {
         jObject.Add(key, floatResult.Item);
     }
     else
     {
         jObject.Add(key, warewolfAtom.ToString());
     }
 }
Ejemplo n.º 6
0
 public static string WarewolfAtomToStringNullAsNothing(DataStorage.WarewolfAtom a) => a == null ? null : (a.IsNothing ? null : a.ToString());
Ejemplo n.º 7
0
 public static string WarewolfAtomToString(DataStorage.WarewolfAtom a) => a?.ToString() ?? string.Empty;
 public static string WarewolfAtomToString(DataStorage.WarewolfAtom a)
 {
     return(a?.ToString() ?? string.Empty);
 }