protected static void GuerillaPreProcessMethod(BinaryReader binaryReader, IList<tag_field> fields)
 {
     fields.Insert(0, new tag_field() { type = field_type._field_long_integer, Name = "Block Length" });
     fields.Insert(1, new tag_field() { type = field_type._field_long_integer, Name = "SBSP virtual start address" });
     fields.Insert(2, new tag_field() { type = field_type._field_long_integer, Name = "LTMP virtual start address" });
     fields.Insert(3, new tag_field() { type = field_type._field_tag, Name = "SBSP class" });
 }
        // Arg(ControllerName),Param(..),.. -> Arg(ControllerName),Arg('Index'),...
        public static IList<Token> Rewrite(IList<Token> tokens)
        {
            //"--command"
            if (tokens.Count() >= 2
                && tokens[0].TokenType==TokenType.Argument
                && tokens[0].Value.EqualsIC("help")
                && tokens[1].TokenType==TokenType.Argument)
            {
                tokens[1] = new Token(tokens[1].Value,TokenType.ParameterValue,tokens[1].Index);
                tokens.Insert(1,new Token("command",TokenType.Parameter,1));
                //index:2
                if (tokens.Count() >= 4) { tokens[3] = new Token(tokens[3].Value, TokenType.ParameterValue, tokens[1].Index); }
                tokens.Insert(3, new Token("action", TokenType.Parameter, 2));
            }
            //help maps to index (should have routing here)
            if (tokens.Count() == 0)
            {
                tokens.Add(new Token("help",TokenType.Argument,0));
            }

            //Index rewrite:
            var indexToken= new Token("Index", TokenType.Argument,1);
            if (tokens.Count()>=2
                && tokens[1].TokenType!=TokenType.Argument
                && tokens[0].TokenType==TokenType.Argument)
            {
                tokens.Insert(1,indexToken);
            }
            else if (tokens.Count()==1
                && tokens[0].TokenType==TokenType.Argument)
            {
                tokens.Add(indexToken);
            }
            return tokens;
        }
 private void ModifyListForTest(IList<string> list)
 {
     list[0] = "OneModified";
     list.Insert(0, "Zero");
     list.RemoveAt(0);
     list.Insert(0, "ZeroAgain");
     list.Insert(4, "Four");
     list.RemoveAt(4);
     list.Insert(4, "FourAgain");
 }
 public static void RegisterDisplayModes(IList<IDisplayMode> modes)
 {
     modes.Insert(0, new DefaultDisplayMode("android")
     {
         ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf
           ("Android", StringComparison.OrdinalIgnoreCase) >= 0)
     });
     modes.Insert(1, new DefaultDisplayMode("iPhone")
     {
         ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf
           ("iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
     });
 }
 public static void RotateRight(IList sequence, int count)
 {
     //This method makes a swap of the list elements to the right
     object tmp = sequence[count - 1];
     sequence.RemoveAt(count - 1);
     sequence.Insert(0, tmp);
 }
 protected static void GuerillaPreProcessMethod(BinaryReader binaryReader, IList<tag_field> fields)
 {
     var index = (from field in fields
                  where field.Name == "Object Data"
                  select fields.IndexOf(field)).Single();
     fields.Insert(++index, new tag_field() { type = field_type._field_pad, Name = "indexer", definition = 4 });
 }
        public void Update(ICacheService cacheService, Account selectedAccount, WorkPeriod currentWorkPeriod)
        {
            var accountType = cacheService.GetAccountTypeById(selectedAccount.AccountTypeId);
            var transactions = Dao.Query(GetCurrentRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)).OrderBy(x => x.Date);
            Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
            if (accountType.DefaultFilterType > 0)
            {
                var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                if (pastCredit > 0 || pastDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.Total, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Name = Resources.PastTransactions,
                            Credit = pastCredit,
                            Debit = pastDebit,
                            Exchange = pastExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Insert(0, detailValue);
                }
            }

            Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));

            for (var i = 0; i < Transactions.Count; i++)
            {
                Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
                if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
            }
        }
Example #8
1
        private static void CheckActionList(IList<IBfsAction> actions, IBfsDataBlock block)
        {
            if (actions == null)
                return;

            for( int index = 0; index < actions.Count; index++)
            {
                IBfsAction action = actions[index];

                if (action is BfsActionUnresolvedAssignment)
                {
                    BfsActionUnresolvedAssignment unresolved = action as BfsActionUnresolvedAssignment;
                    BfsActionAssignment assignment = new BfsActionAssignment();
                    assignment.Expression = unresolved.Expression;
                    assignment.SourceRange = unresolved.SourceRange;
                    if (block.LocalFields.ContainsKey(unresolved.UnresolvedVariableName))
                        assignment.LocalVariable = block.LocalFields[unresolved.UnresolvedVariableName];
                    else
                        BfsCompiler.ReportError(assignment.SourceRange,
                            "Could not find local variable: '"+unresolved.UnresolvedVariableName+"'");

                    actions.Insert(index, assignment);
                    actions.Remove(action);
                }
            }
        }
        public void Update(Account selectedAccount, DateTime? start, DateTime? end)
        {
            Start = start;
            End = end;
            var transactions = Dao.Query(GetCurrentRange(start, end, x => x.AccountId == selectedAccount.Id)).OrderBy(x => x.Date);
            Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
            if (start.HasValue)
            {
                var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                if (pastCredit > 0 || pastDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.TransactionTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Date = start.GetValueOrDefault(),
                            Name = Resources.BalanceBroughtForward,
                            Credit = pastCredit,
                            Debit = pastDebit,
                            Exchange = pastExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Insert(0, detailValue);
                }
            }
            if (end.HasValue && end != start)
            {
                var futureDebit = Dao.Sum(x => x.Debit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                var futureCredit = Dao.Sum(x => x.Credit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                var futureExchange = Dao.Sum(x => x.Exchange, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                if (futureCredit > 0 || futureDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.DateRangeTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Date = end.GetValueOrDefault(),
                            Name = Resources.BalanceAfterDate,
                            Credit = futureCredit,
                            Debit = futureDebit,
                            Exchange = futureExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Add(detailValue);
                }
            }

            Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));

            for (var i = 0; i < Transactions.Count; i++)
            {
                Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
                if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
            }
        }
Example #10
0
        private void ReplayChanges(IndividualCollectionChange change, IList ilist)
        {
            CefCoreSessionSingleton.Session.Dispatcher.Run(() =>
            {
                switch (change.CollectionChangeType)
                {
                    case CollectionChangeType.Add:
                    if (change.Index == ilist.Count)
                    {
                        ilist.Add(change.Object.CValue);
                        Items.Add(change.Object);
                    }
                    else
                    {
                        ilist.Insert(change.Index, change.Object.CValue);
                        Items.Insert(change.Index, change.Object);
                    }
                    break;

                    case CollectionChangeType.Remove:
                        ilist.RemoveAt(change.Index);
                        Items.RemoveAt(change.Index);
                    break;
                }
            });
        }
Example #11
0
 public ClassMethodHandler(MethodInfo method)
 {
     this.method = method;
     parameters = method.GetParameters ().Select (x => new ProcedureParameter (x)).ToList ();
     parameters.Insert (0, new ProcedureParameter (typeof(ulong), "this"));
     parametersArray = Parameters.ToArray ();
 }
        public Expression Parse(IList<Token> tokens)
        {
            if (tokens.Count > 1 && tokens[0].Type == Symbol.Subtract)
            {
                if (tokens[1].Type == Symbol.Number)
                {
                    tokens.RemoveAt(0);

                    double num = double.Parse(tokens[0].Value);
                    num *= -1;

                    tokens[0].Value = num.ToString();
                }
                else
                {
                    tokens[0].Type = Symbol.Number;
                    tokens[0].Value = "-1";

                    tokens.Insert(1, new Token(Symbol.Multiply));
                }
            }

            int index = 0;

            return sums(tokens, ref index);
        }
 public IndexViewModel(IList<State> states)
 {
     var state = new State();
     state.Id = 0;
     state.Name = "";
     states.Insert(0, state);
     States = new SelectList(states, "Id", "Name");
 }
Example #14
0
 public static void Insert(IList list, int index, IIndexable item)
 {
     item.Index = index;
     for (int i = index; i < list.Count - 1; i++)
     {
         list[i].As<IIndexable>().Index++;
     }
     list.Insert(index, item);
 }
Example #15
0
 //public static SqlParameterCollection Sqlparams;
 public static void AddItem(IList list, Type type, string valueMember,string displayMember, string displayText)
 {
     Object obj = Activator.CreateInstance(type);
     PropertyInfo displayProperty = type.GetProperty(displayMember);
     displayProperty.SetValue(obj, displayText, null);
     PropertyInfo valueProperty = type.GetProperty(valueMember);
     valueProperty.SetValue(obj, -1, null);
     list.Insert(0, obj);
 }
Example #16
0
	// private

	private void Visit (Node node, IList list) {
		node.marked = true;
		foreach (Node adj in node.edges) {
			if (!adj.marked)
				Visit (adj, list);
		}

		list.Insert (0, node.value);
	}
Example #17
0
 public static void AddItemsStaff(IList<tStaff> list, Type type, string valueMember, string displayMember, string displayText)
 {
     var obj = Activator.CreateInstance(type);
     var displayProperty = type.GetProperty(displayMember);
     displayProperty.SetValue(obj, displayText, null);
     var valueProperty = type.GetProperty(valueMember);
     valueProperty.SetValue(obj, -1, null);
     list.Insert(0, obj as tStaff);
 }
        public static void ReorderableList(IList list, System.Action<int> GUICallback, UnityObject unityObject = null)
        {
            if (list.Count == 1){
                GUICallback(0);
                return;
            }

            if (!pickedObjectList.ContainsKey(list))
                pickedObjectList[list] = null;

            var e = Event.current;
            var lastRect = new Rect();
            var picked = pickedObjectList[list];
            GUILayout.BeginVertical();
            for (var i= 0; i < list.Count; i++){

                GUILayout.BeginVertical();
                GUICallback(i);
                GUILayout.EndVertical();

                GUI.color = Color.white;
                GUI.backgroundColor = Color.white;

                lastRect = GUILayoutUtility.GetLastRect();
                EditorGUIUtility.AddCursorRect(lastRect, MouseCursor.MoveArrow);

                if (picked != null && picked == list[i])
                    GUI.Box(lastRect, "");

                if (picked != null && lastRect.Contains(e.mousePosition) && picked != list[i]){

                    var markRect = new Rect(lastRect.x,lastRect.y-2,lastRect.width, 2);
                    if (list.IndexOf(picked) < i)
                        markRect.y = lastRect.yMax - 2;

                    GUI.Box(markRect, "");
                    if (e.type == EventType.MouseUp){
                        if (unityObject != null)
                            Undo.RecordObject(unityObject, "Reorder");
                        list.Remove(picked);
                        list.Insert(i, picked);
                        pickedObjectList[list] = null;
                        if (unityObject != null)
                            EditorUtility.SetDirty(unityObject);
                    }
                }

                if (lastRect.Contains(e.mousePosition) && e.type == EventType.MouseDown)
                    pickedObjectList[list] = list[i];
            }

            GUILayout.EndVertical();

            if (e.type == EventType.MouseUp)
                pickedObjectList[list] = null;
        }
		/*--------------------------------------------------------------------------------------------*/
		public static void SplitTrackSegments(ReadOnlyCollection<TrackSegment> pSegments, 
							ReadOnlyCollection<TrackSegment> pCuts, IList<TrackSegment> pSliceResults) {
			pSliceResults.Clear();

			for ( int segI = 0 ; segI < pSegments.Count ; segI++ ) {
				TrackSegment seg = pSegments[segI];
				pSliceResults.Add(seg);
			}

			for ( int cutI = 0 ; cutI < pCuts.Count ; cutI++ ) {
				TrackSegment cut = pCuts[cutI];

				for ( int sliceI = 0 ; sliceI < pSliceResults.Count ; sliceI++ ) {
					TrackSegment slice = pSliceResults[sliceI];

					if ( cut.StartValue >= slice.StartValue && cut.EndValue <= slice.EndValue ) {
						var slice2 = new TrackSegment();
						slice2.StartValue = cut.EndValue;
						slice2.EndValue = slice.EndValue;
						slice2.IsFill = slice.IsFill;
						pSliceResults.Insert(sliceI+1, slice2);

						slice.EndValue = cut.StartValue;
						pSliceResults[sliceI] = slice;
						continue;
					}

					if ( cut.StartValue >= slice.StartValue && cut.StartValue <= slice.EndValue ) {
						slice.EndValue = cut.StartValue;
						pSliceResults[sliceI] = slice;
						continue;
					}

					if ( cut.EndValue <= slice.EndValue && cut.EndValue >= slice.StartValue ) {
						slice.StartValue = cut.EndValue;
						pSliceResults[sliceI] = slice;
						continue;
					}

					if ( cut.StartValue <= slice.StartValue && cut.EndValue >= slice.EndValue ) {
						pSliceResults.RemoveAt(sliceI);
						sliceI--;
					}
				}
			}

			for ( int sliceI = 0 ; sliceI < pSliceResults.Count ; sliceI++ ) {
				TrackSegment slice = pSliceResults[sliceI];

				if ( Math.Abs(slice.StartValue-slice.EndValue) <= 0.01f ) {
					pSliceResults.RemoveAt(sliceI);
					sliceI--;
				}
			}
		}
 public void SetCompanyList(IList<Company> companies)
 {
     CompanyList = companies.OrderBy(x => x.Name)
                            .Select(x => new SelectListItem
                            {
                                Value = x.Id.ToString(),
                                Text = x.Name
                            })
                            .ToList();
     CompanyList.Insert(0, new SelectListItem { Value = "0", Text = "<None Selected>" });
 }
Example #21
0
        public JobLogger(IEnumerable<ILogger> loggers)
        {
            logOutput = new List<bool> (Constants.Output.Count);
            logOutput.Insert((int)LogOutputType.Console, GetBooleanValue (Constants.Output.Console));
            logOutput.Insert((int)LogOutputType.Database, GetBooleanValue (Constants.Output.Database));
            logOutput.Insert((int)LogOutputType.File, GetBooleanValue (Constants.Output.File));
            if (logOutput.All (outputFlag => !outputFlag)) {
                throw new NotSupportedLogTypeException ();
            }

            logLevel = new List<bool> (Constants.Level.Count);
            logLevel.Insert((int)LogMessageLevel.Message, GetBooleanValue (Constants.Level.Message));
            logLevel.Insert((int)LogMessageLevel.Warning, GetBooleanValue (Constants.Level.Warning));
            logLevel.Insert((int)LogMessageLevel.Error, GetBooleanValue (Constants.Level.Error));
            if (logLevel.All (levelFlag => !levelFlag)) {
                throw new NotSupportedLogLevelException ();
            }

            this.Loggers = loggers.ToArray();
        }
Example #22
0
        public void AddStartStopSymbols(IList<string> tokens)
        {
            if (extractor.MaxNGramSize <= 1) return;

            for (int i = 0; i < extractor.MaxNGramSize - 1; i++)
            {
                string index = (i).ToString();
                tokens.Insert(0, Start.Insert(2, index));
            }

            tokens.Add(Stop);
        }
Example #23
0
 /// <summary>
 /// Appends a single part, including (useless) optimizations
 /// </summary>
 /// <param name="parts"></param>
 /// <param name="index"></param>
 /// <param name="part"></param>
 public static void InsertPart(IList<SqlPart> parts, int index, SqlPart part)
 {
     // optimization if top part is a literal, and the one we're adding is a literal too
     // in this case, we combine both
     // (this is useless, just pretty)
     if (part is SqlLiteralPart && index > 0 && parts[index - 1] is SqlLiteralPart)
     {
         parts[index - 1] = new SqlLiteralPart(parts[index - 1].Sql + part.Sql);
     }
     else
         parts.Insert(index, part);
 }
 public void FilterErrorList(IList<ICssError> errors, ICssCheckerContext context)
 {
     for (int i = errors.Count - 1; i > -1; i--)
     {
         ICssError error = errors[i];
         Declaration dec = error.Item.FindType<Declaration>();
         if (dec != null && dec.IsValid && dec.PropertyName.Text == "-ms-filter")
         {
             errors.RemoveAt(i);
             errors.Insert(i, CreateNewError(error));
         }
     }
 }
        public static DefaultResponse BuildFailedResponseWithMessages(this APIException exception, IList<string> modelErrors)
        {
            if (!string.IsNullOrWhiteSpace(exception.Message))
            {
                modelErrors.Insert(0, exception.Message);
            }

            return new DefaultResponse
            {
                Success = false,
                Message = string.Join(" ", modelErrors)
            };
        }
Example #26
0
		/// <inheritdoc/>
		public override void Split(int splitVisualColumn, IList<VisualLineElement> elements, int elementIndex)
		{
			if (splitVisualColumn <= VisualColumn || splitVisualColumn >= VisualColumn + VisualLength)
				throw new ArgumentOutOfRangeException("splitVisualColumn", splitVisualColumn, "Value must be between " + (VisualColumn + 1) + " and " + (VisualColumn + VisualLength - 1));
			if (elements == null)
				throw new ArgumentNullException("elements");
			if (elements[elementIndex] != this)
				throw new ArgumentException("Invalid elementIndex - couldn't find this element at the index");
			int relativeSplitPos = splitVisualColumn - VisualColumn;
			VisualLineText splitPart = CreateInstance(DocumentLength - relativeSplitPos);
			SplitHelper(this, splitPart, splitVisualColumn, relativeSplitPos + RelativeTextOffset);
			elements.Insert(elementIndex + 1, splitPart);
		}
Example #27
0
 /// <summary>
 /// Add true objects for the Specified fields
 /// </summary>
 /// <param name="args">List of parameters for a methodcall</param>
 /// <param name="m">Methodinfo</param>
 public static void addTrueForSpecified(IList<object> args, MethodInfo m)
 {
     ParameterInfo[] paraminfo = m.GetParameters();
     if (paraminfo.Length <= args.Count && paraminfo.Length < 2 && args.Count <= 0) return;
     int i = 0;
     while (i + 1 < paraminfo.Length)
     {
         String paramName = paraminfo[i].Name + "Specified";
         if ((paraminfo[i + 1].ParameterType.Equals(typeof(System.Boolean))) &&
             paramName.Equals(paraminfo[i + 1].Name)) args.Insert(i + 1, true);
         i = i + 2;
     }
 }
		/// <summary>
		/// 初始化dbcode的集合,依赖于数据库的shardingNum
		/// </summary>
		private void setDbCodeCollection()
		{
			dbCodeCollection = new List<string>(shardingNum);
			int codeLength = Integer.toBinaryString(shardingNum - 1).length();
			for (int i = 0; i < shardingNum; i++)
			{
				string dbcode = Integer.toBinaryString(i);
				for (int j = dbcode.Length; j < codeLength; j++)
				{
					dbcode = "0" + dbcode;
				}
				dbCodeCollection.Insert(i, dbcode);
			}
		}
Example #29
0
        /// <summary>
        ///     Reads the contents of the "loca" table from the supplied stream 
        ///     at the current position.
        /// </summary>
        /// <param name="reader"></param>
        protected internal override void Read(FontFileReader reader) {
            FontFileStream stream = reader.Stream;

            // Glyph offsets can be stored in either short of long format
            bool isShortFormat = reader.GetHeaderTable().IsShortFormat;

            // Number of glyphs including extra entry
            int glyphCount = reader.GetMaximumProfileTable().GlyphCount + 1;

            offsets = new ArrayList(glyphCount);
            for (int i = 0; i < glyphCount; i++) {
                offsets.Insert(i, (isShortFormat) ? (uint) (stream.ReadUShort() << 1) : stream.ReadULong());
            }
        }
 public void FilterErrorList(IList<ICssError> errors, ICssCheckerContext context)
 {
     for (int i = errors.Count - 1; i > -1; i--)
     {
         ICssError error = errors[i];
         if (error.Item.IsValid)
         {
             Declaration dec = error.Item.FindType<Declaration>();
             if (dec != null && dec.IsValid && dec.PropertyName.Text == "cursor")
             {
                 if (error.Item.Text == "hand")
                 {
                     errors.RemoveAt(i);
                     errors.Insert(i, CreateNewError(error, "cursorhand"));
                 }
                 else if (error.Item.Text == "normal")
                 {
                     errors.RemoveAt(i);
                     errors.Insert(i, CreateNewError(error, "cursornormal"));
                 }
             }
         }
     }
 }