Example #1
0
 public InMemBlob(Dictionary<string, string> metadata, byte[] data)
 {
     if (metadata == null) throw new ArgumentNullException(nameof(metadata));
     if (data == null) throw new ArgumentNullException(nameof(data));
     Metadata = metadata.Clone();
     Data = data;
 }
        public void ApplicationModel_with_one_aspect_Can_Be_Saved()
        {
            var dictionary1 = new Dictionary(new DictionaryXmlReader().ReadFromString("<Application><BOModel><Class Name=\"MyClass\" Caption=\"Default\"></Class><Class Name=\"MyClass2\" Caption=\"Default\"></Class></BOModel></Application>"),Schema.GetCommonSchema());
            var dictionary =dictionary1.Clone();
            var elDict = new Dictionary(new DictionaryXmlReader().ReadFromString("<Application><BOModel><Class Name=\"MyClass\" Caption=\"elDefault\" AttributeWithOnlyAspect=\"something\"></Class><Class Name=\"MyClass2\" Caption=\"Default\"></Class></BOModel></Application>"), Schema.GetCommonSchema());
            dictionary.AddAspect("el", elDict.RootNode);
            var application =Isolate.Fake.Instance<DifferenceObject>(Members.CallOriginal, ConstructorWillBe.Called,Session.DefaultSession);
            application.Model = dictionary;
            application.Save();

            application.Reload();

            Assert.AreEqual(dictionary1.RootNode.ToXml(), new DictionaryXmlReader().ReadFromString(new DictionaryXmlWriter().GetAspectXML(DictionaryAttribute.DefaultLanguage, application.Model.RootNode)).ToXml());
            Assert.AreEqual(elDict.RootNode.ToXml(), new DictionaryXmlReader().ReadFromString(new DictionaryXmlWriter().GetAspectXML("el", application.Model.RootNode)).ToXml());
        }
        public void Model_With_UpDownDotSymbol_Inside_AttributeValue_Is_Valid()
        {
            string ss = "{0:ProductName}<br>{0:Version}<br><br>{0:Copyright}<br><br>{0:Company}<br><br>{0:Description}".XMLEncode();
            string formatStr = "<Application><Views><DetailView><Items><StaticText ID=\"AboutText\" Text=\"" +ss+ "\"/></Items></DetailView></Views></Application>";
            DictionaryNode readFromString = new DictionaryXmlReader().ReadFromString(formatStr);
            var dictionary1 = new Dictionary(readFromString, Schema.GetCommonSchema());
            var differenceObject = Isolate.Fake.Instance<DifferenceObject>(Members.CallOriginal, ConstructorWillBe.Called, Session.DefaultSession);
            differenceObject.Model=dictionary1.Clone();
            differenceObject.Save();

            differenceObject.Reload();

            Assert.AreEqual(dictionary1.RootNode.ToXml(), differenceObject.Model.RootNode.ToXml());
            
        }
        public void Test()
        {
            const string elXml = "<Application><BOModel><Class Name=\"MyClass\" Caption=\"el&amp;caption\"></Class></BOModel></Application>";
            const string xml = "<Application><BOModel><Class Name=\"MyClass\" Caption=\"capt&quot;ion\"></Class></BOModel></Application>";
            var elDict = new Dictionary(new DictionaryXmlReader().ReadFromString(elXml), Schema.GetCommonSchema());
            var dict = new Dictionary(new DictionaryXmlReader().ReadFromString(xml), Schema.GetCommonSchema());
            Dictionary dictionary = dict.Clone();
            dictionary.AddAspect("el", elDict.RootNode);

            var dictionaryHelper = new DictionaryHelper();
            string aspectFromXml = dictionaryHelper.GetAspectFromXml(new List<string> { "el" }, dictionary.RootNode);

            Assert.AreEqual(dict.RootNode.ToXml(), new DictionaryXmlReader().ReadFromString(aspectFromXml).ToXml());
//            Assert.AreEqual(elDict.RootNode.ToXml(), new DictionaryXmlReader().ReadFromString(dictionaryHelper.AspectValues["el"]).ToXml());


        }
Example #5
0
        public Experience GetExperience(Dictionary<ExperienceFactor, int> factors, bool addIfMissing = false)
        {
            foreach (var exp in Experiences)
            {
                if (exp.Levels.Contains(factors, true))
                {
                    return exp;
                }
            }

            if (addIfMissing)
            {
                Experiences.Add(new Experience
                {
                    Number = Experiences.Count,
                    Levels = factors.Clone()
                });

                return Experiences[Experiences.Count - 1];
            }

            throw new KeyNotFoundException("No such experience");
        }
Example #6
0
 public Dictionary GetCombinedModel(Dictionary dictionary)
 {
     Dictionary clone = dictionary.Clone();
     clone.ResetIsModified();
     clone.CombineWith(Model);
     return clone;
 }
 Dictionary GetCombinedModel(Dictionary dictionary, bool isSaving) {
     Dictionary clone = dictionary.Clone();
     clone.ResetIsModified();
     if (!isSaving)
         clone.CombineWith(Model);
     return clone;
 }
Example #8
0
        /// <summary>
        /// Create some preset filters
        /// </summary>
        /// <returns></returns>
        private IEnumerable<Preset> CreatePresets()
        {
            Dictionary<string, bool> All = new Dictionary<string, bool>();
            foreach (Control c in this.Controls)
                if (c is CheckBox)
                    All[c.Text] = true;
            yield return new Preset() { Name = "All", Filter = All };

            Dictionary<string, bool> None = new Dictionary<string, bool>();
            foreach (Control c in this.Controls)
                if (c is CheckBox)
                    None[c.Text] = false;
            yield return new Preset() { Name = "None", Filter = None };

            Dictionary<string, bool> LessVerbose = All.Clone();
            LessVerbose["GameTickMessage"] = false;
            LessVerbose["TrickleMessage"] = false;
            LessVerbose["ACDTranslateFacingMessage"] = false;
            yield return new Preset() { Name = "Less verbose", Filter = LessVerbose };

            Dictionary<string, bool> Questing = None.Clone();
            Questing["QuestCounterMessage"] = true;
            Questing["QuestMeterMessage"] = true;
            Questing["QuestUpdateMessage"] = true;
            Questing["WorldTargetMessage"] = true;
            yield return new Preset() { Name = "Questing", Filter = Questing };

            Dictionary<string, bool> Conversation = None.Clone();
            Conversation["PlayConvLineMessage"] = true;
            Conversation["FinishConversationMessage"] = true;
            Conversation["EndConversationMessage"] = true;
            Conversation["RequestCloseConversationWindowMessage"] = true;
            Conversation["StopConvLineMessage"] = true;
            Conversation["WorldTargetMessage"] = true;

            yield return new Preset() { Name = "Conversation", Filter = Conversation };
 
        }
Example #9
0
        private Dictionary<string, NodeInfo> GetNodeFactors(ConfigNode node, Dictionary<string, NodeInfo> source)
        {
            var result = source.Clone();

            if (node != null)
            {
                foreach (var v in node.values.Cast<ConfigNode.Value>())
                {
                    result[v.name] = new NodeInfo(v.value);
                }
            }

            if (!result.ContainsKey("base"))
            {
                result["base"] = new NodeInfo(Family, 1.0f);
            }

            return result;
        }
        public void Application_Model_With_More_Than_one_Aspect_And_Spaces_Between_Attribute_Values_Can_Be_Saved(){
            const string defaultS = "ProtectedContentText=\"Protected Content\" PreferredLanguage=\"el\" VersionFormat=\"Version {0}.{1}.{2}\" Title=\"Solution1\" Logo=\"ExpressAppLogo\" Company=\"Endligh\" WebSite=\"1\" CanClose=\"True\" ";
            var dictionary1 = new Dictionary(new DictionaryXmlReader().ReadFromString("<Application "+defaultS + "><BOModel><Class Name=\"MyClass2\" Caption=\"Default\"></Class></BOModel></Application>"), Schema.GetCommonSchema());
            Dictionary dictionary = dictionary1.Clone();
            dictionary1.AddAspect("el", new DictionaryXmlReader().ReadFromString("<Application Company=\"Greek\"></Application>"));
            var application = Isolate.Fake.Instance<DifferenceObject>(Members.CallOriginal, ConstructorWillBe.Called, Session.DefaultSession);
            application.Model=dictionary1;
            application.Save();

            application.Reload();


            var dictionaryXmlWriter = new DictionaryXmlWriter();
            Assert.AreEqual(dictionary.RootNode.ToXml(), new DictionaryXmlReader().ReadFromString(dictionaryXmlWriter.GetAspectXML(DictionaryAttribute.DefaultLanguage, application.Model.RootNode)).ToXml());
        }