Exemplo n.º 1
0
 public OhlcSeries ToOhlcSeries()
 {
     return(new OhlcSeries(TimeSpanSeconds, ImmutableList.CreateRange(_ohlcItems)));
 }
Exemplo n.º 2
0
 internal void TestApply(string[] list)
 {
     _ = ApplyAsync(IProjectVersionedValueFactory.Create(ImmutableList.CreateRange(list)));
 }
Exemplo n.º 3
0
        public ObjectWithObjectProperties()
        {
            Address = new Address();
            ((Address)Address).Initialize();

            List = new List <string> {
                "Hello", "World"
            };
            Array       = new string[] { "Hello", "Again" };
            IEnumerable = new List <string> {
                "Hello", "World"
            };
            IList = new List <string> {
                "Hello", "World"
            };
            ICollection = new List <string> {
                "Hello", "World"
            };
            IEnumerableT = new List <string> {
                "Hello", "World"
            };
            IListT = new List <string> {
                "Hello", "World"
            };
            ICollectionT = new List <string> {
                "Hello", "World"
            };
            IReadOnlyCollectionT = new List <string> {
                "Hello", "World"
            };
            IReadOnlyListT = new List <string> {
                "Hello", "World"
            };
            ISetT = new HashSet <string> {
                "Hello", "World"
            };
            StackT = new Stack <string>(new List <string> {
                "Hello", "World"
            });
            QueueT = new Queue <string>(new List <string> {
                "Hello", "World"
            });
            HashSetT = new HashSet <string>(new List <string> {
                "Hello", "World"
            });
            LinkedListT = new LinkedList <string>(new List <string> {
                "Hello", "World"
            });
            SortedSetT = new SortedSet <string>(new List <string> {
                "Hello", "World"
            });
            IImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello", "World"
            });
            IImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello", "World"
            });
            IImmutableQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello", "World"
            });
            IImmutableSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello", "World"
            });
            ImmutableHashSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello", "World"
            });
            ImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello", "World"
            });
            ImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello", "World"
            });
            ImmutableQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello", "World"
            });
            ImmutableSortedSetT = ImmutableSortedSet.CreateRange(new List <string> {
                "Hello", "World"
            });

            NullableInt      = new int?(42);
            Object           = new object();
            NullableIntArray = new int?[] { null, 42, null };
        }
Exemplo n.º 4
0
        // IMMUTABLE
        //
        // ReportSettings contains a list of reportInfos, each of which represents an individual report with R scripts to run on it.
        // An empty reportSettings is a valid instance of this class, as configurations don't require reports to run the batch commands.



        public ReportSettings(List <ReportInfo> reports)
        {
            Reports = ImmutableList.CreateRange(reports);
        }
Exemplo n.º 5
0
 public Building(InventoryItem.Factory inventoryFactory, int currentFloor, List <Floor> floors)
 {
     _inventoryFactory = inventoryFactory;
     CurrentFloor      = currentFloor;
     Floors            = ImmutableList.CreateRange(floors);
 }
Exemplo n.º 6
0
        public Dependency(IDependencyModel dependencyModel, ITargetedDependenciesSnapshot snapshot)
        {
            Requires.NotNull(dependencyModel, nameof(dependencyModel));
            Requires.NotNull(snapshot, nameof(snapshot));
            Requires.NotNullOrEmpty(dependencyModel.ProviderType, nameof(dependencyModel.ProviderType));
            Requires.NotNullOrEmpty(dependencyModel.Id, nameof(dependencyModel.Id));

            Snapshot         = snapshot;
            _modelId         = dependencyModel.Id;
            ProviderType     = dependencyModel.ProviderType;
            Name             = dependencyModel.Name ?? string.Empty;
            Version          = dependencyModel.Version ?? string.Empty;
            Caption          = dependencyModel.Caption ?? string.Empty;
            OriginalItemSpec = dependencyModel.OriginalItemSpec ?? string.Empty;
            Path             = dependencyModel.Path ?? string.Empty;
            SchemaName       = dependencyModel.SchemaName ?? Folder.SchemaName;
            _schemaItemType  = dependencyModel.SchemaItemType ?? Folder.PrimaryDataSourceItemType;
            Resolved         = dependencyModel.Resolved;
            TopLevel         = dependencyModel.TopLevel;
            Implicit         = dependencyModel.Implicit;
            Visible          = dependencyModel.Visible;
            Priority         = dependencyModel.Priority;
            Flags            = dependencyModel.Flags;

            // Just in case custom providers don't do it, add corresponding flags for Resolved state.
            // This is needed for tree update logic to track if tree node changing state from unresolved
            // to resolved or vice-versa (it helps to decide if we need to remove it or update in-place
            // in the tree to avoid flicks).
            if (Resolved)
            {
                Flags = Flags.Union(DependencyTreeFlags.ResolvedFlags);
            }
            else
            {
                Flags = Flags.Union(DependencyTreeFlags.UnresolvedFlags);
            }

            Icon                   = dependencyModel.Icon;
            ExpandedIcon           = dependencyModel.ExpandedIcon;
            UnresolvedIcon         = dependencyModel.UnresolvedIcon;
            UnresolvedExpandedIcon = dependencyModel.UnresolvedExpandedIcon;
            Properties             = dependencyModel.Properties ??
                                     ImmutableDictionary <string, string> .Empty
                                     .Add(Folder.IdentityProperty, Caption)
                                     .Add(Folder.FullPathProperty, Path);

            if (dependencyModel.DependencyIDs == null)
            {
                DependencyIDs = ImmutableList <string> .Empty;
            }
            else
            {
                var normalizedDependencyIDs = new List <string>();
                foreach (var id in dependencyModel.DependencyIDs)
                {
                    normalizedDependencyIDs.Add(GetID(Snapshot.TargetFramework, ProviderType, id));
                }

                DependencyIDs = ImmutableList.CreateRange(normalizedDependencyIDs);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the target list to be executed for every project in the graph, given a particular target list for the entry project.
        /// </summary>
        /// <remarks>
        /// This method uses the ProjectReferenceTargets items to determine the targets to run per node. The results can then be used
        /// to start building each project individually, assuming a given project is built after its references.
        /// </remarks>
        /// <param name="entryProjectTargets">
        /// The target list for the <see cref="GraphRoots"/>. May be null or empty, in which case the entry projects' default targets will be used.
        /// </param>
        /// <returns>A dictionary containing the target list for each node.</returns>
        public IReadOnlyDictionary <ProjectGraphNode, ImmutableList <string> > GetTargetLists(ICollection <string> entryProjectTargets)
        {
            // Seed the dictionary with empty lists for every node. In this particular case though an empty list means "build nothing" rather than "default targets".
            var targetLists = ProjectNodes.ToDictionary(node => node, node => ImmutableList <string> .Empty);

            var encounteredEdges = new HashSet <ProjectGraphBuildRequest>();
            var edgesToVisit     = new Queue <ProjectGraphBuildRequest>();

            // Initial state for the graph roots
            foreach (var entryPointNode in GraphRoots)
            {
                var entryTargets = entryProjectTargets == null || entryProjectTargets.Count == 0
                    ? ImmutableList.CreateRange(entryPointNode.ProjectInstance.DefaultTargets)
                    : ImmutableList.CreateRange(entryProjectTargets);
                var entryEdge = new ProjectGraphBuildRequest(entryPointNode, entryTargets);
                encounteredEdges.Add(entryEdge);
                edgesToVisit.Enqueue(entryEdge);
            }

            // Traverse the entire graph, visiting each edge once.
            while (edgesToVisit.Count > 0)
            {
                var buildRequest     = edgesToVisit.Dequeue();
                var node             = buildRequest.Node;
                var requestedTargets = buildRequest.RequestedTargets;

                targetLists[node] = targetLists[node].AddRange(requestedTargets);

                // No need to continue if this node has no project references.
                if (node.ProjectReferences.Count == 0)
                {
                    continue;
                }

                // Based on the entry points of this project, determine which targets to propagate down to project references.
                var targetsToPropagate = ProjectInterpretation.TargetsToPropagate.FromProjectAndEntryTargets(node.ProjectInstance, requestedTargets);

                // Queue the project references for visitation, if the edge hasn't already been traversed.
                foreach (var projectReference in node.ProjectReferences)
                {
                    var applicableTargets = targetsToPropagate.GetApplicableTargets(projectReference.ProjectInstance);

                    var projectReferenceEdge = new ProjectGraphBuildRequest(
                        projectReference,
                        ExpandDefaultTargets(applicableTargets, projectReference.ProjectInstance.DefaultTargets));

                    if (encounteredEdges.Add(projectReferenceEdge))
                    {
                        edgesToVisit.Enqueue(projectReferenceEdge);
                    }
                }
            }

            // Dedupe target lists
            var entriesToUpdate = new List <KeyValuePair <ProjectGraphNode, ImmutableList <string> > >();

            foreach (var pair in targetLists)
            {
                var targetList = pair.Value;

                var seenTargets = new SortedSet <string>(StringComparer.OrdinalIgnoreCase);
                var i           = 0;
                while (i < targetList.Count)
                {
                    if (seenTargets.Add(targetList[i]))
                    {
                        i++;
                    }
                    else
                    {
                        targetList = targetList.RemoveAt(i);
                    }
                }

                // Only update if it changed
                if (targetList != pair.Value)
                {
                    entriesToUpdate.Add(new KeyValuePair <ProjectGraphNode, ImmutableList <string> >(pair.Key, targetList));
                }
            }

            // Update in a separate pass to avoid modifying a collection while iterating it.
            foreach (var pair in entriesToUpdate)
            {
                targetLists[pair.Key] = pair.Value;
            }

            return(targetLists);
        }
Exemplo n.º 8
0
 public CssStyleSheet ParseStyleSheet()
 {
     return(new CssStyleSheet(ImmutableList.CreateRange(_rootScope.ParseRuleList(true))));
 }
Exemplo n.º 9
0
 [Benchmark] public void Immutable_List() => SerializeAndDeserialize(ImmutableList.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg", "adafd0xd" }));
Exemplo n.º 10
0
 public BaseListMessageData(IEnumerable <IMessageData> data)
 {
     Items = ImmutableList.CreateRange(data);
 }
        /// <summary>
        /// To the immutable list.
        /// </summary>
        /// <returns>System.Collections.Immutable.IImmutableList&lt;T&gt;.</returns>
        public IImmutableList <T> ToImmutableList()
        {
            this.SortCollection();

            return(ImmutableList.CreateRange(this));
        }
Exemplo n.º 12
0
 public Game(List <Player> players, List <DevelopmentCardType> developmentCards, Dictionary <PlayerColor, Dictionary <BuildableType, int> > buildablePool)
 {
     Players          = ImmutableList.CreateRange(players);
     DevelopmentCards = developmentCards;
     BuildablePool    = buildablePool;
 }
Exemplo n.º 13
0
        public static Entity InformModifiers(MutatingWorld world, Entity entity, Func <IModifier, IModifier> modFunc)
        {
            if (entity.Modifiers.Count > 0)
            {
                List <IModifier> newModifiers = new List <IModifier>(entity.Modifiers.Count);
                for (int i = 0; i < entity.Modifiers.Count; i++)
                {
                    var mod = entity.Modifiers[i];
                    mod = modFunc(mod);
                    if (mod != null)
                    {
                        newModifiers.Add(mod);
                    }
                }

                world.Entities[entity.ID] = new Entity(world.Entities[entity.ID], modifiers: (Maybe <ImmutableList <IModifier> >)ImmutableList.CreateRange(newModifiers));
            }

            return(world.Entities[entity.ID]);
        }
Exemplo n.º 14
0
        public void Initialize()
        {
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyIImmutableList = ImmutableList.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyIImmutableStack = ImmutableStack.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyIImmutableQueue = ImmutableQueue.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyIImmutableSet = ImmutableHashSet.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyImmutableHashSet = ImmutableHashSet.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyImmutableList = ImmutableList.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyImmutableStack = ImmutableStack.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
            {
                SimpleTestClass obj1 = new SimpleTestClass();
                obj1.Initialize();

                SimpleTestClass obj2 = new SimpleTestClass();
                obj2.Initialize();

                MyImmutableQueue = ImmutableQueue.CreateRange(new List <SimpleTestClass> {
                    obj1, obj2
                });
            }
        }
        public void Initialize()
        {
            MyInt16               = 1;
            MyInt32               = 2;
            MyInt64               = 3;
            MyUInt16              = 4;
            MyUInt32              = 5;
            MyUInt64              = 6;
            MyByte                = 7;
            MySByte               = 8;
            MyChar                = 'a';
            MyString              = "Hello";
            MyBooleanTrue         = true;
            MyBooleanFalse        = false;
            MySingle              = 1.1f;
            MyDouble              = 2.2d;
            MyDecimal             = 3.3m;
            MyDateTime            = new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc);
            MyDateTimeOffset      = new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0));
            MyGuid                = new Guid("1B33498A-7B7D-4DDA-9C13-F6AA4AB449A6");
            MyUri                 = new Uri("https://github.com/dotnet/runtime");
            MyEnum                = SampleEnum.Two;
            MyInt64Enum           = SampleEnumInt64.MinNegative;
            MyUInt64Enum          = SampleEnumUInt64.Max;
            MyInt16Array          = new short[] { 1 };
            MyInt32Array          = new int[] { 2 };
            MyInt64Array          = new long[] { 3 };
            MyUInt16Array         = new ushort[] { 4 };
            MyUInt32Array         = new uint[] { 5 };
            MyUInt64Array         = new ulong[] { 6 };
            MyByteArray           = new byte[] { 7 };
            MySByteArray          = new sbyte[] { 8 };
            MyCharArray           = new char[] { 'a' };
            MyStringArray         = new string[] { "Hello" };
            MyBooleanTrueArray    = new bool[] { true };
            MyBooleanFalseArray   = new bool[] { false };
            MySingleArray         = new float[] { 1.1f };
            MyDoubleArray         = new double[] { 2.2d };
            MyDecimalArray        = new decimal[] { 3.3m };
            MyDateTimeArray       = new DateTime[] { new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc) };
            MyDateTimeOffsetArray = new DateTimeOffset[] { new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0)) };
            MyGuidArray           = new Guid[] { new Guid("1B33498A-7B7D-4DDA-9C13-F6AA4AB449A6") };
            MyUriArray            = new Uri[] { new Uri("https://github.com/dotnet/runtime") };
            MyEnumArray           = new SampleEnum[] { SampleEnum.Two };
            MySimpleStruct        = new SimpleStruct {
                One = 11, Two = 1.9999
            };
            MySimpleTestStruct = new SimpleTestStruct {
                MyInt64 = 64, MyString = "Hello", MyInt32Array = new int[] { 32 }
            };

            MyInt16TwoDimensionArray    = new int[2][];
            MyInt16TwoDimensionArray[0] = new int[] { 10, 11 };
            MyInt16TwoDimensionArray[1] = new int[] { 20, 21 };

            MyInt16TwoDimensionList = new List <List <int> >();
            MyInt16TwoDimensionList.Add(new List <int> {
                10, 11
            });
            MyInt16TwoDimensionList.Add(new List <int> {
                20, 21
            });

            MyInt16ThreeDimensionArray       = new int[2][][];
            MyInt16ThreeDimensionArray[0]    = new int[2][];
            MyInt16ThreeDimensionArray[1]    = new int[2][];
            MyInt16ThreeDimensionArray[0][0] = new int[] { 11, 12 };
            MyInt16ThreeDimensionArray[0][1] = new int[] { 13, 14 };
            MyInt16ThreeDimensionArray[1][0] = new int[] { 21, 22 };
            MyInt16ThreeDimensionArray[1][1] = new int[] { 23, 24 };

            MyInt16ThreeDimensionList = new List <List <List <int> > >();
            var list1 = new List <List <int> >();

            MyInt16ThreeDimensionList.Add(list1);
            list1.Add(new List <int> {
                11, 12
            });
            list1.Add(new List <int> {
                13, 14
            });
            var list2 = new List <List <int> >();

            MyInt16ThreeDimensionList.Add(list2);
            list2.Add(new List <int> {
                21, 22
            });
            list2.Add(new List <int> {
                23, 24
            });

            MyStringList = new List <string>()
            {
                "Hello"
            };

            MyStringIEnumerable = new string[] { "Hello" };
            MyStringIList       = new string[] { "Hello" };
            MyStringICollection = new string[] { "Hello" };

            MyStringIEnumerableT         = new string[] { "Hello" };
            MyStringIListT               = new string[] { "Hello" };
            MyStringICollectionT         = new string[] { "Hello" };
            MyStringIReadOnlyCollectionT = new string[] { "Hello" };
            MyStringIReadOnlyListT       = new string[] { "Hello" };
            MyStringISetT = new HashSet <string> {
                "Hello"
            };

            MyStringToStringKeyValuePair = new KeyValuePair <string, string>("myKey", "myValue");
            MyStringToStringIDict        = new Dictionary <string, string> {
                { "key", "value" }
            };

            MyStringToStringGenericDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringGenericIDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringGenericIReadOnlyDict = new Dictionary <string, string> {
                { "key", "value" }
            };

            MyStringToStringImmutableDict       = ImmutableDictionary.CreateRange(MyStringToStringGenericDict);
            MyStringToStringIImmutableDict      = ImmutableDictionary.CreateRange(MyStringToStringGenericDict);
            MyStringToStringImmutableSortedDict = ImmutableSortedDictionary.CreateRange(MyStringToStringGenericDict);

            MyStringStackT = new Stack <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringQueueT = new Queue <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringHashSetT = new HashSet <string>(new List <string>()
            {
                "Hello"
            });
            MyStringLinkedListT = new LinkedList <string>(new List <string>()
            {
                "Hello"
            });
            MyStringSortedSetT = new SortedSet <string>(new List <string>()
            {
                "Hello"
            });

            MyStringIImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableHashSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutablQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableSortedSetT = ImmutableSortedSet.CreateRange(new List <string> {
                "Hello"
            });

            MyListOfNullString = new List <string> {
                null
            };
        }
Exemplo n.º 16
0
 public void ReplaceAll(IEnumerable <TItemView> items)
 {
     Volatile.Write(
         ref this.cacheSnapshot,
         Tuple.Create <DateTime?, ImmutableList <TItemView> >(DateTime.UtcNow, ImmutableList.CreateRange <TItemView>(items)));
 }
Exemplo n.º 17
0
 public StringIImmutableListWrapper(List <string> items)
 {
     _list = ImmutableList.CreateRange(items);
 }
Exemplo n.º 18
0
        public override async Task <ImmutableList <World> > FetchWorldsInSectorAsync(int sectorX, int sectorY)
        {
            ImmutableList <World> result;
            var cacheKey = Tuple.Create(sectorX, sectorY);

            if (m_WorldsInSector.TryGetValue(cacheKey, out result))
            {
                return(result);
            }


            var baseUri = new Uri(string.Format("http://travellermap.com/api/sec?sx={0}&sy={1}&type=TabDelimited", sectorX, sectorY));
            var rawFile = await s_Client.GetStringAsync(baseUri).ConfigureAwait(false);

            if (rawFile.Length == 0)
            {
                return(ImmutableList.Create <World>());
            }

            var memStream = new StringReader(rawFile);

            var temp = new List <World>();

            using (var parser = new TextFieldParser(memStream))
            {
                parser.SetDelimiters("\t");


                var headers = new Dictionary <string, int>();
                var index   = 0;
                foreach (var header in parser.ReadFields())
                {
                    headers[header] = index++;
                }


                while (!parser.EndOfData)
                {
                    //Sector	SS	Hex	Name	UWP	Bases	Remarks	Zone	PBG	Allegiance	Stars	{Ix}	(Ex)	[Cx]	Nobility	W	RU
                    World world = new World();

                    var fields = parser.ReadFields();

                    world.SectorX = sectorX;
                    world.SectorY = sectorY;
                    //world.SectorCode = fields[headers["Sector"]];
                    world.SubSectorIndex = fields[headers["SS"]];
                    world.Hex            = fields[headers["Hex"]];
                    world.Name           = fields[headers["Name"]];
                    world.UWP            = fields[headers["UWP"]];
                    world.Bases          = fields[headers["Bases"]];
                    world.Remarks        = fields[headers["Remarks"]];
                    world.Zone           = fields[headers["Zone"]];
                    world.PBG            = fields[headers["PBG"]];
                    world.Allegiance     = fields[headers["Allegiance"]];
                    //world.Stars = fields[headers["Stars"]];
                    world.Ix       = fields[headers["{Ix}"]];
                    world.Ex       = fields[headers["(Ex)"]];
                    world.Cx       = fields[headers["[Cx]"]];
                    world.Nobility = fields[headers["Nobility"]];
                    int tmp;
                    int.TryParse(fields[headers["W"]], out tmp);
                    world.Worlds        = tmp;
                    world.ResourceUnits = int.Parse(fields[headers["RU"]]);



                    temp.Add(world);
                }
            }


            result = ImmutableList.CreateRange(temp);
            m_WorldsInSector.TryAdd(cacheKey, result);
            return(result);
        }
Exemplo n.º 19
0
 internal void Finish(IList <PlantUmlComponentDependency> dependencies)
 {
     _dependencies = ImmutableList.CreateRange(dependencies);
 }
Exemplo n.º 20
0
        /// <summary>
        /// To the immutable.
        /// </summary>
        /// <typeparam name="T">The type of T.</typeparam>
        /// <param name="values">The values.</param>
        /// <returns>IImmutableList&lt;T&gt;.</returns>
        public static ImmutableList <T> ToImmutable <T>(this IEnumerable <T> values)
        {
            var builder = ImmutableList.CreateRange <T>(values);

            return(builder);
        }
Exemplo n.º 21
0
 public TradesDownloader(IList <IMarketApi> marketApis)
 {
     _marketApis = ImmutableList.CreateRange(marketApis);
 }
Exemplo n.º 22
0
 /// <summary>
 ///     Convert the <see cref="JobData"/> to a <see cref="Job"/>.
 /// </summary>
 /// <returns>
 ///     The new <see cref="Job"/>.
 /// </returns>
 public Job ToJob()
 {
     return(new Job(Id, Status, TargetUrl, Content,
                    messages: ImmutableList.CreateRange(Messages)
                    ));
 }
Exemplo n.º 23
0
        public override void Initialize()
        {
            base.Initialize();

            MyInt16Array        = new short[] { 1 };
            MyInt32Array        = new int[] { 2 };
            MyInt64Array        = new long[] { 3 };
            MyUInt16Array       = new ushort[] { 4 };
            MyUInt32Array       = new uint[] { 5 };
            MyUInt64Array       = new ulong[] { 6 };
            MyByteArray         = new byte[] { 7 };
            MySByteArray        = new sbyte[] { 8 };
            MyCharArray         = new char[] { 'a' };
            MyStringArray       = new string[] { "Hello" };
            MyBooleanTrueArray  = new bool[] { true };
            MyBooleanFalseArray = new bool[] { false };
            MySingleArray       = new float[] { 1.1f };
            MyDoubleArray       = new double[] { 2.2d };
            MyDecimalArray      = new decimal[] { 3.3m };
            MyDateTimeArray     = new DateTime[] { new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc) };
            MyEnumArray         = new SampleEnum[] { SampleEnum.Two };

            MyStringList = new List <string>()
            {
                "Hello"
            };

            MyStringIEnumerable = new string[] { "Hello" };
            MyStringIList       = new string[] { "Hello" };
            MyStringICollection = new string[] { "Hello" };

            MyStringIEnumerableT         = new string[] { "Hello" };
            MyStringIListT               = new string[] { "Hello" };
            MyStringICollectionT         = new string[] { "Hello" };
            MyStringIReadOnlyCollectionT = new string[] { "Hello" };
            MyStringIReadOnlyListT       = new string[] { "Hello" };
            MyStringIReadOnlyListT       = new HashSet <string> {
                "Hello"
            };

            MyStringISetT = new HashSet <string> {
                "Hello"
            };

            MyStringToStringKeyValuePair = new KeyValuePair <string, string>("myKey", "myValue");
            MyStringToStringIDict        = new Dictionary <string, string> {
                { "key", "value" }
            };

            MyStringToStringGenericDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringGenericIDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringGenericIReadOnlyDict = new Dictionary <string, string> {
                { "key", "value" }
            };

            MyStringToStringImmutableDict       = ImmutableDictionary.CreateRange((Dictionary <string, string>)MyStringToStringGenericDict);
            MyStringToStringIImmutableDict      = ImmutableDictionary.CreateRange((Dictionary <string, string>)MyStringToStringGenericDict);
            MyStringToStringImmutableSortedDict = ImmutableSortedDictionary.CreateRange((Dictionary <string, string>)MyStringToStringGenericDict);

            MyStringStackT = new Stack <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringQueueT = new Queue <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringHashSetT = new HashSet <string>(new List <string>()
            {
                "Hello"
            });
            MyStringLinkedListT = new LinkedList <string>(new List <string>()
            {
                "Hello"
            });
            MyStringSortedSetT = new SortedSet <string>(new List <string>()
            {
                "Hello"
            });

            MyStringIImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableHashSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutablQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableSortedSetT = ImmutableSortedSet.CreateRange(new List <string> {
                "Hello"
            });
        }
Exemplo n.º 24
0
 public SuccessAction(IEnumerable <int> data)
 {
     this.data = ImmutableList.CreateRange(data);
 }
 public ProgressCompletedEventArgs(IEnumerable <ProgressTask> additionalTasks)
 {
     AdditionalTasks = ImmutableList.CreateRange(additionalTasks);
 }
Exemplo n.º 26
0
        public void Serialize_ImmutableList()
        {
            var collection = ImmutableList.CreateRange(new[] { "abc", "cbd0", "sdsd4", "4dfg" });

            _serializer.Serialize(collection, _stream);
        }
Exemplo n.º 27
0
        public static void ArrayAsRootObject()
        {
            const string ExpectedJson         = @"[1,true,{""City"":""MyCity""},null,""foo""]";
            const string ReversedExpectedJson = @"[""foo"",null,{""City"":""MyCity""},true,1]";

            string[] expectedObjects = { @"""foo""", @"null", @"{""City"":""MyCity""}", @"true", @"1" };

            var address = new Address();

            address.Initialize();

            var    array = new object[] { 1, true, address, null, "foo" };
            string json  = JsonSerializer.Serialize(array);

            Assert.Equal(ExpectedJson, json);

            var dictionary = new Dictionary <string, string> {
                { "City", "MyCity" }
            };
            var arrayWithDictionary = new object[] { 1, true, dictionary, null, "foo" };

            json = JsonSerializer.Serialize(arrayWithDictionary);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(array);
            Assert.Equal(ExpectedJson, json);

            List <object> list = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(list);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(list);
            Assert.Equal(ExpectedJson, json);

            IEnumerable ienumerable = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(ienumerable);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(ienumerable);
            Assert.Equal(ExpectedJson, json);

            IList ilist = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(ilist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(ilist);
            Assert.Equal(ExpectedJson, json);

            ICollection icollection = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(icollection);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(icollection);
            Assert.Equal(ExpectedJson, json);

            IEnumerable <object> genericIEnumerable = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIEnumerable);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIEnumerable);
            Assert.Equal(ExpectedJson, json);

            IList <object> genericIList = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIList);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIList);
            Assert.Equal(ExpectedJson, json);

            ICollection <object> genericICollection = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericICollection);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericICollection);
            Assert.Equal(ExpectedJson, json);

            IReadOnlyCollection <object> genericIReadOnlyCollection = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIReadOnlyCollection);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIReadOnlyCollection);
            Assert.Equal(ExpectedJson, json);

            IReadOnlyList <object> genericIReadonlyList = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIReadonlyList);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIReadonlyList);
            Assert.Equal(ExpectedJson, json);

            ISet <object> iset = new HashSet <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(iset);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iset);
            Assert.Equal(ExpectedJson, json);

            Stack <object> stack = new Stack <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(stack);
            Assert.Equal(ReversedExpectedJson, json);

            json = JsonSerializer.Serialize <object>(stack);
            Assert.Equal(ReversedExpectedJson, json);

            Queue <object> queue = new Queue <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(queue);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(queue);
            Assert.Equal(ExpectedJson, json);

            HashSet <object> hashset = new HashSet <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(hashset);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(hashset);
            Assert.Equal(ExpectedJson, json);

            LinkedList <object> linkedlist = new LinkedList <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(linkedlist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(linkedlist);
            Assert.Equal(ExpectedJson, json);

            IImmutableList <object> iimmutablelist = ImmutableList.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutablelist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iimmutablelist);
            Assert.Equal(ExpectedJson, json);

            IImmutableStack <object> iimmutablestack = ImmutableStack.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iimmutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            IImmutableQueue <object> iimmutablequeue = ImmutableQueue.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutablequeue);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iimmutablequeue);
            Assert.Equal(ExpectedJson, json);

            IImmutableSet <object> iimmutableset = ImmutableHashSet.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutableset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            json = JsonSerializer.Serialize <object>(iimmutableset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            ImmutableHashSet <object> immutablehashset = ImmutableHashSet.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablehashset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            json = JsonSerializer.Serialize <object>(immutablehashset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            ImmutableList <object> immutablelist = ImmutableList.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablelist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(immutablelist);
            Assert.Equal(ExpectedJson, json);

            ImmutableStack <object> immutablestack = ImmutableStack.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            json = JsonSerializer.Serialize <object>(immutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            ImmutableQueue <object> immutablequeue = ImmutableQueue.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablequeue);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(immutablequeue);
            Assert.Equal(ExpectedJson, json);
        }
 /// <summary>
 /// Create an immutable list
 /// </summary>
 public static IImmutableList <T> toList <T>(IEnumerable <T> items) =>
 ImmutableList.CreateRange(items);
Exemplo n.º 29
0
 public static ImmutableList <T> ToImmutable <T>([NotNull] this IEnumerable <T> list)
 {
     return(ImmutableList.CreateRange(list));
 }
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="items">the feature flags, indexed by key</param>
 public FullDataSet(IEnumerable <KeyValuePair <string, ItemDescriptor> > items)
 {
     Items = items is null ? ImmutableList <KeyValuePair <string, ItemDescriptor> > .Empty :
             ImmutableList.CreateRange(items);
 }