Ejemplo n.º 1
0
        // Ripped from the original BranchActivity and modified
        private static IEnumerable <string> GetBranches(ActivityContext context)
        {
            var branches = new List <string>();

            var firstBranch = context.GetState <string>(ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.FirstBranch));

            if (firstBranch != null)
            {
                branches.Add(FirstBranchOutcome);
            }

            var secondBranch = context.GetState <string>(ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.SecondBranch));

            if (!string.IsNullOrEmpty(secondBranch))
            {
                branches.AddRange(secondBranch.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList());
            }

            var thirdBranch = context.GetState <bool>(ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.ThirdBranch));

            if (thirdBranch)
            {
                branches.Add(ThirdBranchOutcome);
            }

            branches.AddRange(new[] { ErrorOutcome, DoneOutcome });

            return(branches);
        }
Ejemplo n.º 2
0
        public void Describe(DescribeContext context)
        {
            Func <IShapeFactory, dynamic> formFactory = shape =>
            {
                var form = this.Shape.Form(
                    Id: ConditionalBranchTask.EventName,
                    _Type: this.Shape.FieldSet(
                        Title: this.T("Resume the workflow on a conditional branch."),
                        _FirstBranch: this.Shape.Textbox(
                            Id: ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.FirstBranch),
                            Name: ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.FirstBranch),
                            Title: this.T("The first branch"),
                            Description: this.T("A comma separated list of something"),
                            Classes: new[] { "text", "large", "tokenized" }),
                        _SecondBranch: this.Shape.Textbox(
                            Id: ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.SecondBranch),
                            Name: ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.SecondBranch),
                            Title: this.T("The second branch"),
                            Description: this.T("A comma separated list of something"),
                            Classes: new[] { "text", "large", "tokenized" }),
                        _ThirdBranch: this.Shape.Checkbox(
                            Id: ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.ThirdBranch),
                            Name: ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.ThirdBranch),
                            Title: this.T("The third branch"),
                            Description: this.T("Check to enable the branch"),
                            Value: false)
                        ));

                return(form);
            };

            context.Form(ConditionalBranchTask.EventName, formFactory);
        }
        public void ReflectOnShouldWorkOnIndexers()
        {
            Assert.That(ReflectOn <TestClass> .NameOf(p => p[0].MyTestClass[1].MyProperty), Is.EqualTo("[0].MyTestClass[1].MyProperty"));
            int j     = 5;
            int index = j;

            Assert.That(ReflectOn <TestClass> .NameOf(p => p.MyTestClass[index].MyProperty), Is.EqualTo("MyTestClass[5].MyProperty"));
        }
Ejemplo n.º 4
0
        public static void CreateIndexForSingleColumn <TRecord>(this AlterTableCommand self, Expression <Func <TRecord, object> > expression, string indexNameOverride = null)
        {
            var property = ReflectOn <TRecord> .NameOf(expression);

            var indexName = indexNameOverride.HasValue() ? indexNameOverride : CreateIndexKeyName <TRecord>(expression);

            self.CreateIndex(indexName, new[] { property });
        }
Ejemplo n.º 5
0
        /// <summary>Creates a column with the name of TBaseRecordProperty_Id. This follows the standard orchard conventions.</summary>
        /// <typeparam name="TForeignRecord">The Record-Type of the virtual property.</typeparam>
        /// <typeparam name="TBaseRecord">The ContentPartRecord holding the virtual property pointing to the foreign record.</typeparam>
        /// <param name="self">A CreateTableCommand</param>
        /// <param name="expression">An expression to get the virtual property.</param>
        /// <param name="column">Actions to alter the column further.</param>
        /// <returns>The CreateTableCommand</returns>
        public static CreateTableCommand ColumnForForeignKey <TForeignRecord, TBaseRecord>(this CreateTableCommand self, Expression <Func <TBaseRecord, TForeignRecord> > expression, Action <CreateColumnCommand> column = null)
        {
            var dbType = SchemaUtils.ToDbType(typeof(int));

            var property = ReflectOn <TBaseRecord> .NameOf(expression);

            var columnName = string.Format("{0}_Id", property);

            return(self.Column(columnName, dbType, column));
        }
Ejemplo n.º 6
0
        public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext)
        {
            // Do whatever here....
            // This stuff here is obviously pretty useless and only exists to see if the activity works.
            var possibleOutcomes = GetBranches(activityContext);

            var firstBranchValue = activityContext.GetState <string>(ReflectOn <ConditionalBranchViewModel> .NameOf(x => x.FirstBranch));

            if (possibleOutcomes.Contains(FirstBranchOutcome) && !string.IsNullOrWhiteSpace(firstBranchValue) && firstBranchValue.Equals("ThrowError", StringComparison.OrdinalIgnoreCase))
            {
                yield return(this.T(ErrorOutcome));
            }
            else
            {
                foreach (var outcome in possibleOutcomes)
                {
                    yield return(this.T(outcome));
                }
            }
        }
 public void ReflectOnShouldWorkOnDottedProperties()
 {
     Assert.That(ReflectOn <TestClass> .NameOf(p => p.MyTestClass.MyTestClass.MyProperty), Is.EqualTo("MyTestClass.MyTestClass.MyProperty"));
 }
Ejemplo n.º 8
0
        public static string CreateIndexKeyName <TRecord>(Expression <Func <TRecord, object> > expression)
        {
            var property = ReflectOn <TRecord> .NameOf(expression);

            return(string.Format("IX_{0}_{1}", typeof(TRecord).FullName, property));
        }
Ejemplo n.º 9
0
 public ReflectFluidOn <T> AddNameOf <TResult>(Expression <Func <T, TResult> > expression)
 {
     this.memberNames.Add(ReflectOn <T> .NameOf(expression));
     return(this);
 }
Ejemplo n.º 10
0
 public ReflectFluidOn <T> AddNameOf(Expression <Action <T> > expression)
 {
     this.memberNames.Add(ReflectOn <T> .NameOf(expression));
     return(this);
 }