/// <summary>
 /// Creates a controller node for a resource dependency as a child of the resource node
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="type"></param>
 public ControllerNode(ExplorerNode parent, ControllerType type, ControllerNodeType nodeType)
     : base(parent, type.Name, ACTIVITY_ICON, ACTIVITY_ICON)
 {
     //this.type = type;
     //type.Register(this);
     //this.nodeType = nodeType;
 }
Exemplo n.º 2
0
        private void CreateBindingNodes(ITypeInfo classInfo)
        {

            ControllerType type;
            if (controllerTypes.TryGetValue(classInfo.FullName, out type))
            {
                controllerTypes.Remove(classInfo.FullName);
                type.Dispose();
            }
            type = new ControllerType(classInfo);

            controllerTypes.Add(type.Name, type);

            List<string> bindings = new List<string>();
            foreach (IAttributeInfo attribute in classInfo.Attributes)
                if (attribute.Type == typeof(BindAttribute).FullName && attribute.Parameters.Count > 0)
                    bindings.Add(attribute.Parameters[0].AsString());
            if (bindings.Count == 0)
            {
                // TODO: define the default binding
            }

            foreach (string item in bindings)
            {
                Match match = bindingParser.Match(item);
                if (match.Success)
                {
                    string methodUrl = match.Groups["binding"].Captures[0].Value;
                    string verb;
                    switch (methodUrl[0])
                    {
                        case '?':
                        case '/':
                            verb = "*";
                            break;
                        default:
                            verb = methodUrl.Substring(0, methodUrl.IndexOfAny(new char[] { ' ', '/', '?' }));
                            methodUrl = methodUrl.Substring(methodUrl.IndexOfAny(new char[] { '/', '?' }));
                            break;

                    }
                    foreach (Binding method in root.PlaceController(verb, methodUrl))
                        //                        method.Register(new Controller(method, type, methodUrl));
                        method.Register(method, type, methodUrl);
                }
                else
                    RaiseInvalidBinding(type, item);
            }
        }
Exemplo n.º 3
0
        internal void CreateControllerNodes(ControllerType type, string methodUrl)
        {
            //string verb;
            //switch (methodUrl[0])
            //{
            //    case '?':
            //    case '/':
            //        verb = "*";
            //        break;
            //    default:
            //        verb = methodUrl.Substring(0, methodUrl.IndexOfAny(new char[] { ' ', '/', '?' }));
            //        methodUrl = methodUrl.Substring(methodUrl.IndexOfAny(new char[] { '/', '?' }));
            //        break;

            //}
            //foreach (BindingNode parent in PlaceController(verb, methodUrl))
            //    new ControllerNode(parent, type, methodUrl);
        }
Exemplo n.º 4
0
 internal void Unregister(ControllerType controllerType)
 {
     providers.RemoveAll(provider => provider == controllerType);
     dependents.RemoveAll(provider => provider == controllerType);
     requiredBy.RemoveAll(provider => provider == controllerType);
 }
Exemplo n.º 5
0
 internal void AddRequiredBy(ControllerType controller)
 {
     requiredBy.Add(controller);
     controller.Register(this);
 }
Exemplo n.º 6
0
 internal void AddDependents(ControllerType controller)
 {
     dependents.Add(controller);
     controller.Register(this);
 }
Exemplo n.º 7
0
 internal void AddProvider(ControllerType controller)
 {
     providers.Add(controller);
     controller.Register(this);
 }
Exemplo n.º 8
0
 public Controller(Binding binding, ControllerType type, string methodUrl)
 {
     this.type = type;
     this.binding = binding;
 }
Exemplo n.º 9
0
 public virtual void RaiseInvalidBinding(ControllerType controller, params string[] args)
 {
 }
Exemplo n.º 10
0
        //internal void Register(Controller controller)
        //{
        //    controllers.Add(controller);
        //    controller.Type.Register(controller);
        //    foreach (string resourceName in controller.Type.Provides)
        //        lookupResource(resourceName).AddProvider(controller.Type);
        //    foreach (string resourceName in controller.Type.Requires)
        //        lookupResource(resourceName).AddRequiredBy(controller.Type);
        //    foreach (string resourceName in controller.Type.DependsOn)
        //        lookupResource(resourceName).AddDependents(controller.Type);
        //}

        internal void Register(Binding binding,ControllerType ctrType, string methodUrl)
        {
            foreach (Controller ctr in controllers)
            {
                if (ctr.Type == ctrType)
                    return;
            }
            Controller controller = new Controller(binding, ctrType, methodUrl);
            controllers.Add(controller);
            ctrType.Register(controller);
            foreach (string resourceName in controller.Type.Provides)
                lookupResource(resourceName).AddProvider(controller.Type);
            foreach (string resourceName in controller.Type.Requires)
                lookupResource(resourceName).AddRequiredBy(controller.Type);
            foreach (string resourceName in controller.Type.DependsOn)
                lookupResource(resourceName).AddDependents(controller.Type);
        }