public PMNameNode(ExpressionNode node, string tokenString, ExpressionContext context)
			: base(node, tokenString, context)
		{
			string[] parts = Name.Split('.');

			if (parts.Length == 3)
			{
				isAttribute = true;
				ObjectName = (PMObjectType)Enum.Parse(typeof(PMObjectType), parts[0], true);
				FieldName = parts[2].Trim('[',']').Trim();
			}
			else if (parts.Length == 2)
			{
				ObjectName = (PMObjectType)Enum.Parse(typeof(PMObjectType), parts[0], true);
				if (parts[1].Trim().EndsWith("_Attributes"))
				{
					isAttribute = true;
					FieldName = parts[1].Substring(0, parts[1].Length - 11);
				}
				else
					FieldName = parts[1];
			}
			else
			{
				ObjectName = PMObjectType.PMTran;
				FieldName = Name;
			}
		}
Example #2
0
 public ForStatementNode(ExpressionNode variable, ExpressionNode initialValue, ExpressionNode finalValue, List<StatementNode> list)
 {
     Variable = variable;
     InitialValue = initialValue;
     FinalValue = finalValue;
     Code = list;
 }
Example #3
0
 public IList<Person> FindPersons(ExpressionNode query)
 {
     try
     {
         var expression = query.ToBooleanExpression<Person>();
         return _persons.Where(expression.Compile()).ToList();
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine(ex);
         return new List<Person>();
     }
 }
Example #4
0
    public static ExpressionNode GenerateEmotionalExpression(float arousal, float valence, float transitionTime = 1f)
    {
        var offset = new ExpressionNode();
        offset.Name = string.Format("{0} {1}", arousal, valence);
        offset.TransitionTime = transitionTime;
        offset.RevertTime = -1f;
        offset.HoldTime = 0f;
        offset.EaseIn = 0;
        offset.EaseOut = 0;
        offset.Weight = 0.7f;

        string valenceExpr = (valence < Config.Neutral ? "unhappy" : "happy");
        string arousalExpr = (arousal < Config.Neutral ? "calm" : "surprised");
        float v = Mathf.Abs(valence - Config.Neutral);
        float a = Mathf.Abs(arousal - Config.Neutral);
        Vector3 valenceWeight = new Vector3(v, v, v);
        Vector3 arousalWeight = new Vector3(a, a, a);
        offset.GoalPos = new Dictionary<string, Vector3>();

        if (ExpressionLibrary.Contains(valenceExpr)) {
            var valGoal = new Dictionary<string, Vector3>(ExpressionLibrary.Get(valenceExpr));
            var aroGoal = new Dictionary<string, Vector3>(ExpressionLibrary.Get(arousalExpr));
            float u = 0.8f;
            float l = -0.02f;
            foreach(var key in valGoal.Keys)
            {
                Vector3 tinyError = new Vector3(Random.Range(l, u), Random.Range(l, u), Random.Range(l, u));
                tinyError.Scale(valenceWeight);
                var vec = Vector3.Scale(valGoal[key], valenceWeight);
                if (offset.GoalPos.ContainsKey(key)) offset.GoalPos[key] = vec + Vector3.Scale(vec, tinyError);
                else offset.GoalPos.Add(key, vec + Vector3.Scale(valGoal[key], tinyError));
            }
            foreach (var key in aroGoal.Keys)
            {
                Vector3 tinyError = new Vector3(Random.Range(l, u), Random.Range(l, u), Random.Range(l, u));
                tinyError.Scale(arousalWeight);
                var vec = Vector3.Scale(aroGoal[key], arousalWeight);
                if (offset.GoalPos.ContainsKey(key)) offset.GoalPos[key] += vec + Vector3.Scale(vec, tinyError);
                else offset.GoalPos.Add(key, vec + Vector3.Scale(aroGoal[key], tinyError));
            }

        } else {
            throw new UnityException("what the fuck");
        }

        return offset;
    }
Example #5
0
        public object Select(object o)
        {
            if (string.IsNullOrEmpty(MemberName))
            {
                return o;
            }

            if (_expressionNode == null)
            {
                _expressionNode = ExpressionNodeBuilder.Build(MemberName);

                _memberValueNode = _expressionNode;

                while (_memberValueNode.Next != null)
                {
                    _memberValueNode = _memberValueNode.Next;
                }
            }

            _expressionNode.Target = new WeakReference(o);

            object result = _memberValueNode.CurrentValue.Target;

            _expressionNode.Target = null;

            if (result == AvaloniaProperty.UnsetValue)
            {
                return null;
            }
            else if (result is BindingError)
            {
                return null;
            }

            return result;
        }
 /// <summary>
 /// Initializes a new instance of <see cref="BelowCenterLineFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">SPC type field which stores SPC preferences as xml</param>
 /// <param name="parameter2">Size of subgroup in samples</param>
 /// <param name="parameter3">Number of subgroups in a row to satisfy a condition</param>
 /// <param name="parameter4">Chart type</param>
 public SPC_BelowCenterLineFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2, ExpressionNode parameter3, ExpressionNode parameter4)
     : base(ExpressionNodeType.BelowCenterLine, parameter1, parameter2, parameter3, parameter4)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RegexMatchFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">
 /// The parameter 1.
 /// </param>
 /// <param name="parameter2">
 /// The parameter 2.
 /// </param>
 public RegexMatchFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     : base(ExpressionNodeType.RegexMatch, parameter1, parameter2)
 {   
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FormatValueFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">
 /// The parameter 1.
 /// </param>
 /// <param name="parameter2">
 /// The parameter 2.
 /// </param>
 /// <param name="dataType">
 /// The data type.
 /// </param>
 public FormatValueFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2, NodeDataType dataType)
     : base(ExpressionNodeType.FormatValue, parameter1, parameter2)
 {
     DataType = dataType;
 }
        private void AssertIsIndexer(ExpressionNode node, params object[] args)
        {
            Assert.IsType<IndexerNode>(node);

            var e = (IndexerNode)node;
            Assert.Equal(e.Arguments.ToArray(), args.ToArray());
        }
 /// <summary>
 /// Initializes a new instance of <see cref="AppraiserPartAverageFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">Gage R&amp;R type field</param>
 /// <param name="parameter2">Appraiser code</param>
 /// <param name="parameter3">Part name</param>
 public GageRR_AppraiserPartAverageFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2, ExpressionNode parameter3)
     : base(ExpressionNodeType.AppraiserPartAverage, parameter1, parameter2, parameter3)
 {
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of <see cref="SumFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1"></param>
 /// <param name="parameter2"></param>
 public SumFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     : base(ExpressionNodeType.Sum, parameter1, parameter2)
 {
 }
 /// <summary>
 /// Initializes a new instance of <see cref="FailedPercentFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">SPC type field which stores SPC preferences as xml</param>
 /// <param name="parameter2">Size of subgroup in samples</param>
 /// <param name="parameter3">Percent of samples failed in subgroup (1 = 1%)</param>
 /// <param name="parameter4">Chart type</param>
 public SPC_FailedPercentFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2, ExpressionNode parameter3, ExpressionNode parameter4)
     : base(ExpressionNodeType.FailedPercent, parameter1, parameter2, parameter3, parameter4)
 {
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of <see cref="IsLessFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1"></param>
 /// <param name="parameter2"></param>
 public IsLessFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     : base(ExpressionNodeType.IsLess, parameter1, parameter2)
 {
 }
 /// <summary>
 /// Initializes a new instance of <see cref="HasRemovedItemsFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter"> </param>
 public HasRemovedItemsFunctionNode(ExpressionNode parameter)
     : base(ExpressionNodeType.HasRemovedItems, parameter)
 {
 }
Example #15
0
        /// <summary>
        /// Initializes a new instance of <see cref="DateMonthFunctionNode"/> class.
        /// </summary>
        /// <param name="parameter"></param>
        public DateMonthFunctionNode(ExpressionNode parameter)
            : base(ExpressionNodeType.DateMonth, parameter)
        {

        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BitwiseOrFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">The first parameter.</param>
 /// <param name="parameter2">The second parameter.</param>
 public BitwiseOrFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     : base(ExpressionNodeType.BitwiseOr, parameter1, parameter2)
 {
 }
 public MultiplicationNode(ExpressionNode leftNode, ExpressionNode rightNode)
     : base(leftNode, rightNode)
 {
 }
Example #18
0
        /// <summary>
        /// Initializes a new instance of <see cref="TrimFunctionNode"/> class.
        /// </summary>
        /// <param name="parameter"></param>
        public TrimFunctionNode(ExpressionNode parameter)
            : base(ExpressionNodeType.Trim, parameter)
        {

        }
Example #19
0
 /// <summary>
 /// Initializes a new instance of <see cref="AreEqualFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1"></param>
 /// <param name="parameter2"></param>
 public AreEqualFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     : base(ExpressionNodeType.AreEqual, parameter1, parameter2)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetArrayItemFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">
 /// The parameter 1.
 /// </param>
 /// <param name="parameter2">
 /// The parameter 2.
 /// </param>
 /// <param name="elementType">
 /// The element type.
 /// </param>
 public GetArrayItemFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2, NodeDataType elementType)
     : base(ExpressionNodeType.GetArrayItem, parameter1, parameter2)
 {
     _elementType = elementType;
 }
        private void AssertIsProperty(ExpressionNode node, string name)
        {
            Assert.IsType<PropertyAccessorNode>(node);

            var p = (PropertyAccessorNode)node;
            Assert.Equal(name, p.PropertyName);
        }
 /// <summary>
 /// Initializes a new instance of <see cref="ZoneAorBeyondFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">SPC type field which stores SPC preferences as xml</param>
 /// <param name="parameter2">Size of subgroup in samples</param>
 /// <param name="parameter3">Number of subgroups to satisfy a condition</param>
 /// <param name="parameter4">Number of a larger subset of subgroups which includes subgroups from parameter3</param>
 /// <param name="parameter5">Chart type</param>
 public SPC_ZoneAorBeyondFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2, ExpressionNode parameter3, ExpressionNode parameter4, ExpressionNode parameter5)
     : base(ExpressionNodeType.ZoneAorBeyond, parameter1, parameter2, parameter3, parameter4, parameter5)
 {
 }
        private List<ExpressionNode> ToList(ExpressionNode node)
        {
            var result = new List<ExpressionNode>();
            
            while (node != null)
            {
                result.Add(node);
                node = node.Next;
            }

            return result;
        }
Example #24
0
        /// <summary>
        /// Initializes a new instance of <see cref="DateWeekFunctionNode"/> class.
        /// </summary>
        /// <param name="parameter"></param>
        public DateWeekFunctionNode(ExpressionNode parameter)
            : base(ExpressionNodeType.DateWeek, parameter)
        {

        }
 /// <summary>
 /// Initializes a new instance of <see cref="AppraiserXBarFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">Gage R&amp;R type field</param>
 /// <param name="parameter2">Appraiser code</param>
 public GageRR_AppraiserXBarFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     : base(ExpressionNodeType.AppraiserXBar, parameter1, parameter2)
 {
 }
Example #26
0
 /// <summary>
 /// Initializes a new instance of <see cref="AddFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1"></param>
 /// <param name="parameter2"></param>
 public AddFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     :base(ExpressionNodeType.Add, parameter1, parameter2)
 {
 }
Example #27
0
 protected override void Visit(ExpressionNode expressionNode)
 {
 }
 /// <summary>
 /// Initializes a new instance of <see cref="GoingDownFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1">SPC type field which stores SPC preferences as xml</param>
 /// <param name="parameter2">Size of subgroup in samples</param>
 /// <param name="parameter3">Number of subgroups in a row to satisfy a condition</param>
 /// <param name="parameter4">Chart type</param>
 public SPC_GoingDownFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2, ExpressionNode parameter3, ExpressionNode parameter4)
     : base(ExpressionNodeType.GoingDown, parameter1, parameter2, parameter3, parameter4)
 {
 }
Example #29
0
 /// <summary>
 /// Initializes a new instance of <see cref="ConcatFunctionNode"/> class.
 /// </summary>
 /// <param name="parameter1"></param>
 /// <param name="parameter2"></param>
 public ConcatFunctionNode(ExpressionNode parameter1, ExpressionNode parameter2)
     :base(ExpressionNodeType.Concat, parameter1, parameter2)
 {
 }
 public void SetChildren(ExpressionNode left, ExpressionNode right)
 {
     Left = left;
     Right = right;
 }