public static VariableValue Draw(GUIContent label, VariableValue value, ValueDefinition definition, bool drawStores) { var height = GetHeight(value, definition, drawStores); var rect = EditorGUILayout.GetControlRect(true, height); return(Draw(rect, label, value, definition, drawStores)); }
public InputSpatialSurrogate(ITimeSpaceInput input) { _inputOriginal = input; if (input == null) { SetDescribes(new Describes("Unspecified Input")); ValueDefinition = new ValueDefinition(); SpatialDefinition = new SpatialDefinition(); Component = null; } else { SetDescribes(input); ValueDefinition = input.ValueDefinition; Component = input.Component; var inputTime = input as BaseInputSpaceTime; SpatialDefinition = inputTime != null ? inputTime.SpatialDefinition : new SpatialDefinition(); } }
public void TestViewDefinitionQuery() { var fieldRefDefinitions = FieldRefDefinitions.FromNames("Id", "Title", "Date Modified", "Date Created"); var viewDef = new ViewDefinition { List = 1, DisplayName = "Common fields view", ViewFields = fieldRefDefinitions, Query = new CamlQueryRoot { Where = new LogicalJoinDefinition { BeginsWith = { new LogicalTestDefinition { FieldRef = { fieldRefDefinitions.FieldRef[1] }, Value = { ValueDefinition.NewTextValue("Anti-") } } } } } }; var caml = viewDef.ToCamlString(); Assert.IsTrue(caml.IsNotEmpty()); }
public static float GetHeight(ValueDefinition definition, VariableInitializerType initializerType, TagList tags, bool isExpanded) { var height = EditorGUIUtility.singleLineHeight; if (HasConstraint(definition.Type, definition.Constraint, definition.IsConstraintLocked)) { height += GetConstraintHeight(definition.Type, definition.Constraint); } if (HasInitializer(definition.Type, initializerType)) { if (initializerType == VariableInitializerType.Expression && definition.Initializer != null) { height += ExpressionControl.GetFoldoutHeight(definition.Initializer, isExpanded, true, 2, 3) + RectHelper.VerticalSpace; } else { height += RectHelper.LineHeight; } } if (HasTags(tags)) { height += RectHelper.LineHeight; } return(height); }
public ExchangeItem(ITimeSpaceExchangeItem item) : base(item) { _id = item.Id; if (item.ValueDefinition != null) { if (item.ValueDefinition is IQuality) { _valueDefinition = new Quality((IQuality)item.ValueDefinition); } else { _valueDefinition = new Quantity((IQuantity)item.ValueDefinition); } } if (item.ElementSet() != null) { _elementSet = new ElementSet(item.ElementSet()); } if (item.TimeSet != null) { _timeSet = new TimeSet(item.TimeSet); } if (item.Component != null) { _component = new Component(item.Component); } }
private float GetVariableHeight(int index) { var variable = _pool.Variables[index]; var definition = ValueDefinition.Create(VariableType.Empty); return(VariableValueDrawer.GetHeight(variable, definition, true)); }
private void setControlsFromValue(ValueDefinition v) { removeButton.Enabled = true; //Set the name nameTextBox.CausesValidation = true; nameTextBox.Enabled = true; nameTextBox.Text = v.Name; //Set the type typeComboBox.CausesValidation = true; typeComboBox.Enabled = true; typeComboBox.SelectedIndex = ValueDefinition.VALUE_TYPES.FindIndex(e => e == v.GetType()); //Remove the old value editor if (valueEditor != null) { Controls.Remove(valueEditor); } //Add the new one! valueEditor = v.GetEditor(); if (valueEditor != null) { valueEditor.TabIndex = 2; Controls.Add(valueEditor); } }
/// <summary> /// Used to get the query root element containing the where condition. /// </summary> /// <param name="isLookupId">Explicitly specify whether the field referenced in the logical test query condition is a look up field.</param> /// <returns>The query root element containing a where condition.</returns> protected CamlQueryRoot GetCamlQueryRootForWhere(bool isLookupId) { CamlQueryRoot camlQuery = new CamlQueryRoot(); // Construct a LogicalTestDefinition based on PTF Configure file. LogicalTestDefinition logicalTest = new LogicalTestDefinition(); FieldRefDefinitionQueryTest fieldRef = new FieldRefDefinitionQueryTest(); fieldRef.Name = Common.GetConfigurationPropertyValue("FieldRefWhere_Name", this.Site); logicalTest.FieldRef = fieldRef; logicalTest.FieldRef.LookupId = isLookupId.ToString().ToUpper(); ValueDefinition value = new ValueDefinition(); value.Type = Common.GetConfigurationPropertyValue("FieldRefWhere_Type", this.Site); value.Text = new string[] { Common.GetConfigurationPropertyValue("FieldRefWhere_Text", this.Site) }; logicalTest.Value = value; // Use Equal to construct a Where condition. camlQuery.Where = new LogicalJoinDefinition(); camlQuery.Where.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.Eq }; camlQuery.Where.Items = new LogicalTestDefinition[] { logicalTest }; // Construct an OrderBy element. camlQuery.OrderBy = new OrderByDefinition(); camlQuery.OrderBy.FieldRef = new FieldRefDefinitionOrderBy[1]; camlQuery.OrderBy.FieldRef[0] = new FieldRefDefinitionOrderBy(); camlQuery.OrderBy.FieldRef[0].Ascending = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Ascending", this.Site); camlQuery.OrderBy.FieldRef[0].Name = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Name", this.Site); return(camlQuery); }
public override void Draw(Rect position, SerializedProperty property, GUIContent label) { var expanded = property.isExpanded; var definition = ValueDefinition.Create((VariableType)_typeProperty.enumValueIndex, _constraint, null, null, _isTypeLockedProperty.boolValue, _isConstraintLockedProperty.boolValue); definition = Draw(position, label, definition, VariableInitializerType.None, null, true, ref expanded); _typeProperty.enumValueIndex = (int)definition.Type; _constraint = definition.Constraint; _constraintProperty.stringValue = _constraint != null?VariableHandler.SaveConstraint(definition.Type, _constraint, ref _objects) : string.Empty; if (_objects != null) { _objectsProperty.arraySize = _objects.Count; for (var i = 0; i < _objects.Count; i++) { _objectsProperty.GetArrayElementAtIndex(i).objectReferenceValue = _objects[i]; } } else { _objectsProperty.arraySize = 0; } property.isExpanded = expanded; }
public override float GetHeight(SerializedProperty property, GUIContent label) { var type = (VariableType)_typeProperty.enumValueIndex; var definition = ValueDefinition.Create(type, _constraint, null, null, _isTypeLockedProperty.boolValue, _isConstraintLockedProperty.boolValue); return(GetHeight(definition, VariableInitializerType.None, null, property.isExpanded)); }
public void ExampleCamlQueryEqValue() { var queryDef = new CamlQueryRoot { Where = new LogicalJoinDefinition { And = { new ExtendedLogicalJoinDefinition { Eq = { new LogicalTestDefinition { FieldRef = FieldRefDefinition.FromNames("State"), Value = ValueDefinition.NewTextValues("Queensland") } } } } } }; queryDef.Where.And.First().Eq.Add(new LogicalTestDefinition { FieldRef = FieldRefDefinition.FromNames("Country"), Value = ValueDefinition.NewTextValues("Australia") }); var andClauses = queryDef.Untyped.Descendants().Where(d => d.Name.LocalName == "And").ToList(); var query = new Query(queryDef); var queryString = query.ToString(); var chameleonQueryString = queryDef.ToCamlString(); Assert.IsTrue(queryString.IsNotEmpty()); Assert.IsTrue(chameleonQueryString.IsNotEmpty()); }
public void Setup(VariablePoolControl control, int index) { _control = control; _index = index; _name = control._pool.Names[index]; _definition = control._pool.Definitions[index]; }
private void ApplyDefinition(int index, string name, ValueDefinition definition) { using (new UndoScope(_property.serializedObject.targetObject, true)) { _pool.ChangeName(index, name); _pool.ChangeDefinition(index, definition); } }
private float GetHeight(int index) { var name = _proxy.GetName(index); var value = Store.GetVariable(name); var definition = ValueDefinition.Create(VariableType.Empty); return(VariableValueDrawer.GetHeight(value, definition, false)); }
public OrphanedInputSpaceTime() { var describes = new Describes("Temporal Target", "= Temporal Target"); SetIdentity(new Identity("FluidEarth2.Sdk.OrphanedInputSpaceTime", describes)); Component = null; ValueDefinition = new ValueDefinition(); SpatialDefinition = new SpatialDefinition(); TimeSet = new TimeSet(); }
private static void DrawDefaultValue(Rect rect, ref ValueDefinition definition) { var value = definition.Initializer.Execute(null, null); // context isn't necessary since the object that would be the context is currently drawing if (value.IsEmpty) // If the initializer hasn't been set, use the default value. { value = VariableHandler.CreateDefault(definition.Type, definition.Constraint); } DrawIndentedLabel(ref rect, _defaultLabel); using (var changes = new EditorGUI.ChangeCheckScope()) { value = VariableValueDrawer.Draw(rect, GUIContent.none, value, definition, true); if (changes.changed) { switch (definition.Type) { case VariableType.Bool: definition.Initializer.SetStatement(value.Bool ? "true" : "false"); break; case VariableType.Float: definition.Initializer.SetStatement(value.Float.ToString()); break; case VariableType.Int: definition.Initializer.SetStatement(value.Int.ToString()); break; case VariableType.Int2: definition.Initializer.SetStatement(string.Format("Vector2Int({0}, {1})", value.Int2.x, value.Int2.y)); break; case VariableType.Int3: definition.Initializer.SetStatement(string.Format("Vector3Int({0}, {1}, {2})", value.Int3.x, value.Int3.y, value.Int3.z)); break; case VariableType.IntRect: definition.Initializer.SetStatement(string.Format("RectInt({0}, {1}, {2}, {3})", value.IntRect.x, value.IntRect.y, value.IntRect.width, value.IntRect.height)); break; case VariableType.IntBounds: definition.Initializer.SetStatement(string.Format("BoundsInt({0}, {1}, {2}, {3}, {4}, {5})", value.IntBounds.x, value.IntBounds.y, value.IntBounds.z, value.IntBounds.size.x, value.IntBounds.size.y, value.IntBounds.size.z)); break; case VariableType.Vector2: definition.Initializer.SetStatement(string.Format("Vector2({0}, {1})", value.Vector2.x, value.Vector2.y)); break; case VariableType.Vector3: definition.Initializer.SetStatement(string.Format("Vector3({0}, {1}, {2})", value.Vector3.x, value.Vector3.y, value.Vector3.z)); break; case VariableType.Vector4: definition.Initializer.SetStatement(string.Format("Vector4({0}, {1}, {2}, {3})", value.Vector4.x, value.Vector4.y, value.Vector4.z, value.Vector4.w)); break; case VariableType.Quaternion: var euler = value.Quaternion.eulerAngles; definition.Initializer.SetStatement(string.Format("Quaternion({0}, {1}, {2})", euler.x, euler.y, euler.z)); break; case VariableType.Rect: definition.Initializer.SetStatement(string.Format("Rect({0}, {1}, {2}, {3})", value.Rect.x, value.Rect.y, value.Rect.width, value.Rect.height)); break; case VariableType.Bounds: definition.Initializer.SetStatement(string.Format("Bounds({0}, {1})", value.Bounds.center, value.Bounds.extents)); break; case VariableType.Color: definition.Initializer.SetStatement(string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", Mathf.RoundToInt(value.Color.r * 255), Mathf.RoundToInt(value.Color.g * 255), Mathf.RoundToInt(value.Color.b * 255), Mathf.RoundToInt(value.Color.a * 255))); break; case VariableType.String: definition.Initializer.SetStatement("\"" + value.String + "\""); break; } } } }
public static ValueDefinition Draw(Rect position, GUIContent label, ValueDefinition definition, VariableInitializerType initializer, TagList tags, bool showConstraintLabel, ref bool isExpanded) { var tag = definition.Tag; var constraint = definition.Constraint; var hasInitializer = HasInitializer(definition.Type, initializer); var hasConstraint = HasConstraint(definition.Type, definition.Constraint, definition.IsConstraintLocked); var hasTag = HasTags(tags); var typeRect = RectHelper.TakeLine(ref position); if (label != GUIContent.none) { var labelRect = RectHelper.TakeWidth(ref typeRect, RectHelper.CurrentLabelWidth); EditorGUI.LabelField(labelRect, label); } var type = DrawType(typeRect, definition.IsTypeLocked, definition.Type); if (hasConstraint) { var constraintHeight = GetConstraintHeight(definition.Type, definition.Constraint); var constraintRect = RectHelper.TakeHeight(ref position, constraintHeight); DrawConstraint(constraintRect, type, definition.IsConstraintLocked, ref constraint, showConstraintLabel); } if (hasInitializer && definition.Initializer != null) { if (initializer == VariableInitializerType.Expression) { var initializerHeight = ExpressionControl.GetFoldoutHeight(definition.Initializer, isExpanded, true, 2, 3); var initializerRect = RectHelper.TakeHeight(ref position, initializerHeight); RectHelper.TakeVerticalSpace(ref position); DrawInitializer(initializerRect, ref definition, ref isExpanded); } else if (initializer == VariableInitializerType.DefaultValue) { var initializerRect = RectHelper.TakeLine(ref position); DrawDefaultValue(initializerRect, ref definition); } } if (hasTag) { var tagRect = RectHelper.TakeLine(ref position); tag = DrawTag(tagRect, tag, tags); } return(ValueDefinition.Create(type, constraint, tag, definition.Initializer, definition.IsTypeLocked, definition.IsConstraintLocked)); }
public override T Rewrite <T>(T term) { if (!(term is ValueDefinition)) { return(null); } ValueDefinition valueDefinition = ((ValueDefinition)(BaseTerm)term); if (!Regex.IsMatch(valueDefinition.Name, pattern)) { return(null); } return((T)(BaseTerm)valueDefinition.Value); }
public static float GetHeight(VariableValue value, ValueDefinition definition, bool drawStores) { switch (value.Type) { case VariableType.Empty: return(GetEmptyHeight()); case VariableType.Bool: return(GetBoolHeight()); case VariableType.Int: return(GetIntHeight()); case VariableType.Float: return(GetFloatHeight()); case VariableType.Int2: return(GetInt2Height()); case VariableType.Int3: return(GetInt3Height()); case VariableType.IntRect: return(GetIntRectHeight()); case VariableType.IntBounds: return(GetIntBoundsHeight()); case VariableType.Vector2: return(GetVector2Height()); case VariableType.Vector3: return(GetVector3Height()); case VariableType.Vector4: return(GetVector4Height()); case VariableType.Quaternion: return(GetQuaternionHeight()); case VariableType.Rect: return(GetRectHeight()); case VariableType.Bounds: return(GetBoundsHeight()); case VariableType.Color: return(GetColorHeight()); case VariableType.String: return(GetStringHeight()); case VariableType.Enum: return(GetEnumHeight()); case VariableType.Object: return(GetObjectHeight()); case VariableType.Store: return(GetStoreHeight(value, definition.Constraint as StoreVariableConstraint, drawStores)); case VariableType.List: return(GetListHeight(value, definition.Constraint as ListVariableConstraint, drawStores)); default: return(EditorGUIUtility.singleLineHeight); } }
public void ValueDefinitionTest1() { var valueDefinition = new ValueDefinition { Untyped = XElement.Parse("<Value>Queensland </Value>"), XML = { "This is custom xml" } }; Assert.IsTrue(valueDefinition.XML.Any()); var first = valueDefinition.XML.First(); Assert.IsTrue(first.IsNotEmpty()); var camlString = valueDefinition.ToCamlString(); Assert.IsTrue(camlString.IsNotEmpty()); Assert.IsTrue(camlString.Contains("<Value>")); Assert.IsTrue(camlString.Contains("<XML>")); }
private void typeComboBox_SelectionChangeCommitted(object sender, EventArgs e) { ValueDefinition oldDef = values[listBox.SelectedIndex]; ValueDefinition newDef = null; for (int i = 0; i < ValueDefinition.VALUE_TYPES.Count; i++) { if (typeComboBox.SelectedIndex == i) { newDef = (ValueDefinition)Activator.CreateInstance(ValueDefinition.VALUE_TYPES[i]); break; } } newDef.Name = oldDef.Name; values[listBox.SelectedIndex] = newDef; setControlsFromValue(newDef); }
public override void OnGUI(Rect position) { var rect = RectHelper.Inset(position, 5.0f); var nameRect = RectHelper.TakeLine(ref rect); var buttonRect = RectHelper.TakeTrailingHeight(ref rect, EditorGUIUtility.singleLineHeight); RectHelper.TakeTrailingHeight(ref rect, RectHelper.VerticalSpace); var isExpanded = false; _name = EditorGUI.TextField(nameRect, _name); _definition = ValueDefinitionControl.Draw(rect, GUIContent.none, _definition, VariableInitializerType.None, null, false, ref isExpanded); if (GUI.Button(buttonRect, "Apply")) { _control.ApplyDefinition(_index, _name, _definition); editorWindow.Close(); } }
private static VariableValue DrawList(Rect rect, VariableValue value, ListVariableConstraint constraint, bool drawStores) { var itemDefinition = constraint != null ? ValueDefinition.Create(constraint.ItemType, constraint.ItemConstraint) : ValueDefinition.Create(VariableType.Empty); var remove = -1; for (var i = 0; i < value.List.Count; i++) { if (i != 0) { RectHelper.TakeVerticalSpace(ref rect); } var item = value.List.GetVariable(i); var height = GetHeight(item, itemDefinition, drawStores); var itemRect = RectHelper.TakeHeight(ref rect, height); var removeRect = RectHelper.TakeTrailingIcon(ref itemRect); item = Draw(itemRect, GUIContent.none, item, itemDefinition, drawStores); value.List.SetVariable(i, item); if (GUI.Button(removeRect, _removeListButton.Content, GUIStyle.none)) { remove = i; } } var addRect = RectHelper.TakeTrailingIcon(ref rect); if (GUI.Button(addRect, _addListButton.Content, GUIStyle.none)) { value.List.AddVariable(itemDefinition.Generate(null)); } if (remove >= 0) { value.List.RemoveVariable(remove); } return(value); }
/// <summary> /// Extracts a AExpressionDefinition from the ParseTreeNode /// </summary> /// <param name="myParseTreeNode"></param> /// <returns></returns> protected AExpressionDefinition GetExpressionDefinition(ParseTreeNode myParseTreeNode) { AExpressionDefinition retVal = null; if (myParseTreeNode.Term is NonTerminal) { #region left is NonTerminal if (myParseTreeNode.AstNode is IDNode) { retVal = (myParseTreeNode.AstNode as IDNode).IDChainDefinition; } else if (myParseTreeNode.AstNode is TupleNode) { retVal = (myParseTreeNode.AstNode as TupleNode).TupleDefinition; } else if (myParseTreeNode.AstNode is BinaryExpressionNode) { retVal = (myParseTreeNode.AstNode as BinaryExpressionNode).BinaryExpressionDefinition; } else if (myParseTreeNode.AstNode is UnaryExpressionNode) { retVal = (myParseTreeNode.AstNode as UnaryExpressionNode).UnaryExpressionDefinition; } else if (myParseTreeNode.AstNode is AggregateNode) { retVal = (myParseTreeNode.AstNode as AggregateNode).AggregateDefinition; } #endregion } else { #region No NonTerminal retVal = new ValueDefinition(myParseTreeNode.Token.Value); #endregion } return(retVal); }
public static float GetListHeight(VariableValue value, ListVariableConstraint constraint, bool drawStores) { var height = EditorGUIUtility.singleLineHeight; var itemDefinition = constraint != null ? ValueDefinition.Create(constraint.ItemType, constraint.ItemConstraint) : ValueDefinition.Create(VariableType.Empty); for (var i = 0; i < value.List.Count; i++) { if (i != 0) { height += EditorGUIUtility.standardVerticalSpacing; } var item = value.List.GetVariable(i); height += GetHeight(item, itemDefinition, drawStores); } return(height); }
private static ValueDefinition GetCorrectValueDefinition(IAttributeDefinition typeAttribute, IVertexType graphDBType, ValueDefinition myValueDefinition) { if (typeAttribute.Kind == AttributeType.IncomingEdge) { return(GetCorrectValueDefinition( ((IIncomingEdgeDefinition)typeAttribute).RelatedEdgeDefinition, graphDBType, myValueDefinition)); } else { if (typeAttribute.Kind == AttributeType.Property) { return(myValueDefinition); } else { throw new InvalidVertexAttributeValueException(typeAttribute.Name, myValueDefinition.Value); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var target = PropertyHelper.GetObject <VariableValueSource>(property); var typeRect = RectHelper.TakeLine(ref position); RectHelper.TakeLabel(ref position); using (new EditObjectScope(property.serializedObject)) { using (new UndoScope(property.serializedObject.targetObject, false)) { target.Type = (VariableSourceType)EnumDisplayDrawer.Draw(typeRect, label, (int)target.Type, typeof(VariableSourceType), EnumDisplayType.Buttons, false, 50); if (target.Type == VariableSourceType.Value) { if (!target.Definition.IsTypeLocked) { var variableRect = RectHelper.TakeWidth(ref position, position.width * 0.5f); RectHelper.TakeHorizontalSpace(ref position); var definitionType = (VariableType)EditorGUI.EnumPopup(variableRect, target.Definition.Type); if (definitionType != target.Definition.Type) { target.Definition = ValueDefinition.Create(definitionType, target.Definition.Constraint, target.Definition.Tag, target.Definition.Initializer, false, false); target.Value = target.Definition.Generate(null); } } target.Value = VariableValueDrawer.Draw(position, GUIContent.none, target.Value, target.Definition, true); } else if (target.Type == VariableSourceType.Reference) { VariableReferenceControl.Draw(position, target.Reference, GUIContent.none); } } } }
protected override void Draw(Rect rect, int index) { var name = _proxy.GetName(index); var value = Store.GetVariable(name); var definition = ValueDefinition.Create(VariableType.Empty); if (value.IsEmpty) { EditorGUI.LabelField(rect, name, EmptyText); } else { if (value.HasStore) { if (DrawStoreView(ref rect)) { Selected = value.Store; SelectedName = name; } } using (var changes = new EditorGUI.ChangeCheckScope()) { var labelRect = RectHelper.TakeWidth(ref rect, _labelWidth); labelRect = RectHelper.TakeHeight(ref labelRect, EditorGUIUtility.singleLineHeight); EditorGUI.LabelField(labelRect, name); value = VariableValueDrawer.Draw(rect, GUIContent.none, value, definition, false); if (changes.changed) { Store.SetVariable(name, value); } } } }
/// <summary> /// Extracts data for a binary expression /// </summary> /// <param name="myComplexValue">The complex part of the binary expression.</param> /// <param name="mySimpleValue">The simple/atomic part of the expression.</param> /// <param name="errors">The list of errors.</param> /// <param name="typeOfBinExpr">The kind of the binary expression</param> /// <returns>A data tuple.</returns> private static DataContainer ExtractData(AExpressionDefinition myComplexValue, AExpressionDefinition mySimpleValue, ref TypesOfBinaryExpression typeOfBinExpr, GQLPluginManager myPluginManager, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken, Boolean aggregateAllowed) { #region data //the complex IDNode (sth. like U.Age or Count(U.Friends)) IDChainDefinition complexIDNode = null; //the value that is on the opposite of the complex IDNode AExpressionDefinition simpleValue = null; //a complex IDNode may result in a complexValue (i.e. Count(U.Friends) --> 3) AExpressionDefinition complexValue = null; //reference to former myComplexValue AExpressionDefinition extraordinaryValue = null; #endregion #region extraction if (myComplexValue is IDChainDefinition) { #region IDNode #region Data complexIDNode = (IDChainDefinition)myComplexValue; complexIDNode.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, false); if (complexIDNode.Any(id => id is ChainPartFuncDefinition)) { if (complexIDNode.Edges == null || complexIDNode.Edges.Count == 0) { #region parameterless function var fcn = (complexIDNode.First(id => id is ChainPartFuncDefinition) as ChainPartFuncDefinition); // somes functions (aggregates) like SUM are not valid for where expressions, though they are not resolved if (fcn.Function == null) { throw new FunctionDoesNotExistException(fcn.FuncName); } FuncParameter pResult = fcn.Function.ExecFunc(null, null, null, myGraphDB, mySecurityToken, myTransactionToken); //simpleValue = new AtomValue(fcn.Function.TypeOfResult, ((FuncParameter)pResult.Value).Value); //the new simple value extraced from the function simpleValue = new ValueDefinition(((FuncParameter)pResult).Value); typeOfBinExpr = TypesOfBinaryExpression.Unknown; //we do not know if we are left or right associated complexIDNode = null; //we resolved it... so it's null #endregion } else { //extraordinaryValue = (complexIDNode.First(id => id is ChainPartFuncDefinition) as ChainPartFuncDefinition); extraordinaryValue = complexIDNode; if (mySimpleValue is ValueDefinition) { simpleValue = mySimpleValue; } } } else { if (mySimpleValue is ValueDefinition) { try { if (complexIDNode.IsUndefinedAttribute) { throw new VertexAttributeIsNotDefinedException(complexIDNode.UndefinedAttribute); } simpleValue = GetCorrectValueDefinition(complexIDNode.LastAttribute, complexIDNode.LastType, ((ValueDefinition)mySimpleValue)); } catch (FormatException) { throw new DataTypeDoesNotMatchException(((IPropertyDefinition)complexIDNode.LastAttribute).BaseType.Name, ((ValueDefinition)mySimpleValue).Value.GetType().Name); } } else { if (mySimpleValue is TupleDefinition) { ((TupleDefinition)mySimpleValue).ConvertToAttributeType(myPluginManager, complexIDNode.LastAttribute, myGraphDB, mySecurityToken, myTransactionToken); simpleValue = mySimpleValue; } } } #endregion #endregion } else if (myComplexValue is TupleDefinition) { #region TupleSetNode complexValue = ((TupleDefinition)myComplexValue); simpleValue = mySimpleValue; typeOfBinExpr = TypesOfBinaryExpression.Atom; #endregion } else if (myComplexValue is AggregateDefinition) { #region AggregateNode if (aggregateAllowed) { if (((AggregateDefinition)myComplexValue).ChainPartAggregateDefinition.Parameters.Count != 1) { throw new GQLAggregateArgumentException("An aggregate must have exactly one expression."); } if (!(((AggregateDefinition)myComplexValue).ChainPartAggregateDefinition.Parameters[0] is IDChainDefinition)) { throw new GQLAggregateArgumentException("An aggregate must have exactly one IDNode."); } #region Data complexIDNode = (((AggregateDefinition)myComplexValue).ChainPartAggregateDefinition.Parameters[0] as IDChainDefinition); if (complexIDNode == null) { throw new InvalidIDNodeException("Only single IDNodes are currently allowed in aggregates!"); } #endregion #region values simpleValue = mySimpleValue; extraordinaryValue = myComplexValue; #endregion } else { throw new AggregateNotAllowedException(((AggregateDefinition)myComplexValue).ChainPartAggregateDefinition.Aggregate.PluginShortName); } #endregion } else { throw new NotImplementedQLException(""); } #endregion return(new DataContainer(new Tuple <IDChainDefinition, IDChainDefinition>(complexIDNode, null), new Tuple <AExpressionDefinition, AExpressionDefinition>(simpleValue, complexValue), new Tuple <AExpressionDefinition, AExpressionDefinition>(extraordinaryValue, null))); }
/// <summary> /// Used to get the query root element containing the where condition. /// </summary> /// <param name="isLookupId">Explicitly specify whether the field referenced in the logical test query condition is a look up field.</param> /// <returns>The query root element containing a where condition.</returns> protected CamlQueryRoot GetCamlQueryRootForWhere(bool isLookupId) { CamlQueryRoot camlQuery = new CamlQueryRoot(); // Construct a LogicalTestDefinition based on PTF Configure file. LogicalTestDefinition logicalTest = new LogicalTestDefinition(); FieldRefDefinitionQueryTest fieldRef = new FieldRefDefinitionQueryTest(); fieldRef.Name = Common.GetConfigurationPropertyValue("FieldRefWhere_Name", this.Site); logicalTest.FieldRef = fieldRef; logicalTest.FieldRef.LookupId = isLookupId.ToString().ToUpper(); ValueDefinition value = new ValueDefinition(); value.Type = Common.GetConfigurationPropertyValue("FieldRefWhere_Type", this.Site); value.Text = new string[] { Common.GetConfigurationPropertyValue("FieldRefWhere_Text", this.Site) }; logicalTest.Value = value; // Use Equal to construct a Where condition. camlQuery.Where = new LogicalJoinDefinition(); camlQuery.Where.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.Eq }; camlQuery.Where.Items = new LogicalTestDefinition[] { logicalTest }; // Construct an OrderBy element. camlQuery.OrderBy = new OrderByDefinition(); camlQuery.OrderBy.FieldRef = new FieldRefDefinitionOrderBy[1]; camlQuery.OrderBy.FieldRef[0] = new FieldRefDefinitionOrderBy(); camlQuery.OrderBy.FieldRef[0].Ascending = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Ascending", this.Site); camlQuery.OrderBy.FieldRef[0].Name = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Name", this.Site); return camlQuery; }
public VariableValueSource(VariableType type, ValueDefinition definition) { Value = definition.Generate(null); Definition = definition; }
public VariableValueSource() { Value = VariableValue.Empty; Definition = ValueDefinition.Create(VariableType.Empty); }
static Quantity GetQuantity(IDescribable describes, IDimension iDimension, int dimension) { ValueDefinition vd; switch (dimension) { case 1: vd = new ValueDefinition(describes, typeof(double), Double.NegativeInfinity); break; case 2: vd = new ValueDefinition(describes, typeof(Vector2d<double>), new Vector2d<double>(Double.NegativeInfinity)); break; case 3: vd = new ValueDefinition(describes, typeof(Vector3d<double>), new Vector3d<double>(Double.NegativeInfinity)); break; default: throw new NotImplementedException(dimension.ToString()); } var unit = new Unit(describes, iDimension); return new Quantity(vd, unit); }
static IEnumerable <Assignment> GetEquations(ValueTerm pattern, ValueTerm term) { if (pattern is BasicValueTerm) { if (!(term is BasicValueTerm)) { return(null); } BasicValueTerm patternBasicValueTerm = (BasicValueTerm)pattern; BasicValueTerm termBasicValueTerm = (BasicValueTerm)term; if (patternBasicValueTerm != termBasicValueTerm) { return(null); } return(Enumerables.Create <Assignment>()); } if (pattern is ValueDefinition) { if (!(term is ValueDefinition)) { return(null); } ValueDefinition patternBasicValueTerm = (ValueDefinition)pattern; ValueDefinition termBasicValueTerm = (ValueDefinition)term; if (patternBasicValueTerm != termBasicValueTerm) { return(null); } return(Enumerables.Create <Assignment>()); } if (pattern is Variable) { Variable patternVariable = (Variable)pattern; return(Enumerables.Create(new Assignment(patternVariable, term))); } if (pattern is Application) { if (!(term is Application)) { return(null); } Application patternApplication = (Application)pattern; Application termApplication = (Application)term; if (patternApplication.Function != termApplication.Function) { return(null); } return(GetEquations(patternApplication.Parameter, termApplication.Parameter)); } if (pattern is Vector) { if (!(term is Vector)) { return(null); } Vector patternVector = (Vector)pattern; Vector termVector = (Vector)term; if (patternVector.Terms.Count() != termVector.Terms.Count()) { return(null); } List <Assignment> result = new List <Assignment>(); foreach (IEnumerable <Assignment> equations in Enumerable.Zip(patternVector.Terms, termVector.Terms, GetEquations)) { if (equations == null) { return(null); } result.AddRange(equations); } return(result); } if (pattern is Selection) { if (!(term is Selection)) { return(null); } Selection patternSelection = (Selection)pattern; Selection termSelection = (Selection)term; if (patternSelection.Index != termSelection.Index) { return(null); } return(GetEquations(patternSelection.Term, termSelection.Term)); } throw new InvalidOperationException(); }
public InputSurrogate(IBaseInput input) { _inputOriginal = input; if (input == null) { SetDescribes(new Describes("Unspecified Input")); ValueDefinition = new ValueDefinition(); Component = null; } else { SetDescribes(input); ValueDefinition = input.ValueDefinition; Component = input.Component; } }