/// <summary> Adds a factory for deriving reference URI's into references</summary> /// <param name="factory">A raw ReferenceFactory capable of creating /// a reference. /// </param> public virtual void addReferenceFactory(ReferenceFactory factory) { if (!factories.contains(factory)) { factories.addElement(factory); } }
public HandlerDistributorConnector(ReferenceFactory referenceFactory, IWorkerSelectorFactory workerSelectorFactory) { _referenceFactory = referenceFactory; _messageConnector = new MessageDistributorConnector <TMessage>(workerSelectorFactory); }
/// <summary> Adds a factory for deriving reference URI's into references</summary> /// <param name="factory">A raw ReferenceFactory capable of creating /// a reference. /// </param> public virtual void addReferenceFactory(ReferenceFactory factory) { if (!factories.Contains(factory)) { factories.Add(factory); } }
public ConsumerDistributorConnector(ReferenceFactory referenceFactory, IWorkerSelectorFactory workerSelectorFactory) { _workerSelectorFactory = workerSelectorFactory; _referenceFactory = referenceFactory; Type[] interfaces = typeof(T).GetInterfaces(); if (interfaces.Contains(typeof(ISaga))) { throw new ConfigurationException("A saga cannot be registered as a consumer"); } if (interfaces.Implements(typeof(InitiatedBy <>)) || interfaces.Implements(typeof(Orchestrates <>)) || interfaces.Implements(typeof(Observes <,>))) { throw new ConfigurationException("InitiatedBy, Orchestrates, and Observes can only be used with sagas"); } _connectors = ConsumesSelectedContext() .Concat(ConsumesContext()) .Concat(ConsumesSelected()) .Concat(ConsumesAll()) .Distinct((x, y) => x.MessageType == y.MessageType) .ToList(); }
public StateMachineSubscriptionBuilder(StateMachine <TInstance> stateMachine, StateMachineSagaRepository <TInstance> repository, ReferenceFactory referenceFactory) { _connector = new StateMachineConnector <TInstance>(stateMachine, repository); _referenceFactory = referenceFactory; }
public InstanceSubscriptionBuilder(object instance, ReferenceFactory referenceFactory) { _instance = instance; _connector = InstanceConnectorCache.GetInstanceConnector(instance.GetType()); _referenceFactory = referenceFactory; }
private void PrintReference() { human _human = _fe.humans.FirstOrDefault(id => id.idh == _humanid); if (_reference != EnumPReferences.NoReference) { ReferenceFactory refsfactory = new ReferenceFactory(_human, _ge, _fe); try { refsfactory.GetReference(new List <int> { _testresult.idtr }, _reference).Print(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { try{ ReportFactory.CreateReport(_test, _human, _testresult, _ge, _fe, false).Print(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public InstanceSubscriptionBuilder(object instance, ReferenceFactory referenceFactory) { _instance = instance; _connector = InstanceConnectorCache.GetInstanceConnector(instance.GetType()); _referenceFactory = referenceFactory; }
public ConsumerSubscriptionBuilder(IConsumerFactory <TConsumer> consumerFactory, ReferenceFactory referenceFactory) { _consumerFactory = consumerFactory; _referenceFactory = referenceFactory; _consumerConnector = ConsumerConnectorCache.GetConsumerConnector <TConsumer>(); }
public HandlerSubscriptionBuilder(HandlerSelector <TMessage> handler, ReferenceFactory referenceFactory) { _handler = handler; _referenceFactory = referenceFactory; _connector = new HandlerSubscriptionConnector <TMessage>(); }
public ActionResult AddRole(AspNetRole role) { role.Id = ReferenceFactory.GenerateReference(role.Name, 9); ent.AspNetRoles.Add(role); ent.SaveChanges(); return(RedirectToAction("DisplayRoles")); }
/// <summary> /// Initializes a new instance of the <see cref="WeavingContext"/> class. /// </summary> /// <param name="module">The module that this weaving context is for.</param> public WeavingContext(ModuleDefinition module) { this.module = module ?? throw new ArgumentNullException("module"); baseReference = ReferenceFactory.InitializeBaseReference(module); ExecutionSwitches = SwitchFactory.InitializeSwitchSet(); ReturnSwitches = SwitchFactory.InitializeSwitchSet(); ExecutionContextSwitches = SwitchFactory.InitializeSwitchSet(); ExecutionVariableSwitchableSection = SwitchFactory.InitializeSwitchableSection(); ReturnVariableSwitchableSection = SwitchFactory.InitializeSwitchableSection(); ReturnFinallySwitchableSection = SwitchFactory.InitializeSwitchableSection(); ExecutionContextVariableSwitchableSection = SwitchFactory.InitializeSwitchableSection(); }
public ActionResult CreateApplication(CreateApplicationViewModel app) { if (ModelState.IsValid) { int dateId = WebSettings.getCurrentDate(); SinisianDatabase sinDb = srch.FindInSinisian(app.FirstName, app.MiddleName, app.LastName); string referenceNum = ReferenceFactory.GenerateReference(app.FirstName + app.MiddleName + app.LastName); if (sinDb == null) { TempData["errorMsg"] = "Sorry we cannot find your identity."; return(RedirectToAction("CreateApplication", app)); } int count = ent.Applications.Where(m => m.SinId == sinDb.SinId && m.DSetIdApplied == dateId).Count(); if (count >= 1) { TempData["errorMsg"] = "You already have an application. You can check your status from the \"Application Status\" in the navbar."; return(RedirectToAction("CreateApplication")); } /** * isa, if officer na siya hindi na siya pwede pang mag aaply pa para maging officer */ Application application = new Application() { ATypeId = int.Parse(app.ApplicationType), ASTypId = ent.ApplicationStatusTypes.Where(m => m.Name.ToLower() == "queue").Select(m => m.ASTypId).FirstOrDefault(), DSetIdApplied = dateId, RerenceNum = referenceNum, SinId = sinDb.SinId, }; ent.Applications.Add(application); ent.SaveChanges(); Mailer.SendEmail(new IdentityMessage() { Subject = "Application Reference Number", Body = "<b>" + referenceNum + "</b> is your reference number to your application.<br><br>Please click this link to check application status.<br><br><br><br><b>Sincerely,</b><br>Flores De Mayo President.<br><br><br><br>If you have any concern please send a feedback to us at <a href=\"\">this link.</a>", Destination = app.Email }); } else { } return(RedirectToAction("CreateApplication")); }
private void FillReferences() { dg_references.Rows.Clear(); if (_currenthumanid != 0) { dg_references.Rows.Clear(); human h = _fe.humans.First(hh => hh.idh == _currenthumanid); _referfactory = new ReferenceFactory(h, _ge, _fe); for (int rowindex = 0; rowindex < _referfactory.EvalRefs.Count; rowindex++) { dg_references.Rows.Add(_referfactory.EvalRefs[rowindex]); } } }
public ActionResult CreateAlayan(CreateAlayanViewModel alayanVM) { if (ModelState.IsValid) { SinisianDatabase sinDb = srch.FindInSinisian(alayanVM.FirstName, alayanVM.MiddleName, alayanVM.LastName); string referenceNum = ReferenceFactory.GenerateReference(alayanVM.FirstName + alayanVM.MiddleName + alayanVM.LastName); int dateId = WebSettings.getCurrentDate(); if (sinDb == null) { TempData["errorMsg"] = "Sorry we cannot find your identity."; return(RedirectToAction("CreateAlayan")); } int count = ent.Alayans.Where(m => m.SinId == sinDb.SinId && m.DSetIdApplied == dateId).Count(); if (count >= 1) { TempData["errorMsg"] = "You already have an application. You can check your status from the \"Application Status\" in the navbar."; return(RedirectToAction("CreateAlayan")); } Alayan alayan = new Alayan() { ADatId = alayanVM.AlayDate, ATypId = alayanVM.AlayType, DSetIdApplied = dateId, Reference = referenceNum, SinId = sinDb.SinId }; ent.Alayans.Add(alayan); ent.SaveChanges(); Mailer.SendEmail(new IdentityMessage() { Subject = "Alayan Schedule Reference Number", Body = "<b>" + referenceNum + "</b> is your reference number to your alayan schedule.<br><br>Please click this link to check the summary.<br><br><br><br><b>Sincerely,</b><br>Flores De Mayo President.<br><br><br><br>If you have any concern please send a feedback to us at <a href=\"\">this link.</a>", Destination = alayanVM.Email }); return(RedirectToAction("CreateAlayan")); } else { TempData["errorMsg"] = "Sorry, please try again."; return(RedirectToAction("CreateAlayan")); } }
public HandlerWorkerConnector(HandlerSelector <TMessage> handler, ReferenceFactory referenceFactory) { _handler = handler; _referenceFactory = referenceFactory; }
public GrammarP(CultureInfo cultureInfo) : base(new Domain()) { B = new BnfTerms(new TerminalFactoryS(this), cultureInfo); this.DefaultCulture = cultureInfo; this.Root = B.Program; B.Program.Rule = B.PROGRAM + B.Name.BindTo(B.Program, t => t.Name) + (B.NAMESPACE + B.NamespaceName).QRef().BindTo(B.Program, t => t.Namespace) + B.Function.StarList().BindTo(B.Program, t => t.Functions) + B.BEGIN + B.Statement.PlusList().BindTo(B.Program, t => t.Body) + B.END + B.DOT ; B.Function.Rule = B.FUNCTION + B.ASYNC.QVal(false).BindTo(B.Function, t => t.IsAsync) + B.Name.BindTo(B.Function, t => t.Name) + B.LEFT_PAREN + B.Parameter.StarList(B.COMMA).BindTo(B.Function, t => t.Parameters) + B.RIGHT_PAREN + (B.COLON + B.Type).QVal().BindTo(B.Function, t => t.ReturnType) + B.BEGIN + B.Statement.PlusList().BindTo(B.Function, t => t.Body) + B.END ; B.Parameter.Rule = B.VAR + B.Name.BindTo(B.Parameter, t => t.Name) + B.COLON + B.Type.BindTo(B.Parameter, t => t.Type) ; B.Statement.SetRuleOr( B.LocalVariable + B.SEMICOLON, B.Assignment + B.SEMICOLON, B.While, B.For, B.If, #if SEPARATE_IFELSE B.IfElse, #endif B.FunctionCall + B.SEMICOLON, B.Write + B.SEMICOLON, B.WriteLn + B.SEMICOLON, B.Return + B.SEMICOLON, B.StatementList ); B.Return.Rule = B.RETURN + B.Expression.BindTo(B.Return, t => t.Value) ; B.LocalVariable.Rule = B.VAR + B.Name.BindTo(B.LocalVariable, t => t.Name) + B.COLON + B.Type.BindTo(B.LocalVariable, t => t.Type) + (B.LET + B.Expression).QRef().BindTo(B.LocalVariable, t => t.InitValue) ; B.Assignment.Rule = B.VariableReference.BindTo(B.Assignment, t => t.LValue) + B.LET + B.Expression.BindTo(B.Assignment, t => t.RValue) ; B.VariableReference.Rule = B.NameRef .ConvertValue(_nameRef => ReferenceFactory.Get <D.IVariable>(_nameRef), _variableReference => _variableReference.NameRef) .BindTo(B.VariableReference, t => t.Target) ; B.FunctionReference.Rule = B.NameRef.ConvertValue(_nameRef => ReferenceFactory.Get <D.Function>(_nameRef), _functionReference => _functionReference.NameRef) ; B.StatementList.Rule = B.BEGIN + B.Statement.PlusList().BindTo(B.StatementList, t => t.Body) + B.END ; B.While.Rule = B.WHILE + B.LEFT_PAREN + B.Expression.BindTo(B.While, t => t.Condition) + B.RIGHT_PAREN + B.DO + B.Statement.BindTo(B.While, t => t.Body) ; B.For.Rule = B.FOR + B.LEFT_PAREN + B.LocalVariable.StarList(B.COMMA).BindTo(B.For, t => t.Init) + B.SEMICOLON + B.Expression.BindTo(B.For, t => t.Condition) + B.SEMICOLON + B.Assignment.StarList(B.COMMA).BindTo(B.For, t => t.Update) + B.RIGHT_PAREN + B.DO + B.Statement.BindTo(B.For, t => t.Body) ; #if SEPARATE_IFELSE B.If.Rule = B.IF + B.LEFT_PAREN + B.Expression.BindTo(B.If, t => t.Condition) + B.RIGHT_PAREN + B.THEN + B.Statement.BindTo(B.If, t => t.Body) ; B.IfElse.Rule = B.If.Copy(B.IfElse) + B.ELSE + B.Statement.BindTo(B.IfElse, t => t.ElseBody) ; #else B.If.Rule = B.IF + B.LEFT_PAREN + B.Expression.BindTo(B.If, t => t.Condition) + B.RIGHT_PAREN + B.THEN + B.Statement.BindTo(B.If, t => t.Body) + (B.ELSE + B.Statement).QRef().BindTo(B.If, t => t.ElseBody) ; #endif B.FunctionCall.Rule = B.FunctionReference.BindTo(B.FunctionCall, t => t.FunctionReference) + B.LEFT_PAREN + B.Argument.StarList(B.COMMA).BindTo(B.FunctionCall, t => t.Arguments) + B.RIGHT_PAREN ; B.Argument.Rule = B.Expression.BindTo(B.Argument, t => t.Expression) ; B.Write.Rule = B.WRITE + B.LEFT_PAREN + B.Expression.StarList(B.COMMA).BindTo(B.Write, t => t.Arguments) + B.RIGHT_PAREN ; B.WriteLn.Rule = B.WRITELN + B.LEFT_PAREN + B.Expression.StarList(B.COMMA).BindTo(B.WriteLn, t => t.Arguments) + B.RIGHT_PAREN ; B.Name.Rule = B.IDENTIFIER.BindTo(B.Name, t => t.Value); B.NameRef.Rule = B.IDENTIFIER.ConvertValue(_identifier => new NameRef(_identifier), _nameRef => _nameRef.Value); B.NamespaceName.Rule = B.IDENTIFIER .PlusList(B.DOT) .ConvertValue( _identifiers => new NameRef(string.Join(B.DOT.Text, _identifiers)), _nameRef => _nameRef.Value.Split(new string[] { B.DOT.Text }, StringSplitOptions.None) ); B.Expression.SetRuleOr( B.BinaryExpression, B.UnaryExpression, B.ConditionalTernaryExpression, B.NumberLiteral, B.DateLiteral, B.StringLiteral, B.BoolLiteral, B.ColorLiteral, B.FunctionCall, B.VariableReference, B.LEFT_PAREN + B.Expression + B.RIGHT_PAREN ); B.BinaryExpression.Rule = B.Expression.BindTo(B.BinaryExpression, t => t.Term1) + B.BinaryOperator.BindTo(B.BinaryExpression, t => t.Op) + B.Expression.BindTo(B.BinaryExpression, t => t.Term2) ; /* * NOTE: ImplyPrecedenceHere does not work properly, so we do not use it (it parsed operator NEG as operator POS, and omitted the expression after). * So we use ReduceHere instead, which means that unary operators has the highest precedence among operators when used inside a unary expressions. * */ B.UnaryExpression.Rule = B.UnaryOperator.BindTo(B.UnaryExpression, t => t.Op) + B.Expression.BindTo(B.UnaryExpression, t => t.Term) + ReduceHere() // this is needed for implying precedence (see note above) ; B.ConditionalTernaryExpression.Rule = B.Expression.BindTo(B.ConditionalTernaryExpression, t => t.Cond) + B.QUESTION_MARK + B.Expression.BindTo(B.ConditionalTernaryExpression, t => t.Term1) + B.COLON + B.Expression.BindTo(B.ConditionalTernaryExpression, t => t.Term2) ; var numberLiteralInfo = new NumberLiteralInfo() .AddSuffix("D", TypeCode.Double) .AddSuffix("M", TypeCode.Decimal) .AddPrefix("#b", NumberLiteralBase.Binary) .AddPrefix("#o", NumberLiteralBase.Octal) .AddPrefix("#x", NumberLiteralBase.Hexadecimal); B.NumberLiteral.Rule = TerminalFactoryS.CreateNumberLiteral <DE.NumberLiteral>(numberLiteralInfo); // B.NumberLiteral.Rule = TerminalFactoryS.CreateNumberLiteral().BindTo(B.NumberLiteral, t => t.Value); // B.NumberLiteral used to be a BnfiTermRecord B.StringLiteral.Rule = TerminalFactoryS.CreateStringLiteral(name: "stringliteral", startEndSymbol: "'").BindTo(B.StringLiteral, t => t.Value); B.BoolLiteral.Rule = B.BOOL_CONSTANT.BindTo(B.BoolLiteral, t => t.Value); B.ColorLiteral.Rule = B.COLOR_CONSTANT.BindTo(B.ColorLiteral, t => t.Value); B.DateLiteral.Rule = TerminalFactoryS.CreateDataLiteralDateTimeQuoted(name: "dateliteral", startEndSymbol: "$", dateTimeFormat: D.DateLiteral.Format).BindTo(B.DateLiteral, t => t.Value); B.BinaryOperator.Rule = B.ADD_OP | B.SUB_OP | B.MUL_OP | B.DIV_OP | B.POW_OP | B.MOD_OP | B.EQ_OP | B.NEQ_OP | B.LT_OP | B.LTE_OP | B.GT_OP | B.GTE_OP | B.AND_OP | B.OR_OP; B.UnaryOperator.Rule = B.POS_OP | B.NEG_OP | B.NOT_OP; B.Type.Rule = B.INTEGER_TYPE | B.REAL_TYPE | B.STRING_TYPE | B.CHAR_TYPE | B.BOOL_TYPE | B.COLOR_TYPE | B.DATE_TYPE; /* * NOTE: RegisterOperators in Irony is string-based, therefore it is impossible to specify different precedences * for binary '+' and unary '+', and for binary '-' and unary '-', so we encode the precedences of unary operators * into the grammar by specifying a ReduceHere() hint after unary expressions. * */ RegisterOperators(10, Associativity.Right, B.QUESTION_MARK, B.COLON); RegisterOperators(20, B.OR_OP); RegisterOperators(30, B.AND_OP); RegisterOperators(40, B.EQ_OP, B.NEQ_OP); RegisterOperators(50, B.LT_OP, B.LTE_OP, B.GT_OP, B.GTE_OP); RegisterOperators(60, B.ADD_OP, B.SUB_OP); RegisterOperators(70, B.MUL_OP, B.DIV_OP, B.MOD_OP); RegisterOperators(80, Associativity.Right, B.POW_OP); RegisterOperators(90, Associativity.Neutral, recurse: false, operators: new[] { B.NEG_OP, B.POS_OP, B.NOT_OP }); // NOTE: for the parser the unary operators precedences are encoded into the grammar, but for the unparser we have to specify the precedences // NOTE: we must not recurse, since NEG_OP and POS_OP has the same terminals as SUB_OP and ADD_OP, respectively ('-' and '+'). RegisterBracePair(B.LEFT_PAREN, B.RIGHT_PAREN); CommentTerminal DelimitedComment = new CommentTerminal("DelimitedComment", "(@", "@)"); CommentTerminal SingleLineComment = new CommentTerminal("SingleLineComment", "@@", Environment.NewLine, "\n", "\r"); NonGrammarTerminals.Add(DelimitedComment); NonGrammarTerminals.Add(SingleLineComment); }
public SagaSubscriptionBuilder(ISagaRepository <TSaga> sagaRepository, ReferenceFactory referenceFactory) { _connector = new SagaConnector <TSaga>(sagaRepository); _referenceFactory = referenceFactory; }
public virtual bool removeReferenceFactory(ReferenceFactory factory) { return(factories.Remove(factory)); }
public virtual bool removeReferenceFactory(ReferenceFactory factory) { return(factories.removeElement(factory)); }
public TInterface Permanent() { _referenceFactory = PermanentSubscriptionReference.Create; return(this as TInterface); }
public TInterface Transient() { _referenceFactory = TransientSubscriptionReference.Create; return(this as TInterface); }
/// <summary> /// Добавить в программу обьект используя его тип. /// </summary> /// <param name="type"></param> /// <param name="as_global"></param> public void AddObjectOfType(Type type, LibraryClassAttribute attribute = null) { if (attribute == null) { attribute = (LibraryClassAttribute)Attribute.GetCustomAttribute(type, typeof(LibraryClassAttribute), false); } ScriptModule module = new ScriptModule(attribute.Name, attribute.Alias, ModuleTypeEnum.OBJECT, attribute.AsGlobal) { InstanceType = type }; foreach (PropertyInfo property in type.GetTypeInfo().GetProperties().Where(m => m.GetCustomAttributes(typeof(LibraryClassPropertyAttribute), false).Length > 0)) { LibraryClassPropertyAttribute property_attr = property.GetCustomAttribute <LibraryClassPropertyAttribute>(false); IVariableReference reference = ReferenceFactory.Create(type, property); IVariable var = new Variable() { Name = property_attr.Name, Alias = property_attr.Alias, Public = true, Reference = reference }; module.Variables.Add(property_attr.Name, var); if (attribute.AsGlobal) { _programm.GlobalVariables.Add(var); } } foreach (MethodInfo method in type.GetTypeInfo().DeclaredMethods.Where(m => m.GetCustomAttributes(typeof(LibraryClassMethodAttribute), false).Length > 0)) { LibraryClassMethodAttribute method_attr = method.GetCustomAttribute <LibraryClassMethodAttribute>(false); IFunction function = module.Functions.Create(method_attr.Name, true); if (function == null) { throw new Exception($"Функция с именем {method_attr.Name} уже существует."); } function.Alias = method_attr.Alias; function.Type = method.ReturnType == typeof(void) ? FunctionTypeEnum.PROCEDURE : FunctionTypeEnum.FUNCTION; GetFunctionParameters(function, method); function.Method = LibraryMethodFactory.Create(type, method); if (attribute.AsGlobal) { _programm.GlobalFunctions.Add(function); } } if (module.Variables.Get("ЭтотОбъект") == null && !attribute.AsGlobal) { module.Variables.Create("ЭтотОбъект", true, module.ModuleScope); } _programm.Modules.Add(module); if (attribute.RegisterType) { _programm.InternalTypes.Add(new InternalScriptType() { Name = attribute.Name, Alias = attribute.Alias, Description = attribute.Alias, Module = module, Type = type }); } if (attribute.AsGlobal) { _programm.GlobalVariables.Add(new Variable() { Name = attribute.Name, Alias = attribute.Alias, Reference = new SimpleReference() }); } }
public TInterface SetReferenceFactory(ReferenceFactory referenceFactory) { _referenceFactory = referenceFactory; return(this as TInterface); }