コード例 #1
0
        public static OverrideRule Create(WebObjectLibrary lib, string path)
        {
            var    context = findeOverrideTargetObject(lib, path);
            object cObj    = context.source;

            if (context.subPath[0] == "id" || context.subPath[0] == "category")
            {
                MessageBox.Show("The 'id' and 'category' types are now allowed to be overridden", "Invalid Request", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
            else
            {
                /// Decided these objects really are not deep enough to drill down this much
                //foreach (string prop in context.subPath)
                //{
                //    if (cObj.GetType().IsArray)
                //    {
                //        int index = Convert.ToInt32(prop.TrimStart('[').TrimEnd(']'));
                //        cObj = (cObj as object[])[index];
                //    }
                //    else
                //        cObj = cObj.GetType().GetProperty(prop).GetValue(cObj);
                //}

                return(new OverrideRule()
                {
                    fullSelectedPath = path,
                    targetProperty = context.subPath.First(),
                    id = context.source.id,
                    jsonValue = cObj.GetType().GetProperty(context.subPath[0]).GetValue(cObj).toJSON(Newtonsoft.Json.Formatting.Indented),
                    notes = "Why?"
                });
            }
        }
コード例 #2
0
        private void btnScrapeAllContent_Click(object sender, RoutedEventArgs e)
        {
            WebObjectLibrary ejoLib = new WebObjectLibrary();

            foreach (var key in CatagorizedLinks.Keys)
            {
                foreach (var link in CatagorizedLinks[key])
                {
                    var filePath = dataFolder + Enum.GetName(linkCategory.NotUsed.GetType(), link.category) + "\\" + link.guid + ".html";
                    if (System.IO.File.Exists(filePath) == true)
                    {
                        ScrapeDocument doc   = new ScrapeDocument(filePath, link);
                        List <string>  enums = new List <string>();
                        foreach (ejoHelpEntity item in doc.items)
                        {
                            switch (item.category)
                            {
                            case ejoCategory.OBJECT:
                                if (ejoLib.objects.ContainsKey(item.id.ToLower()) == false)
                                {
                                    ejoLib.objects.Add(item.id.ToLower(), (ejoObject)item);
                                }
                                break;

                            case ejoCategory.FUNCTION:
                            case ejoCategory.METHOD:
                                var meth = (ejoFunction)item;
                                if (doc.items.Count == 1 && ejoLib.functions.ContainsKey(item.id.ToLower()) == false)
                                {
                                    ejoLib.functions.Add(item.id.ToLower(), meth);
                                }
                                else if (doc.items.Count >= 2 && ejoLib.ambiguousFunctions.ContainsKey(item.id.ToLower()) == false)
                                {
                                    ejoLib.ambiguousFunctions.Add(item.id.ToLower(), new List <ejoFunction>()
                                    {
                                        meth
                                    });
                                }
                                else if (doc.items.Count >= 2 && ejoLib.ambiguousFunctions.ContainsKey(item.id.ToLower()) == true)
                                {
                                    ejoLib.ambiguousFunctions[item.id.ToLower()].Add(meth);
                                }
                                foreach (ejoValueType val in meth.arguments.Concat(new[] { meth.returnType }).ToArray())
                                {
                                    foreach (var eId in val.enums)
                                    {
                                        if (ejoLib.enumerators.ContainsKey(eId.ToLower()) == false && eId.Length >= 4 && eId.ToLower() != "vlax:true" && eId.ToLower() != "vlax:false")
                                        {
                                            ejoLib.enumerators.Add(eId.ToLower(), item.id.ToLower());
                                        }
                                    }
                                }
                                break;

                            case ejoCategory.PROPGETTER:
                            case ejoCategory.PROPSETTER:
                                var func = (ejoFunction)item;
                                if (ejoLib.functions.ContainsKey(item.id.ToLower()) == false)
                                {
                                    ejoLib.functions.Add(item.id.ToLower(), func);
                                }
                                foreach (ejoValueType val in func.arguments.Concat(new[] { func.returnType }).ToArray())
                                {
                                    foreach (var eId in val.enums)
                                    {
                                        if (ejoLib.enumerators.ContainsKey(eId.ToLower()) == false && eId.Length >= 4 && val.primitive == "enum")
                                        {
                                            ejoLib.enumerators.Add(eId.ToLower(), item.id.ToLower());
                                        }
                                    }
                                }
                                break;

                            case ejoCategory.DCLTILE:
                                if (ejoLib.dclTiles.ContainsKey(item.id.ToLower()) == false)
                                {
                                    ejoLib.dclTiles.Add(item.id.ToLower(), (ejoTile)item);
                                }
                                break;

                            case ejoCategory.DCLATT:
                                if (ejoLib.dclAttributes.ContainsKey(item.id.ToLower()) == false)
                                {
                                    ejoLib.dclAttributes.Add(item.id.ToLower(), (ejoAttribute)item);
                                }
                                break;

                            case ejoCategory.EVENT:
                                if (ejoLib.events.ContainsKey(item.id.ToLower()) == false)
                                {
                                    ejoLib.events.Add(item.id.ToLower(), (ejoEvent)item);
                                }
                                break;
                            }
                        }
                    }
                }
            }
            ejoLib.Pack(ioPathHelpAbstraction);
            tabInterface.SelectedIndex += 1;
        }
コード例 #3
0
        public static (ejoHelpEntity source, string[] subPath) findeOverrideTargetObject(WebObjectLibrary lib, string fullPath)
        {
            string[]      points  = fullPath.Split(',');
            ejoHelpEntity ent     = null;
            int           skipQty = 2;

            switch (points[0])
            {
            case nameof(lib.dclAttributes): ent = lib.dclAttributes[points[1]]; break;

            case nameof(lib.dclTiles): ent = lib.dclTiles[points[1]]; break;

            case nameof(lib.events): ent = lib.events[points[1]]; break;

            case nameof(lib.functions): ent = lib.functions[points[1]]; break;

            case nameof(lib.objects): ent = lib.objects[points[1]]; break;

            case nameof(lib.ambiguousFunctions):
                ent     = lib.ambiguousFunctions[points[1]][Convert.ToInt32(points[2].Substring(1, 1))];
                skipQty = 3;
                break;
            }
            return(ent, points.Skip(skipQty).ToArray());
        }