示例#1
0
        public void When_adding_newItem_should_be_added_to_list()
        {
            var sut = new PairList<string>();
              sut.AddNewItem("");

              Assert.AreEqual(1, sut.AddedItems.Count());
        }
示例#2
0
        public static PairList <string, int> SectionPositionsFromSortedList(IList <IGroupingItem> sortedList)
        {
            if (sortedList == null)
            {
                return(new PairList <string, int>());
            }

            PairList <string, int> positions = new PairList <string, int>();

            string lastGroupingLetter = null;
            int    lastIndex          = 0;

            for (int i = 0; i < sortedList.Count; i++)
            {
                string groupingName = sortedList[i].GroupingName;
                if (groupingName == null || groupingName.Length == 0)
                {
                    continue;
                }

                char firstLetter = Char.ToUpper(groupingName[0]);
                if (lastGroupingLetter == null || firstLetter != lastGroupingLetter[0])
                {
                    lastGroupingLetter = firstLetter.ToString();
                    lastIndex          = i;
                    positions.Add(lastGroupingLetter, lastIndex);
                }
            }

            return(positions);
        }
示例#3
0
    /// <summary>
    /// Adds game objects that show the level's general information: two text objects and a background image.
    /// </summary>
    /// <param name="title">The title of the level.</param>
    /// <param name="description">The one-line description of the level.</param>
    void AddLevelInfoObjects(string title, string description)
    {
        // - background box
        SpriteGameObject infoBackground = new SpriteGameObject("Sprites/spr_level_info");

        infoBackground.SetOriginToCenter();
        infoBackground.LocalPosition = new Vector2(600, 820);
        AddChild(infoBackground);

        // - title text
        TextGameObject titleText = new TextGameObject("Fonts/HelpFont", Color.Blue, TextGameObject.Alignment.Center);

        titleText.Text          = LevelIndex + " - " + title;
        titleText.LocalPosition = new Vector2(600, 786);
        AddChild(titleText);

        // - description text
        TextGameObject descriptionText = new TextGameObject("Fonts/HelpFont", Color.DarkBlue, TextGameObject.Alignment.Center);

        descriptionText.Text          = description;
        descriptionText.LocalPosition = new Vector2(600, 820);
        AddChild(descriptionText);

        // - number of pairs
        pairList = new PairList(targetNumberOfPairs);
        pairList.LocalPosition = new Vector2(20, 20);
        AddChild(pairList);
    }
示例#4
0
 public PlaylistsResponse(string error, IList <Playlist> playlists, IList <IMediaItem> mediaItems, PairList <string, int> sectionPositions)
 {
     Error            = error;
     Playlists        = playlists;
     MediaItems       = mediaItems;
     SectionPositions = sectionPositions;
 }
示例#5
0
        public override Expression CloneExpressionOnly()
        {
            PairList <Expression, OrderDirection> collectionClone =
                new PairList <Expression, OrderDirection>(this.ExpressionToOrderDirectionMap.Select(pair => new KeyValuePair <Expression, OrderDirection>(pair.Key.CloneExpressionOnly(), pair.Value)));

            return(new OrderByClause(collectionClone, null));
        }
示例#6
0
 private void AddPairs(G2Protocol protocol, G2Frame sync, byte name, PairList pairs)
 {
     if (pairs != null && pairs.Count > 0)
     {
         protocol.WritePacket(sync, name, pairs.ToBytes());
     }
 }
        private PairList <CFGBlockLogicalConstruct, List <int> > GetOrderedCFGSuccessorToLabelsMap(SwitchData switchData)
        {
            //Ugly but effective. Sorry
            PairList <CFGBlockLogicalConstruct, List <int> > result = new PairList <CFGBlockLogicalConstruct, List <int> >();
            Dictionary <InstructionBlock, KeyValuePair <int, List <int> > > blockSuccessorToResultPositionMap =
                new Dictionary <InstructionBlock, KeyValuePair <int, List <int> > >();

            for (int i = 0; i < switchData.OrderedCasesArray.Length; i++)
            {
                InstructionBlock instructionBlock = switchData.OrderedCasesArray[i];
                if (instructionBlock != switchData.DefaultCase)
                {
                    KeyValuePair <int, List <int> > positionToLabelListPair;
                    if (!blockSuccessorToResultPositionMap.TryGetValue(instructionBlock, out positionToLabelListPair))
                    {
                        positionToLabelListPair = new KeyValuePair <int, List <int> >(result.Count, new List <int>());

                        result.Add(GetCFGLogicalConstructFromBlock(instructionBlock), positionToLabelListPair.Value);

                        blockSuccessorToResultPositionMap.Add(instructionBlock, positionToLabelListPair);
                    }
                    positionToLabelListPair.Value.Add(i);
                }
            }

            return(result);
        }
示例#8
0
        private void SaveTunerDef()
        {
            PairList pairList = this.tunerDef;

            pairList.Clear();
            IEnumerator enumerator = this.tunerBox.Nodes.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    string[] array = ((TreeNode)enumerator.Current).Text.Split(new char[]
                    {
                        '='
                    });
                    pairList[array[0]] = array[1];
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            pairList.Save();
        }
示例#9
0
 void OnApplicationPause(bool pauseStatus)
 {
     if (pauseStatus)
     {
         PairList.Save();
     }
 }
    public static void Main()
    {
        goto atlamanoktasi;
        //ornek olması acısından->RawView
        ArrayList listarray = new ArrayList();

        listarray.Add(new Pair("W", 1919));
        listarray.Add(new Pair("X", 1923));
        listarray.Add(new Pair("Y", 1071));
        listarray.Add(new Pair("Z", 1453));

        /* Pair d = (Pair)listarray[0];
         * Console.WriteLine("{0}", d.Data);*/

        foreach (Pair item in listarray)
        {
            Pair d = item;
            Console.WriteLine("{0}", d.Data);
        }



atlamanoktasi:
        PairList row = new PairList();

        row.Load();
        Pair val = row["A"];

        Console.WriteLine("A: {0}", val.Data);
        Console.WriteLine("B: {0}", row["B"].Data);
        row["Q"].Data = "new value";    // set the name
        Console.WriteLine("Q: {0}", row["Q"].Data);
    }
示例#11
0
        public PairList GetAllTableStyleInfoPairs()
        {
            var pairs = new PairList();

            using (var rdr = ExecuteReader(SqlSelectAllTableStyle))
            {
                while (rdr.Read())
                {
                    var styleInfo = GetTableStyleInfoByReader(rdr);
                    var inputType = styleInfo.InputType;
                    if (InputTypeUtils.IsWithStyleItems(inputType))
                    {
                        styleInfo.StyleItems = DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id);
                    }

                    var key = TableStyleManager.GetCacheKey(styleInfo.RelatedIdentity, styleInfo.TableName, styleInfo.AttributeName);
                    if (!pairs.ContainsKey(key))
                    {
                        var pair = new Pair(key, styleInfo);
                        pairs.Add(pair);
                    }
                }
                rdr.Close();
            }

            return(pairs);
        }
示例#12
0
 public AlbumsResponse(string error, IList <Album> albums, IList <Song> songs, PairList <string, int> sectionPositions)
 {
     Error            = error;
     Albums           = albums;
     Songs            = songs;
     SectionPositions = sectionPositions;
 }
示例#13
0
 /// <summary>
 /// Initializes an empty context for a given branch.
 /// </summary>
 /// <param name="branchName">The branch name.</param>
 internal WorldBranchContext(string branchName)
 {
     BranchName = branchName;
     _context   = new SolutionContext();
     _drivers   = new List <ISolutionDriver>();
     _pairList  = new PairList(this);
 }
示例#14
0
 public PlaylistsResponse(string error, IList<Playlist> playlists, IList<IMediaItem> mediaItems, PairList<string, int> sectionPositions)
 {
     Error = error;
     Playlists = playlists;
     MediaItems = mediaItems;
     SectionPositions = sectionPositions;
 }
示例#15
0
        /// <summary>
        /// <para>Creates a CMSSolutions.Collections.Generic.PairCollection&lt;TFirst,TSecond&gt; from a System.Collections.Generic.IEnumerable&lt;T&gt;</para>
        /// <para>according to specified first and second selector functions.</para>
        /// </summary>
        /// <typeparam name="TSource">The type of the elements of source.</typeparam>
        /// <typeparam name="TFirst">The type of the First returned by firstSelector.</typeparam>
        /// <typeparam name="TSecond">The type of the Second returned by secondSelector.</typeparam>
        /// <param name="source">An System.Collections.Generic.IEnumerable&lt;T&gt; to create a CMSSolutions.Collections.Generic.PairCollection&lt;TFirst,TSecond&gt; from</param>
        /// <param name="firstSelector">A transform function to produce a result element First from each element.</param>
        /// <param name="secondSelector">A transform function to produce a result element Second from each element.</param>
        /// <returns>
        /// <para>A CMSSolutions.Collections.Generic.PairCollection&lt;TFirst,TSecond&gt; that contains values</para>
        /// <para> of type TFirst and TSecond selected from the input sequence.</para>
        /// </returns>
        public static PairList <TFirst, TSecond> ToPairList <TSource, TFirst, TSecond>(
            this IEnumerable <TSource> source,
            Func <TSource, TFirst> firstSelector,
            Func <TSource, TSecond> secondSelector)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (firstSelector == null)
            {
                throw new ArgumentNullException("firstSelector");
            }
            if (secondSelector == null)
            {
                throw new ArgumentNullException("secondSelector");
            }
            var dictionary = new PairList <TFirst, TSecond>();

            foreach (TSource item in source)
            {
                dictionary.Add(firstSelector(item), secondSelector(item));
            }
            return(dictionary);
        }
示例#16
0
        public static PairList<string, int> SectionPositionsFromSortedList(IList<IGroupingItem> sortedList)
        {
            if (sortedList == null)
                return new PairList<string, int>();

            PairList<string, int> positions = new PairList<string, int>();

            string lastGroupingLetter = null;
            int lastIndex = 0;
            for (int i = 0; i < sortedList.Count; i++)
            {
                string groupingName = sortedList[i].GroupingName;
                if (groupingName == null || groupingName.Length == 0)
                    continue;

                char firstLetter = Char.ToUpper(groupingName[0]);
                if (lastGroupingLetter == null || firstLetter != lastGroupingLetter[0])
                {
                    lastGroupingLetter = firstLetter.ToString();
                    lastIndex = i;
                    positions.Add(lastGroupingLetter, lastIndex);
                }
            }

            return positions;
        }
示例#17
0
        internal void AddThreadlines(SyncPacket packet)
        {
            foreach (var flow in XRay.FlowMap)
            {
                if (!NewStackItems.ContainsKey(flow.ThreadID) || NewStackItems[flow.ThreadID] == 0)
                {
                    continue;
                }

                PairList threadline;
                if (!Threadlines.TryGetValue(flow.ThreadID, out threadline))
                {
                    threadline = new PairList();
                    Threadlines[flow.ThreadID] = threadline;
                }

                int newItems  = NewStackItems[flow.ThreadID];
                int minDepth  = int.MaxValue;
                int sendCount = Math.Min(newItems, MaxStackItemsPerThreadSent);

                foreach (var item in flow.EnumerateThreadline(sendCount))
                {
                    if (item.Depth < minDepth)
                    {
                        minDepth = item.Depth;
                    }

                    threadline.Add(new Tuple <int, int>((item.Call == null) ? item.NodeID : item.Call.ID, item.Depth));
                }
                // set new items to 0, iterate new items on threadline add
                NewStackItems[flow.ThreadID] = 0;

                // send top level of stack, so remote node is in sync (these are often pushed off the threadline)
                PairList threadstack;
                if (!ThreadStacks.TryGetValue(flow.ThreadID, out threadstack))
                {
                    threadstack = new PairList();
                    ThreadStacks[flow.ThreadID] = threadstack;
                }
                for (int i = minDepth - 1; i >= 0; i--)
                {
                    var item = flow.Stack[i];
                    threadstack.Add(new Tuple <int, int>((item.Call == null) ? item.NodeID : item.Call.ID, item.Depth));
                }
            }

            if (Threadlines.Count > 0)
            {
                packet.Threadlines = Threadlines;
                Threadlines        = new Dictionary <int, PairList>();
                DataToSend         = true;
            }

            if (ThreadStacks.Count > 0)
            {
                packet.ThreadStacks = ThreadStacks;
                ThreadStacks        = new Dictionary <int, PairList>();
                DataToSend          = true;
            }
        }
示例#18
0
        public PairList GetChords()
        {
            Dict chord = new Dict();

            //string[] NoteName = NoteNameSharp;

            for (int i = 0; i < notes.Count; i++)
            {
                int    note  = notes[i];
                double decay = hold[i] ? 0.5 : 1;
                int    scale;
                // Major
                scale = NoteScale.FromNumber(note);     // as 1th
                Acc(chord, NoteName[scale], decay / 3);
                scale = NoteScale.FromNumber(note - 4); // as 3th
                Acc(chord, NoteName[scale], decay / 3);
                scale = NoteScale.FromNumber(note - 7); // as 5th
                Acc(chord, NoteName[scale], decay / 3);
                // Minor
                scale = NoteScale.FromNumber(note);     // as 1th
                Acc(chord, NoteName[scale] + "m", decay / 3);
                scale = NoteScale.FromNumber(note - 3); // as 3th
                Acc(chord, NoteName[scale] + "m", decay / 3);
                scale = NoteScale.FromNumber(note - 7); // as 5th
                Acc(chord, NoteName[scale] + "m", decay / 3);
                // 7th
                scale = NoteScale.FromNumber(note);      // as 1th
                Acc(chord, NoteName[scale] + "7", decay / 4);
                scale = NoteScale.FromNumber(note - 4);  // as 3th
                Acc(chord, NoteName[scale] + "7", decay / 4);
                scale = NoteScale.FromNumber(note - 7);  // as 5th
                Acc(chord, NoteName[scale] + "7", decay / 4);
                scale = NoteScale.FromNumber(note - 10); // as 7th
                Acc(chord, NoteName[scale] + "7", decay / 4);
            }
            if (l != null)
            {
                PairList chord_l = l.GetChords();
                foreach (var pair in chord_l)
                {
                    Acc(chord, pair.Key, pair.Value);
                }
            }
            if (r != null)
            {
                PairList chord_r = r.GetChords();
                foreach (var pair in chord_r)
                {
                    Acc(chord, pair.Key, pair.Value / 2);
                }
            }
            List <KeyValuePair <string, double> > ret = new List <KeyValuePair <string, double> >();

            foreach (var c in chord)
            {
                ret.Add(c);
            }
            ret.Sort((a, b) => (b.Value.CompareTo(a.Value)));
            return(ret);
        }
示例#19
0
        public void When_adding_newItem_should_be_added_to_list()
        {
            var sut = new PairList <string>();

            sut.AddNewItem("");

            Assert.AreEqual(1, sut.AddedItems.Count());
        }
示例#20
0
        public void When_adding_reference_and_new_item_should_be_added_to_equal_list()
        {
            var sut = new PairList<string>();
              sut.AddReferenceItem("");
              sut.AddNewItem("");

              Assert.AreEqual(1, sut.EqualItems.Count());
        }
示例#21
0
 private void ResetPairList(IEnumerable <NameValuePair> list)
 {
     PairList.Clear();
     foreach (var x in list)
     {
         PairList.Add(x);
     }
 }
示例#22
0
 private QuadTree(double x, double y, double w, double h, QuadTree Root)
     : base(x, y, w, h)
 {
     Objects = new List<ICollidable>();
     Collisions = new PairList<ICollidable>();
     Offset = new Vector2D();
     this.Root = Root;
 }
    public static void Main()
    {
        PairList Row_ = new PairList();

        Row_.Load();
        Console.WriteLine("Column 1: {0}", Row_[1].Data);
        Row_[1].Data = 12;
    }
示例#24
0
 public QuadTree(double x, double y, double w, double h)
     : base(x, y, w, h)
 {
     Objects = new List<ICollidable>();
     Collisions = new PairList<ICollidable>();
     Offset = new Vector2D();
     Root = this;
 }
示例#25
0
 public FoldersResponse(string error, Folder containingFolder, IList <Folder> folders, IList <Song> songs, IList <Video> videos, PairList <string, int> sectionPositions)
 {
     Error            = error;
     ContainingFolder = containingFolder;
     Folders          = folders;
     Songs            = songs;
     Videos           = videos;
     SectionPositions = sectionPositions;
 }
示例#26
0
 void AddPairs(ref PairList localPairs, ref PairList packetPairs)
 {
     if (localPairs.Count > 0)
     {
         packetPairs = localPairs;
         localPairs  = new PairList();
         DataToSend  = true;
     }
 }
示例#27
0
 public FoldersResponse(string error, Folder containingFolder, IList<Folder> folders, IList<Song> songs, IList<Video>videos, PairList<string, int> sectionPositions)
 {
     Error = error;
     ContainingFolder = containingFolder;
     Folders = folders;
     Songs = songs;
     Videos = videos;
     SectionPositions = sectionPositions;
 }
示例#28
0
        public void When_adding_new_and_reference_item_should_be_added_to_equal_list()
        {
            var sut = new PairList <string>();

            sut.AddNewItem("");
            sut.AddReferenceItem("");

            Assert.AreEqual(1, sut.EqualItems.Count());
        }
示例#29
0
 private void LoadTunerDef()
 {
     this.tunerDef = new PairList(Util.GetUserPath("tuner.def"));
     this.tunerDef.Load();
     foreach (KeyValuePair <string, string> current in this.tunerDef)
     {
         this.tunerBox.Nodes.Add(current.Key + "=" + current.Value);
     }
 }
示例#30
0
        public void When_adding_referenceItem_should_be_added_to_list()
        {
            var sut = new PairList<string>();
              sut.AddReferenceItem("old");
              sut.AddNewItem("new");

              Assert.AreEqual(1, sut.RemovedItems.Count());
              Assert.AreEqual(1, sut.AddedItems.Count());
        }
示例#31
0
        public TestStateManager(object specification)
        {
            TestType = specification.GetType();
            Givens = new PairList<Delegate, string>();
            Whens = new PairList<Delegate, string>();
            Thens = new PairList<MethodInfo, StatedThen>();
            _teardownMethods = new List<after>();

            TestRunManager.CurrentTestRun.AddTest(this, specification.GetType());
        }
示例#32
0
 public GenresResponse(string error, IList <Genre> genres, IList <Folder> folders, IList <Artist> artists, IList <Album> albums, IList <Song> songs, PairList <string, int> sectionPositions)
 {
     Error            = error;
     Genres           = genres;
     Folders          = folders;
     Artists          = artists;
     Albums           = albums;
     Songs            = songs;
     SectionPositions = sectionPositions;
 }
示例#33
0
 public ArtistsResponse(string error, IList<Artist> artists, IList<Album> albums, IList<Song> songs, Dictionary<string, int> counts, string lastfmInfo, PairList<string, int> sectionPositions)
 {
     Error = error;
     Artists = artists;
     Songs = songs;
     Albums = albums;
     Counts = counts;
     LastfmInfo = lastfmInfo;
     SectionPositions = sectionPositions;
 }
示例#34
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reward">reward</param>
 /// <param name="spawns">spawn points</param>
 public Wave(PairList<string, object> data)
 {
     spawns = new List<SpawnPoint>();
     foreach (PairListNode<string, object> element in data)
         if (element.Key.Equals("Reward"))
             reward = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("Spawns"))
             foreach (object spawn in element.Value as SimpleList<object>)
                 spawns.Add(new SpawnPoint(spawn as PairList<string, object>));
 }
示例#35
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="data">enemy data</param>
 public EnemyInstance(PairList<string, object> data)
 {
     foreach (PairListNode<string, object> element in data)
         if (element.Key.Equals("Name"))
             name = element.Value.ToString();
         else if (element.Key.Equals("Delay"))
             delay = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("Quantity"))
             quantity = int.Parse(element.Value.ToString());
 }
示例#36
0
 public AlbumArtistsResponse(string error, IList <AlbumArtist> albumArtists, IList <Album> albums, IList <Song> songs, Dictionary <string, int> counts, string lastfmInfo, PairList <string, int> sectionPositions)
 {
     Error            = error;
     AlbumArtists     = albumArtists;
     Songs            = songs;
     Albums           = albums;
     Counts           = counts;
     LastfmInfo       = lastfmInfo;
     SectionPositions = sectionPositions;
 }
示例#37
0
        public void When_adding_referenceItem_should_be_added_to_list()
        {
            var sut = new PairList <string>();

            sut.AddReferenceItem("old");
            sut.AddNewItem("new");

            Assert.AreEqual(1, sut.RemovedItems.Count());
            Assert.AreEqual(1, sut.AddedItems.Count());
        }
示例#38
0
 public GenresResponse(string error, IList<Genre> genres, IList<Folder> folders, IList<Artist> artists, IList<Album> albums, IList<Song> songs, PairList<string, int> sectionPositions)
 {
     Error = error;
     Genres = genres;
     Folders = folders;
     Artists = artists;
     Albums = albums;
     Songs = songs;
     SectionPositions = sectionPositions;
 }
示例#39
0
        /// <summary>
        /// Process returns a JSON response list of genres
        /// </summary>
        public void Process(UriWrapper uri, IHttpProcessor processor, User user)
        {
            // Generate return lists of folders, songs, videos
            IList <Genre>          listOfGenres     = new List <Genre>();
            IList <Folder>         listOfFolders    = new List <Folder>();
            IList <Artist>         listOfArtists    = new List <Artist>();
            IList <Album>          listOfAlbums     = new List <Album>();
            IList <Song>           listOfSongs      = new List <Song>();
            PairList <string, int> sectionPositions = new PairList <string, int>();

            // ID specified
            if (uri.Id != null)
            {
                // Default: artists
                string type = "artists";
                if (uri.Parameters.ContainsKey("type"))
                {
                    type = uri.Parameters["type"];
                }

                // Get single genre, add it for output
                Genre genre = Injection.Kernel.Get <IGenreRepository>().GenreForId((int)uri.Id);
                listOfGenres.Add(genre);

                switch (type)
                {
                case "folders":
                    listOfFolders = genre.ListOfFolders();
                    break;

                case "albums":
                    listOfAlbums = genre.ListOfAlbums();
                    break;

                case "songs":
                    listOfSongs = genre.ListOfSongs();
                    break;

                case "artists":
                default:
                    listOfArtists = genre.ListOfArtists();
                    break;
                }
            }
            else
            {
                // No id parameter
                listOfGenres     = Injection.Kernel.Get <IGenreRepository>().AllGenres();
                sectionPositions = Utility.SectionPositionsFromSortedList(new List <IGroupingItem>(listOfGenres.Select(c => (IGroupingItem)c)));
            }

            // Return all results
            processor.WriteJson(new GenresResponse(null, listOfGenres, listOfFolders, listOfArtists, listOfAlbums, listOfSongs, sectionPositions));
            return;
        }
示例#40
0
        /// <summary>
        /// Process returns a JSON response list of genres
        /// </summary>
        public void Process(UriWrapper uri, IHttpProcessor processor, User user)
        {
            // Generate return lists of folders, songs, videos
            IList<Genre> listOfGenres = new List<Genre>();
            IList<Folder> listOfFolders = new List<Folder>();
            IList<Artist> listOfArtists = new List<Artist>();
            IList<Album> listOfAlbums = new List<Album>();
            IList<Song> listOfSongs = new List<Song>();
            PairList<string, int> sectionPositions = new PairList<string, int>();

            // ID specified
            if (uri.Id != null)
            {
                // Default: artists
                string type = "artists";
                if (uri.Parameters.ContainsKey("type"))
                {
                    type = uri.Parameters["type"];
                }

                // Get single genre, add it for output
                Genre genre = Injection.Kernel.Get<IGenreRepository>().GenreForId((int)uri.Id);
                listOfGenres.Add(genre);

                switch (type)
                {
                    case "folders":
                        listOfFolders = genre.ListOfFolders();
                        break;
                    case "albums":
                        listOfAlbums = genre.ListOfAlbums();
                        break;
                    case "songs":
                        listOfSongs = genre.ListOfSongs();
                        break;
                    case "artists":
                    default:
                        listOfArtists = genre.ListOfArtists();
                        break;
                }
            }
            else
            {
                // No id parameter
                listOfGenres = Injection.Kernel.Get<IGenreRepository>().AllGenres();
                sectionPositions = Utility.SectionPositionsFromSortedList(new List<IGroupingItem>(listOfGenres.Select(c => (IGroupingItem)c)));
            }

            // Return all results
            processor.WriteJson(new GenresResponse(null, listOfGenres, listOfFolders, listOfArtists, listOfAlbums, listOfSongs, sectionPositions));
            return;
        }
        private void InitializeCities()
        {
            nationCity = new PairList <string, string>();

            // Argentina
            nationCity.Add("Argentina", "Boca");
            nationCity.Add("Argentina", "Buenos Aires");

            // England
            nationCity.Add("England", "London");
            nationCity.Add("England", "Birmingham");
            nationCity.Add("England", "Liverpool");
            nationCity.Add("England", "Manchester");

            // Brazil
            nationCity.Add("Brazil", "Rio de Janeiro");
            nationCity.Add("Brazil", "Sao Paulo");

            // Canada
            nationCity.Add("Canada", "Toronto");
            nationCity.Add("Canada", "Montreal");
            nationCity.Add("Canada", "Vancouver");
            nationCity.Add("Canada", "Calgary");
            nationCity.Add("Canada", "Winnipeg");
            nationCity.Add("Canada", "Ottawa");
            nationCity.Add("Canada", "Halifax");
            nationCity.Add("Canada", "Quebec");
            nationCity.Add("Canada", "Thunder Bay");
            nationCity.Add("Canada", "Regina");
            nationCity.Add("Canada", "Scarborough");
            nationCity.Add("Canada", "Mississauga");
            nationCity.Add("Canada", "Edmonton");
            nationCity.Add("Canada", "Hamilton");
            nationCity.Add("Canada", "Burlington");
            nationCity.Add("Canada", "London");
            nationCity.Add("Canada", "Niagara Falls");
            nationCity.Add("Canada", "Windsor");

            // Iceland
            nationCity.Add("Iceland", "Reykjavik");
            nationCity.Add("Iceland", "Kopavogur");

            // Denmark
            nationCity.Add("Denmark", "Copenhagen");

            // USA
            nationCity.Add("USA", "New York");
            nationCity.Add("USA", "Boston");
            nationCity.Add("USA", "Los Angeles");
        }
        private void CreateSwitchConstruct(CFGBlockLogicalConstruct switchBlock, ILogicalConstruct parentConstruct,
                                           SwitchData switchData, DominatorTree dominatorTree)
        {
            List <KeyValuePair <CFGBlockLogicalConstruct, List <int> > >    cfgSuccessorToLabelsMap           = GetOrderedCFGSuccessorToLabelsMap(switchData);
            Dictionary <ILogicalConstruct, HashSet <ISingleEntrySubGraph> > validCaseEntryToDominatedNodesMap = GetValidCases(dominatorTree, switchBlock);

            List <CaseLogicalConstruct> orderedCaseConstructs = new List <CaseLogicalConstruct>();
            PairList <List <int>, CFGBlockLogicalConstruct> labelsToCFGSuccessorsList = new PairList <List <int>, CFGBlockLogicalConstruct>();

            foreach (KeyValuePair <CFGBlockLogicalConstruct, List <int> > cfgSuccessorToLabelsPair in cfgSuccessorToLabelsMap)
            {
                ILogicalConstruct successor;
                HashSet <ISingleEntrySubGraph> dominatedNodes;
                if (LogicalFlowUtilities.TryGetParentConstructWithGivenParent(cfgSuccessorToLabelsPair.Key, parentConstruct, out successor) &&
                    validCaseEntryToDominatedNodesMap.TryGetValue(successor, out dominatedNodes))
                {
                    CaseLogicalConstruct newCaseConstruct = new CaseLogicalConstruct(successor);
                    newCaseConstruct.CaseNumbers.AddRange(cfgSuccessorToLabelsPair.Value);
                    newCaseConstruct.Body.UnionWith(dominatedNodes.Cast <ILogicalConstruct>());
                    newCaseConstruct.AttachCaseConstructToGraph();
                    orderedCaseConstructs.Add(newCaseConstruct);
                }
                else
                {
                    labelsToCFGSuccessorsList.Add(cfgSuccessorToLabelsPair.Value, cfgSuccessorToLabelsPair.Key);
                }
            }

            CaseLogicalConstruct           defaultCase         = null;
            CFGBlockLogicalConstruct       defaultCFGSuccessor = GetCFGLogicalConstructFromBlock(switchData.DefaultCase);
            ILogicalConstruct              defaultSuccessor;
            HashSet <ISingleEntrySubGraph> defaultCaseNodes;

            if (LogicalFlowUtilities.TryGetParentConstructWithGivenParent(defaultCFGSuccessor, parentConstruct, out defaultSuccessor) &&
                validCaseEntryToDominatedNodesMap.TryGetValue(defaultSuccessor, out defaultCaseNodes))
            {
                defaultCase = new CaseLogicalConstruct(defaultSuccessor);
                if (HasSuccessors(defaultCaseNodes))
                {
                    defaultCase.Body.UnionWith(defaultCaseNodes.Cast <ILogicalConstruct>());
                }
                defaultCase.AttachCaseConstructToGraph();
            }

            SwitchLogicalConstruct theSwitch = SwitchLogicalConstruct.GroupInSwitchConstruct(switchBlock, orderedCaseConstructs, labelsToCFGSuccessorsList, defaultCase, defaultCFGSuccessor);

            UpdateDominatorTree(dominatorTree, theSwitch);
        }
示例#43
0
        /// <summary>
        /// Process returns a JSON response list of folders
        /// </summary>
        public void Process(UriWrapper uri, IHttpProcessor processor, User user)
        {
            // Generate return lists of folders, songs, videos
            IList<Folder> listOfFolders = new List<Folder>();
            IList<Song> listOfSongs = new List<Song>();
            IList<Video> listOfVideos = new List<Video>();
            Folder containingFolder = null;
            bool recursive = false;
            PairList<string, int> sectionPositions = new PairList<string, int>();

            // If ID present, return that folder
            if (uri.Id != null)
            {
                // Return the folder for this id
                containingFolder = Injection.Kernel.Get<IFolderRepository>().FolderForId((int)uri.Id);
                listOfFolders = containingFolder.ListOfSubFolders();

                if (uri.Parameters.ContainsKey("recursiveMedia") && uri.Parameters["recursiveMedia"].IsTrue())
                {
                    recursive = true;
                }

                // Get it, son.
                listOfSongs = containingFolder.ListOfSongs(recursive);
                listOfVideos = containingFolder.ListOfVideos(recursive);

                // Return all results
                processor.WriteJson(new FoldersResponse(null, containingFolder, listOfFolders, listOfSongs, listOfVideos, sectionPositions));
                return;
            }

            // No id parameter
            if (uri.Parameters.ContainsKey("mediaFolders") && uri.Parameters["mediaFolders"].IsTrue())
            {
                // They asked for the media folders
                listOfFolders = Injection.Kernel.Get<IFolderRepository>().MediaFolders();
            }
            else
            {
                // They didn't ask for media folders, so send top level folders
                listOfFolders = Injection.Kernel.Get<IFolderRepository>().TopLevelFolders();
                sectionPositions = Utility.SectionPositionsFromSortedList(new List<IGroupingItem>(listOfFolders.Select(c => (IGroupingItem)c)));
            }

            // Return all results
            processor.WriteJson(new FoldersResponse(null, containingFolder, listOfFolders, listOfSongs, listOfVideos, sectionPositions));
            return;
        }
示例#44
0
        /// <summary>
        /// Process returns a JSON response list of folders
        /// </summary>
        public void Process(UriWrapper uri, IHttpProcessor processor, User user)
        {
            // Generate return lists of folders, songs, videos
            IList <Folder>         listOfFolders    = new List <Folder>();
            IList <Song>           listOfSongs      = new List <Song>();
            IList <Video>          listOfVideos     = new List <Video>();
            Folder                 containingFolder = null;
            bool                   recursive        = false;
            PairList <string, int> sectionPositions = new PairList <string, int>();

            // If ID present, return that folder
            if (uri.Id != null)
            {
                // Return the folder for this id
                containingFolder = Injection.Kernel.Get <IFolderRepository>().FolderForId((int)uri.Id);
                listOfFolders    = containingFolder.ListOfSubFolders();

                if (uri.Parameters.ContainsKey("recursiveMedia") && uri.Parameters["recursiveMedia"].IsTrue())
                {
                    recursive = true;
                }

                // Get it, son.
                listOfSongs  = containingFolder.ListOfSongs(recursive);
                listOfVideos = containingFolder.ListOfVideos(recursive);

                // Return all results
                processor.WriteJson(new FoldersResponse(null, containingFolder, listOfFolders, listOfSongs, listOfVideos, sectionPositions));
                return;
            }

            // No id parameter
            if (uri.Parameters.ContainsKey("mediaFolders") && uri.Parameters["mediaFolders"].IsTrue())
            {
                // They asked for the media folders
                listOfFolders = Injection.Kernel.Get <IFolderRepository>().MediaFolders();
            }
            else
            {
                // They didn't ask for media folders, so send top level folders
                listOfFolders    = Injection.Kernel.Get <IFolderRepository>().TopLevelFolders();
                sectionPositions = Utility.SectionPositionsFromSortedList(new List <IGroupingItem>(listOfFolders.Select(c => (IGroupingItem)c)));
            }

            // Return all results
            processor.WriteJson(new FoldersResponse(null, containingFolder, listOfFolders, listOfSongs, listOfVideos, sectionPositions));
            return;
        }
示例#45
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="data">spawn point data</param>
 public SpawnPoint(PairList<string, object> data)
 {
     enemies = new List<EnemyInstance>();
     foreach (PairListNode<string, object> element in data)
         if (element.Key.Equals("xStart"))
             xStart = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("yStart"))
             yStart = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("xEnd"))
             xEnd = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("yEnd"))
             yEnd = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("Enemies"))
             foreach (object enemy in element.Value as SimpleList<object>)
                 enemies.Add(new EnemyInstance(enemy as PairList<string, object>));
 }
示例#46
0
        public static DbExpression MakeCondition(PairList <PrimitivePropertyDescriptor, object> propertyValuePairs, DbTable dbTable)
        {
            DbExpression conditionExp = null;

            foreach (var pair in propertyValuePairs)
            {
                PrimitivePropertyDescriptor propertyDescriptor = pair.Item1;
                object val = pair.Item2;

                DbExpression left     = new DbColumnAccessExpression(dbTable, propertyDescriptor.Column);
                DbExpression right    = DbExpression.Parameter(val, propertyDescriptor.PropertyType, propertyDescriptor.Column.DbType);
                DbExpression equalExp = new DbEqualExpression(left, right);
                conditionExp = conditionExp.And(equalExp);
            }

            return(conditionExp);
        }
        private void CreateSwitchConstruct(CFGBlockLogicalConstruct switchBlock, ILogicalConstruct parentConstruct,
            SwitchData switchData, DominatorTree dominatorTree)
        {
            List<KeyValuePair<CFGBlockLogicalConstruct, List<int>>> cfgSuccessorToLabelsMap = GetOrderedCFGSuccessorToLabelsMap(switchData);
            Dictionary<ILogicalConstruct, HashSet<ISingleEntrySubGraph>> validCaseEntryToDominatedNodesMap = GetValidCases(dominatorTree, switchBlock);

            List<CaseLogicalConstruct> orderedCaseConstructs = new List<CaseLogicalConstruct>();
            PairList<List<int>, CFGBlockLogicalConstruct> labelsToCFGSuccessorsList = new PairList<List<int>, CFGBlockLogicalConstruct>();
            foreach (KeyValuePair<CFGBlockLogicalConstruct, List<int>> cfgSuccessorToLabelsPair in cfgSuccessorToLabelsMap)
            {
                ILogicalConstruct successor;
                HashSet<ISingleEntrySubGraph> dominatedNodes;
                if (LogicalFlowUtilities.TryGetParentConstructWithGivenParent(cfgSuccessorToLabelsPair.Key, parentConstruct, out successor) &&
                    validCaseEntryToDominatedNodesMap.TryGetValue(successor, out dominatedNodes))
                {
                    CaseLogicalConstruct newCaseConstruct = new CaseLogicalConstruct(successor);
                    newCaseConstruct.CaseNumbers.AddRange(cfgSuccessorToLabelsPair.Value);
                    newCaseConstruct.Body.UnionWith(dominatedNodes.Cast<ILogicalConstruct>());
                    newCaseConstruct.AttachCaseConstructToGraph();
                    orderedCaseConstructs.Add(newCaseConstruct);
                }
                else
                {
                    labelsToCFGSuccessorsList.Add(cfgSuccessorToLabelsPair.Value, cfgSuccessorToLabelsPair.Key);
                }
            }

            CaseLogicalConstruct defaultCase = null;
            CFGBlockLogicalConstruct defaultCFGSuccessor = GetCFGLogicalConstructFromBlock(switchData.DefaultCase);
            ILogicalConstruct defaultSuccessor;
            HashSet<ISingleEntrySubGraph> defaultCaseNodes;
            if (LogicalFlowUtilities.TryGetParentConstructWithGivenParent(defaultCFGSuccessor, parentConstruct, out defaultSuccessor) &&
                    validCaseEntryToDominatedNodesMap.TryGetValue(defaultSuccessor, out defaultCaseNodes))
            {
                defaultCase = new CaseLogicalConstruct(defaultSuccessor);
                if (HasSuccessors(defaultCaseNodes))
                {
                    defaultCase.Body.UnionWith(defaultCaseNodes.Cast<ILogicalConstruct>());
                }
                defaultCase.AttachCaseConstructToGraph();
            }

            SwitchLogicalConstruct theSwitch = SwitchLogicalConstruct.GroupInSwitchConstruct(switchBlock, orderedCaseConstructs, labelsToCFGSuccessorsList, defaultCase, defaultCFGSuccessor);
            UpdateDominatorTree(dominatorTree, theSwitch);
        }
        private SwitchLogicalConstruct(CFGBlockLogicalConstruct entry, ICollection<CaseLogicalConstruct> body,
            PairList<List<int>, CFGBlockLogicalConstruct> nonDominatedCFGSuccessors, CaseLogicalConstruct defaultCase,
            CFGBlockLogicalConstruct defaultCFGSuccessor)
	    {
            this.SwitchConditionExpression = entry.LogicalConstructExpressions[0];
            this.DefaultCase = defaultCase;
            this.DefaultCFGSuccessor = defaultCFGSuccessor;
            this.NonDominatedCFGSuccessors = nonDominatedCFGSuccessors;

            FillCasesArray(body);

            this.Entry = entry;
            RedirectChildrenToNewParent(GetBodyCollection());

            if (entry.CFGSuccessors.Contains(entry))
            {
                this.AddToPredecessors(entry);
                this.AddToSuccessors(entry);
            }
	    }
示例#49
0
        protected float critDamagePct; //Default = 2... add with runes/items (change with yasuo's passive)

        public Stats()
        {
            for (var i = 0; i < stats.Length; i++)
                stats[i] = new PairList<int, float>();

            updatedHealth = false;
            goldPerSecond = 0;
            healthPerLevel = 0;
            manaPerLevel = 0;
            adPerLevel = 0;
            armorPerLevel = 0;
            magicArmorPerLevel = 0;
            hp5RegenPerLevel = 0;
            mp5RegenPerLevel = 0;
            movementSpeedPercentageModifier = 0;
            baseMovement = 0;
            baseAttackSpeed = 0.625f;
            spellCostReduction = 0;
            critDamagePct = 2;
        }
示例#50
0
 /// <summary>
 /// Loads tile data
 /// </summary>
 public static void Load()
 {
     tileTypes = new PairList<string,bool?>();
     try
     {
         using (StreamReader read = new StreamReader(directory + "\\Data"))
         {
             JSONParser parser = new JSONParser(read.ReadToEnd());
             foreach (PairList<string, object> collection in parser.Objects)
                 foreach (PairListNode<string, object> element in collection)
                     if (element.Key.Equals("Tiles"))
                         foreach (string tile in element.Value as SimpleList<object>)
                         {
                             string[] details = tile.Split(splitter);
                             tileTypes.Add(details[0], details[1] == "null" ? null : (bool?) bool.Parse(details[1]));
                         }
         }
     }
     catch (Exception) { }
 }
示例#51
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="data">JSON data list</param>
 public Status(PairList<string, object> data)
 {
     name = data[0].Key;
     data = data[0].Value as PairList<string, object>;
     foreach (PairListNode<string, object> element in data)
         if (element.Key.Equals("Stun"))
             stunDuration = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("SlowD"))
             slowDuration = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("SlowM"))
             slowMultiplier = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("SlowB"))
             slowBonus = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("ExtraD"))
             extraDamageDuration = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("ExtraM"))
             extraDamageMultiplier = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("ExtraB"))
             extraDamageBonus = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("DOTD"))
             dotDuration = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("DOTF"))
             dotFrameDamage = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("DOTM"))
             dotMoveDamage = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("FearC"))
             fearChance = int.Parse(element.Value.ToString());
         else if (element.Key.Equals("FearD"))
             fearDuration = int.Parse(element.Value.ToString());
 }
示例#52
0
 public PairList<byte, List<int>> getUpdatedStats()
 {
     var ret = new PairList<byte, List<int>>();
     lock (updatedStats)
     {
         foreach (var blocks in updatedStats)
         {
             var retStats = new List<int>();
             foreach (var stat in blocks.Item2)
                 retStats.Add(stat);
             ret.Add(blocks.Item1, retStats);
         }
     }
     return ret;
 }
示例#53
0
 private void AddPairs(G2Protocol protocol, G2Frame sync, byte name, PairList pairs)
 {
     if (pairs != null && pairs.Count > 0)
         protocol.WritePacket(sync, name, pairs.ToBytes());
 }
示例#54
0
        private static void ReadPairListMap(ref Dictionary<int, PairList> map, SyncPacket sync, G2Header child)
        {
            if (map == null)
                map = new Dictionary<int, PairList>();

            int id = 0;
            PairList list = new PairList();

            foreach (var sub in G2Protocol.EnumerateChildren(child))
                if (sub.Name == ChildPacket_ThreadID)
                    id = BitConverter.ToInt32(sub.Data, sub.PayloadPos);
                else if (sub.Name == ChildPacket_PairList)
                    list = PairList.FromBytes(sub.Data, sub.PayloadPos, sub.PayloadSize);

            map[id] = list;
        }
示例#55
0
        private void CheckCollisions(PairList<ICollidable> collisions)
        {
            if (!IsDivided() && Objects.Count > 1 && PrimaryCount > 0)
            {
                for (var i = 0; i < Objects.Count - 1; i++)
                {
                    for (var j = i + 1; j < Objects.Count; j++)
                    {
                        if (!Objects[i].Primary && !Objects[j].Primary) continue;
                        if (!Objects[i].Enabled || !Objects[j].Enabled) continue;
                        if (!Objects[i].Shape.Intersects(Objects[j].Shape)) continue;

                        collisions.Add(Objects[i], Objects[j]);
                    }
                }
            }
            else
            {
                if (Children != null)
                    for (int i = 0; i < Children.Length; i++)
                    {
                        Children[i].CheckCollisions(collisions);
                    }
            }
        }
 public OrderByClause(PairList<Expression, OrderDirection> expressionToOrderMap, IEnumerable<Instruction> instructions) : base(instructions)
 {
     this.ExpressionToOrderDirectionMap = expressionToOrderMap;
 }
示例#57
0
        public PairList<byte, List<int>> getAllStats()
        {
            var toReturn = new PairList<byte, List<int>>();

            for (byte i = 0; i < 5; ++i)
            {
                foreach (var kv in stats[i])
                {
                    if (!toReturn.ContainsKey((byte)(1 << i)))
                        toReturn.Add((byte)(1 << i), new List<int>());
                    toReturn[(byte)(1 << i)].Add(kv.Item1);
                }
            }
            return toReturn;
        }
 public override Expression CloneExpressionOnly()
 {
     PairList<Expression, OrderDirection> collectionClone =
         new PairList<Expression, OrderDirection>(this.ExpressionToOrderDirectionMap.Select(pair => new KeyValuePair<Expression, OrderDirection>(pair.Key.CloneExpressionOnly(), pair.Value)));
     return new OrderByClause(collectionClone, null);
 }
示例#59
0
        private void InitializeCities()
        {
            nationCity = new PairList<string, string>();

            // Argentina
            nationCity.Add("Argentina", "Boca");
            nationCity.Add("Argentina", "Buenos Aires");

            // England
            nationCity.Add("England", "London");
            nationCity.Add("England", "Birmingham");
            nationCity.Add("England", "Liverpool");
            nationCity.Add("England", "Manchester");

            // Brazil
            nationCity.Add("Brazil", "Rio de Janeiro");
            nationCity.Add("Brazil", "Sao Paulo");

            // Canada
            nationCity.Add("Canada", "Toronto");
            nationCity.Add("Canada", "Montreal");
            nationCity.Add("Canada", "Vancouver");
            nationCity.Add("Canada", "Calgary");
            nationCity.Add("Canada", "Winnipeg");
            nationCity.Add("Canada", "Ottawa");
            nationCity.Add("Canada", "Halifax");
            nationCity.Add("Canada", "Quebec");
            nationCity.Add("Canada", "Thunder Bay");
            nationCity.Add("Canada", "Regina");
            nationCity.Add("Canada", "Scarborough");
            nationCity.Add("Canada", "Mississauga");
            nationCity.Add("Canada", "Edmonton");
            nationCity.Add("Canada", "Hamilton");
            nationCity.Add("Canada", "Burlington");
            nationCity.Add("Canada", "London");
            nationCity.Add("Canada", "Niagara Falls");
            nationCity.Add("Canada", "Windsor");

            // Iceland
            nationCity.Add("Iceland", "Reykjavik");
            nationCity.Add("Iceland", "Kopavogur");

            // Denmark
            nationCity.Add("Denmark", "Copenhagen");

            // USA
            nationCity.Add("USA", "New York");
            nationCity.Add("USA", "Boston");
            nationCity.Add("USA", "Los Angeles");
        }
示例#60
0
        public PairList<ICollidable> GetCollisions()
        {
            var Collisions = new PairList<ICollidable>();

            CheckCollisions(Collisions);

            return Collisions;
        }