Пример #1
0
        public void Update(string path, [Optional] Ev3DModelImportOptions options)
        {
            // Prepare arguments.
            Dict args = new Dict();

            args.Add("obj_id", Id);
            args.Add("path", path);

            if (options != null)
            {
                args.Add("options", new Dict()
                {
                    { "tesselation_quality", options.TesselationQuality },
                    { "use_brep", options.UseBrep },
                    { "fit_to_page", options.FitToPage }
                });
            }

            // Prepare command.
            Dict cmd = new Dict()
            {
                { "type", "cmd" },
                { "cmd", "obj.3d_model.update" },
                { "args", args }
            };

            // Issue command.
            Dict output = _conn.IssueCommand(cmd);
        }
Пример #2
0
        internal static Symbol GetSymbol(Guid guid)
        {
            int id;
            var locked = false;

            try
            {
                s_lock.Enter(ref locked);
                if (!s_guidDict.TryGetValue(guid, out id))
                {
                    id = s_allStrings.Count;
                    var str = guid.ToString();
                    s_guidDict.Add(guid, id);
                    s_stringDict.Add(str, id);
                    s_allStrings.Add(str);
                    s_allGuids.Add(guid);
                }
            }
            finally { if (locked)
                      {
                          s_lock.Exit();
                      }
            }
            return(new Symbol(id));
        }
Пример #3
0
        public void TestDictionaryGetException()
        {
            var d = new Dict <int, int>();

            d.Add(1, 2);
            d.Add(2, 3);
            d.Get(3);
        }
Пример #4
0
        /// <summary>
        /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换
        /// </summary>
        public void OpenView(string rViewName, GameObject rViewPrefab, View.State rViewState, Action <View> rOpenCompleted)
        {
            if (rViewPrefab == null)
            {
                return;
            }

            //把View的GameObject结点加到rootCanvas下
            GameObject rViewGo = this.RootCanvas.transform.AddChild(rViewPrefab, "UI");

            View rView = View.CreateView(rViewGo);

            if (rView == null)
            {
                Debug.LogErrorFormat("GameObject {0} has not View script.", rViewGo.name);
                UtilTool.SafeExecute(rOpenCompleted, null);
                return;
            }

            //生成GUID
            string rViewGUID = Guid.NewGuid().ToString();

            //为View的初始化设置
            rView.Initialize(rViewName, rViewGUID, rViewState);

            //新的View的存储逻辑
            switch (rView.CurState)
            {
            case View.State.fixing:
                mCurFixedViews.Add(rViewGUID, rView);
                break;

            case View.State.overlap:
                mCurViews.Add(rViewGUID, rView);
                break;

            case View.State.dispatch:
                if (mCurViews.Count == 0)
                {
                    mCurViews.Add(rViewGUID, rView);
                }
                else
                {
                    mCurViews[mCurViews.LastKey()] = rView;
                }
                break;

            default:
                break;
            }

            rView.Open((rNewView) =>
            {
                UnloadUnusedViewAssets();
                UtilTool.SafeExecute(rOpenCompleted, rNewView);
            });
        }
Пример #5
0
        public void TestDictionaryToString()
        {
            var d = new Dict <int, int>();

            d.Add(1, 2);
            d.Add(2, 3);

            Assert.AreEqual("{2 => 3, 1 => 2}", d.ToString());
        }
        private static void ReleaseStatsUpdated(
            Client client,
            string runId,
            string userId,
            DateTime eventTime,
            // User properties
            long totalReleasesAlbumSold,
            long totalReleasesAssetSold,
            long totalReleasesAssetSoldIndividually,
            long totalReleasesAssetSoldThroughAlbum,
            long totalReleasesAssetStreamed,
            // Event properties
            long albumSold,
            long assetSold,
            long assetSoldIndividually,
            long assetSoldThroughAlbum,
            long assetStreamed
            )
        {
            var segmentContext = new Context()
            {
                { "active", false },
                { "app", new Dict()
                  {
                      { "name", "Backend" },
                  } }
            };

            var options = new Options()
                          .SetTimestamp(eventTime)
                          .SetContext(segmentContext);

            var userProperties = new Dict();

            userProperties.Add("L - Total Releases Album Sold", totalReleasesAlbumSold);
            userProperties.Add("L - Total Releases Asset Sold", totalReleasesAssetSold);
            userProperties.Add("L - Total Releases Asset Sold (Individually)", totalReleasesAssetSoldIndividually);
            userProperties.Add("L - Total Releases Asset Sold (Through Album)", totalReleasesAssetSoldThroughAlbum);
            userProperties.Add("L - Total Releases Asset Streamed", totalReleasesAssetStreamed);

            client.Identify(userId, userProperties, options);

            var eventProperties = new Dict();

            eventProperties.Add("L - Event Category", runId);
            eventProperties.Add("L - Album Sold", albumSold);
            eventProperties.Add("L - Asset Sold", assetSold);
            eventProperties.Add("L - Asset Sold (Individually)", assetSoldIndividually);
            eventProperties.Add("L - Asset Sold (Through Album)", assetSoldThroughAlbum);
            eventProperties.Add("L - Asset Streamed", assetStreamed);
            eventProperties.Add("category", "Release");

            client.Track(userId, "Release Stats Updated", eventProperties, options);
        }
Пример #7
0
        public void TestDictionaryGet()
        {
            var d = new Dict <int, int>();

            d.Add(1, 2);
            d.Add(2, 3);
            d.Add(1, 4);

            Assert.IsTrue(d.ContainsKey(1));
            Assert.IsTrue(d.ContainsKey(2));
            Assert.IsFalse(d.ContainsKey(3));
        }
Пример #8
0
        /// <summary>
        /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换
        /// </summary>
        private void OpenView(GameObject rViewPrefab, View.State rViewState, Action <View> rOpenCompleted)
        {
            if (rViewPrefab == null)
            {
                return;
            }

            //把View的GameObject结点加到rootCanvas下
            GameObject rViewGo = this.rootCanvas.transform.AddChild(rViewPrefab, "UI");

            View rView = rViewGo.SafeGetComponent <View>();

            if (rView == null)
            {
                Debug.LogErrorFormat("GameObject {0} has not View script.", rViewGo.name);
                UtilTool.SafeExecute(rOpenCompleted, null);
                return;
            }

            //生成GUID
            string rViewGUID = Guid.NewGuid().ToString();

            //为View的初始化设置
            rView.Initialize(rViewGUID, rViewState);

            //新的View的存储逻辑
            switch (rView.curState)
            {
            case View.State.fixing:
                curFixedViews.Add(rViewGUID, rView);
                break;

            case View.State.overlap:
                curViews.Add(rViewGUID, rView);
                break;

            case View.State.dispatch:
                if (curViews.Count == 0)
                {
                    curViews.Add(rViewGUID, rView);
                }
                else
                {
                    curViews[curViews.LastKey()] = rView;
                }
                break;

            default:
                break;
            }

            rView.Open(rOpenCompleted);
        }
Пример #9
0
 public void ItShouldAdd()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     bool actual = test.ContainsKey(1);
     bool expected = true;
     Assert.AreEqual(expected, actual);
 }
Пример #10
0
        public EvObject InsertImage(
            string path,
            [Optional] EvPoint pos,
            [Optional] EvSize size,
            [Optional] EnvOptions envOpt)
        {
            // Prepare arguments.
            Dict args = new Dict();

            args.Add("path", path);

            if (pos != null)
            {
                args.Add("pos", new Dict()
                {
                    { "x", pos.X },
                    { "y", pos.Y }
                });
            }

            if (pos != null)
            {
                args.Add("size", new Dict()
                {
                    { "w", size.W },
                    { "h", size.H }
                });
            }

            if (envOpt != null)
            {
                args.Add("env_opt", new Dict()
                {
                    { "units", envOpt.Units }
                });
            }

            // Prepare command.
            Dict cmd = new Dict()
            {
                { "type", "cmd" },
                { "cmd", "insert.image" },
                { "args", args }
            };

            // Issue command.
            Dict output = _conn.IssueCommand(cmd);

            // Process output.
            string id = (string)Convert.ToDictionary(output["obj"])["id"];

            return(new EvObject(id, _conn));
        }
Пример #11
0
        private Dict median(double[] chaine, double conf)
        {
            Array.Sort(chaine);
            var    med = new Dict();
            double est = chaine[chaine.Length / 2];
            double lcl = new Quantile((100 - conf) / 200).Compute(chaine)[0];
            double ucl = new Quantile(1 - (100 - conf) / 200).Compute(chaine)[0];

            med.Add("est", est);
            med.Add("lcl", lcl);
            med.Add("ucl", ucl);
            return(med);
        }
Пример #12
0
        /// <summary>
        /// (Re)initialize the debugger. This method must
        /// be called whenever a program is compiled.
        /// </summary>
        /// <param name="scene"></param>
        public static void Initilize(Dict scene)
        {
            // allocate GPU resources
            buf = new GLBuffer(DbgBufKey, "dbg", BufferUsageHint.DynamicRead, stage_size * 6 * 16);
            tex = new GLTexture(DbgTexKey, "dbg", GpuFormat.Rgba32f, buf, null);

#if DEBUG   // add to scene for debug inspection
            scene.Add(DbgBufKey, buf);
            scene.Add(DbgTexKey, tex);
#endif
            passes.Clear();
            // reset watch count for indexing in debug mode
            dbgVarCount = 0;
        }
Пример #13
0
        public void Dict_Test1()
        {
            var rDict1 = new Dict <string, A>();

            rDict1.Add("xxx1", new A()
            {
                A1 = 1, A2 = 10000000000, A3 = "XXX1"
            });
            rDict1.Add("xxx2", new A()
            {
                A1 = 2, A2 = 20000000000, A3 = "XXX2"
            });
            rDict1.Add("xxx3", new A()
            {
                A1 = 3, A2 = 30000000000, A3 = "XXX3"
            });

            Assert.AreEqual(rDict1["xxx1"].A1, 1);
            Assert.AreEqual(rDict1["xxx2"].A2, 20000000000);
            Assert.AreEqual(rDict1["xxx3"].A3, "XXX3");

            LogAssert.Expect(LogType.Log, "1, 10000000000, XXX1");
            LogAssert.Expect(LogType.Log, "2, 20000000000, XXX2");
            LogAssert.Expect(LogType.Log, "3, 30000000000, XXX3");

            foreach (var rPair in rDict1)
            {
                Debug.Log(rPair.Value.A1 + ", " + rPair.Value.A2 + ", " + rPair.Value.A3);
            }

            A rA1 = null;

            Assert.AreEqual(rDict1.TryGetValue("xxx1", out rA1), true);
            Assert.AreEqual(rA1.A3, "XXX1");

            A rA4 = null;

            Assert.AreEqual(rDict1.TryGetValue("xxx4", out rA4), false);

            Assert.AreEqual(rDict1.FirstKey(), "xxx1");
            Assert.AreEqual(rDict1.FirstValue().A3, "XXX1");

            Assert.AreEqual(rDict1.LastKey(), "xxx3");
            Assert.AreEqual(rDict1.LastValue().A2, 30000000000);

            Assert.AreEqual(rDict1.Count, 3);

            rDict1.Clear();
            Assert.AreEqual(rDict1.Count, 0);
        }
Пример #14
0
        public virtual HResult OnStatus(Request r)
        {
            r.res.StatusCode      = 200;
            r.res.ContentEncoding = Encoding.UTF8;
            r.res.ContentType     = "application/json";
            var data  = new Dict();
            var tasks = new Dict();

            tasks.Add("queued", TaskPool.Shared.Queued.Count);
            tasks.Add("running", TaskPool.Shared.Running.Count);
            data.Add("tasks", tasks.data);
            data.Add("word_c", WordCov.Cached.Count);
            r.WriteLine(Json.stringify(data.data));
            r.Flush();
            return(HResult.HRES_RETURN);
        }
 static DictionaryIntIntSerializationBenchmark()
 {
     for (int i = 0; i < 100000; i++)
     {
         Dict.Add(int.MaxValue - i, int.MaxValue);
     }
 }
Пример #16
0
    static List<AssetBundleBuild> GeneratorAssetbundleEntry()
    {
        string path = Application.dataPath + "/" + PackagePlatform.packageConfigPath;
        if (string.IsNullOrEmpty(path)) return null;

        string str = File.ReadAllText(path);

        Dict<string, ABEntry> abEntries = new Dict<string, ABEntry>();

        PackageConfig apc = JsonUtility.FromJson<PackageConfig>(str);

        AssetBundlePackageInfo[] bundlesInfo = apc.bundles;

        for (int i = 0; i < bundlesInfo.Length; i++)
        {
            ABEntry entry = new ABEntry();
            entry.bundleInfo = bundlesInfo[i];

            if (!abEntries.ContainsKey(entry.bundleInfo.name))
            {
                abEntries.Add(entry.bundleInfo.name, entry);
            }
        }

        List<AssetBundleBuild> abbList = new List<AssetBundleBuild>();
        foreach (var rEntryItem in abEntries)
        {
            abbList.AddRange(rEntryItem.Value.ToABBuild());
        }
        return abbList;
    }
 static DictionaryStringIntSerializationBenchmark()
 {
     for (int i = 0; i < 100000; i++)
     {
         Dict.Add(i.ToString(), i);
     }
 }
Пример #18
0
    public void ParserCSV(string content)
    {
        string[] row         = content.Split(new char[] { '\n' });
        string[] columnHeads = row[0].Split(new char[] { ',' });


        for (int i = 1; i < row.Length; i++)
        {
            Dict <string, string> rowDict = new Dict <string, string>();
            string[] column = row[i].Split(new char[] { ',' });

            for (int j = 0; j < columnHeads.Length; j++)
            {
                if (!String.IsNullOrEmpty(column[j]))
                {
                    rowDict.Add(columnHeads[j], column[j]);
                }
                else
                {
                    Debug.Log("file error");
                }
            }
            this.table.AddRow(column[0], rowDict);
        }
    }
Пример #19
0
        private void handleQueue(AsyncRequestQueue q, int cnt)
        {
            Stopwatch w = new Stopwatch();

            w.Start();
            Dict <int, int> dict = new Dict <int, int>(cnt);

            for (int i = 0; i < cnt; i++)
            {
                dict.Add(i, -1);

                AsyncElt popped = (AsyncElt)q.PushAndOptionalPop(new AsyncElt(i));
                processPopped(dict, popped);
            }
            while (true)
            {
                AsyncElt popped = (AsyncElt)q.Pop();
                if (popped == null)
                {
                    break;
                }
                processPopped(dict, popped);
            }

            Assert.AreEqual(cnt, dict.Count);

            foreach (var kvp in dict)
            {
                Assert.AreEqual(2 * kvp.Key, kvp.Value, "value for {0} was {1}", kvp.Key, kvp.Value);
            }
            Console.WriteLine("Elapsed: {0}ms for q={1}", w.ElapsedMilliseconds, q);
        }
Пример #20
0
        /// <summary>
        /// 初始化存放称量值
        /// </summary>
        public void InitWeighList()
        {
            if (Dict.Count > 0)
            {
                return;
            }
            int          groupsNum = Convert.ToInt32(groups);
            int          countsNum = Convert.ToInt32(counts);
            Weigh        w         = null;
            List <Weigh> list      = null;

            for (int i = 1; i <= groupsNum; i++)
            {
                list = new List <Weigh>();
                for (int j = 1; j <= countsNum; j++)
                {
                    w = new Weigh(j, i, 0, 0, this);
                    list.Add(w);
                }
                if (!Dict.ContainsKey(i))
                {
                    Dict.Add(i, list);
                }
            }
        }
Пример #21
0
        public void setDict(string input)
        {
            //count letters frequency
            foreach (char currentChar in input)
            {
                if (Dict.ContainsKey(currentChar))
                {
                    Dict[currentChar]++;
                }
                else
                {
                    Dict.Add(currentChar, 1);
                }
            }

            List <KeyValuePair <char, int> > sortedlist = Dict.ToList();
            var sorted = from entry in Dict orderby entry.Value
                         descending select entry;

            StreamWriter wr2 = new StreamWriter("dictionary.txt");

            foreach (KeyValuePair <char, int> entry in sorted)
            {
                wr2.WriteLine(entry);
            }
            wr2.Close();
        }
Пример #22
0
        public void Working()
        {
            foreach (var type in Codes)
            {
                DataOne one = new DataOne();
                foreach (var val in SFS)
                {
                    ReadData(new string[] {
                        string.Format("Select SUM(PZYDMJ),SUM(YDZMJ),SUM(WJPZYDMJ),SUM(JZZMJ),SUM(JZZDMJ),SUM(WPZJZMJ),SUM(WPZJZZDMJ),SUM(TDDJMJ),SUM(DYMJ),SUM(CZQYSL) from GYYD_YDDW where HYDM='{0}' AND SFGSQY='{1}' AND TDSYQK='1'", type, val),
                        string.Format("Select COUNT(*) from GYYD_YDDW where SFGXQY='是' AND HYDM='{0}' AND SFGSQY='{1}' AND TDSYQK='1'", type, val),
                        string.Format("Select SUM(CYRS),SUM(LJGDZCTZ),SUM(YDL2012),SUM(YDL2013),SUM(YDL2014),SUM(GSRKSS2012),SUM(GSRKSS2013),SUM(GSRKSS2014),SUM(DSRKSS2012),SUM(DSRKSS2013),SUM(DSRKSS2014),SUM(ZYYSR2012),SUM(ZYYSR2013),SUM(ZYYSR2014) from GYYD_YDDW where  HYDM='{0}' AND SFGSQY='{1}' AND TDSYQK='1'", type, val)
                    });
                    DataBase database = Translate(queue) / 10000;
                    switch (val)
                    {
                    case "是":
                        one.Up = database;
                        break;

                    case "否":
                        one.Down = database;
                        break;
                    }
                }
                Dict.Add(type, one);
                Sum = Sum + one;
            }
        }
        /// <summary>
        /// setup root and dictionary
        /// </summary>
        public void Setup()
        {
            // clear selected nodes
            SelectedNodes.Clear();

            // if there's no child object, clear dictionary and null root
            if (this.gameObject.transform.childCount == 0)
            {
                Dict.Clear();
                Root = null;
                return;
            }
            else // construct internal data structure and dictionary if there's a loaded object
            {
                // initialize root
                Root = new Node(this.transform.GetChild(0).gameObject, null, this.transform);

                // setup dictionary
                Dict.Clear();
                List <Node> curNodes = new List <Node>();
                curNodes.Add(Root);
                while (curNodes.Count > 0)
                {
                    Node curNode = curNodes[0];
                    Dict.Add(curNode.GameObject, curNode);
                    foreach (var child in curNode.Childs)
                    {
                        curNodes.Add(child);
                    }
                    curNodes.RemoveAt(0);
                }
            }
        }
Пример #24
0
 void UpdateLoad(string resource, int amount)
 {
     if (load.ContainsKey(resource))
     {
         load.Remove(resource);
     }
     load.Add(resource, amount);
 }
Пример #25
0
 public void AddRow(string key, Dict <string, string> value)
 {
     if (rowTable.ContainsKey(key))
     {
         return;
     }
     rowTable.Add(key, value);
 }
Пример #26
0
 public static void Acc(Dict chord, string chordname, double prob)
 {
     if (!chord.ContainsKey(chordname))
     {
         chord.Add(chordname, 0);
     }
     chord[chordname] += prob;
 }
Пример #27
0
        public static Dict <TKey, TElement> ToDict <TSource, TKey, TElement>(this IEnumerable <TSource> items, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector)
        {
            var dict = new Dict <TKey, TElement>();

            items.ForEach((item, i) => dict.Add(keySelector(item), elementSelector(item)));

            return(dict);
        }
Пример #28
0
 public void AddOption(P key, string description, Action action)
 {
     if (IsKeyInDict(key) && !Vali.IsValid(key))
     {
         return;
     }
     Dict.Add(key, new Option(description, action));
 }
Пример #29
0
 void OnEnable()
 {
     foreach (BuildingAsset ba in BuildingAssetEntries)
     {
         Dict.Add(ba.bt, ba.asset);
         UnityEngine.Debug.Log("added " + ba.bt.ToString() + " to Dictionary.");
     }
 }
Пример #30
0
        private static Dict SetN(Dict dict, IReadOnlyList <string> path, object value, int start)
        {
            switch (path.Count - start)
            {
            case 1:
                dict.Add(path[start], value);
                return(dict);

            default:
            {
                var k = path[start];
                var v = SetN(new Dict(), path, value, start + 1);
                dict.Add(k, v);
                return(dict);
            }
            }
        }
Пример #31
0
        public void Add(ManifestFileInfo manFileInfo)
        {
            if (Dict.ContainsKey(manFileInfo.FileHash) == false)
            {
                Dict.Add(manFileInfo.FileHash, new List <ManifestFileInfo>());
            }

            Dict[manFileInfo.FileHash].Add(manFileInfo);
        }
Пример #32
0
    public static Dict <TKey, TValue> Clone <TKey, TValue>(this Dict <TKey, TValue> rDict)
    {
        var newDict = new Dict <TKey, TValue>();

        foreach (var item in rDict)
        {
            newDict.Add((TKey)item.Key, (TValue)item.Value);
        }
        return(newDict);
    }
Пример #33
0
 // Add a symbol -- all go through here
 internal void Add(Symbol sym, string name = null)
 {
     if (name != null)
     {
         sym.Name = name;
     }
     sym.Level = this.Level;
     Logger.Assert(!Dict.ContainsKey(sym.Name), "add dup {0}", sym.Name);
     Dict.Add(sym.Name, sym);
 }
Пример #34
0
 public void ItShouldGetValueForSpecificKey()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     test.Add(18, "Eightteen");
     string actual = test[18];
     string expected = "Eightteen";
     Assert.AreEqual(expected, actual);
 }
Пример #35
0
 public void ItShouldRemove()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     test.Add(18, "Eightteen");
     test.Remove(3);
     bool actual=test.ContainsKey(3);
     bool expected=false;
     Assert.AreEqual(expected, actual);
 }
Пример #36
0
 public void ItShouldClear()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     test.Add(18, "Eightteen");
     test.Clear();
     int expected = 0;
     int actual = test.Count;
     Assert.AreEqual(expected, actual);
 }
Пример #37
0
    public void ParserCSV(string content)
    {
        string[] row = content.Split(new char[]{'\n'});
        string[] columnHeads = row[0].Split(new char[]{','});

        for(int i = 1; i < row.Length; i++)
        {
            Dict<string, string> rowDict = new Dict<string, string>();
            string[] column =row[i].Split(new char[]{','});

            for(int j = 0; j < columnHeads.Length; j++)
            {
                if(!String.IsNullOrEmpty(column[j]))
                {
                    rowDict.Add(columnHeads[j], column[j]);
                }
                else
                {
                    Debug.Log("file error");
                }
            }
            this.table.AddRow(column[0], rowDict);
        }
    }
Пример #38
0
        /// <summary>
        /// Extracts the link tag info from the page using RegEx
        /// </summary>
        /// <param name="p_strPageHtmlContent"></param>
        /// <returns>Deprecated</returns>
        private static Dict<string, Anchor> GetAnchorsList(string p_strPageHtmlContent)
        {
            Dict<string, Anchor> dictReturnSet = new Dict<string, Anchor>();
            Anchor ancrLink = new Anchor();

            //   Try grabbing the meta info of the page into a dictionary
            string pattern = "<a.+?(?:href=(?:\"|')(.*?)(?:\"|').*?)?(?:title=(?:\"|')(.*?)(?:\"|').*?)?(?:href=(?:\"|')(.*?)(?:\"|'))?/?>.*?</head>";
            RegexOptions rxoOptions = RegexOptions.IgnoreCase | RegexOptions.Singleline;

            foreach (Match match in Regex.Matches(p_strPageHtmlContent, pattern, rxoOptions))
            {
                ancrLink = new Anchor();
                ancrLink.Rel = match.Groups[1].Value;
                ancrLink.Type = match.Groups[2].Value;
                ancrLink.Href = match.Groups[3].Value;
                dictReturnSet.Add(match.Groups[1].Value, ancrLink);
            }

            return dictReturnSet;
        }
Пример #39
0
        /// <summary>
        /// Grabs and returns generic tags as (safe) dictionaries from an HTML document - for futureproving
        /// </summary>
        /// <param name="htmlDocDocument"></param>
        /// <returns></returns>
        private static Dict<string, string> GetGenericTag(HtmlDocument p_htmlDocDocument, string p_strTagName)
        {
            Dict<string, string> dictTag = new Dict<string, string>();

            foreach (HtmlNode hnItem in p_htmlDocDocument.DocumentNode.SelectNodes("//" + p_strTagName))
            {
                foreach (HtmlAttribute haItem in hnItem.Attributes)
                {
                    //  Generate name-value pair of the tag's attribute
                    dictTag.Add(haItem.Name, GetHtmlAttributeValue(hnItem.Attributes, haItem.Name));
                }
            }

            return dictTag;
        }
Пример #40
0
        /// <summary>
        /// Extracts the meta tag info from the page using RegEx
        /// </summary>
        /// <param name="p_strPageHtmlContent"></param>
        /// <returns>Deprecated</returns>
        private static Dict<string, PageMeta> GetPageMetaInfo(string p_strPageHtmlContent)
        {
            Dict<string, PageMeta> dictReturnSet = new Dict<string, PageMeta>();
            PageMeta pmMetaTag = new PageMeta();

            //   Try grabbing the meta info of the page into a dictionary
            string pattern = "<meta.+?(?:name=(?:\"|')(.*?)(?:\"|').*?)?(?:property=(?:\"|')(.*?)(?:\"|').*?)?(?:content=(?:\"|')(.*?)(?:\"|'))?/?>.*?</head>";
            RegexOptions rxoOptions = RegexOptions.IgnoreCase | RegexOptions.Singleline;

            foreach (Match match in Regex.Matches(p_strPageHtmlContent, pattern, rxoOptions))
            {
                pmMetaTag = new PageMeta();
                pmMetaTag.Name = match.Groups[1].Value;
                pmMetaTag.Property = match.Groups[2].Value;
                pmMetaTag.Content = match.Groups[3].Value;
                if (!dictReturnSet.ContainsKey(match.Groups[1].Value))
                {
                    dictReturnSet.Add(match.Groups[1].Value, pmMetaTag);
                }
            }

            return dictReturnSet;
        }
Пример #41
0
        /// <summary>
        /// Extracts the link tag info from the page using RegEx
        /// </summary>
        /// <param name="p_strPageHtmlContent"></param>
        /// <returns>Deprecated</returns>
        private static Dict<string, PageMetaLink> GetPageMetaLinkInfo(string p_strPageHtmlContent)
        {
            Dict<string, PageMetaLink> dictReturnSet = new Dict<string, PageMetaLink>();
            PageMetaLink pmlLinkTag = new PageMetaLink();

            //   Try grabbing the meta info of the page into a dictionary
            string pattern = "<link.+?(?:rel=(?:\"|')(.*?)(?:\"|').*?)?(?:type=(?:\"|')(.*?)(?:\"|').*?)?(?:href=(?:\"|')(.*?)(?:\"|'))?/?>.*?</head>";
            RegexOptions rxoOptions = RegexOptions.IgnoreCase | RegexOptions.Singleline;

            foreach (Match match in Regex.Matches(p_strPageHtmlContent, pattern, rxoOptions))
            {
                pmlLinkTag = new PageMetaLink();
                pmlLinkTag.Rel = match.Groups[1].Value;
                pmlLinkTag.Type = match.Groups[2].Value;
                pmlLinkTag.Href = match.Groups[3].Value;
                dictReturnSet.Add(match.Groups[1].Value, pmlLinkTag);
            }

            return dictReturnSet;
        }
Пример #42
0
 public virtual HResult OnStatus(Request r)
 {
     r.res.StatusCode = 200;
     r.res.ContentEncoding = Encoding.UTF8;
     r.res.ContentType = "application/json";
     var data = new Dict();
     var tasks = new Dict();
     tasks.Add("queued", TaskPool.Shared.Queued.Count);
     tasks.Add("running", TaskPool.Shared.Running.Count);
     data.Add("tasks", tasks.data);
     data.Add("word_c", WordCov.Cached.Count);
     r.WriteLine(Json.stringify(data.data));
     r.Flush();
     return HResult.HRES_RETURN;
 }
Пример #43
0
 internal IDictionary<object, object> GetAttrDict(ICallerContext context)
 {
     if (HaveInterfaces) {
         Dict res = new Dict();
         foreach (DynamicType type in interfaces) {
             Dict dict = type.GetAttrDict(context, obj);
             foreach (KeyValuePair<object, object> val in dict) {
                 if (!res.ContainsKey(val.Key)) {
                     res.Add(val);
                 }
             }
         }
         return res;
     } else {
         return new Dict(0);
     }
 }
Пример #44
0
 public void ItShouldTryGetValue()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     test.Add(18, "Eightteen");
     string actual;
     test.TryGetValue(3,out actual);
     string expected = "Three";
     Assert.AreEqual(expected, actual);
 }
Пример #45
0
 public void ItShouldTryGetValueAndReturnFalse()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     test.Add(18, "Eightteen");
     string value;
     bool actual = test.TryGetValue(6, out value);
     bool expected = false;
     Assert.AreEqual(expected, actual);
 }
Пример #46
0
        internal IDictionary<object, object> GetAttrDictWithCustomDict(ICallerContext context, ICustomAttributes self, IAttributesDictionary selfDict)
        {
            Debug.Assert(IsInstanceOfType(self));

            // Get the attributes from the instance
            Dict res = new Dict(selfDict);

            // Add the attributes from the type
            Dict typeDict = base.GetAttrDict(context, self);
            foreach (KeyValuePair<object, object> pair in (IDictionary<object, object>)typeDict) {
                res.Add(pair);
            }

            return res;
        }
Пример #47
0
 public void ItShouldRemoveAndAdd()
 {
     Dict<int, string> test = new Dict<int, string>();
     test.Add(1, "One");
     test.Add(2, "Two");
     test.Add(3, "Three");
     test.Add(4, "Four");
     test.Add(5, "Five");
     test.Remove(3);
     test.Add(3, "NewThree");
     string actual = test[3];
     string expected = "NewThree";
     Assert.AreEqual(expected, actual);
 }
Пример #48
0
        public virtual Dict GetAttrDict(ICallerContext context, object self)
        {
            // Get the entries from the type
            Dict res = new Dict(GetAttrDict(context));

            // Add the entries from the instance
            ISuperDynamicObject sdo = self as ISuperDynamicObject;
            if (sdo != null) {
                IAttributesDictionary dict = sdo.GetDict();
                if (dict != null) {
                    foreach (KeyValuePair<object, object> val in dict) {
                        object fieldName = val.Key;
                        if (!res.ContainsKey(fieldName)) {
                            res.Add(new KeyValuePair<object, object>(fieldName, val.Value));
                        }
                    }
                }
            }
            return res;
        }
Пример #49
0
 protected FrozenSetCollection(object set)
 {
     IEnumerator setData = Ops.GetEnumerator(set);
     items = new Dict();
     while (setData.MoveNext()) {
         object o = setData.Current;
         if (!items.ContainsKey(o)) {
             items.Add(o, o);
         }
     }
     CalculateHashCode();
 }