Ejemplo n.º 1
0
        public static Renderer GetRenderer(ProcessURI uri, IProcessResponse response)
        {
            RenderingSection config = RenderingSection.Current;
            if (renderer == null)
            {
                Type rendererType = Type.GetType(config.Type);
                Assembly asm = rendererType.Assembly;
                renderer = asm.CreateInstance(rendererType.FullName) as Renderer;
                renderer.Path = ParseRendererPath(config);

                //foreach (CustomHelper helper in config.CustomHelpers)
                //    renderer.Helpers.Add(CreateHelperInstance(helper));

                renderer.UrlHelper = new UrlHelper("url");
                renderer.AppHelper = new AppHelper("app");
                renderer.StateHelper = new StateHelper("state");
                renderer.AjaxHelper = new AjaxHelper("ajax");
                renderer.TypeHelper = new TypeHelper("type");
            }

            renderer.URI = uri;

            Configuration.Template template = renderer.GetTemplate(response);
            renderer.LayoutFileName = template != null
                                          ? ((string.IsNullOrEmpty(template.LayoutFileName))
                                                 ? config.LayoutFileName
                                                 : template.LayoutFileName)
                                          : config.LayoutFileName;

            return renderer;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Executes the supplied <see cref="uri"/>.
 /// </summary>
 /// <param name="uri">Specifies the <see cref="ProcessURI"/> to be executed.</param>
 /// <param name="domain">Specifies the <see cref="Domain"/> with the information necessary to execute.</param>
 /// <returns>The <see cref="IProcessResponse"/> of the executed process.</returns>
 public static IProcessResponse Execute(ProcessURI uri, Domain domain)
 {
     List<IInterceptor> interceptors = CoreSection.Current.GetInteceptors();
     return GetProcess(uri).Execute(domain,
         o => interceptors.ForEach(i => i.OnProcessExecuting(uri, o)),
         o => interceptors.ForEach(i => i.OnProcessExecuted(uri, o)));
 }
Ejemplo n.º 3
0
 public static AuthorizationRule GetRule(ProcessURI uri)
 {
     AuthorizationURI authorizationURI = SecuritySection.Current.Authorization.URIs.Find(uri);
     if (authorizationURI != null)
         return GetRule(authorizationURI);
     return null;
 }
Ejemplo n.º 4
0
 public Template Find(ProcessURI uri)
 {
     foreach (Template tpl in this)
         if (tpl.IsUriTemplate(uri))
             return tpl;
     return null;
 }
 public AuthorizationURI Find(ProcessURI uri)
 {
     foreach (AuthorizationURI authorizationURI in this)
         if (uri.ToString().Contains(authorizationURI.Pattern))
             return authorizationURI;
     return null;
 }
Ejemplo n.º 6
0
 public EntityCollectionDomain(Type type, Type collectionType, ProcessURI uri, object instance, Domain parent)
     : base(type, uri, null)
 {
     if (collectionType == null) throw new ArgumentNullException("collectionType");
     CollectionType = collectionType;
     Instance = instance;
     Parent = parent;
 }
Ejemplo n.º 7
0
 public void OnProcessExecuted(ProcessURI uri, object obj)
 {
     switch (uri.Behavior)
     {
         case ProcessBehavior.New:
             SaveChange(uri, obj);
             break;
     }
 }
 public virtual ProcessURI Evaluate(Expression expression, ProcessURI uri)
 {
     var nodes = Evaluate(expression);
     var args = new List<object>();
     foreach (var node in nodes)
         args.AddRange(ExtractValue(node));
     uri.Argument = ProcessArgument.Parse(uri.Behavior, args.ToArray());
     return uri;
 }
Ejemplo n.º 9
0
 public void OnProcessExecuting(ProcessURI uri, object obj)
 {
     switch (uri.Behavior)
     {
         case ProcessBehavior.Edit:
         case ProcessBehavior.Delete:
         case ProcessBehavior.Exec:
             SaveChange(uri, obj);
             break;
     }
 }
Ejemplo n.º 10
0
        private VelocityContext CreateTemplateContext(ProcessURI uri, IProcessResponse response, Domain domain)
        {
            VelocityContext context = new VelocityContext();
            context.Put("uri", uri);
            context.Put("renderer", this);

            if (response != null) context.Put("response", response);
            if (domain != null) context.Put("domain", domain);

            foreach (RendererHelper helper in Helpers)
                context.Put(helper.Name, helper);

            return context;
        }
Ejemplo n.º 11
0
 public static IProcessResponse Evaluate(ProcessURI uri, IProcessResponse response)
 {
     if (IsAuthorized(uri))
     {
         Expression expression = GetRuleResponseExpression(uri) ?? Expression.Empty;
         if (expression != Expression.Empty)
         {
             var expressionURI = ProcessURI.Parse(expression.ToString());
             foreach (AuthorizationKeyEvaluator evaluator in Evaluators)
                 expressionURI = evaluator.Evaluate(expression, expressionURI);
             //TODO: Apply new URI to the response subset
         }
     }
     return response;
 }
Ejemplo n.º 12
0
        public static ProcessURI Evaluate(ProcessURI uri)
        {
            if (IsAuthorized(uri))
            {
                if (uri.Behavior == ProcessBehavior.Query)
                {
                    Expression expression = GetRuleExpression(uri) ??
                                            Expression.Parse(uri.Argument.ToString(), uri.Behavior) ??
                                            Expression.Empty;

                    foreach (AuthorizationKeyEvaluator evaluator in Evaluators)
                        uri = evaluator.Evaluate(expression, uri);
                }
            }
            return uri;
        }
Ejemplo n.º 13
0
        private static void SaveChange(ProcessURI uri, object obj)
        {
            if (obj != null)
            {
                object userId = null;
                if (SecurityHelper.IsAuthenticated)
                {
                    var token = SecurityHelper.AuthenticationToken;
                    userId = ContextFactory.GetContext(token.GetType()).GetID(token);
                }
                var entityId = ContextFactory.GetContext(obj.GetType()).GetID(obj);

                var change = new EntityChange(DateTime.Now, uri.ToString(), entityId, obj, userId != null ? userId.ToString() : null);
                ContextFactory.GetContext(typeof(EntityChange)).Insert(change);
            }
        }
Ejemplo n.º 14
0
        private static QueryProcessResponse CreateResponse(Type type, IEnumerable items, ProcessURI uri)
        {
            var domains = new DomainCollection();
            var enumerator = items.GetEnumerator();
            while (enumerator.MoveNext())
            {
                var instance = enumerator.Current;
                var entity = new EntityDomain(type, uri)
                {
                    Instance = instance,
                    Value = ContextFactory.GetContext(type).GetID(instance),
                };

                domains.Add(entity);
            }
            return new QueryProcessResponse(type, domains) { URI = uri };
        }
Ejemplo n.º 15
0
 private static EntityProcess Create(ProcessURI uri)
 {
     switch (uri.Behavior)
     {
         case ProcessBehavior.New:
             return new EntityNewProcess(uri);
         case ProcessBehavior.Exec:
             return new EntityExecProcess(uri);
         case ProcessBehavior.Edit:
             return new EntityEditProcess(uri);
         case ProcessBehavior.View:
             return new EntityViewProcess(uri);
         case ProcessBehavior.Delete:
             return new EntityDeleteProcess(uri);
     }
     return null;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Get the process specified by ProcessURI uri.
 /// </summary>
 /// <param name="uri">A ProcessURI uri.</param>
 /// <returns>A Process' instance.</returns>
 private static Process GetProcess(ProcessURI uri)
 {
     switch (uri.Behavior)
     {
         case ProcessBehavior.Schema:
             return new SchemaProcess(uri);
         case ProcessBehavior.Service:
             return new ServiceProcess(uri);
         case ProcessBehavior.Workflow:
             return new WorkflowProcess(uri);
         case ProcessBehavior.Query:
             return new QueryProcess(uri);
         case ProcessBehavior.Index:
             return new IndexProcess(uri);
         case ProcessBehavior.Session:
             return new SessionProcess(uri);
         default:
             return new EntityProcess(uri);
     }
 }
Ejemplo n.º 17
0
 public QueryProcess(ProcessURI uri)
     : base(uri)
 {
 }
Ejemplo n.º 18
0
 public static bool IsAuthorized(ProcessURI uri)
 {
     return SecurityHandler.IsAuthorized(uri);
 }
Ejemplo n.º 19
0
 public ServiceProcess(ProcessURI uri)
     : base(uri)
 {
 }
Ejemplo n.º 20
0
 public RedirectProcessResponse(ProcessURI uri)
 {
     if (uri == null)
         throw new ArgumentNullException("uri");
     URI = uri;
 }
Ejemplo n.º 21
0
 protected HttpHandlerBase(ProcessURI requestedURI)
 {
     this.requestedURI = requestedURI;
 }
Ejemplo n.º 22
0
 public SessionProcess(ProcessURI uri)
     : base(uri)
 {
 }
Ejemplo n.º 23
0
 public EntityEditProcess(ProcessURI uri)
     : base(uri)
 {
 }
Ejemplo n.º 24
0
 public EntityDomain(Type type, ProcessURI uri, object value)
     : this(type, uri)
 {
     Value = value;
 }
Ejemplo n.º 25
0
 protected string GetTemplateName(ProcessURI uri, Domain domain)
 {
     Template template = RenderingSection.Current.Templates.Find(uri);
     if (template != null)
         return template.TemplateDomains.Find(domain).FileName;
     return string.Empty;
 }
Ejemplo n.º 26
0
 public EntityDeleteProcess(ProcessURI uri)
     : base(uri)
 {
 }
Ejemplo n.º 27
0
 public EntityDomain(Type type, ProcessURI uri, object value, object instance)
     : this(type, uri, value)
 {
     Instance = instance;
 }
Ejemplo n.º 28
0
 public static EntityDomain CreateDomain(Type type, ProcessURI uri)
 {
     return new EntityDomain(type, uri);
 }
Ejemplo n.º 29
0
 public WorkflowProcess(ProcessURI uri)
     : base(uri)
 {
 }
Ejemplo n.º 30
0
 public static IProcessResponse ExecuteProcess(ProcessURI uri, Domain domain)
 {
     return ProcessFactory.Execute(uri, domain);
 }