Exemplo n.º 1
0
        public static string CanExecute <T>(this T entity, IEntityOperationSymbolContainer <T> symbol)
            where T : class, IEntity
        {
            var op = Find <IEntityOperation>(entity.GetType(), symbol.Symbol);

            return(op.CanExecute(entity));
        }
Exemplo n.º 2
0
        protected virtual string WriteConstructFrom(IEntityOperationSymbolContainer oper)
        {
            List <Type> type = oper.GetType().GetGenericArguments().ToList();

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("new Graph<{0}>.ConstructFrom<{1}>({2})".FormatWith(type[0].TypeName(), type[1].TypeName(), oper.Symbol.ToString()));
            sb.AppendLine("{");
            sb.AppendLine("    Construct = ({0}, _) => new {1}".FormatWith(GetVariableName(type[1]), type[0].TypeName()));
            sb.AppendLine("    {");
            sb.AppendLine("    }");
            sb.AppendLine("}.Register();");
            return(sb.ToString());
        }
Exemplo n.º 3
0
        protected virtual string WriteDeleteOperation(IEntityOperationSymbolContainer oper)
        {
            Type type = oper.GetType().GetGenericArguments().Single();

            string v = GetVariableName(type);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("new Graph<{0}>.Delete({1})".FormatWith(type.TypeName(), oper.Symbol.ToString()));
            sb.AppendLine("{");
            sb.AppendLine("    Delete = ({0}, _) => {0}.Delete()".FormatWith(v));
            sb.AppendLine("}.Register();");
            return(sb.ToString());
        }
Exemplo n.º 4
0
        protected virtual string WriteExecuteOperation(IEntityOperationSymbolContainer oper)
        {
            Type type = oper.GetType().GetGenericArguments().Single();

            var v = GetVariableName(type);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("new Graph<{0}>.Execute({1})".FormatWith(type.TypeName(), oper.Symbol.ToString()));
            sb.AppendLine("{");
            if (IsSave(oper))
            {
                sb.AppendLine("    AllowsNew = true,");
                sb.AppendLine("    Lite = false,");
            }
            sb.AppendLine("    Execute = ({0}, _) => {{ }}".FormatWith(v));
            sb.AppendLine("}.Register();");
            return(sb.ToString());
        }
Exemplo n.º 5
0
 public static IWebElement OperationClickCapture <T>(this IEntityButtonContainer <T> container, IEntityOperationSymbolContainer <T> symbol)
     where T : Entity
 {
     return(container.OperationClickCapture(symbol.Symbol));
 }
Exemplo n.º 6
0
 public static WebElementLocator OperationButton <T>(this IEntityButtonContainer <T> container, IEntityOperationSymbolContainer <T> symbol)
     where T : Entity
 {
     return(container.OperationButton(symbol.Symbol));
 }
Exemplo n.º 7
0
 public static void Register <T>(this IEntityOperationSymbolContainer <T> entityOperation, ContextualOperationSettings <T> settings) where T : class, IEntity
 {
     ProcessContextualOperartions[entityOperation.Symbol] = settings;
 }
Exemplo n.º 8
0
 /// <param name="symbolContainer">A ExecuteSymbol&lt;T&gt;, DeleteSymbol&lt;T&gt; or a Construct&lt;R&gt;.From&lt;T&gt;</param>
 public EntityOperationSettings(IEntityOperationSymbolContainer <T> symbolContainer)
     : base(symbolContainer.Symbol)
 {
     this.Contextual         = new ContextualOperationSettings <T>(symbolContainer);
     this.ContextualFromMany = new ContextualOperationSettings <T>(symbolContainer);
 }
Exemplo n.º 9
0
 internal ContextualOperationSettings(IEntityOperationSymbolContainer <T> symbolContainer)
     : base(symbolContainer.Symbol)
 {
 }
Exemplo n.º 10
0
 public static bool OperationDisabled <T>(this IEntityButtonContainer <T> container, IEntityOperationSymbolContainer <T> symbol)
     where T : Entity
 {
     return(container.ButtonDisabled(symbol.Symbol.KeyWeb()));
 }
Exemplo n.º 11
0
        protected virtual string WriteDeleteOperation(IEntityOperationSymbolContainer oper)
        {
            Type type = oper.GetType().GetGenericArguments().Single();

            string v = GetVariableName(type);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("new Graph<{0}>.Delete({1})".FormatWith(type.TypeName(), oper.Symbol.ToString()));
            sb.AppendLine("{");
            sb.AppendLine("    Delete = ({0}, _) => {0}.Delete()".FormatWith(v));
            sb.AppendLine("}.Register();");
            return sb.ToString();
        }
Exemplo n.º 12
0
 protected virtual bool IsSave(IEntityOperationSymbolContainer oper)
 {
     return oper.ToString().Contains("Save"); ;
 }
Exemplo n.º 13
0
        protected virtual string WriteExecuteOperation(IEntityOperationSymbolContainer oper)
        {
            Type type = oper.GetType().GetGenericArguments().Single();

            var v = GetVariableName(type);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("new Graph<{0}>.Execute({1})".FormatWith(type.TypeName(), oper.Symbol.ToString()));
            sb.AppendLine("{");
            if (IsSave(oper))
            {
                sb.AppendLine("    AllowsNew = true,");
                sb.AppendLine("    Lite = false,");
            }
            sb.AppendLine("    Execute = ({0}, _) => {{ }}".FormatWith(v));
            sb.AppendLine("}.Register();");
            return sb.ToString();
        }
Exemplo n.º 14
0
 protected virtual bool IsSave(IEntityOperationSymbolContainer oper)
 {
     return(oper.ToString().Contains("Save"));;
 }
Exemplo n.º 15
0
 public static EntityOperationSettings <T> GetEntitySettings <T>(IEntityOperationSymbolContainer <T> operation) where T : class, IEntity
 {
     return(Manager.GetSettings <EntityOperationSettings <T> >(typeof(T), operation.Symbol));
 }
Exemplo n.º 16
0
 public static By OperationLocator <T>(this IEntityButtonContainer <T> container, IEntityOperationSymbolContainer <T> symbol)
     where T : Entity
 {
     return(container.ButtonLocator(symbol.Symbol.KeyWeb()));
 }
Exemplo n.º 17
0
        protected virtual string WriteConstructFrom(IEntityOperationSymbolContainer oper)
        {
            List<Type> type = oper.GetType().GetGenericArguments().ToList();

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("new Graph<{0}>.ConstructFrom<{1}>({2})".FormatWith(type[0].TypeName(), type[1].TypeName(), oper.Symbol.ToString()));
            sb.AppendLine("{");
            sb.AppendLine("    Construct = ({0}, _) => new {1}".FormatWith(GetVariableName(type[1]), type[0].TypeName()));
            sb.AppendLine("    {");
            sb.AppendLine("    }");
            sb.AppendLine("}.Register();");
            return sb.ToString();
        }
Exemplo n.º 18
0
 public static void OperationClick <T>(this IEntityButtonContainer <T> container, IEntityOperationSymbolContainer <T> symbol)
     where T : Entity
 {
     container.ButtonClick(symbol.Symbol.KeyWeb());
 }
Exemplo n.º 19
0
 public static bool OperationNotPresent <T>(this IEntityButtonContainer <T> container, IEntityOperationSymbolContainer <T> symbol)
     where T : Entity
 {
     return(container.OperationButton(symbol).TryFind() == null);
 }