Exemplo n.º 1
0
            public LandingPageVariable(Func <Tuple <SiteInfo, ItemInfo> > siteAndItem, ItemInfoClient itemInfo)
            {
                _siteAndItem = siteAndItem;
                _itemInfo    = itemInfo;

                DependentVariables.Add("Language"); //TODO: Language?
                DependentVariables.Add("Campaign");
            }
Exemplo n.º 2
0
 /// <summary>
 /// Rename the assignment we are making.
 /// </summary>
 /// <param name="originalName"></param>
 /// <param name="newName"></param>
 public void RenameVariable(string originalName, string newName)
 {
     ResultVariable.RenameRawValue(originalName, newName);
     ResultVariables = new HashSet <string>()
     {
         ResultVariable.RawValue
     };
     Expression.RenameRawValue(originalName, newName);
     DependentVariables = DependentVariables.Select(p => p.ReplaceVariableNames(originalName, newName)).ToHashSet();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Rename the variables.
 /// </summary>
 /// <param name="originalName"></param>
 /// <param name="newName"></param>
 public void RenameVariable(string originalName, string newName)
 {
     ResultVariable.RenameParameter(originalName, newName);
     ResultVariables = new HashSet <string>()
     {
         ResultVariable.RawValue
     };
     Expression.RenameRawValue(originalName, newName);
     DependentVariables = new HashSet <string>(DependentVariables.Select(s => s.ReplaceVariableNames(originalName, newName)));
 }
Exemplo n.º 4
0
        public ExternalSearchVariable(Func <SearchEngine> engine,
                                      Func <IEnumerable <string> > keywords,
                                      double localizeTld = 0.5)
        {
            Engine      = engine;
            Keywords    = keywords;
            LocalizeTld = localizeTld;

            DependentVariables.Add("Channel");
            DependentVariables.Add("DomainPostfix");
            DependentVariables.Add("Tld");
        }
Exemplo n.º 5
0
 /// <summary>
 /// Rename all variables.
 /// </summary>
 /// <param name="originalName"></param>
 /// <param name="newName"></param>
 public void RenameVariable(string originalName, string newName)
 {
     _cppResult.RenameRawValue(originalName, newName);
     ResultVariables = new HashSet <string>()
     {
         _cppResult.RawValue
     };
     _paramReplacesments = _paramReplacesments
                           .Select(p => Tuple.Create(p.Item1, p.Item2.ReplaceVariableNames(originalName, newName)))
                           .ToList();
     _linesOfCode       = _linesOfCode.Select(l => l.ReplaceVariableNames(originalName, newName)).ToList();
     DependentVariables = DependentVariables.Select(r => r.ReplaceVariableNames(originalName, newName)).ToHashSet();
 }
        /// <summary>
        /// Resizes functions for the given argumentVariable. if x is dependend on y, x gets resized
        /// </summary>
        /// <param name="argumentVariable">The argument variable that is altered</param>
        /// <param name="action">action on the argument</param>
        /// <param name="index">index in argument array</param>
        private void ResizeDependendFunctionValues(IVariable argumentVariable, NotifyCollectionChangedAction action,
                                                   int index, int oldIndex)
        {
            if (!DependentVariables.ContainsKey(argumentVariable))
            {
                return;
            }

            switch (action)
            {
            case NotifyCollectionChangedAction.Add:

                foreach (IVariable dependentVariable in DependentVariables[argumentVariable])
                {
                    if (!dependentVariable.Attached)
                    {
                        continue;
                    }

                    int dependentVariableIndex = Functions.IndexOf(dependentVariable);
                    int argumentIndex          = dependentVariable.Arguments.IndexOf(argumentVariable);
                    //argument based dependency

                    if (argumentIndex != -1)
                    {
                        FunctionValues[dependentVariableIndex].InsertAt(argumentIndex, index);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (IVariable dependentVariable in DependentVariables[argumentVariable])
                {
                    if (!dependentVariable.Attached)
                    {
                        continue;
                    }

                    int dependentVariableIndex = Functions.IndexOf(dependentVariable);
                    int argumentIndex          = dependentVariable.Arguments.IndexOf(argumentVariable);
                    //argument based dependency
                    if (argumentIndex != -1)
                    {
                        FunctionValues[dependentVariableIndex].RemoveAt(argumentIndex, index);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                if (index != oldIndex)
                {
                    foreach (IVariable dependentVariable in DependentVariables[argumentVariable])
                    {
                        if (!dependentVariable.Attached)     // TODO: what is attach?
                        {
                            continue;
                        }

                        int dependentVariableIndex = Functions.IndexOf(dependentVariable);
                        int argumentIndex          = dependentVariable.Arguments.IndexOf(argumentVariable);

                        //argument based dependency
                        if (oldIndex != -1)
                        {
                            // TODO: extend it to work with Length > 1
                            FunctionValues[dependentVariableIndex].Move(argumentIndex, index, 1, oldIndex);  //, 1, index);
                        }
                    }
                }
                break;
            }
        }