Пример #1
0
        public INumber Execute(RuntimeData runtime, INumber left, INumber right)
        {
            // 両辺に含まれる変数
            List <Variable> vars = new List <Expression.Variable>();

            //両辺に含まれる変数をチェックする
            Action <Variable> addVar = new Action <Variable>(v => {
                foreach (var va in vars)
                {
                    if (va.Name == v.Name)
                    {
                        return;
                    }
                }
                vars.Add(v);
            });
            Action <INumber> checkFormula = null; checkFormula = new Action <INumber>((formula) => {
                if (formula is Variable)
                {
                    addVar(formula as Variable);
                }
                if (formula is Member)
                {
                    addVar((formula as Member).GetVariable(runtime));
                }
                if (formula is IFormula)
                {
                    foreach (var item in (formula as IFormula).Items)
                    {
                        if (item is INumber)
                        {
                            checkFormula(item as INumber);
                        }
                    }
                }
            });

            checkFormula(left); checkFormula(right);

            foreach (var var in vars)
            {
                var res = CheckValue(var, left, right);
            }


            throw new NotImplementedException();
        }
Пример #2
0
        public void ExecuteAsParameter(RuntimeData runtime)
        {
            List <IExpression> line = new List <Interface.IExpression>();

            if (this.Count == 0)
            {
                return;
            }

            if (!(this.Items.Last() is LineBreak))
            {
                this.AddItem(runtime, new LineBreak());
            }

            for (int i = 0; i < this.Count; i++)
            {
                if (this.Items[i] is LineBreak)
                {
                    if (line.Count == 0)
                    {
                        throw new SyntaxException(string.Format("パラメータが空です。"), this);
                    }

                    if (line.Count == 1)
                    {
                        runtime.NowBlock.Push(line[0]);
                        line.Clear();
                    }
                    else
                    {
                        Formula f = new Expression.Formula();
                        foreach (var item in line)
                        {
                            f.AddItem(runtime, item);
                        }
                        runtime.NowBlock.Push(f);

                        line.Clear();
                    }
                    continue;
                }
                else
                {
                    line.Add(this.Items[i]);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 二次方程式を解決する
        /// </summary>
        private INumber SolutionQuadraticEquation(RuntimeData runtime, string varname, Dictionary <int, INumber> keisu)
        {
            if (!(keisu.Keys.Where(k => k >= 3).Count() == 0 &&                    // x^3のような大きなべき乗がない
                  keisu.Values.Where(v => !(v is IConstParameter)).Count() == 0 && // 係数が全て実数である
                  keisu.ContainsKey(2) &&                                          // x^2が含まれている
                  !(keisu[2] is Number && (keisu[2] as Number).Value == 0)))       // x^2の係数が0ではない
            {
                return(null);
            }

            runtime.AddLogWay("AsQuadraticEquation", keisu[2], keisu[1], keisu[0]);

            INumber res1 = null, res2 = null;

            try {
                runtime.AddBlock(new BlockData()
                {
                    MoreScope = false
                });
                runtime.NowBlock.Variables.Add("a", keisu[2]);
                runtime.NowBlock.Variables.Add("b", keisu[1]);
                runtime.NowBlock.Variables.Add("c", keisu[0]);

                // ( -b ± √(b^2 - 4ac)) / 2a
                res1 = (runtime.Setting.GetExpression("((0-b)+sqrt(b^2-4a*c))/(2a)") as IEval).Eval(runtime);
                res2 = (runtime.Setting.GetExpression("((0-b)-sqrt(b^2-4a*c))/(2a)") as IEval).Eval(runtime);

                var vr = new Variable(varname);
                runtime.AddLogWay("_QuadraticEquationWay1", vr, res1);
                runtime.AddLogWay("_QuadraticEquationWay2", vr, res2);
            }
            finally { runtime.PopBlock(); }

            if (res1 == null && res2 == null)
            {
                return(null);
            }

            Results ress = new Results(new Variable(varname));

            ress.items.Add(res1);
            if (!res1.Equals(runtime, res2))
            {
                ress.items.Add(res2);
            }
            return(ress);
        }
Пример #4
0
        public static IntegralConstant Create(RuntimeData runtime)
        {
            int i = 1;

            for (; ; i++)
            {
                if (!runtime.ContainsKey("C" + i, true))
                {
                    break;
                }
            }

            IntegralConstant res = new Expression.IntegralConstant();

            res.id = i;
            return(res);
        }
Пример #5
0
        public INumber ExecuteDiff(RuntimeData runtime, string t, INumber[] parameters)
        {
            var res = new FuncedINumber(runtime.Functions["cos"], parameters);

            var vaDiff = parameters[0].ExecuteDiff(runtime, t);

            if (vaDiff.Equals(runtime, Number.New(0)))
            {
                return(res);
            }

            MultipleFormula mf = new MultipleFormula();

            mf.AddItem(runtime, vaDiff);
            mf.AddItem(runtime, res);
            return(mf);
        }
Пример #6
0
        private RuntimeData Load()
        {
            lock (this.commandLockObject)
            {
                string configFile = Path.Combine(this.folderService.GetAppDataFolder(), RUNTIMEDATA_FILE);

                RuntimeData runtimeData = new RuntimeData();

                if (File.Exists(configFile))
                {
                    XDocument doc = XDocument.Load(configFile);
                    runtimeData = RuntimeData.GetFromXml(doc.Root);
                }

                return(runtimeData);
            }
        }
Пример #7
0
        public override INumber Optimise(RuntimeData runtime)
        {
            INumber res = Number.New(1);

            for (int i = 0; i < this.Count; i++)
            {
                res = res.Multiple(runtime, this.items[i]);
                if (!(res is MultipleFormula))
                {
                    res = res.Optimise(runtime);
                }
            }
            //if (!(res is MultipleFormula))
            //    return res.Optimise(runtime);

            return(res);
        }
Пример #8
0
        public override INumber Power(RuntimeData runtime, INumber val)
        {
            var pow = val.FinalEval(runtime);

            if (pow is IConstParameter && (pow as IConstParameter).ConstValue == 0)
            {
                return(Number.New(1));
            }

            if (runtime.IsConstValue(pow))
            {
                var me = this.Clone() as FloatNumber;
                me.value = (decimal)Math.Pow((double)this.value, (double)(pow as IConstParameter).ConstValue);
                return(me);
            }
            return(base.Power(runtime, val));
        }
Пример #9
0
        public override INumber FinalEval(RuntimeData runtime)
        {
            var me = this.Eval(runtime).Optimise(runtime) as Fraction;

            me.Denominator = me.Denominator.FinalEval(runtime);
            me.Numerator   = me.Numerator.FinalEval(runtime);

            if (FuncCalc.Runtime.Func.Differential.IsConstValue(runtime, me.Denominator) &&
                FuncCalc.Runtime.Func.Differential.IsConstValue(runtime, me.Numerator))
            {
                var res =
                    (me.Numerator.FinalEval(runtime) as IConstParameter).ConstValue /
                    (me.Denominator.FinalEval(runtime) as IConstParameter).ConstValue;
                return(new FloatNumber(res));
            }
            return(me);
        }
Пример #10
0
        public override INumber Divide(RuntimeData runtime, INumber val)
        {
            var v = val.Eval(runtime);

            if (val is Number && (val as Number).Value == 0)
            {
                if (this.ValueType == ValueType.Plus)
                {
                    return(InfinityValue.PlusValue);
                }
                else
                {
                    return(InfinityValue.MinusValue);
                }
                // ValueType.Unknownになることはない
            }

            if (v is Number)
            {
                if (this.Pow.Equals(runtime, val.Pow))
                {
                    if (this.Value % (v as Number).Value == 0) // 割り切れるなら数値として返す
                    {
                        return(Number.New(this.Value / (v as Number).Value));
                    }
                    else // 割り切れないなら分数として返す
                    {
                        return(new Fraction(v, this));
                    }
                }
                else
                {
                    return(new Fraction(v, this));
                }
            }

            if (v is Fraction)
            {
                return
                    ((new Fraction((v as Fraction).Numerator, (v as Fraction).Denominator)).Multiple(runtime, this));
            }

            // こちらの方で対応していないものも半ば強引に解決させる
            return(new Fraction(val, this));
        }
Пример #11
0
        public void Save()
        {
            lock (_commandLockObject)
            {
                RuntimeData runtimeData = RuntimeData;

                XDocument doc = new XDocument(new XDeclaration("1.0", "UTF-8", null));

                XElement runtimeDataEl = new XElement(RUNTIMEDATA_EL);
                runtimeDataEl.Add(new XAttribute(RUNTIMEDATA_VERSION_ATTR, _tlVersion));
                doc.Add(runtimeDataEl);

                if (runtimeData.AuthInfo != null)
                {
                    XElement authenticationEl = runtimeData.AuthInfo.GetXml();

                    if (authenticationEl.HasElements)
                    {
                        runtimeDataEl.Add(authenticationEl);
                    }
                }

                if (runtimeData.MainWindowInfo != null)
                {
                    XElement mainWindowInfoEl = runtimeData.MainWindowInfo.GetXml();

                    if (mainWindowInfoEl.HasElements)
                    {
                        XElement applicationEl = new XElement(APP_EL);
                        applicationEl.Add(mainWindowInfoEl);
                        runtimeDataEl.Add(applicationEl);
                    }
                }

                string appDataFolder = _folderService.GetAppDataFolder();

                FileSystem.CreateDirectory(appDataFolder);

                string configFile = Path.Combine(appDataFolder, RUNTIMEDATA_FILE);

                doc.Save(configFile);

                _runtimeData = runtimeData;
            }
        }
Пример #12
0
        private void Save()
        {
            errorText.text = string.Empty;
            List <int> skillIds = new List <int>();

            for (int i = 0; i < skillDPs.Length; i++)
            {
                skillIds.Add(int.Parse(skillDPs[i].captionText.text.Substring(0, 3)));
            }
            //存在重复技能
            if (skillIds.Count() != skillIds.Distinct().Count())
            {
                errorText.text = "技能不能重复选择";
            }
            else
            {
                for (int i = 0; i < skills.Length; i++)
                {
                    skills[i] = PublicDataManager.instance.GetSkillModel(skillIds[i]);
                }
                //各项属性修改为最终能力值
                for (int i = 0; i < abilityValueTexts.Length; i++)
                {
                    switch (i)
                    {
                    case 0: pokemon.hp = int.Parse(abilityValueTexts[i].text); break;

                    case 1: pokemon.attack = int.Parse(abilityValueTexts[i].text); break;

                    case 2: pokemon.defense = int.Parse(abilityValueTexts[i].text); break;

                    case 3: pokemon.sp_attack = int.Parse(abilityValueTexts[i].text); break;

                    case 4: pokemon.sp_defense = int.Parse(abilityValueTexts[i].text); break;

                    case 5: pokemon.speed = int.Parse(abilityValueTexts[i].text); break;
                    }
                }
                Pokemon p = new Pokemon(pokemon, character, personality, item, skills);
                p.isMe = true;
                RuntimeData.SetCurrentMyPokemon(p);
                UIDelegateManager.NotifyUI(UIMessageType.RefreshParty, RuntimeData.GetCurrentMyIndex());
                Close();
            }
        }
Пример #13
0
 public void SetupIngame()
 {
     if (ReviveScript.instance.alreadyRevived)
     {
         postRevive = new RuntimeData();
         postRevive.totalCountRevive++;
         value           = postRevive;
         value.startTime = Time.realtimeSinceStartup;
     }
     else
     {
         postRevive = new RuntimeData();
         preRevive  = new RuntimeData();
         preRevive.totalGamesPlayed++;
         value           = preRevive;
         value.startTime = Time.realtimeSinceStartup;
     }
 }
Пример #14
0
        public virtual INumber Power(RuntimeData runtime, INumber val)
        {
            if (val is Number && (val as Number).Value == 0)
            {
                return(Number.New(0));
            }
            if (val is Number && (val as Number).Value < 0)
            {
                return(new Fraction(
                           this.Clone().Power(runtime, val.Multiple(runtime, Number.New(-1))),
                           Number.New(1)));
            }

            var me = this.Clone();

            me.Pow = me.Pow.Multiple(runtime, val);
            return(me);
        }
Пример #15
0
 public override INumber Eval(RuntimeData runtime)
 {
     if (runtime.ContainsKey(this.Token.Text))
     {
         var res = runtime.GetData(this.Token);
         res = res.Multiple(runtime, this.multi);
         res = res.Power(runtime, this.Pow);
         if (res == this)
         {
             return(this);
         }
         return(res.Eval(runtime));
     }
     else
     {
         return(this);
     }
 }
Пример #16
0
        public override INumber Add(RuntimeData runtime, INumber val)
        {
            if (val is InfinityValue)
            {
                return(val);
            }
            if (val is IConstParameter)
            {
                var me = this.Clone() as FloatNumber;
                me.value += (val as IConstParameter).ConstValue;
                return(me);
            }

            AdditionFormula af = new AdditionFormula();

            af.AddItem(runtime, val);
            af.AddItem(runtime, this);
            return(af);
        }
Пример #17
0
        private IEnumerator LoadWeaponInfos(WeaponDefinition definition)
        {
            AssetReference weaponIllustrationReference = definition.GetWeaponIllustrationReference();

            m_weaponTextField.SetText(definition.i18nNameId);
            m_weaponLevelField.SetText(68066, new IndexedValueProvider(m_level.ToString()));
            AssetLoadRequest <Sprite> assetReferenceRequest = weaponIllustrationReference.LoadFromAssetBundleAsync <Sprite>(AssetBundlesUtility.GetUICharacterResourcesBundleName());

            while (!assetReferenceRequest.get_isDone())
            {
                yield return(null);
            }
            if (AssetManagerError.op_Implicit(assetReferenceRequest.get_error()) != 0)
            {
                Log.Error($"Error while loading illustration for {((object)definition).GetType().Name} {definition.get_name()} error={assetReferenceRequest.get_error()}", 305, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\UI\\Player\\DeckRoot\\DeckUIRoot.cs");
                yield break;
            }
            WeaponData value = new WeaponData(definition, m_level);

            m_weaponVisual.SetValue(value);
            m_weaponPassiveText.SetText(definition.i18nDescriptionId, new FightValueProvider(definition, m_level));
            m_pedestalWeaponCellRenderer.SetValue(value);
            if (definition != null)
            {
                List <Id <SpellDefinition> > list = definition.spells.ToList();
                if (list.Count != 0 && RuntimeData.spellDefinitions.TryGetValue(list[0].value, out SpellDefinition value2))
                {
                    SpellData spellData = new SpellData(value2, m_level);
                    m_pedestalSpellCellRenderer.SetValue(spellData);
                    m_equippedFX.SetElement(value2.element);
                    m_spellRenderer.SetValue(new SpellData(value2, m_level));
                    string text = RuntimeData.FormattedText(spellData.definition.i18nNameId);
                    m_spellName.SetText(33557, new IndexedValueProvider(text));
                    m_spellDescription.SetText(spellData.definition.i18nDescriptionId, new FightValueProvider(spellData.definition, m_level));
                    int valueWithLevel  = definition.movementPoints.GetValueWithLevel(m_level);
                    int valueWithLevel2 = definition.life.GetValueWithLevel(m_level);
                    int valueWithLevel3 = definition.actionValue.GetValueWithLevel(m_level);
                    m_strengthField.SetText(valueWithLevel3.ToString());
                    m_lifeField.SetText(valueWithLevel2.ToString());
                    m_moveField.SetText(valueWithLevel.ToString());
                }
            }
        }
Пример #18
0
        public override INumber ExecuteDiff(RuntimeData runtime, string t)
        {
            var pow = Runtime.Func.Differential.DiffPow(runtime, t, this);

            runtime.Setting.Logger.AddWarning("Formula型の表現を直接微分はバグってる可能性あり");
            Debugger.Break();

            var res = this.Eval(runtime).ExecuteDiff(runtime, t);

            if (pow != null)
            {
                pow.AddItem(runtime, res);
                return(pow);
            }
            else
            {
                return(res);
            }
        }
Пример #19
0
 public static MultipleFormula DiffPow(RuntimeData runtime, string t, INumber val)
 {
     if (!val.Pow.Equals(runtime, Number.New(1)))
     {
         var res = val.Pow.ExecuteDiff(runtime, t);
         if (!res.Equals(runtime, Number.New(0)))
         {
             // powの所に式が含まれているため対数微分法を使う必要がある
             throw new NotImplementedException("未実装: Powに式が含まれているため対数微分法を使って微分する必要あり");
         }
         else
         {
             MultipleFormula mf = new Expression.MultipleFormula();
             mf.AddItem(runtime, val.Pow);
             return(mf);
         }
     }
     return(null);
 }
Пример #20
0
        public override INumber Add(RuntimeData runtime, INumber val)
        {
            if (val is Number)
            {
                if (this.Pow.Equals(runtime, val.Pow))
                {
                    return(Number.New(this.Value + (val as Number).Value));
                }
                else
                {
                    AdditionFormula af = new Expression.AdditionFormula();
                    af.AddItem(runtime, this);
                    af.AddItem(runtime, val);
                    return(af);
                }
            }

            return(val.Add(runtime, this));
        }
Пример #21
0
        public void Save()
        {
            lock (this.commandLockObject)
            {
                RuntimeData runtimeData = this.RuntimeData;

                XDocument doc = new XDocument(new XDeclaration("1.0", "UTF-8", null));

                XElement runtimeDataEl = new XElement(RUNTIMEDATA_EL);
                runtimeDataEl.Add(new XAttribute(RUNTIMEDATA_VERSION_ATTR, this.tlVersion));
                doc.Add(runtimeDataEl);

                if (!string.IsNullOrWhiteSpace(runtimeData.AccessToken))
                {
                    XElement authEl = new XElement(AUTH_EL);
                    runtimeDataEl.Add(authEl);

                    XElement accessTokenEl = new XElement(AUTH_ACCESSTOKEN_EL);
                    accessTokenEl.SetValue(runtimeData.AccessToken);
                    authEl.Add(accessTokenEl);
                }

                if (runtimeData.MainWindowInfo != null)
                {
                    XElement mainWindowInfoEl = runtimeData.MainWindowInfo.GetXml();

                    if (mainWindowInfoEl.HasElements)
                    {
                        XElement applicationEl = new XElement(APP_EL);
                        applicationEl.Add(mainWindowInfoEl);
                        runtimeDataEl.Add(applicationEl);
                    }
                }

                string appDataFolder = this.folderService.GetAppDataFolder();

                FileSystem.CreateDirectory(appDataFolder);

                string configFile = Path.Combine(appDataFolder, RUNTIMEDATA_FILE);

                doc.Save(configFile);
            }
        }
Пример #22
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("***********************************************");
            System.Console.WriteLine("Welcome to online movie ticket booking system!");
            System.Console.WriteLine("Now let's start choose your favorite movie!");
            System.Console.WriteLine("***********************************************");
            System.Console.WriteLine();
            Movies       movies        = RuntimeData.GetAllMovies();
            int          intMovieIndex = ConsoleController.ChooseFromList <MovieData>(movies.Values, "Movies");
            ScheduleData movieSchedule = RuntimeData.GetMovieSchedule(movies.Values[intMovieIndex].Id);

            System.Console.WriteLine();
            if (movieSchedule == null)
            {
                System.Console.WriteLine($"No schedule for movie <{movies.Values[intMovieIndex].Name}> yet, please be patient.");
            }
            else
            {
                movies.Values[intMovieIndex].ShowMovieDetail();
                System.Console.WriteLine();
                int scheduleIndex = ConsoleController.ChooseFromList <ScheduleDatum>(movieSchedule.Schedule, $"Schedule for movie <{movies.Values[intMovieIndex].Name}>");
                System.Console.WriteLine();
                if (movieSchedule.Schedule[scheduleIndex].SeatAvailable == 0)
                {
                    System.Console.WriteLine($"No seat available!");
                }
                else
                {
                    bool book = ConsoleController.ConfirmationYN("Do you want to book this movie?");
                    System.Console.WriteLine();
                    if (book)
                    {
                        System.Console.WriteLine($"You have successfully booked movie <{movies.Values[intMovieIndex].Name}> at {movieSchedule.Schedule[scheduleIndex].Time}");
                    }
                    else
                    {
                        System.Console.WriteLine("Ticket has not been booked.");
                    }
                }
            }
            ConsoleController.QuitApplication();
        }
Пример #23
0
        public override INumber Multiple(RuntimeData runtime, INumber val)
        {
            if (val is IConstParameter)
            {
                var me = this.Clone() as FloatNumber;
                me.value *= (val as IConstParameter).ConstValue;
                return(me);
            }
            if (val is InfinityValue)
            {
                return(val.Multiple(runtime, this));
            }

            MultipleFormula mf = new MultipleFormula();

            mf.AddItem(runtime, val);
            mf.AddItem(runtime, this);

            return(mf);
        }
Пример #24
0
 private void OnCloneConfirme()
 {
     if (DeckUtility.GetRemainingSlotsForWeapon(m_weapon) != 0)
     {
         m_selectedSlot = m_selectedSlot.Clone(keepPreconstructed: false);
         RuntimeData.TryGetText(92537, out string value);
         m_selectedSlot.SetName(value);
         m_previousSlot             = null;
         m_selectedSlot.DeckInfo.Id = null;
         m_ui.interactable          = true;
         DeckInfo obj = new DeckInfo(m_selectedSlot.DeckInfo)
         {
             Name = RuntimeData.FormattedText(92537),
             Id   = null
         };
         DeckInfo deckInfo = m_selectedSlot.DeckInfo.TrimCopy();
         m_ui.OnCloneValidate(m_selectedSlot);
         m_frame.SendSaveSquadRequest(deckInfo.Id, deckInfo.Name, (Family)deckInfo.God, deckInfo.Weapon, (IReadOnlyList <int>)deckInfo.Companions, (IReadOnlyList <int>)deckInfo.Spells);
     }
 }
Пример #25
0
        public override bool Equals(RuntimeData runtime, INumber val)
        {
            var me = this.Eval(runtime);

            if (me is Variable && val is Variable)
            {
                Variable m = me as Variable, v = val as Variable;
                if (m.Name == v.Name &&
                    m.multi.Equals(runtime, v.multi) &&
                    m.Pow.Equals(runtime, v.Pow))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false); // 正確には一致しているか分からない
        }
Пример #26
0
        public override INumber Execute(RuntimeData runtime, params INumber[] parameters)
        {
            var l = parameters[0].FinalEval(runtime);
            var r = parameters[1].FinalEval(runtime);

            if (!(l is IConstParameter && r is IConstParameter))
            {
                throw new RuntimeException("パラメータは値である必要があります。",
                                           l is IConstParameter ? r : l);
            }

            if ((l as IConstParameter).ConstValue > (r as IConstParameter).ConstValue)
            {
                return(parameters[1]);
            }
            else
            {
                return(parameters[0]);
            }
        }
Пример #27
0
        public override INumber ForceExecute(RuntimeData runtime, params INumber[] parameters)
        {
            var param = parameters[1].FinalEval(runtime);
            var Base  = parameters[0].FinalEval(runtime);

            if (parameters[0] is NaturalLogarithm &&
                parameters[0].Pow is Number &&
                (parameters[0].Pow as Number).Value == 1)
            {
                return(new FloatNumber((decimal)(System.Math.Log(
                                                     (double)(param as IConstParameter).ConstValue))));
            }
            if (runtime.IsConstValue(param) && runtime.IsConstValue(Base))
            {
                return(new FloatNumber((decimal)(System.Math.Log(
                                                     (double)(param as IConstParameter).ConstValue,
                                                     (double)(Base as IConstParameter).ConstValue))));
            }
            return(param);
        }
Пример #28
0
        public void AddItem(RuntimeData runtime, INumber val)
        {
            var v = val.Eval(runtime);

            if (v is Number && (val as Number).Value == 0)
            {
            }
            else if (v is AdditionFormula &&
                     (v.Pow is Number && (v.Pow as Number).Value == 1))
            {
                foreach (var item in (val as AdditionFormula).items)
                {
                    this.items.Add(item);
                }
            }
            else
            {
                this.items.Add(v);
            }
        }
Пример #29
0
        public void Save()
        {
            lock (this.commandLockObject)
            {
                RuntimeData runtimeData = this.RuntimeData;

                XDocument doc = new XDocument(new XDeclaration("1.0", "UTF-8", null));

                XElement runtimeDataEl = runtimeData.GetXml();

                doc.Add(runtimeDataEl);

                string appDataFolder = this.folderService.GetAppDataFolder();

                FileSystem.CreateDirectory(appDataFolder);

                string configFile = Path.Combine(appDataFolder, RUNTIMEDATA_FILE);

                doc.Save(configFile);
            }
        }
Пример #30
0
        private static object Union(RuntimeData thisRuntime, RuntimeData thatRuntime)
        {
            foreach (KeyValuePair <string, JsonDictionary <Version, ModuleData> > moduleVersions in thatRuntime.Modules)
            {
                if (!thisRuntime.Modules.ContainsKey(moduleVersions.Key))
                {
                    thisRuntime.Modules.Add(moduleVersions.Key, moduleVersions.Value);
                    continue;
                }

                thisRuntime.Modules[moduleVersions.Key] = DictionaryUnion(thisRuntime.Modules[moduleVersions.Key], moduleVersions.Value, Union);
            }

            thisRuntime.NativeCommands = StringDictionaryUnion(thisRuntime.NativeCommands, thatRuntime.NativeCommands, ArrayUnion);

            thisRuntime.Common = (CommonPowerShellData)Union(thisRuntime.Common, thatRuntime.Common);

            Union(thisRuntime.Types, thatRuntime.Types);

            return(thisRuntime);
        }