System.Collections.Generic.List.Add(System.Action)

Here are the examples of the csharp api System.Collections.Generic.List.Add(System.Action) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

889 Examples 7

19 View Source File : LifecycleManager.cs
License : Apache License 2.0
Project Creator : andijakl

public AsyncTask<ApkAvailabilityStatus> CheckApkAvailability()
        {
            Action<ApkAvailabilityStatus> onComplete;
            AsyncTask<ApkAvailabilityStatus> task =
                new AsyncTask<ApkAvailabilityStatus>(out onComplete);

            ExternApi.ArPresto_checkApkAvailability(m_CheckApkAvailabilityResultCallback,
                IntPtr.Zero);

            m_PendingAvailabilityCheckCallbacks.Add(onComplete);

            return task;
        }

19 View Source File : ActionManager.cs
License : GNU General Public License v3.0
Project Creator : anotak

public Action[] GetActionsByKey(int key)
		{
			List<Action> actionnames = new List<Action>();

			// Go for all actions
			foreach(KeyValuePair<string, Action> a in actions)
			{
				// This action is replacedociated with this key?
				if(a.Value.KeyMatches(key))
				{
					// List short name
					actionnames.Add(a.Value);
				}
			}

			// Return result;
			return actionnames.ToArray();
		}

19 View Source File : GraphBuilder.cs
License : MIT License
Project Creator : alelievr

public GraphBuilder CustomAfterExecute(Action< BaseGraph > callback)
		{
			postExecuteCallbacks.Add(callback);
			return this;
		}

19 View Source File : RuntimeSet.cs
License : MIT License
Project Creator : alexjhetherington

public void RegisterItemRemovedListener(Action<T> listener)
    {
        if (!itemRemovedListeners.Contains(listener))
            itemRemovedListeners.Add(listener);
    }

19 View Source File : Layout.cs
License : MIT License
Project Creator : alelievr

public void EndVertical()
		{
			layoutActions.Add(() => EditorGUILayout.EndVertical());
			currentOrientation.Pop();
		}

19 View Source File : ZSocketSetup.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public ZSocketSetup SetSocketOption<T>(Expression<Func<ZSocket, T>> property, T value)
		{
			PropertyInfo propertyInfo;

			if (property.Body is MemberExpression)
			{
				propertyInfo = ((MemberExpression)property.Body).Member as PropertyInfo;
			}
			else
			{
				propertyInfo = ((MemberExpression)((UnaryExpression)property.Body).Operand).Member as PropertyInfo;
			}

			if (propertyInfo == null)
			{
				throw new InvalidOperationException("The specified ZSocket member is not a property: " + property.Body);
			}

			_socketInitializers.Add(s => propertyInfo.SetValue(s, value, null));

			return this;
		}

19 View Source File : DynamicParameters.cs
License : MIT License
Project Creator : anet-team

public DynamicParameters Output<T>(T target, Expression<Func<T, object>> expression, DbType? dbType = null, int? size = null)
        {
            var failMessage = "Expression must be a property/field chain off of a(n) {0} instance";
            failMessage = string.Format(failMessage, typeof(T).Name);
            Action @throw = () => throw new InvalidOperationException(failMessage);

            // Is it even a MemberExpression?
            var lastMemberAccess = expression.Body as MemberExpression;

            if (lastMemberAccess == null
                || (!(lastMemberAccess.Member is PropertyInfo)
                    && !(lastMemberAccess.Member is FieldInfo)))
            {
                if (expression.Body.NodeType == ExpressionType.Convert
                    && expression.Body.Type == typeof(object)
                    && ((UnaryExpression)expression.Body).Operand is MemberExpression)
                {
                    // It's got to be unboxed
                    lastMemberAccess = (MemberExpression)((UnaryExpression)expression.Body).Operand;
                }
                else
                {
                    @throw();
                }
            }

            // Does the chain consist of MemberExpressions leading to a ParameterExpression of type T?
            MemberExpression diving = lastMemberAccess;
            // Retain a list of member names and the member expressions so we can rebuild the chain.
            List<string> names = new List<string>();
            List<MemberExpression> chain = new List<MemberExpression>();

            do
            {
                // Insert the names in the right order so expression
                // "Post.Author.Name" becomes parameter "PostAuthorName"
                names.Insert(0, diving?.Member.Name);
                chain.Insert(0, diving);

                var constant = diving?.Expression as ParameterExpression;
                diving = diving?.Expression as MemberExpression;

                if (constant != null && constant.Type == typeof(T))
                {
                    break;
                }
                else if (diving == null
                    || (!(diving.Member is PropertyInfo)
                        && !(diving.Member is FieldInfo)))
                {
                    @throw();
                }
            }
            while (diving != null);

            var dynamicParamName = string.Concat(names.ToArray());

            // Before we get all emitty...
            var lookup = string.Join("|", names.ToArray());

            var cache = CachedOutputSetters<T>.Cache;
            var setter = (Action<object, DynamicParameters>)cache[lookup];
            if (setter != null) goto MAKECALLBACK;

            // Come on let's build a method, let's build it, let's build it now!
            var dm = new DynamicMethod("ExpressionParam" + Guid.NewGuid().ToString(), null, new[] { typeof(object), GetType() }, true);
            var il = dm.GetILGenerator();

            il.Emit(OpCodes.Ldarg_0); // [object]
            il.Emit(OpCodes.Castclreplaced, typeof(T));    // [T]

            // Count - 1 to skip the last member access
            var i = 0;
            for (; i < (chain.Count - 1); i++)
            {
                var member = chain[0].Member;

                if (member is PropertyInfo)
                {
                    var get = ((PropertyInfo)member).GetGetMethod(true);
                    il.Emit(OpCodes.Callvirt, get); // [Member{i}]
                }
                else // Else it must be a field!
                {
                    il.Emit(OpCodes.Ldfld, (FieldInfo)member); // [Member{i}]
                }
            }

            var paramGetter = GetType().GetMethod("Get", new Type[] { typeof(string) }).MakeGenericMethod(lastMemberAccess.Type);

            il.Emit(OpCodes.Ldarg_1); // [target] [DynamicParameters]
            il.Emit(OpCodes.Ldstr, dynamicParamName); // [target] [DynamicParameters] [ParamName]
            il.Emit(OpCodes.Callvirt, paramGetter); // [target] [value], it's already typed thanks to generic method

            // GET READY
            var lastMember = lastMemberAccess.Member;
            if (lastMember is PropertyInfo)
            {
                var set = ((PropertyInfo)lastMember).GetSetMethod(true);
                il.Emit(OpCodes.Callvirt, set); // SET
            }
            else
            {
                il.Emit(OpCodes.Stfld, (FieldInfo)lastMember); // SET
            }

            il.Emit(OpCodes.Ret); // GO

            setter = (Action<object, DynamicParameters>)dm.CreateDelegate(typeof(Action<object, DynamicParameters>));
            lock (cache)
            {
                cache[lookup] = setter;
            }

            // Queue the preparation to be fired off when adding parameters to the DbCommand
            MAKECALLBACK:
            (outputCallbacks ?? (outputCallbacks = new List<Action>())).Add(() =>
            {
                // Finally, prep the parameter and attach the callback to it
                var targetMemberType = lastMemberAccess?.Type;
                int sizeToSet = (!size.HasValue && targetMemberType == typeof(string)) ? DbString.DefaultLength : size ?? 0;

                if (parameters.TryGetValue(dynamicParamName, out ParamInfo parameter))
                {
                    parameter.ParameterDirection = parameter.AttachedParam.Direction = ParameterDirection.InputOutput;

                    if (parameter.AttachedParam.Size == 0)
                    {
                        parameter.Size = parameter.AttachedParam.Size = sizeToSet;
                    }
                }
                else
                {
                    dbType = (!dbType.HasValue)
#pragma warning disable 618
                    ? SqlMapper.LookupDbType(targetMemberType, targetMemberType?.Name, true, out SqlMapper.ITypeHandler handler)
#pragma warning restore 618
                    : dbType;

                    // CameFromTemplate property would not apply here because this new param
                    // Still needs to be added to the command
                    Add(dynamicParamName, expression.Compile().Invoke(target), null, ParameterDirection.InputOutput, sizeToSet);
                }

                parameter = parameters[dynamicParamName];
                parameter.OutputCallback = setter;
                parameter.OutputTarget = target;
            });

            return this;
        }

19 View Source File : MoveToManager.cs
License : GNU General Public License v3.0
Project Creator : ACEmulator

public void add_listener(Action listener)
        {
            Callbacks.Add(listener);
        }

19 View Source File : BaseIntegrationFixture.cs
License : MIT License
Project Creator : ansel86castro

public TestHostPipeline UseService<TService, TImplementation>()
                where TService: clreplaced
                where TImplementation : clreplaced
            {
                _setups.Add(services =>
                {                    
                    var descriptor = services.FirstOrDefault(x => x.ServiceType == typeof(TService));
                    if (descriptor != null)
                    {
                        services.Remove(descriptor);                        
                    }
                    services.AddTransient<TImplementation>();
                });
                return this;
            }

19 View Source File : StickyManager.cs
License : GNU General Public License v3.0
Project Creator : ACEmulator

public void add_unsticky_listener(Action listener)
        {
            UnstickyCallbacks.Add(listener);
        }

19 View Source File : IntVariable.cs
License : MIT License
Project Creator : alexjhetherington

public void RegisterListener(Action<int> listener)
    {
        if (!variableChangedListeners.Contains(listener))
            variableChangedListeners.Add(listener);
    }

19 View Source File : AppHostBuilder.cs
License : MIT License
Project Creator : alethic

public AppHostBuilder OnStarted(Action<AppHost> hook)
        {
            onStartedHooks.Add(hook);
            return this;
        }

19 View Source File : ServerServiceDefinition.cs
License : MIT License
Project Creator : AElfProject

public Builder AddMethod<TRequest, TResponse>(
                Method<TRequest, TResponse> method,
                UnaryServerMethod<TRequest, TResponse> handler)
                    where TRequest : clreplaced
                    where TResponse : clreplaced
            {
                duplicateDetector.Add(method.FullName, null);
                addMethodActions.Add((serviceBinder) => serviceBinder.AddMethod(method, handler));
                return this;
            }

19 View Source File : VoidEvent.cs
License : MIT License
Project Creator : alexjhetherington

public void RegisterListener(Action listener)
    {
        if (!eventListener.Contains(listener))
            eventListener.Add(listener);
    }

19 View Source File : WebSocketPlayController.cs
License : MIT License
Project Creator : a1q123456

public override async Task OnConnect()
        {
            var publisher = _publisherSessionService.FindPublisher(StreamName);
            if (publisher != null)
            {
                _cleanupActions.Add(() =>
                {
                    publisher.OnAudioMessage -= SendAudio;
                    publisher.OnVideoMessage -= SendVideo;
                });

                var metadata = (Dictionary<string, object>)publisher.FlvMetadata.Data.Last();
                var hasAudio = metadata.ContainsKey("audiocodecid");
                var hasVideo = metadata.ContainsKey("videocodecid");

                await Session.SendFlvHeaderAsync(hasAudio, hasVideo);

                await Session.SendMessageAsync(publisher.FlvMetadata);
                if (hasAudio)
                {
                    await Session.SendMessageAsync(publisher.AACConfigureRecord);
                }
                if (hasVideo)
                {
                    await Session.SendMessageAsync(publisher.AVCConfigureRecord);
                }

                publisher.OnAudioMessage += SendAudio;
                publisher.OnVideoMessage += SendVideo;
            }
            // play record
            else
            {
                _recordFile = new FileStream(_recordService.GetRecordFilename(StreamName) + ".flv", FileMode.Open, FileAccess.Read);
                var fromStr = Query.Get("from");
                long from = 0;
                if (fromStr != null)
                {
                    from = long.Parse(fromStr);
                }
                var toStr = Query.Get("to");
                _playRangeTo = -1;
                if (toStr != null)
                {
                    _playRangeTo = long.Parse(toStr);
                }

                var header = new byte[9];

                await _recordFile.ReadBytesAsync(header);
                await Session.SendRawDataAsync(header);

                from = Math.Max(from, 9);

                _recordFile.Seek(from, SeekOrigin.Begin);

                await PlayRecordFile();
            }
        }

19 View Source File : AsyncTask.cs
License : Apache License 2.0
Project Creator : andijakl

public AsyncTask<T> ThenAction(Action<T> doAfterTaskComplete)
        {
            // Perform action now if task is already complete.
            if (IsComplete)
            {
                doAfterTaskComplete(Result);
                return this;
            }

            // Allocate list if needed (avoids allocation if then is not used).
            if (m_ActionsUponTaskCompletion == null)
            {
                m_ActionsUponTaskCompletion = new List<Action<T>>();
            }

            m_ActionsUponTaskCompletion.Add(doAfterTaskComplete);
            return this;
        }

19 View Source File : GvrVideoPlayerTexture.cs
License : MIT License
Project Creator : alanplotko

public void SetOnVideoEventCallback(Action<int> callback) {
    if (onEventCallbacks == null) {
      onEventCallbacks = new List<Action<int>>();
    }
    onEventCallbacks.Add(callback);
    SetOnVideoEventCallback(videoPlayerPtr, InternalOnVideoEventCallback,
      ToIntPtr(this));
  }

19 View Source File : ActionManager.cs
License : GNU General Public License v3.0
Project Creator : anotak

internal bool KeyPressed(int key)
		{
			int strippedkey = key & ~((int)Keys.Alt | (int)Keys.Shift | (int)Keys.Control);
			if((strippedkey == (int)Keys.ShiftKey) || (strippedkey == (int)Keys.ControlKey)) key = strippedkey;
			bool repeat = pressedkeys.Contains(strippedkey);
			
			// Update pressed keys
			if(!repeat) pressedkeys.Add(strippedkey);
			
			// Add action to active list
			Action[] acts = GetActionsByKey(key);
			bool absorbed = acts.Length > 0;
			foreach(Action a in acts) if(!activeactions.Contains(a)) activeactions.Add(a);

			// Invoke actions
			absorbed |= BeginActionByKey(key, repeat);

			return absorbed;
		}

19 View Source File : CustomEditorBase.cs
License : MIT License
Project Creator : 39M

protected void specifyCustomDecorator(string propertyName, Action<SerializedProperty> decoratorDrawer) {
      if (!validateProperty(propertyName)) {
        return;
      }

      List<Action<SerializedProperty>> list;
      if (!_specifiedDecorators.TryGetValue(propertyName, out list)) {
        list = new List<Action<SerializedProperty>>();
        _specifiedDecorators[propertyName] = list;
      }

      list.Add(decoratorDrawer);
    }

19 View Source File : BaseIntegrationFixture.cs
License : MIT License
Project Creator : ansel86castro

public TestHostPipeline ConfigureServices(Action<IServiceCollection> configureServices)
            {
                _setups.Add(configureServices);
                return this;
            }

19 View Source File : Layout.cs
License : MIT License
Project Creator : alelievr

public void EndHorizontal()
		{
			layoutActions.Add(() => EditorGUILayout.EndHorizontal());
			currentOrientation.Pop();
		}

19 View Source File : Layout.cs
License : MIT License
Project Creator : alelievr

public void BeginVertical()
		{
			currentOrientation.Push(LayoutOrientation.Vertical);
			layoutActions.Add(() => EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true)));
		}

19 View Source File : ViewModelBinding.cs
License : MIT License
Project Creator : 404Lcc

public void Add<TProperty>(string name, Action<TProperty, TProperty> valueChange)
        {
            FieldInfo fieldInfo = typeof(T).GetField(name, BindingFlags.Instance | BindingFlags.Public);
            if (fieldInfo == null) return;
            viewModelBindingList.Add((viewModel) =>
            {
                GetPropertyValue<TProperty>(viewModel, fieldInfo).ValueChange += valueChange;
            });
            unViewModelBindingList.Add((viewModel) =>
            {
                GetPropertyValue<TProperty>(viewModel, fieldInfo).ValueChange -= valueChange;
            });
        }

19 View Source File : Layout.cs
License : MIT License
Project Creator : alelievr

void AddPanel(LayoutSeparator sep, LayoutPanel panel)
		{
			layoutActions.Add(() => {
				Rect r = sep.Begin();
				layoutRects.Add(r);
				panel.Draw(r);
				sep.End();
				layoutRects.Add(sep.GetSeparatorRect());
			});
			loadedSeparators.Add(sep);
			loadedPanels.Add(panel);
		}

19 View Source File : BankIdBuilder.cs
License : MIT License
Project Creator : ActiveLogin

public void ConfigureHttpClient(Action<HttpClient> configureHttpClient)
        {
            _httpClientConfigurators.Add(configureHttpClient);
        }

19 View Source File : FloatVariable.cs
License : MIT License
Project Creator : alexjhetherington

public void RegisterListener(Action<float> listener)
    {
        if (!variableChangedListeners.Contains(listener))
            variableChangedListeners.Add(listener);
    }

19 View Source File : AppHostBuilder.cs
License : MIT License
Project Creator : alethic

public AppHostBuilder OnStopped(Action<AppHost> hook)
        {
            onStoppedHooks.Add(hook);
            return this;
        }

19 View Source File : ControlFlowGraphFabrication.cs
License : MIT License
Project Creator : adamant

private void Convert(IExpression expression)
        {
            switch (expression)
            {
                default:
                    throw ExhaustiveMatch.Failed(expression);
                case INewObjectExpression _:
                case IFieldAccessExpression _:
                    throw new NotImplementedException($"Convert({expression.GetType().Name}) Not Implemented.");
                case IBorrowExpression exp:
                    Convert(exp.Referent);
                    break;
                case IShareExpression exp:
                    Convert(exp.Referent);
                    break;
                case IMoveExpression exp:
                    Convert(exp.Referent);
                    break;
                case IImplicitNumericConversionExpression exp:
                    Convert(exp.Expression);
                    break;
                case IImplicitOptionalConversionExpression exp:
                    Convert(exp.Expression);
                    break;
                case IImplicitImmutabilityConversionExpression exp:
                    Convert(exp.Expression);
                    break;
                case ILoopExpression exp:
                {
                    var loopEntry = graph.NewEntryBlock(currentBlock!, exp.Block.Span.AtStart(), CurrentScope);
                    currentBlock = loopEntry;
                    continueToBlock = loopEntry;
                    var loopExit = ConvertLoopBody(exp.Block, exitRequired: false);
                    // If it always breaks, there isn't a current block
                    currentBlock?.End(new GotoInstruction(loopEntry.Number, exp.Block.Span.AtEnd(), CurrentScope));
                    currentBlock = loopExit;
                }
                break;
                case IWhileExpression whileExpression:
                {
                    // There is a block for the condition, it then goes either to
                    // the body or the after block.
                    var conditionBlock = graph.NewEntryBlock(currentBlock!,
                        whileExpression.Condition.Span.AtStart(), CurrentScope);
                    currentBlock = conditionBlock;
                    var condition = ConvertToOperand(whileExpression.Condition);
                    var loopEntry = graph.NewBlock();
                    continueToBlock = conditionBlock;
                    currentBlock = loopEntry;
                    var loopExit = ConvertLoopBody(whileExpression.Block);
                    // Generate if branch now that loop exit is known
                    conditionBlock.End(new IfInstruction(condition, loopEntry.Number, loopExit!.Number,
                            whileExpression.Condition.Span, CurrentScope));
                    // If it always breaks, there isn't a current block
                    currentBlock?.End(new GotoInstruction(conditionBlock.Number,
                        whileExpression.Block.Span.AtEnd(), CurrentScope));
                    currentBlock = loopExit;
                }
                break;
                case IForeachExpression exp:
                {
                    // For now, we support only range syntax `foreach x: T in z..y`. Range operators
                    // aren't yet supported by the rest of the language, so they must be directly
                    // translated here. The for each loop is basically desugared into:
                    // var x: T = z;
                    // let temp = y;
                    // loop
                    // {
                    //     <loop body>
                    //     x += 1;
                    //     if x > temp => break;
                    // }
                    if (!(exp.InExpression is IBinaryOperatorExpression inExpression)
                        || (inExpression.Operator != BinaryOperator.DotDot
                            && inExpression.Operator != BinaryOperator.LessThanDotDot
                            && inExpression.Operator != BinaryOperator.DotDotLessThan
                            && inExpression.Operator != BinaryOperator.LessThanDotDotLessThan))
                        throw new NotImplementedException(
                            "`foreach in` non-range expression not implemented");

                    var startExpression = inExpression.LeftOperand;
                    var endExpression = inExpression.RightOperand;

                    var variableType = (IntegerType)exp.Symbol.DataType;
                    var loopVariable = graph.AddVariable(exp.Symbol.IsMutableBinding,
                                            variableType, CurrentScope, exp.Symbol);
                    var loopVariablePlace = loopVariable.Place(exp.Span);
                    var loopVariableReference = loopVariable.Reference(exp.Span);

                    var includeStart = inExpression.Operator == BinaryOperator.DotDot
                                       || inExpression.Operator == BinaryOperator.DotDotLessThan;
                    var includeEnd = inExpression.Operator == BinaryOperator.DotDot
                                       || inExpression.Operator == BinaryOperator.LessThanDotDot;

                    // Load up the constant 1
                    var one = graph.Let(variableType, CurrentScope);
                    currentBlock!.Add(new LoadIntegerInstruction(one.Place(exp.Span), 1, variableType,
                                            exp.Span, CurrentScope));

                    // emit var x: T = z (+1);
                    ConvertIntoPlace(startExpression, loopVariablePlace);
                    if (!includeStart)
                    {
                        var addSpan = inExpression.LeftOperand.Span.AtEnd();
                        currentBlock!.Add(new NumericInstruction(loopVariablePlace, Add, variableType,
                                                loopVariableReference, one.Reference(addSpan), CurrentScope));
                    }

                    // let temp = y;
                    var endValue = ConvertToOperand(endExpression);

                    // Emit block
                    var loopEntry = graph.NewEntryBlock(currentBlock,
                                                exp.Block.Span.AtStart(), CurrentScope);
                    currentBlock = loopEntry;
                    var conditionBlock = continueToBlock = graph.NewBlock();
                    // TODO this generates the exit block too soon if the break condition is non-trivial
                    var loopExit = ConvertLoopBody(exp.Block)!;
                    // If it always breaks, there isn't a current block
                    currentBlock?.End(new GotoInstruction(conditionBlock.Number,
                                            exp.Block.Span.AtEnd(), CurrentScope));
                    currentBlock = conditionBlock;
                    // emit x += 1;
                    currentBlock.Add(new NumericInstruction(loopVariablePlace, Add, variableType, loopVariableReference, one.Reference(exp.Span), CurrentScope));

                    // emit if x (>)|(>=) temp => break;
                    var breakOperator = includeEnd ? GreaterThan : GreaterThanOrEqual;
                    var condition = graph.AddVariable(true, DataType.Bool, CurrentScope);
                    currentBlock.Add(new CompareInstruction(condition.Place(exp.Span),
                        breakOperator, variableType, loopVariableReference, endValue, CurrentScope));

                    currentBlock.End(new IfInstruction(condition.Reference(exp.Span), loopExit.Number, loopEntry.Number,
                            exp.Span, CurrentScope));
                    currentBlock = loopExit;
                }
                break;
                case IBreakExpression exp:
                {
                    // TODO Do we need `ExitScope(exp.Span.AtEnd());` ?
                    // capture the current block for use in the lambda
                    var breakingBlock = currentBlock!;
                    addBreaks.Add(loopExit => breakingBlock.End(new GotoInstruction(loopExit.Number, exp.Span, CurrentScope)));
                    currentBlock = null;
                }
                break;
                case INextExpression exp:
                {
                    // TODO Do we need `ExitScope(nextExpression.Span.AtEnd());` ?
                    currentBlock!.End(new GotoInstruction(continueToBlock?.Number ?? throw new InvalidOperationException(),
                        exp.Span, CurrentScope));
                    currentBlock = null;
                }
                break;
                case IIfExpression exp:
                {
                    var containingBlock = currentBlock!;
                    var condition = ConvertToOperand(exp.Condition);
                    var thenEntry = graph.NewBlock();
                    currentBlock = thenEntry;
                    Convert(exp.ThenBlock);
                    var thenExit = currentBlock;
                    BlockBuilder elseEntry;
                    BlockBuilder? exit = null;
                    if (exp.ElseClause is null)
                    {
                        elseEntry = exit = graph.NewBlock();
                        thenExit?.End(new GotoInstruction(exit.Number, exp.ThenBlock.Span.AtEnd(), CurrentScope));
                    }
                    else
                    {
                        elseEntry = graph.NewBlock();
                        currentBlock = elseEntry;
                        Convert(exp.ElseClause);
                        var elseExit = currentBlock;
                        if (thenExit != null || elseExit != null)
                        {
                            exit = graph.NewBlock();
                            thenExit?.End(new GotoInstruction(exit.Number, exp.ThenBlock.Span.AtEnd(), CurrentScope));
                            elseExit?.End(new GotoInstruction(exit.Number, exp.ElseClause.Span.AtEnd(), CurrentScope));
                        }
                    }

                    containingBlock.End(new IfInstruction(condition, thenEntry.Number, elseEntry.Number, exp.Condition.Span, CurrentScope));
                    currentBlock = exit;
                }
                break;
                case IMethodInvocationExpression exp:
                {
                    var method = exp.ReferencedSymbol;
                    var target = ConvertToOperand(exp.Context);
                    var args = exp.Arguments.Select(ConvertToOperand).ToFixedList();
                    currentBlock!.Add(new CallVirtualInstruction(target, method, args, exp.Span, CurrentScope));
                }
                break;
                case IreplacedignmentExpression exp:
                {
                    var leftOperand = exp.LeftOperand;
                    var replacedignInto = ConvertToPlace(leftOperand);
                    NumericInstructionOperator? op = exp.Operator switch
                    {
                        replacedignmentOperator.Simple => null,
                        replacedignmentOperator.Plus => Add,
                        replacedignmentOperator.Minus => Subtract,
                        replacedignmentOperator.Asterisk => Multiply,
                        replacedignmentOperator.Slash => Divide,
                        _ => throw ExhaustiveMatch.Failed(exp.Operator),
                    };
                    if (op is null)
                        ConvertIntoPlace(exp.RightOperand, replacedignInto);
                    else
                    {
                        var rhs = ConvertToOperand(exp.RightOperand);
                        currentBlock!.Add(new NumericInstruction(replacedignInto, op.Value, (NumericType)leftOperand.DataType.Known(),
                            replacedignInto.ToOperand(leftOperand.Span), rhs, CurrentScope));
                    }
                }
                break;
                case IUnsafeExpression exp:
                    Convert(exp.Expression);
                    break;
                case IBlockExpression exp:
                    foreach (var statement in exp.Statements)
                        Convert(statement);
                    break;
                case IFunctionInvocationExpression exp:
                {
                    var functionName = exp.ReferencedSymbol;
                    var args = exp.Arguments.Select(ConvertToOperand).ToFixedList();
                    currentBlock!.Add(CallInstruction.ForFunction(functionName, args, exp.Span, CurrentScope));
                }
                break;
                case IReturnExpression exp:
                {
                    if (exp.Value is null)
                        currentBlock!.End(new ReturnVoidInstruction(exp.Span, CurrentScope));
                    else
                    {
                        var returnValue = ConvertToOperand(exp.Value);
                        currentBlock!.End(new ReturnValueInstruction(returnValue, exp.Span, CurrentScope));
                    }

                    // There is no exit from a return block, hence null for exit block
                    currentBlock = null;
                }
                break;
                case INameExpression _:
                case IBinaryOperatorExpression _:
                case IUnaryOperatorExpression _:
                case IBoolLiteralExpression _:
                case IStringLiteralExpression _:
                case ISelfExpression _:
                case INoneLiteralExpression _:
                case IIntegerLiteralExpression _:
                case IImplicitNoneConversionExpression _:
                    // These operation have no side effects, so if the result isn't needed, there is nothing to do
                    break;

            }

19 View Source File : RuntimeSet.cs
License : MIT License
Project Creator : alexjhetherington

public void RegisterItemAddedListener(Action<T> listener)
    {
        if (!itemAddedListeners.Contains(listener))
            itemAddedListeners.Add(listener);
    }

19 View Source File : LivingStream.cs
License : MIT License
Project Creator : a1q123456

[RpcMethod("play")]
        public async Task Play(
            [FromOptionalArgument] string streamName,
            [FromOptionalArgument] double start = -1,
            [FromOptionalArgument] double duration = -1,
            [FromOptionalArgument] bool reset = false)
        {
            var publisher = _publisherSessionService.FindPublisher(streamName);
            if (publisher == null)
            {
                throw new KeyNotFoundException();
            }
            var resetData = new AmfObject
            {
                {"level", "status" },
                {"code", "NetStream.Play.Reset" },
                {"description", "Resetting and playing stream." },
                {"details", streamName }
            };
            var resetStatus = RtmpSession.CreateCommandMessage<OnStatusCommandMessage>();
            resetStatus.InfoObject = resetData;
            await MessageStream.SendMessageAsync(ChunkStream, resetStatus);

            var startData = new AmfObject
            {
                {"level", "status" },
                {"code", "NetStream.Play.Start" },
                {"description", "Started playing." },
                {"details", streamName }
            };
            var startStatus = RtmpSession.CreateCommandMessage<OnStatusCommandMessage>();
            startStatus.InfoObject = startData;
            await MessageStream.SendMessageAsync(ChunkStream, startStatus);

            var flvMetadata = RtmpSession.CreateData<DataMessage>();
            flvMetadata.MessageHeader = (MessageHeader)publisher.FlvMetadata.MessageHeader.Clone();
            flvMetadata.Data = publisher.FlvMetadata.Data;
            await MessageStream.SendMessageAsync(ChunkStream, flvMetadata);

            _videoChunkStream = RtmpSession.CreateChunkStream();
            _audioChunkStream = RtmpSession.CreateChunkStream();

            if (publisher.AACConfigureRecord != null)
            {
                await MessageStream.SendMessageAsync(_audioChunkStream, publisher.AACConfigureRecord.Clone() as AudioMessage);
            }
            if (publisher.AVCConfigureRecord != null)
            {
                await MessageStream.SendMessageAsync(_videoChunkStream, publisher.AVCConfigureRecord.Clone() as VideoMessage);
            }

            publisher.OnAudioMessage += SendAudio;
            publisher.OnVideoMessage += SendVideo;
            _cleanupActions.Add(() =>
            {
                publisher.OnVideoMessage -= SendVideo;
                publisher.OnAudioMessage -= SendAudio;
            });
        }

19 View Source File : StringVariable.cs
License : MIT License
Project Creator : alexjhetherington

public void RegisterListener(Action<string> listener)
    {
        if (!variableChangedListeners.Contains(listener))
            variableChangedListeners.Add(listener);
    }

19 View Source File : ServerServiceDefinition.cs
License : MIT License
Project Creator : AElfProject

public Builder AddDescriptors(IEnumerable<ServiceDescriptor> descriptors)
            {
                foreach (var descriptor in descriptors)
                {
                    addDescriptorActions.Add((serviceBinder) => serviceBinder.AddDescriptor(descriptor));
                }
                return this;
            }

19 View Source File : CSVReader.cs
License : GNU Lesser General Public License v3.0
Project Creator : Alois-xx

private void CreateParser(string[] columnNames)
        {
            for(int i=0;i<columnNames.Length;i++)
            {
                switch(columnNames[i])
                {
                    case Memreplacedyzer.AllocatedBytesColumn:
                        Parsers.Add((row, str) => { row.AllocatesBytes = LongColumnParsers[Memreplacedyzer.AllocatedBytesColumn](str); });
                        break;
                    case Memreplacedyzer.AllocatedKBColumn:
                        Parsers.Add((row, str) => { row.AllocatesBytes = LongColumnParsers[Memreplacedyzer.AllocatedKBColumn](str); });
                        break;
                    case Memreplacedyzer.AllocatedMBColumn:
                        Parsers.Add((row, str) => { row.AllocatesBytes = LongColumnParsers[Memreplacedyzer.AllocatedMBColumn](str); });
                        break;
                    case Memreplacedyzer.AllocatedGBColumn:
                        Parsers.Add((row, str) => { row.AllocatesBytes = LongColumnParsers[Memreplacedyzer.AllocatedGBColumn](str); });
                        break;
                    case Memreplacedyzer.InstancesColumn:
                        Parsers.Add((row, str) => { row.Instances = LongColumnParsers[Memreplacedyzer.InstancesColumn](str); });
                        break;
                    case Memreplacedyzer.TypeColumn:
                        Parsers.Add((row, str) => { row.Type = StringColumnParsers[Memreplacedyzer.TypeColumn](str); });
                        break;
                    case Memreplacedyzer.ProcessIdColumn:
                        Parsers.Add((row, str) => { row.ProcessContext.Pid = IntColumnParsers[Memreplacedyzer.ProcessIdColumn](str); });
                        break;
                    case Memreplacedyzer.AgeColumn:
                        Parsers.Add((row, str) => { row.ProcessContext.AgeIns = IntColumnParsers[Memreplacedyzer.AgeColumn](str); });
                        break;
                    case Memreplacedyzer.TimeColumn:
                        Parsers.Add((row, str) => { row.ProcessContext.Time = TimeColumnParsers[Memreplacedyzer.TimeColumn](str); });
                        break;
                    case Memreplacedyzer.CommandeLineColumn:
                        Parsers.Add((row, str) => { row.ProcessContext.CommandLine = StringColumnParsers[Memreplacedyzer.CommandeLineColumn](str); });
                        break;
                    case Memreplacedyzer.NameColumn:
                        Parsers.Add((row, str) => { row.ProcessContext.Name = StringColumnParsers[Memreplacedyzer.NameColumn](str); });
                        break;
                    case Memreplacedyzer.ContextColumn:
                        Parsers.Add((row, str) => { row.ProcessContext.Context = StringColumnParsers[Memreplacedyzer.ContextColumn](str); });
                        break;

                    default:
                        throw new NotSupportedException($"Column name {columnNames[i]} is not recognized as valid column. Cannot parse further.");
                }
            }
        }

19 View Source File : UnityThread.cs
License : MIT License
Project Creator : 1ZouLTReX1

public static void executeInFixedUpdate(System.Action action)
    {
        if (action == null)
        {
            throw new ArgumentNullException("action");
        }

        lock (actionQueuesFixedUpdateFunc)
        {
            actionQueuesFixedUpdateFunc.Add(action);
            noActionQueueToExecuteFixedUpdateFunc = false;
        }
    }

19 View Source File : LifecycleManager.cs
License : Apache License 2.0
Project Creator : andijakl

public AsyncTask<ApkInstallationStatus> RequestApkInstallation(bool userRequested)
        {
            Action<ApkInstallationStatus> onComplete;
            AsyncTask<ApkInstallationStatus> task =
                new AsyncTask<ApkInstallationStatus>(out onComplete);

            ExternApi.ArPresto_requestApkInstallation(userRequested,
                m_RequestApkInstallationResultCallback, IntPtr.Zero);

            m_PendingInstallationRequestCallbacks.Add(onComplete);

            return task;
        }

19 View Source File : EventBase.cs
License : Apache License 2.0
Project Creator : AKruimink

private List<Action<object[]>> GetExecutionStratagies()
        {
            var returnList = new List<Action<object[]>>();

            lock (Subscriptions)
            {
                for (var i = Subscriptions.Count - 1; i >= 0; i--)
                {
                    var lisreplacedem = _subscriptions[i].GetExecutionStrategy();

                    if (lisreplacedem == null)
                    {
                        _subscriptions.RemoveAt(i);
                    }
                    else
                    {
                        returnList.Add(lisreplacedem);
                    }
                }
            }
            return returnList;
        }

19 View Source File : FakeBus.cs
License : GNU General Public License v3.0
Project Creator : andysal

public void RegisterHandler<T>(Action<T> handler) where T : Message
        {
            List<Action<Message>> handlers;
            if(!_routes.TryGetValue(typeof(T), out handlers))
            {
                handlers = new List<Action<Message>>();
                _routes.Add(typeof(T), handlers);
            }
            handlers.Add(DelegateAdjuster.CastArgument<Message, T>(x => handler(x)));
        }

19 View Source File : IntervalExecutor.cs
License : MIT License
Project Creator : a3geek

public void AddAction(Action action)
        {
            this.actions.Add(action);
        }

19 View Source File : Dispatcher.cs
License : GNU Lesser General Public License v3.0
Project Creator : angturil

public static void RunOnMainThread(Action action)
        {
            lock (_backlog)
            {
                _backlog.Add(action);
                _queued = true;
            }
        }

19 View Source File : GvrVideoPlayerTexture.cs
License : MIT License
Project Creator : alanplotko

public void SetOnExceptionCallback(Action<string, string> callback) {
    if (onExceptionCallbacks == null) {
      onExceptionCallbacks = new List<Action<string, string>>();
      SetOnExceptionCallback(videoPlayerPtr, InternalOnExceptionCallback,
        ToIntPtr(this));
    }
    onExceptionCallbacks.Add(callback);
  }

19 View Source File : ActionManager.cs
License : GNU General Public License v3.0
Project Creator : anotak

internal bool BeginActionByKey(int key, bool repeated)
		{
			bool invoked = false;
			
			// Get all actions for which a begin is bound
			List<Action> boundactions = new List<Action>(actions.Count);
			foreach(KeyValuePair<string, Action> a in actions)
				if(a.Value.BeginBound) boundactions.Add(a.Value);
			
			// Go for all actions
			foreach(Action a in boundactions)
			{
				// This action is replacedociated with this key?
				if(a.KeyMatches(key))
				{
					invoked = true;
					
					// Allowed to repeat?
					if(a.Repeat || !repeated)
					{
						// Invoke action
						a.Begin();
					}
					else
					{
						//Logger.WriteLogLine("Action \"" + a.Value.Name + "\" failed because it does not support repeating activation!");
					}
				}
			}

			return invoked;
		}

19 View Source File : UnityThread.cs
License : MIT License
Project Creator : 1ZouLTReX1

public static void executeInUpdate(System.Action action)
    {
        if (action == null)
        {
            throw new ArgumentNullException("action");
        }

        lock (actionQueuesUpdateFunc)
        {
            actionQueuesUpdateFunc.Add(action);
            noActionQueueToExecuteUpdateFunc = false;
        }
    }

19 View Source File : EnvironmentHelper.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

public static void StartActivator(
            Action callback)
        {
            SetTLSProtocol();

            if (!isStarted)
            {
                ActivationManager.Instance.ActivationDeniedCallback = OnActivationDenied;

                AppLog.DefaultLogger.Trace("Activator started.");
                AppLog.DefaultLogger.Trace(typeof(ActivationManager).replacedembly.ToString());
            }

            isStarted = true;

            ActivationDeniedCallbackList.Add(callback);
            ActivationManager.Instance.Start(
                () =>
                    CombatantsManager.Instance.PartyCount >= 4 ||
                    XIVPluginHelper.Instance.InCombat);
        }

19 View Source File : Layout.cs
License : MIT License
Project Creator : alelievr

public void BeginHorizontal()
		{
			currentOrientation.Push(LayoutOrientation.Horizontal);
			layoutActions.Add(() => EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(true)));
		}

19 View Source File : StickyManager.cs
License : GNU General Public License v3.0
Project Creator : ACEmulator

public void add_sticky_listener(Action listener)
        {
            StickyCallbacks.Add(listener);
        }

19 View Source File : DbBuilder.cs
License : MIT License
Project Creator : 17MKH

public IDbBuilder AddAction(Action action)
    {
        if (action == null)
            return this;

        _actions.Add(action);
        return this;
    }

19 View Source File : UnityThread.cs
License : MIT License
Project Creator : 1ZouLTReX1

public static void executeInLateUpdate(System.Action action)
    {
        if (action == null)
        {
            throw new ArgumentNullException("action");
        }

        lock (actionQueuesLateUpdateFunc)
        {
            actionQueuesLateUpdateFunc.Add(action);
            noActionQueueToExecuteLateUpdateFunc = false;
        }
    }

19 View Source File : ByteBuffer.cs
License : MIT License
Project Creator : a1q123456

public void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags)
            {
                if ((flags & ValueTaskSourceOnCompletedFlags.FlowExecutionContext) != 0)
                {
                    this.executionContext = ExecutionContext.Capture();
                }

                if ((flags & ValueTaskSourceOnCompletedFlags.UseSchedulingContext) != 0)
                {
                    SynchronizationContext sc = SynchronizationContext.Current;
                    if (sc != null && sc.GetType() != typeof(SynchronizationContext))
                    {
                        this.scheduler = sc;
                    }
                    else
                    {
                        TaskScheduler ts = TaskScheduler.Current;
                        if (ts != TaskScheduler.Default)
                        {
                            this.scheduler = ts;
                        }
                    }
                }

                // Remember current state
                this.state = state;
                // Remember continuation to be executed on completed (if not already completed, in case of which
                // continuation will be set to CallbackCompleted)
                var previousContinuation = Interlocked.CompareExchange(ref this.continuation, continuation, null);
                if (previousContinuation != null)
                {
                    if (!ReferenceEquals(previousContinuation, CallbackCompleted))
                    {
                        throw new InvalidOperationException();
                    }

                    // Lost the race condition and the operation has now already completed.
                    // We need to invoke the continuation, but it must be asynchronously to
                    // avoid a stack dive.  However, since all of the queueing mechanisms flow
                    // ExecutionContext, and since we're still in the same context where we
                    // captured it, we can just ignore the one we captured.
                    executionContext = null;
                    this.state = null; // we have the state in "state"; no need for the one in UserToken
                    InvokeContinuation(continuation, state, forceAsync: true);
                }

                cb.Add(() => continuation(state));
            }

19 View Source File : BankIdBuilder.cs
License : MIT License
Project Creator : ActiveLogin

public void ConfigureHttpClientHandler(Action<SocketsHttpHandler> configureHttpClientHandler)
        {
            _httpClientHandlerConfigurators.Add(configureHttpClientHandler);
        }

19 View Source File : BooleanVariable.cs
License : MIT License
Project Creator : alexjhetherington

public void RegisterListener(Action<bool> listener)
    {
        if (!variableChangedListeners.Contains(listener))
            variableChangedListeners.Add(listener);
    }

See More Examples