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


C# Collection.Add方法代码示例

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


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

示例1: AddCollectionCode

        private static void AddCollectionCode(PropertyDefinition property, bool isFirst, Collection<Instruction> ins, VariableDefinition resultVariable, MethodDefinition method, TypeDefinition type)
        {
            if (isFirst)
            {
                ins.Add(Instruction.Create(OpCodes.Ldc_I4_0));
                ins.Add(Instruction.Create(OpCodes.Stloc, resultVariable));
            }

            ins.If(
                c =>
                {
                    LoadVariable(property, c, type);

                },
                t =>
                {
                    LoadVariable(property, t, type);
                    var enumeratorVariable = method.Body.Variables.Add(property.Name + "Enumarator", ReferenceFinder.IEnumerator.TypeReference);
                    var currentVariable = method.Body.Variables.Add(property.Name + "Current", ReferenceFinder.Object.TypeReference);

                    GetEnumerator(t, enumeratorVariable);

                    AddCollectionLoop(resultVariable, t, enumeratorVariable, currentVariable);
                },
                f => { });
        }
开发者ID:kzaikin,项目名称:Equals,代码行数:26,代码来源:GetHashCodeInjector.cs

示例2: DrawCore

        protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
        {
            var startPointShapes = new Collection<BaseShape>();
            var endPointShapes = new Collection<BaseShape>();
            var lineShapes = new Collection<BaseShape>();

            //Loops thru the features to display the first and end point of each LineShape of the MultilineShape.
            foreach (var feature in features)
            {
                var shape = feature.GetShape();
                lineShapes.Add(shape);
                if (shape is MultilineShape)
                {
                    var multilineShape = (MultilineShape)shape;
                    for (var i = 0; i <= multilineShape.Lines.Count - 1; i++)
                    {
                        var lineShape = multilineShape.Lines[i];
                        startPointShapes.Add(new PointShape(lineShape.Vertices[0]));
                        endPointShapes.Add(new PointShape(lineShape.Vertices[lineShape.Vertices.Count - 1]));
                    }
                }
                else if (shape is LineShape)
                {
                    var lineShape = (LineShape) shape;
                    startPointShapes.Add(new PointShape(lineShape.Vertices[0]));
                    endPointShapes.Add(new PointShape(lineShape.Vertices[lineShape.Vertices.Count - 1]));
                }
            }

            _lineStyle.Draw(lineShapes, canvas, labelsInThisLayer, labelsInAllLayers);
            _startPointStyle.Draw(startPointShapes, canvas, labelsInThisLayer, labelsInAllLayers);
            _endPointStyle.Draw(endPointShapes, canvas, labelsInThisLayer, labelsInAllLayers);
        }
开发者ID:AuditoryBiophysicsLab,项目名称:ESME-Workbench,代码行数:33,代码来源:CustomStartEndLineStyle.cs

示例3: GetSaleHistoriesOrderByProductCategory

        public virtual IList GetSaleHistoriesOrderByProductCategory(IList searchCriteria)
        {
            var criterionList = new Collection<ICriterion>();
            if (searchCriteria != null)
            {
                foreach (string strCriteria in searchCriteria)
                {
                    var delimiterIndex = strCriteria.IndexOf("|");
                    if (delimiterIndex >= 0)
                        criterionList.Add(
                            Expression.Eq(
                                StringHelper.Left(strCriteria, delimiterIndex),
                                StringHelper.Right(strCriteria, strCriteria.Length - delimiterIndex - 1)));
                    else
                        criterionList.Add(Expression.Sql(strCriteria));
                }
            }

            var orderList =
                new Collection<Order>
                {
                    Order.Asc(SaleOrderReport.ConstSaleOrderProductCategory)
                };

            return SelectObjects(typeof(SaleOrderReport), criterionList, orderList).List();
        }
开发者ID:ViniciusConsultor,项目名称:campos,代码行数:26,代码来源:SaleOrderDataAccess.cs

示例4: OnControlLoad

        public override void OnControlLoad(object sender, EventArgs e)
        {
            string accountNumber = this.Page.Request["AccountNumber"];
            DateTime from = Conversion.TryCastDate(this.Page.Request["From"]);
            DateTime to = Conversion.TryCastDate(this.Page.Request["To"]);

            int userId = AppUsers.GetCurrent().View.UserId.ToInt();
            int officeId = AppUsers.GetCurrent().View.OfficeId.ToInt();

            Collection<KeyValuePair<string, object>> parameter1 = new Collection<KeyValuePair<string, object>>();
            parameter1.Add(new KeyValuePair<string, object>("@OfficeId", officeId.ToString(CultureInfo.InvariantCulture)));
            parameter1.Add(new KeyValuePair<string, object>("@AccountNumber", accountNumber));

            Collection<KeyValuePair<string, object>> parameter2 = new Collection<KeyValuePair<string, object>>();
            parameter2.Add(new KeyValuePair<string, object>("@From", from));
            parameter2.Add(new KeyValuePair<string, object>("@To", to));
            parameter2.Add(new KeyValuePair<string, object>("@UserId", userId.ToString(CultureInfo.InvariantCulture)));
            parameter2.Add(new KeyValuePair<string, object>("@AccountNumber", accountNumber));
            parameter2.Add(new KeyValuePair<string, object>("@OfficeId", officeId.ToString(CultureInfo.InvariantCulture)));

            using (WebReport report = new WebReport())
            {
                report.AddParameterToCollection(parameter1);
                report.AddParameterToCollection(parameter2);
                report.RunningTotalText = Titles.RunningTotal;
                report.Path = "~/Modules/Finance/Reports/Source/Transactions.AccountStatement.xml";
                report.AutoInitialize = true;

                this.Placeholder1.Controls.Add(report);
            }
        }
开发者ID:roczj,项目名称:mixerp,代码行数:31,代码来源:AccountStatementReport.ascx.cs

示例5: GetAppParameters

        public virtual IList GetAppParameters(IList searchCriteria)
        {
            var criterionList = new Collection<ICriterion>();
            if (searchCriteria != null)
            {
                foreach (string strCriteria in searchCriteria)
                {
                    var delimiterIndex = strCriteria.IndexOf("|");
                    if (delimiterIndex >= 0)
                        criterionList.Add(Expression.Eq(
                                              StringHelper.Left(strCriteria, delimiterIndex),
                                              StringHelper.Right(strCriteria, strCriteria.Length - delimiterIndex - 1)));
                    else
                        criterionList.Add(Expression.Sql(strCriteria));
                }
            }
            criterionList.Add(
                Expression.Sql("ParameterTypeId IN (SELECT ParameterTypeId FROM TAppParameterTypes WHERE IsActive = 1)"));

            var orderList = new Collection<Order> {Order.Asc("ParameterTypeId"), Order.Asc("ParameterLabel")};

            return SelectObjects(typeof (AppParameter),
                                 criterionList,
                                 orderList).List();
        }
开发者ID:ViniciusConsultor,项目名称:campos,代码行数:25,代码来源:CommonDataAccess.cs

示例6: CreateToken

        public static JwtSecurityToken CreateToken(IEnumerable<Claim> claims, string secretKey, string audience, string issuer, TimeSpan? lifetime)
        {
            if (claims == null)
            {
                throw new ArgumentNullException("claims");
            }

            if (lifetime != null && lifetime < TimeSpan.Zero)
            {
                string msg = CommonResources.ArgMustBeGreaterThanOrEqualTo.FormatForUser(TimeSpan.Zero);
                throw new ArgumentOutOfRangeException("lifetime", lifetime, msg);
            }

            if (string.IsNullOrEmpty(secretKey))
            {
                throw new ArgumentNullException("secretKey");
            }

            if (claims.SingleOrDefault(c => c.Type == JwtRegisteredClaimNames.Sub) == null)
            {
                throw new ArgumentOutOfRangeException("claims", LoginResources.CreateToken_SubjectRequired);
            }

            // add the claims passed in
            Collection<Claim> finalClaims = new Collection<Claim>();
            foreach (Claim claim in claims)
            {
                finalClaims.Add(claim);
            }

            // add our standard claims
            finalClaims.Add(new Claim("ver", "3"));

            return CreateTokenFromClaims(finalClaims, secretKey, audience, issuer, lifetime);
        }
开发者ID:Azure,项目名称:azure-mobile-apps-net-server,代码行数:35,代码来源:AppServiceLoginHandler.cs

示例7: Main

 private static void Main()
 {
     ICollection<string> myCole = new Collection<string>(); //Initializing a collection of strings
     myCole.Add("Takane"); //Adding elements on a collection
     myCole.Add("Sena");
     myCole.Add("Masuzu");
     myCole.Add("Yusa Emi");
     foreach(string b in myCole){
         Console.WriteLine("myCole contains " + b);
     }
     myCole.Remove("Yusa Emi"); //removing an element on a collection
     Console.WriteLine("Deleted an element");
     bool a = myCole.Contains("Takane"); //tells whether the collection contains a certain element
     //enumerate the elements
     foreach(string b in myCole){
         Console.WriteLine("myCole contains " + b);
     }
     
     //copying the content of a collection to an array
     string[] c = new string[myCole.Count]; // initializes the array with the size equal to myCole
     myCole.CopyTo(c, 0); //Copy to string array c from element 0
     foreach(string d in c){
         Console.WriteLine("String Copy in c: {0}", d);
     }
 }
开发者ID:ChanahC,项目名称:CSharpTrain,代码行数:25,代码来源:CollectionTrial.cs

示例8: ResentDateModel

 public ResentDateModel ()
 {
     Items = new Collection<ResentDateItemModel>();
     Items.Add(new ResentDateItemModel () );
     Items.Add(new ResentDateItemModel());
     Items.Add(new ResentDateItemModel());
 }
开发者ID:tmakk,项目名称:blog,代码行数:7,代码来源:ResentDateModel.cs

示例9: IssuedTokensHeader

 public IssuedTokensHeader(XmlReader xmlReader, MessageVersion version, SecurityStandardsManager standardsManager)
 {
     if (xmlReader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
     }
     if (standardsManager == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("standardsManager"));
     }
     this.standardsManager = standardsManager;
     XmlDictionaryReader reader = XmlDictionaryReader.CreateDictionaryReader(xmlReader);
     MessageHeader.GetHeaderAttributes(reader, version, out this.actor, out this.mustUnderstand, out this.relay, out this.isRefParam);
     reader.ReadStartElement(this.Name, this.Namespace);
     Collection<RequestSecurityTokenResponse> list = new Collection<RequestSecurityTokenResponse>();
     if (this.standardsManager.TrustDriver.IsAtRequestSecurityTokenResponseCollection(reader))
     {
         foreach (RequestSecurityTokenResponse response in this.standardsManager.TrustDriver.CreateRequestSecurityTokenResponseCollection(reader).RstrCollection)
         {
             list.Add(response);
         }
     }
     else
     {
         RequestSecurityTokenResponse item = this.standardsManager.TrustDriver.CreateRequestSecurityTokenResponse(reader);
         list.Add(item);
     }
     this.tokenIssuances = new ReadOnlyCollection<RequestSecurityTokenResponse>(list);
     reader.ReadEndElement();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:IssuedTokensHeader.cs

示例10: ToArray

        public string[] ToArray(bool obfuscate = false)
        {
            var key = WakaTimeConfigFile.ApiKey;
            var parameters = new Collection<string>
            {
                WakaTimeCli.GetCliPath(),
                "--key",
                obfuscate ? string.Format("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX{0}", key.Substring(key.Length - 4)) : key,
                "--file",
                File,
                "--plugin",
                Plugin
            };

            if (IsWrite)
                parameters.Add("--write");

            // ReSharper disable once InvertIf
            if (!string.IsNullOrEmpty(Project))
            {
                parameters.Add("--project");
                parameters.Add(Project);
            }

            return parameters.ToArray();
        }
开发者ID:ermshiperete,项目名称:wakatime-sharp,代码行数:26,代码来源:PythonCliParameters.cs

示例11: CreateServiceBehaviors

 private static ICollection<IServiceBehavior> CreateServiceBehaviors()
 {
     ICollection<IServiceBehavior> serviceBehaviors = new Collection<IServiceBehavior>();
       serviceBehaviors.Add(new UnityServiceBehavior());
       serviceBehaviors.Add(new NHibernateUnitOfWorkServiceBehavior());
       return serviceBehaviors;
 }
开发者ID:kakarotto67,项目名称:ClientServerSimpleSkeleton,代码行数:7,代码来源:BootStrapper.cs

示例12: GetList

 /// <summary>
 ///  Tests a Digital Signature from a package
 /// </summary>
 /// <returns>Digital signatures list</returns>
 public static Collection<string> GetList(OpenXmlPowerToolsDocument doc)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
     {
         // Creates the PackageDigitalSignatureManager
         PackageDigitalSignatureManager digitalSignatureManager = new PackageDigitalSignatureManager(streamDoc.GetPackage());
         // Verifies the collection of certificates in the package
         Collection<string> digitalSignatureDescriptions = new Collection<string>();
         ReadOnlyCollection<PackageDigitalSignature> digitalSignatures = digitalSignatureManager.Signatures;
         if (digitalSignatures.Count > 0)
         {
             foreach (PackageDigitalSignature signature in digitalSignatures)
             {
                 if (PackageDigitalSignatureManager.VerifyCertificate(signature.Signer) != X509ChainStatusFlags.NoError)
                 {
                     digitalSignatureDescriptions.Add(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Signature: {0} ({1})", signature.Signer.Subject, PackageDigitalSignatureManager.VerifyCertificate(signature.Signer)));
                 }
                 else
                     digitalSignatureDescriptions.Add("Signature: " + signature.Signer.Subject);
             }
         }
         else
         {
             digitalSignatureDescriptions.Add("No digital signatures found");
         }
         return digitalSignatureDescriptions;
     }
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:32,代码来源:DigitalSignatureAccessor.cs

示例13: SolutionProjectsPage

        public SolutionProjectsPage(WizardParams Params)
            : base(Params)
        {
            InitializeComponent();

            if (PK.Wrapper.GetProjectTemplates().Count == 0)
            {
                PK.Wrapper.LoadTemplateProjects();
            }

            _treeView.NodeControls.Clear();
            NodeCheckBox checkBox = _treeView.AddCheckBoxControl("Checked");
            checkBox.IsVisibleValueNeeded += new EventHandler<NodeControlValueEventArgs>(checkBox_IsVisibleValueNeeded);
            checkBox.IsEditEnabledValueNeeded += new EventHandler<NodeControlValueEventArgs>(checkBox_IsVisibleValueNeeded);
            _treeView.AddIconControl("Icon");
            _treeView.AddTextBoxControl("Name");

            List<ComponentWrapper> nativeProjects = new List<ComponentWrapper>();
            List<ComponentWrapper> clrProjects = new List<ComponentWrapper>();
            foreach (ProjectWrapper project in PK.Wrapper.GetProjectTemplates())
            {
                ComponentWrapper component = ComponentWrapper.GetComponentWrapper(project);
                if (project.IsClrProject)
                    clrProjects.Add(component);
                else
                    nativeProjects.Add(component);
            }

            Collection<RootNode> roots = new Collection<RootNode>();
            roots.Add(new RootNode(null, "Native Projects", nativeProjects.ToArray()));
            roots.Add(new RootNode(null, "CLR Projects", clrProjects.ToArray()));
            _treeView.SetModel(InventoryBrowserModel.GetModel(roots), true);

        }
开发者ID:AlexandrSurkov,项目名称:PKStudio,代码行数:34,代码来源:SolutionProjectsPage.cs

示例14: ExecutePowershellCommand

        public static IEnumerable<string> ExecutePowershellCommand(this Robot robot, string command)
        {
            var host = new MMBotHost(robot);
            using (var runspace = RunspaceFactory.CreateRunspace(host))
            {
                runspace.Open();
                using (var invoker = new RunspaceInvoke(runspace))
                {
                    Collection<PSObject> psObjects = new Collection<PSObject>();
                    try
                    {
                        IList errors;
                        psObjects = invoker.Invoke(command, null, out errors);
                        if (errors.Count > 0)
                        {
                            string errorString = string.Empty;
                            foreach (var error in errors)
                                errorString += error.ToString();

                            psObjects.Add(new PSObject(errorString));
                        }

                    }
                    catch (Exception ex)
                    {
                        psObjects.Add(new PSObject(ex.Message));
                    }

                    foreach (var psObject in psObjects)
                    {
                        yield return psObject.ConvertToString();
                    }
                }
            }
        }
开发者ID:dcr25568,项目名称:mmbot,代码行数:35,代码来源:Extensions.cs

示例15: Insert

        /// <summary>
        /// 插入角色信息
        /// </summary>
        /// <param name="cInfo"></param>
        /// <returns></returns>
        public bool Insert(Character cInfo)
        {
            string sqlcmd = @"INSERT INTO {0} (
                                CHARACTER_NO
                                ,CHARACTER_NAME
                                ,ANIME_NO
                                ,CV_ID
                                ,LEADING_FLG
                                ,ENABLE_FLG
                                ,LAST_UPDATE_DATETIME
                                )
                            VALUES (
                                @characterNo
                                ,@charactername
                                ,@animeNo
                                ,@CVID
                                ,@leadingFlg
                                ,1
                                ,GETDATE()
                                )";

            Collection<DbParameter> paras = new Collection<DbParameter>();
            paras.Add(new SqlParameter("@characterNo", cInfo.No));
            paras.Add(new SqlParameter("@charactername", cInfo.name));
            paras.Add(new SqlParameter("@animeNo", cInfo.animeNo));
            paras.Add(new SqlParameter("@CVID", cInfo.CVID));
            paras.Add(new SqlParameter("@leadingFlg", cInfo.leadingFLG));

            DbCmd.DoCommand(string.Format(sqlcmd, CommonConst.TableName.T_CHARACTER_TBL), paras);

            return true;
        }
开发者ID:kirisamex,项目名称:Animedata,代码行数:37,代码来源:CharacterInfoDao.cs


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