Exemplo n.º 1
0
        private void AddDetailsFromMetadata()
        {
            var items = AutocompletionData.GetAutocompleteItemsForScripting();

            items = items.Distinct(new AutocompleteItemEqualityComparer()).ToArray();
            foreach (var item in items)
            {
                if (!_details.ContainsKey(item.Text))
                {
                    _details.Add(item.Text,
                                 item.Info);
                }
            }
        }
Exemplo n.º 2
0
        //TODO: this function should create new functions file with all it's previous content and empty spaces for new functions which exists in ElementaryFuntions, SpecialFunctions etc but not in the xml file yet
        public void SaveEmptyFunctionDetailsToXmlFile()
        {
            //var _details = new Dictionary<string, FunctionInfo>();
            //foreach (var item in sourceItems)
            //_details.Add(item.FunctionInfo.Signature, item.FunctionInfo);

            var serializer = new XmlSerializer(typeof(FunctionInfo[]),
                                               new XmlRootAttribute("FunctionsDetails"));
            var stream = new StreamWriter("functions_empty_saved.xml");


            var detailsWithEmpties = new Dictionary <string, FunctionInfo>();

            var items = AutocompletionData.GetAutocompleteItemsForScripting();

            items = items.Distinct(new AutocompleteItemEqualityComparer()).ToArray();
            foreach (var item in items)
            {
                //if(!_details.ContainsKey(item.Text))
                detailsWithEmpties.Add(item.Text,
                                       _details.ContainsKey(item.Text) ? _details[item.Text] : item.Info);
            }


            serializer.Serialize(stream,
                                 detailsWithEmpties.Select(kv =>
                                                           new FunctionInfo
            {
                Signature   = kv.Key,
                Url         = kv.Value.Url,
                Description = ToHtmlXmlEncoded(kv.Value.Description),
                Title       = kv.Value.Title,
                Category    = kv.Value.Category,
                Type        = kv.Value.Type
            }).ToArray());
            stream.Close();

            var sss = File.ReadAllText("functions_empty_saved.xml");

            sss = sss.Replace(@"&gt;", @">");
            sss = sss.Replace(@"&lt;", @"<");
            File.WriteAllText("functions_empty_saved.xml", sss);
        }