当前位置: 首页>>代码示例>>C#>>正文


C# List.ToArray方法代码示例

本文整理汇总了C#中Data.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Data.List的用法示例。


在下文中一共展示了List.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunTest1

 internal void RunTest1()
 {
     //BlockStore.AddBlock("C:\\Users\\jony\\Files\\Data\\SEDM\\v3\\2009\\October2009\\01Oct0900_0.zip");
     string datRoot = "C:\\Users\\jony\\Files\\Data\\SEDM\\v3\\2009\\October2009\\01Oct0900_";
     List<string> files = new List<string>();
     for (int i = 0; i < 10; i++) files.Add(datRoot + i + ".zip");
     BlockStore.AddBlocks(files.ToArray());
 }
开发者ID:ColdMatter,项目名称:EDMSuite,代码行数:8,代码来源:Controller.cs

示例2: gemData

        public int gemData(string Forsøgsnavn, List<double> Rådata)
        {
            Datostempel = DateTime.Now;
            double[] BLOBListe = Rådata.ToArray();
            byte[] BYTEliste = Rådata.SelectMany(value => BitConverter.GetBytes(value)).ToArray();

            String query = "INSERT INTO SEMPRJ3 (Forsøgsnavn, Datostempel, Blodtryksmåling) " +
                "Output Inserted.Id " +
                "VALUES(@Forsøgsnavn, @Dato, @MåleListe) ";
            conn.Open();

            SqlCommand command = new SqlCommand(query, conn);
            command.Parameters.AddWithValue("@Forsøgsnavn", Forsøgsnavn);
            command.Parameters.Add("@Dato", SqlDbType.DateTime).Value = Datostempel;
            command.Parameters.Add("@MåleListe", SqlDbType.Image).Value = BYTEliste;
            GemtId = Convert.ToInt32(command.ExecuteScalar());

            conn.Close();
            return GemtId;
        }
开发者ID:banasik,项目名称:Semesterprojekt3,代码行数:20,代码来源:DatabaseAdgang.cs

示例3: GetAllItems

        private static KeyValuePair<Item, int>[] GetAllItems(IEnumerable<ItemReference> references)
        {
            List<KeyValuePair<Item, int>> result = new List<KeyValuePair<Item, int>>();
            foreach (ItemReference reference in references)
            {
                Database database = Factory.GetDatabase(reference.ItemUri.DatabaseName);
                Item item = database.GetItem(reference.ItemUri.ItemID);

                DoJob(item, reference.Recursive,
                   delegate (Item it)
                   {
                       Item[] itemsWithMedia = Utils.GetAllVersionsWithMedia(it);
                       if (itemsWithMedia != null && itemsWithMedia.Length > 0)
                       {
                           result.Add(new KeyValuePair<Item, int>(it, itemsWithMedia.Length));
                       }
                   });
            }

            return result.ToArray();
        }
开发者ID:ivansharamok,项目名称:MediaConversionTool,代码行数:21,代码来源:MigrationWorker.cs

示例4: GetItemsName

 public string[] GetItemsName()
 {
     List<string> name = new List<string>();
     productId = (IList<string>)Session["ProId"];
     foreach (var item in productId)
     {
         int id = Convert.ToInt32(item);
         name.Add(db.Products.Find(id).ProductName);
     }
     return name.ToArray();
 }
开发者ID:mahmoodali31,项目名称:shop,代码行数:11,代码来源:ShoppingCartController.cs

示例5: SearchSubmitButton_Click

        /// <summary>
        /// Handles the Click event of the SearchSubmitButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void SearchSubmitButton_Click(object sender, EventArgs e)
        {
            List<string> parameters = new List<string>();
            AddParameter(parameters, "Address", this.SearchAddressTextBox.Visible ? this.SearchAddressTextBox.Text : null);
            AddParameter(parameters, "City", this.SearchCityTextBox.Visible ? this.SearchCityTextBox.Text : null);
            AddParameter(parameters, "Region", this.SearchRegionDropDownList.Visible ? this.SearchRegionDropDownList.SelectedValue : null);
            AddParameter(parameters, "Zip", this.SearchPostalCodeTextBox.Visible ? this.SearchPostalCodeTextBox.Text : null);
            AddParameter(parameters, "Country", this.SearchCountryDropDownList.Visible ? this.SearchCountryDropDownList.SelectedValue : null);
            AddParameter(parameters, "Distance", this.SearchRadiusDropDownList.Visible ? this.SearchRadiusDropDownList.SelectedValue : null);
            AddParameter(parameters, "FilterCountry", this.FilterCountryDropDownList.Visible ? this.FilterCountryDropDownList.SelectedValue : null);

            this.Response.Redirect(Globals.NavigateURL(this.DisplayTabId, string.Empty, parameters.ToArray()));
        }
开发者ID:EngageSoftware,项目名称:Engage-Locator,代码行数:18,代码来源:MainDisplay.ascx.cs

示例6: ExecuteReader

		public string ExecuteReader(string queryData)
		{
			try
			{
				var query = LinqServiceSerializer.Deserialize(queryData);

				ValidateQuery(query);

				using (var db = CreateDataContext())
				{
					var obj = db.SetQuery(new QueryContext { SqlQuery = query.Query, Parameters = query.Parameters });

					using (var rd = db.ExecuteReader(obj))
					{
						var ret = new LinqServiceResult
						{
							QueryID    = Guid.NewGuid(),
							FieldCount = rd.FieldCount,
							FieldNames = new string[rd.FieldCount],
							FieldTypes = new Type  [rd.FieldCount],
							Data       = new List<string[]>(),
						};

						for (var i = 0; i < ret.FieldCount; i++)
						{
							ret.FieldNames[i] = rd.GetName(i);
							ret.FieldTypes[i] = rd.GetFieldType(i);
						}

						var varyingTypes = new List<Type>();

						while (rd.Read())
						{
							var data  = new string  [rd.FieldCount];
							var codes = new TypeCode[rd.FieldCount];

							for (var i = 0; i < ret.FieldCount; i++)
								codes[i] = Type.GetTypeCode(ret.FieldTypes[i]);

							ret.RowCount++;

							for (var i = 0; i < ret.FieldCount; i++)
							{
								if (!rd.IsDBNull(i))
								{
									var code = codes[i];
									var type = rd.GetFieldType(i);
									var idx = -1;

									if (type != ret.FieldTypes[i])
									{
										code = Type.GetTypeCode(type);
										idx  = varyingTypes.IndexOf(type);

										if (idx < 0)
										{
											varyingTypes.Add(type);
											idx = varyingTypes.Count - 1;
										}
									}

									switch (code)
									{
										case TypeCode.Decimal  : data[i] = rd.GetDecimal (i).ToString(CultureInfo.InvariantCulture); break;
										case TypeCode.Double   : data[i] = rd.GetDouble  (i).ToString(CultureInfo.InvariantCulture); break;
										case TypeCode.Single   : data[i] = rd.GetFloat   (i).ToString(CultureInfo.InvariantCulture); break;
										case TypeCode.DateTime : data[i] = rd.GetDateTime(i).ToString("o");                          break;
										case TypeCode.Boolean  : data[i] = rd.GetBoolean (i).ToString(CultureInfo.InvariantCulture); break;
										default                :
											{
												if (type == typeof(DateTimeOffset))
												{
													var dt = rd.GetValue(i);

													if (dt is DateTime)
														data[i] = ((DateTime)dt).ToString("o");
													else if (dt is DateTimeOffset)
														data[i] = ((DateTimeOffset)dt).ToString("o");
													else
														data[i] = rd.GetValue(i).ToString();
												}
												else if (ret.FieldTypes[i] == typeof(byte[]))
													data[i] = Convert.ToBase64String((byte[])rd.GetValue(i));
												else
													data[i] = (rd.GetValue(i) ?? "").ToString();

												break;
											}
									}

									if (idx >= 0)
										data[i] = "\0" + (char)idx + data[i];
								}
							}

							ret.Data.Add(data);
						}

						ret.VaryingTypes = varyingTypes.ToArray();

//.........这里部分代码省略.........
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:101,代码来源:LinqService.cs

示例7: UpdatePlanningElementData


//.........这里部分代码省略.........
                                            { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, 
                                            { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, 
                                            { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, 
                                            { ImpModelPlanning.ElementIdStatus, element.Status }, 
                                        }
                                };

                                statementList.Add( update.ToString() );
                            }
                            else
                            {
                                // We must insert a new row.
                                var insert = new ImpactInsert( ImpModelPlanning.Instance )
                                {
                                    Columns =
                                        {
                                            { ImpModelPlanning.Factory, factory }, 
                                            { ImpModelPlanning.Project, project }, 
                                            { ImpModelPlanning.ElementId, element.ElementId }, 
                                            { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, 
                                            { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, 
                                            { ImpModelPlanning.ProductionDate, element.ProductionDate }, 
                                            { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, 
                                            { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, 
                                            { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, 
                                            { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, 
                                            { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, 
                                            { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, 
                                            { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, 
                                            { ImpModelPlanning.ElementIdStatus, element.Status }, 
                                        }
                                };

                                statementList.Add( insert.ToString() );
                            }
                        }

                        database.ExecuteNonQuery( statementList.ToArray() );
                    }
                    break;
                }
                case DataSource.SqlServer:
                case DataSource.SqlServerExpress:
                {
                    List<string> statementList = new List<string>( planningElementList.Count );

                    foreach( var element in planningElementList )
                    {
                        string producingFactory;

                        if( 0 == string.Compare( Factory.External.Number, element.ProducingFactory, StringComparison.OrdinalIgnoreCase ) )
                        {
                            producingFactory = ProjectBrowserLoader.ProducingFactoryExternalValue;
                        }
                        else
                        {
                            producingFactory = element.ProducingFactory;
                        }

                        ImpactInsertOrUpdate insertOrUpdate = new ImpactInsertOrUpdate( ImpModelPlanning.Instance )
                        {
                            Keys =
                            {
                                { ImpModelPlanning.Factory, factory }, 
                                { ImpModelPlanning.Project, project }, 
                                { ImpModelPlanning.ElementId, element.ElementId }, 
                            }, 
                            Columns =
                            {
                                { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, 
                                { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, 
                                { ImpModelPlanning.ProductionDate, element.ProductionDate }, 
                                { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, 
                                { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, 
                                { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, 
                                { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, 
                                { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, 
                                { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, 
                                { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, 
                                { ImpModelPlanning.ElementIdStatus, element.Status }, 
                            }
                        };

                        statementList.Add( insertOrUpdate.ToString() );
                    }

                    using( var database = new ImpactDatabase() )
                    {
                        database.ExecuteNonQuery( statementList.ToArray() );
                    }

                    break;
                }

                default:
                {
                    throw new InvalidOperationException( "Unknown database source." );
                }
            }
        }
开发者ID:FabioOstlind,项目名称:TestRepo,代码行数:101,代码来源:ProjectManager.svc.cs

示例8: SplitStream

		string[] SplitStream( Stream s )
		{
			var list = new List<string>();

			using ( var r = new StreamReader( s ) )
				while ( !r.EndOfStream )
					list.Add( r.ReadLine() );

			return list.ToArray();
		}
开发者ID:yhchen,项目名称:myToolsBox,代码行数:10,代码来源:CompareForm.cs

示例9: GetLocationTypeList

        /// <summary>
        /// Gets a comma-delimited list of the IDs of the selected location types.
        /// </summary>
        /// <returns>A comma-delimited list of the IDs of the selected location types.</returns>
        private string GetLocationTypeList()
        {
            List<string> locationTypeIds = new List<string>();
            foreach (ListItem li in this.lbLocationType.Items)
            {
                if (li.Selected)
                {
                    locationTypeIds.Add(li.Value);
                }
            }

            if (locationTypeIds.Count == 0)
            {
                locationTypeIds.Add(this.lbLocationType.Items[0].Value);
            }

            return string.Join(",", locationTypeIds.ToArray());
        }
开发者ID:EngageSoftware,项目名称:Engage-Locator,代码行数:22,代码来源:settings.ascx.cs

示例10: Build

        public static IEnumerable<IChain> Build(IEnumerable<ISnapshotProvider> sources, IEnumerable<ISnapshotConsumer> sinks, IEnumerable<IMultipleSnapshotConsumer> multiSinks, IEnumerable<ChainElement> configs)
        {
            var chains = new List<IChain>();

            sources = sources.ToArray();
            sinks = sinks.ToArray();
            multiSinks = multiSinks.ToArray();

            foreach(var config in configs)
            {
                try
                {
                    if (!sources.Any(s => config.Sources.Split(',').Any(i => i.Equals(s.Id))))
                    {
                        Log.Warn(string.Format("Couldn't find source '{0}' in the set of sources supplied for chain '{1}'.", config.Sources, config.Id));

                        continue;
                    }

                    if (!sinks.Any(s => config.Sinks.Split(',').Any(i => i.Equals(s.Id))) && !multiSinks.Any(s => config.MultiSinks.Split(',').Any(i => i.Equals(s.Id))))
                    {
                        Log.Warn(string.Format("Couldn't find one of sinks '{0}' in the set of sinks and multisinks supplied for chain '{1}'.", config.Sinks, config.Id));

                        continue;
                    }

                    if (!string.IsNullOrEmpty(config.Sinks) && config.Sources.Split(',').Count().Equals(1))
                    {                      
                        var chosenSource = sources.First(s => s.Id.Equals(config.Sources));

                        var chosenSinks = new List<ISnapshotConsumer>();

                        foreach (var sinkName in config.Sinks.Split(','))
                        {
                            chosenSinks.Add(sinks.First(s => s.Id.Equals(sinkName)));
                        }

                        chains.Add(new MultipleSinkChain(config.Id, config.Name, chosenSource, chosenSinks.ToArray()));
                    }
                    
                    if (!string.IsNullOrEmpty(config.MultiSinks))
                    {
                        var chosenSink = multiSinks.First(s => s.Id.Equals(config.MultiSinks));

                        var chosenSources = new List<ISnapshotProvider>();

                        foreach(var _ in config.Sources.Split(','))
                        {
                            var sourceName = _.TrimStart(' ');

                            chosenSources.Add(sources.First(s => s.Id.Equals(sourceName)));
                        }

                        chains.Add(new MultipleSourceChain(config.Id, config.Name, chosenSink, chosenSources.ToArray()));
                    }
                }
                catch (InvalidOperationException ioe)
                {
                    Log.Warn(string.Format("Couldn't construct chain: '{0}' '{1}' '{2}': {3}", config.Id, config.Sources, config.Sinks, ioe.Message));
                }
            }

            return chains;
        }
开发者ID:timbarrass,项目名称:Alembic.Metrics,代码行数:64,代码来源:ChainBuilder.cs

示例11: Gen

		string[] Gen()
		{
			var l = new List<string>();
			var lines = r.Next( 1000 ) + 500;
			for ( int i = 0 ; i < lines ; i++ )
				l.Add( ( ( char ) ( 'a' + r.Next( 26 ) ) ).ToString() );

			return l.ToArray();
		}
开发者ID:yhchen,项目名称:myToolsBox,代码行数:9,代码来源:CompareForm.cs

示例12: CombineMeshes


//.........这里部分代码省略.........
                {
                    vertexStart = layers[i].vertexStart;
                    vertexCount = layers[i].vertexCount;
                    for(int j = 0; j < vertexCount; j++)
                    {
                        currentVertex = vertexStart + j;
                        uv[currentVertex] = meshes[i]._uvs[j];
                        uv2[currentVertex] = meshes[i]._uvs2[j];
                    }
                }

                if(useOpaqueShader)
                {
                    outputShaders.Add(SVGShader.GradientColorOpaque);
                }
                if(useTransparentShader)
                {
                    outputShaders.Add(SVGShader.GradientColorAlphaBlended);
                }
            } else {
                if(useOpaqueShader)
                {
                    outputShaders.Add(SVGShader.SolidColorOpaque);
                }
                if(useTransparentShader)
                {
                    outputShaders.Add(SVGShader.SolidColorAlphaBlended);
                }
            }

            if(useOpaqueShader && useTransparentShader)
            {
                triangles = new int[2][]{new int[opaqueTriangles], new int[transparentTriangles]};

                int lastVertexIndex = 0;
                int triangleCount;
                int lastOpauqeTriangleIndex = 0;
                int lastTransparentTriangleIndex = 0;

                for(int i = 0; i < totalMeshes; i++)
                {
                    triangleCount = meshes[i]._triangles.Length;
                    if(meshes[i]._fill.blend == FILL_BLEND.OPAQUE)
                    {
                        for(int j = 0; j < triangleCount; j++)
                        {
                            triangles[0][lastOpauqeTriangleIndex++] = lastVertexIndex + meshes[i]._triangles[j];
                        }
                    } else {
                        for(int j = 0; j < triangleCount; j++)
                        {
                            triangles[1][lastTransparentTriangleIndex++] = lastVertexIndex + meshes[i]._triangles[j];
                        }
                    }

                    lastVertexIndex += layers[i].vertexCount;
                }
            } else {
                triangles = new int[1][]{new int[totalTriangles]};

                int lastVertexIndex = 0;
                int triangleCount;
                int lastTriangleIndex = 0;

                for(int i = 0; i < totalMeshes; i++)
                {
                    triangleCount = meshes[i]._triangles.Length;
                    for(int j = 0; j < triangleCount; j++)
                    {
                        triangles[0][lastTriangleIndex++] = lastVertexIndex + meshes[i]._triangles[j];
                    }
                    lastVertexIndex += layers[i].vertexCount;
                }
            }

            if(outputShaders.Count != 0) shaders = outputShaders.ToArray();

            Mesh output = new Mesh();
            output.vertices = vertices;
            output.colors32 = colors32;

            if(hasGradients)
            {
                output.uv = uv;
                output.uv2 = uv2;
            }

            if(triangles.Length == 1)
            {
                output.triangles = triangles[0];
            } else {
                output.subMeshCount = triangles.Length;
                for(int i = 0; i < triangles.Length; i++)
                {
                    output.SetTriangles(triangles[i], i);
                }
            }

            return output;
        }
开发者ID:Ronnie619,项目名称:TouchScreenKiosk,代码行数:101,代码来源:SVGMesh.cs

示例13: TOFDemodulateBlock


//.........这里部分代码省略.........
                }

                //channelsToAnalyse = new int[] { bChannel, dbChannel, ebChannel, edbChannel, dbrf1fChannel,
                //    dbrf2fChannel, brf1fChannel, brf2fChannel, edbrf1fChannel, edbrf2fChannel, ebdbChannel,
                //    rf1fChannel, rf2fChannel, erf1fChannel, erf2fChannel, rf1aChannel, rf2aChannel, dbrf1aChannel,
                //    dbrf2aChannel, lf1Channel, dblf1Channel, lf2Channel, dblf2Channel
                //};
            }

            foreach (int channel in channelsToAnalyse)
            {
                // generate the Channel
                TOFChannel tc = new TOFChannel();
                TOF tOn = new TOF();
                TOF tOff = new TOF();
                for (int i = 0; i < blockLength; i++)
                {
                    if (stateSigns[channel, switchStates[i]]) tOn += ((TOF)((EDMPoint)(b.Points[i])).Shot.TOFs[detectorIndex]);
                    else tOff += ((TOF)((EDMPoint)(b.Points[i])).Shot.TOFs[detectorIndex]);
                }
                tOn /= (blockLength / 2);
                tOff /= (blockLength / 2);
                tc.On = tOn;
                tc.Off = tOff;
                // This "if" is to take care of the case of the "SIG" channel, for which there
                // is no off TOF.
                if (tc.Off.Length != 0) tc.Difference = tc.On - tc.Off;
                else tc.Difference = tc.On;

                // add the Channel to the ChannelSet
                List<string> usedSwitches = new List<string>();
                for (int i = 0; i < modNames.Count; i++)
                    if ((channel & (1 << i)) != 0) usedSwitches.Add(modNames[i]);
                string[] channelName = usedSwitches.ToArray();
                // the SIG channel has a special name
                if (channel == 0) channelName = new string[] {"SIG"};
                tcs.AddChannel(channelName, tc);
            }
            // ** add the special channels **

            // extract the TOFChannels that we need.
            TOFChannel c_eb = (TOFChannel)tcs.GetChannel(new string[] { "E", "B" });
            TOFChannel c_edb = (TOFChannel)tcs.GetChannel(new string[] {"E", "DB"});
            TOFChannel c_dbrf1f = (TOFChannel)tcs.GetChannel(new string[] { "DB", "RF1F" });
            TOFChannel c_dbrf2f = (TOFChannel)tcs.GetChannel(new string[] { "DB", "RF2F" });
            TOFChannel c_b = (TOFChannel)tcs.GetChannel(new string[] { "B" });
            TOFChannel c_db = (TOFChannel)tcs.GetChannel(new string[] { "DB" });
            TOFChannel c_sig = (TOFChannel)tcs.GetChannel(new string[] { "SIG" });

            TOFChannel c_brf1f = (TOFChannel)tcs.GetChannel(new string[] { "B", "RF1F" });
            TOFChannel c_brf2f = (TOFChannel)tcs.GetChannel(new string[] { "B", "RF2F" });
            TOFChannel c_edbrf1f = (TOFChannel)tcs.GetChannel(new string[] { "E", "DB", "RF1F" });
            TOFChannel c_edbrf2f = (TOFChannel)tcs.GetChannel(new string[] { "E", "DB", "RF2F" });
            TOFChannel c_ebdb= (TOFChannel)tcs.GetChannel(new string[] { "E", "B", "DB" });

            TOFChannel c_rf1f = (TOFChannel)tcs.GetChannel(new string[] { "RF1F" });
            TOFChannel c_rf2f = (TOFChannel)tcs.GetChannel(new string[] { "RF2F" });

            TOFChannel c_erf1f = (TOFChannel)tcs.GetChannel(new string[] { "E", "RF1F" });
            TOFChannel c_erf2f = (TOFChannel)tcs.GetChannel(new string[] { "E", "RF2F" });

            TOFChannel c_rf1a = (TOFChannel)tcs.GetChannel(new string[] { "RF1A" });
            TOFChannel c_rf2a = (TOFChannel)tcs.GetChannel(new string[] { "RF2A" });
            TOFChannel c_dbrf1a = (TOFChannel)tcs.GetChannel(new string[] { "DB", "RF1A" });
            TOFChannel c_dbrf2a = (TOFChannel)tcs.GetChannel(new string[] { "DB", "RF2A" });
开发者ID:ColdMatter,项目名称:EDMSuite,代码行数:66,代码来源:BlockTOFDemodulator.cs

示例14: GetWordsFromBoxAndLogContext

        private void GetWordsFromBoxAndLogContext()
        {
            string[] tempphrases = txtSearhBox.Text.Split(' ');
            List<string> phrases = new List<string>();

            for (int i = 0; i < tempphrases.Length; i++)
            {
                string trimmed = tempphrases[i].Trim();

                if (!String.IsNullOrEmpty(trimmed))
                {
                    phrases.Add(trimmed);
                }
            }

            if (phrases.Count > 0)
            {
                phraseLogger_.LogPhrasesToDB(phrases.ToArray());
            }
        }
开发者ID:Alymcgeel,项目名称:ContextSearchHelper,代码行数:20,代码来源:ContextSearchBar.cs

示例15: ReadRecipes

        public Recipe[] ReadRecipes(AuthIdentity identity, Guid[] recipeIds, ReadRecipeOptions options)
        {
            using (var session = this.GetSession())
            {
                var recipes = session.QueryOver<Recipes>()
                   .Fetch(prop => prop.RecipeMetadata).Eager
                   .Fetch(prop => prop.Ingredients).Eager
                   .Fetch(prop => prop.Ingredients[0].Ingredient).Eager
                   .Fetch(prop => prop.Ingredients[0].IngredientForm).Eager
                   .AndRestrictionOn(p => p.RecipeId).IsInG(recipeIds)
                   .TransformUsing(Transformers.DistinctRootEntity)
                   .List();

                if (!recipes.Any())
                {
                    throw new RecipeNotFoundException();
                }

                var ret = new List<Recipe>();
                foreach (var recipie in recipes)
                {
                    var recipe = new Recipe
                    {
                        Id = recipie.RecipeId,
                        Title = recipie.Title,
                        Description = recipie.Description,
                        DateEntered = recipie.DateEntered,
                        ImageUrl = recipie.ImageUrl,
                        ServingSize = recipie.ServingSize,
                        PreparationTime = recipie.PrepTime,
                        CookTime = recipie.CookTime,
                        Credit = recipie.Credit,
                        CreditUrl = recipie.CreditUrl,
                        AvgRating = recipie.Rating
                    };

                    if (options.ReturnMethod)
                    {
                        recipe.Method = recipie.Steps;
                    }

                    if (options.ReturnUserRating)
                    {
                        var id = recipie.RecipeId;
                        var rating = session.QueryOver<RecipeRatings>()
                           .Where(p => p.Recipe.RecipeId == id)
                           .Where(p => p.UserId == identity.UserId)
                           .SingleOrDefault();

                        recipe.UserRating = rating == null ? Rating.None : (Rating)rating.Rating;
                    }

                    recipe.Ingredients = recipie.Ingredients.Select(i => new IngredientUsage
                    {
                        Amount = i.Qty.HasValue ? new Amount(i.Qty.Value, i.Unit) : null,
                        PreparationNote = i.PrepNote,
                        Section = i.Section,
                        Form = i.IngredientForm != null ? i.IngredientForm.AsIngredientForm() : null, // Note: Form will be null when usage has no amount
                        Ingredient = i.Ingredient.AsIngredient()
                    }).ToArray();

                    recipe.Tags = recipie.RecipeMetadata.Tags;
                    ret.Add(recipe);
                }

                return ret.ToArray();
            }
        }
开发者ID:Derneuca,项目名称:KitchenPCTeamwork,代码行数:68,代码来源:DatabaseAdapter.cs


注:本文中的Data.List.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。