private void BuildSigmaScopes(int range, byte level, byte nodeTypeIndex, int nodeCounter, int clusterSize) { int parentSqrt = ScopeValue.ParentSqrt(range); if (levels == null) { levels = new List <vEBTreeLevel>(); } if (levels.Count <= level) { levels.Add(new vEBTreeLevel()); } if (levels[level].Scopes == null) { levels[level].Scopes = new List <vEBTreeNode>(); levels[level].Scopes.Add(new vEBTreeNode()); } else { levels[level].Scopes.Add(new vEBTreeNode()); } levels[level].Scopes[nodeTypeIndex].NodeCounter = nodeCounter; levels[level].Scopes[nodeTypeIndex].NodeSize = parentSqrt; if (parentSqrt > 4) { // sigmaNode BuildSigmaScopes(parentSqrt, (byte)(level + 1), (byte)(2 * nodeTypeIndex), nodeCounter, parentSqrt); // cluster BuildSigmaScopes(parentSqrt, (byte)(level + 1), (byte)(2 * nodeTypeIndex + 1), nodeCounter * parentSqrt, parentSqrt); } }
private static ScopeSpecification CreateScopeSpesification(OctoVariable variable, VariableSetResource variableSet) { var scopeSpecifiaciton = new ScopeSpecification(); variable.Scopes.ForEach(scope => { ScopeField scopeName = FindScopeName(scope); List <ReferenceDataItem> referenceDataItems = FindScopeValue(scopeName, variableSet); List <string> scopeValues = referenceDataItems.Join(scope.Values, refDataItem => refDataItem.Name, selectedScope => selectedScope, (item, s) => item.Id) .ToList(); if (!scopeValues.Any()) { throw new CakeException($"({string.Join(",", scope.Values)}) value(s) can not be found on ({scope.Name}) scope."); } var value = new ScopeValue(scopeValues.First(), scopeValues.Skip(1).ToArray()); scopeSpecifiaciton.Add(scopeName, value); }); return(scopeSpecifiaciton); }
private List <ScopeValue> AddSortAndGroupExpressionValues(List <object> groupExpValues) { List <ScopeValue> list = new List <ScopeValue>(this.m_memberGroupAndSortExpressionFlag.Count); int num = 0; int num2 = 0; for (int i = 0; i < this.m_memberGroupAndSortExpressionFlag.Count; i++) { ScopeValue scopeValue = null; switch (this.m_memberGroupAndSortExpressionFlag[i]) { case ScopeIDType.SortValues: scopeValue = this.CreateScopeValueFromSortExpression(num, this.m_memberGroupAndSortExpressionFlag[i]); num++; break; case ScopeIDType.GroupValues: scopeValue = new ScopeValue(this.NormalizeValue(groupExpValues[num2]), this.m_memberGroupAndSortExpressionFlag[i]); num2++; break; case ScopeIDType.SortGroup: scopeValue = ((groupExpValues.Count != 1) ? this.CreateScopeValueFromSortExpression(num, this.m_memberGroupAndSortExpressionFlag[i]) : new ScopeValue(this.NormalizeValue(groupExpValues[num2]), this.m_memberGroupAndSortExpressionFlag[i])); num2++; num++; break; } if (scopeValue != (ScopeValue)null) { list.Add(scopeValue); } } return(list); }
internal ScopeValue CreateScopeValue(Scope scope, string name) { var result = new ScopeValue(scope, name) { Value = this.Value, Description = this.Description }; return(result); }
/// <summary> /// Creates the custom scope values. /// </summary> /// <param name="scope">The scope.</param> /// <param name="name">The name.</param> /// <param name="column">The column.</param> public static void CreateCustomScopeValues(this Scope scope, string name, DynamicTargetColumn column) { if (column.Scope == DynamicScopeEnum.None) { return; } if (scope.IsCustom) { // TODO: FINISH CUSTOM SCOPE VALUES. JASON } else { if (!string.IsNullOrEmpty(scope.ClrType)) { try { var scopeType = Type.GetType(scope.ClrType); var enumValues = Enum.GetValues(scopeType); // IList<System.Tuple<string, string, object>> enumValuDescList = new List<System.Tuple<string, string, object>>(); foreach (var value in enumValues) { var fi = value.GetType().GetField(value.ToString()); if (null == fi) { continue; // Next } var attrs = fi.GetCustomAttributes(typeof(WingScopeValueAttribute), true).OfType <WingScopeValueAttribute>().ToArray(); if (attrs.Length == 0) { continue; // Next } var item = new ScopeValue(scope, attrs[0].Name) { Description = attrs[0].Description, Value = attrs[0].Value }; if (!item.Owner.Name.EqualsIgnoreCase(scope.Name)) { } if (!scope.Values.Any(sv => sv.Name.EqualsIgnoreCase(item.Name))) { scope.Values.Add(item); } } } catch (Exception) { } } } }
private void CreateScope() { var newScope = new ScopeValue { scriptId = Script.Header.Id, entrance = Script.CurrentPosition, parentScope = ActiveScope }; ActiveScope = newScope; }
private void CreateLevels(int range) { if (levels == null) { int parentSqrt = ScopeValue.ParentSqrt(size); BuildSigmaScopes(range, 0, 0, 1, parentSqrt); } int baseOffset = 0; for (int i = 1; i < levels.Count; i++) { levels[i].BaseOffset = baseOffset; for (int j = 0; j < levels[i].Scopes.Count - 1; j++) { levels[i].Scopes[j].IndexOffset = baseOffset; baseOffset += levels[i].Scopes[j].NodeCounter * levels[i].Scopes[j].NodeSize; } } }