示例#1
0
        public void TemplateSetup()
        {
            this.Ctx.TryAddNamespace("uFrame.Kernel");
            this.Ctx.TryAddNamespace("uFrame.MVVM");
            this.Ctx.TryAddNamespace("uFrame.MVVM.Bindings");
            this.Ctx.TryAddNamespace("uFrame.Serialization");
            if (Ctx.IsDesignerFile)
            {
                Ctx.SetBaseType(typeof(ViewComponent));
            }
            foreach (var property in Ctx.Data.View.Element.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }
            Ctx.AddIterator("ExecuteCommandOverload", _ => _.View.Element.LocalCommands);
            //Ctx.AddIterator("ExecuteCommand", _ => _.View.Element.InheritedCommandsWithLocal.Where(p => string.IsNullOrEmpty(p.RelatedTypeName)));
            ////Ctx.AddIterator("ExecuteCommandOverload", _ => _.View.Element.InheritedCommandsWithLocal);
            //Ctx.AddIterator("ExecuteCommandWithArg", _ => _.View.Element.InheritedCommandsWithLocal.Where(p => !string.IsNullOrEmpty(p.RelatedTypeName) && p.OutputCommand == null));
        }
        public void TemplateSetup()
        {
            var type = InvertApplication.FindTypeByNameExternal(Ctx.Data.RelatedTypeName);

            if (type != null)
            {
                Ctx.TryAddNamespace(type.Namespace);
            }
            else
            {
                type = InvertApplication.FindType(Ctx.Data.RelatedTypeName);
                if (type != null)
                {
                    Ctx.TryAddNamespace(type.Namespace);
                }
            }

            Ctx.CurrentDeclaration.Name = Ctx.Data.Name + "Command";
            Ctx.AddCondition("Argument", _ => _.HasArgument);

            if (!Ctx.IsDesignerFile)
            {
                Ctx.CurrentDeclaration.BaseTypes.Clear();
            }
        }
        public void TemplateSetup()
        {
            this.Ctx.TryAddNamespace("uFrame.IOC");
            this.Ctx.TryAddNamespace("uFrame.Kernel");
            this.Ctx.TryAddNamespace("uFrame.MVVM");
            foreach (var property in Ctx.Data.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            if (Ctx.IsDesignerFile)
            {
                Ctx.CurrentDeclaration.BaseTypes.Add(typeof(MonoBehaviour).ToCodeReference());
                Ctx.SetBaseType(typeof(SystemLoader));
            }

            //Ctx.AddIterator("InstanceProperty", node => node.Instances);
            Ctx.AddIterator("ControllerProperty",
                            node => node.GetContainingNodesInProject(Ctx.Data.Project).OfType <ElementNode>());
        }
示例#4
0
        public void TemplateSetup()
        {
            // Ensure the namespaces for each property type are property set up
            Ctx.CurrentDeclaration.IsPartial = true;
            Ctx.TryAddNamespace("uFrame.IOC");
            Ctx.TryAddNamespace("uFrame.Kernel");
            Ctx.TryAddNamespace("uFrame.MVVM");
            Ctx.TryAddNamespace("uFrame.MVVM.Bindings");
            Ctx.TryAddNamespace("uFrame.Serialization");
            Ctx.TryAddNamespace("UnityEngine");
            Ctx.TryAddNamespace("UniRx");



            foreach (var property in Ctx.Data.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            StateMachineProperties = Ctx.Data.AllProperties.Where(p => (p.RelatedNode() is StateMachineNode)).ToArray();
            ViewModelProperties    = Ctx.Data.AllProperties.Where(p => !StateMachineProperties.Contains(p)).ToArray();
            if (Ctx.IsDesignerFile)
            {
                foreach (var item in Ctx.Data.ComputedProperties)
                {
                    Ctx.CurrentDeclaration._private_(typeof(IDisposable), "_{0}Disposable", item.Name);
                }
            }
        }
示例#5
0
 public void TemplateSetup()
 {
     foreach (var property in Ctx.Data.PersistedItems.OfType <ITypedItem>())
     {
         var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
         if (type == null)
         {
             continue;
         }
         Ctx.TryAddNamespace(type.Namespace);
     }
 }
示例#6
0
        public void TemplateSetup()
        {
            // Support inheritance
            Ctx.CurrentDeclaration.BaseTypes.Clear();
            if (!CommandNode.IsStruct)
            {
                if (CommandNode.BaseNode != null)
                {
                    Ctx.CurrentDeclaration.BaseTypes.Add((CommandNode.BaseNode.Name + "Command").ToCodeReference());
                }
                else
                {
                    Ctx.SetBaseType(typeof(ViewModelCommand));
                }
            }
            else
            {
                if (CommandNode.BaseNode != null)
                {
                    throw new TemplateException(Ctx.Item.Name + " is Struct, but BaseNode = " + CommandNode.BaseNode.FullName);
                }

                Ctx.CurrentDeclaration.IsClass  = false;
                Ctx.CurrentDeclaration.IsStruct = true;

                if (Ctx.IsDesignerFile)
                {
                    Ctx.CurrentDeclaration.BaseTypes.Add(typeof(IViewModelCommand));
                }
            }

            foreach (var property in Ctx.Data.ChildItemsWithInherited.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            if (!Ctx.IsDesignerFile)
            {
                Ctx.CurrentDeclaration.BaseTypes.Clear();
            }
            else
            {
                Ctx.CurrentDeclaration.Name = string.Format("{0}Command", Ctx.Data.Name);
            }
        }
示例#7
0
        public void TemplateSetup()
        {
            // Support inheritance
            Ctx.CurrentDeclaration.BaseTypes.Clear();
            if (!SimpleClassNode.IsStruct)
            {
                if (Ctx.IsDesignerFile)
                {
                    if (SimpleClassNode.BaseNode != null)
                    {
                        Ctx.CurrentDeclaration.BaseTypes.Add((SimpleClassNode.BaseNode.Name).ToCodeReference());
                    }
                    Ctx.CurrentDeclaration.BaseTypes.Add(typeof(IJSonSerializable));
                }
                else
                {
                    Ctx.SetBaseType((SimpleClassNode.Node.Name + "Base").ToCodeReference());
                }
            }
            else
            {
                if (SimpleClassNode.BaseNode != null)
                {
                    throw new TemplateException(Ctx.Item.Name + " is Struct, but BaseNode = " + SimpleClassNode.BaseNode.FullName);
                }

                Ctx.CurrentDeclaration.IsClass  = false;
                Ctx.CurrentDeclaration.IsStruct = true;

                if (Ctx.IsDesignerFile)
                {
                    Ctx.CurrentDeclaration.Name = Ctx.Data.Node.Name.Clean();
                    Ctx.CurrentDeclaration.BaseTypes.Add(typeof(IJSonSerializable));
                }
            }

            foreach (var property in Ctx.Data.ChildItemsWithInherited.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }
            Ctx.AddIterator("Property", node => node.Properties);
            Ctx.AddIterator("Collection", node => node.Collections);
        }
示例#8
0
        public void TemplateSetup()
        {
            foreach (var property in Ctx.Data.ChildItemsWithInherited.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }
            Ctx.AddIterator("Property", node => node.Properties);
            Ctx.AddIterator("Collection", node => node.Collections);
        }
示例#9
0
        public override void TemplateSetup()
        {
            base.TemplateSetup();
            this.Ctx.TryAddNamespace("uFrame.Kernel");
            this.Ctx.TryAddNamespace("uFrame.MVVM");
            this.Ctx.TryAddNamespace("uFrame.Serialization");
            foreach (var property in Ctx.Data.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            Ctx.CurrentDeclaration.IsPartial = true;
        }
        public virtual void TemplateSetup()
        {
            if (Ctx.IsDesignerFile)
            {
                Ctx.SetBaseType(typeof(ViewComponent));
            }

            foreach (var property in Ctx.Data.View.Element.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            Ctx.AddIterator("ExecuteCommandOverload", _ => _.View.Element.LocalCommands);
        }
示例#11
0
        public void TemplateSetup()
        {
            foreach (var property in Ctx.Data.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            if (Ctx.IsDesignerFile)
            {
                Ctx.CurrentDeclaration.BaseTypes.Add(typeof(MonoBehaviour).ToCodeReference());
            }

            Ctx.AddIterator("ControllerProperty", node => node.Children.OfType <ElementNode>());
        }
        public void TemplateSetup()
        {
            this.Ctx.TryAddNamespace("uFrame.Kernel");
            this.Ctx.TryAddNamespace("uFrame.MVVM");
            this.Ctx.TryAddNamespace("uFrame.MVVM.Bindings");
            this.Ctx.TryAddNamespace("uFrame.Serialization");
            foreach (var property in Ctx.Data.ChildItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            Ctx.AddIterator("Property", node => node.Properties);
            Ctx.AddIterator("Collection", node => node.Collections);
        }
示例#13
0
        public void TemplateSetup()
        {
            foreach (var property in Ctx.Data.ChildItemsWithInherited.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            if (!Ctx.IsDesignerFile)
            {
                Ctx.CurrentDeclaration.BaseTypes.Clear();
            }
            else
            {
                Ctx.CurrentDeclaration.Name = string.Format("{0}Command", Ctx.Data.Name);
            }
        }
        public void TemplateSetup()
        {
            this.Ctx.TryAddNamespace("uFrame.Kernel");
            this.Ctx.TryAddNamespace("uFrame.MVVM");
            this.Ctx.TryAddNamespace("uFrame.Serialization");
            var type = InvertApplication.FindTypeByNameExternal(Ctx.Data.RelatedTypeName);

            if (type != null)
            {
                Ctx.TryAddNamespace(type.Namespace);
            }
            else
            {
                type = InvertApplication.FindType(Ctx.Data.RelatedTypeName);
                if (type != null)
                {
                    Ctx.TryAddNamespace(type.Namespace);
                }
            }
            Ctx.CurrentDeclaration.IsPartial = true;
            Ctx.CurrentDeclaration.Name      = Ctx.Data.Name + "Command";
            Ctx.AddCondition("Argument", _ => !string.IsNullOrEmpty(_.RelatedType));
        }
示例#15
0
        public void TemplateSetup()
        {
            foreach (var property in Ctx.Data.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }
                Ctx.TryAddNamespace(type.Namespace);
            }

            StateMachineProperties = Ctx.Data.AllProperties.Where(p => (p.RelatedNode() is StateMachineNode)).ToArray();
            ViewModelProperties    = Ctx.Data.AllProperties.Where(p => !StateMachineProperties.Contains(p)).ToArray();
            if (!Ctx.IsDesignerFile)
            {
                return;
            }
            foreach (var item in Ctx.Data.ComputedProperties)
            {
                Ctx.CurrentDeclaration._private_(typeof(IDisposable), "_{0}Disposable", item.Name);
            }
        }
        public void TemplateSetup()
        {
            var type = InvertApplication.FindTypeByNameExternal(Ctx.Data.RelatedTypeName);

            if (type != null)
            {
                Ctx.TryAddNamespace(type.Namespace);
            }

            Ctx.CurrentDeclaration.Name = Ctx.Data.Name + "Command";
            Ctx.AddCondition("Argument", _ => _.HasArgument);

            if (!Ctx.IsDesignerFile)
            {
                Ctx.CurrentDeclaration.BaseTypes.Clear();
            }

            // Support inheritance
            Ctx.CurrentDeclaration.BaseTypes.Clear();
            if (!CommandsChildItem.IsStruct)
            {
                if (Ctx.IsDesignerFile)
                {
                    Ctx.SetBaseType(typeof(ViewModelCommand));
                }
            }
            else
            {
                Ctx.CurrentDeclaration.IsClass  = false;
                Ctx.CurrentDeclaration.IsStruct = true;

                if (Ctx.IsDesignerFile)
                {
                    Ctx.CurrentDeclaration.BaseTypes.Add(typeof(IViewModelCommand));
                }
            }
        }
示例#17
0
        public virtual void TemplateSetup()
        {
            // Let the Dll Know about uFrame Binding Specific Types
            uFrameBindingType.ObservablePropertyType = typeof(IObservableProperty);
            uFrameBindingType.UFGroupType            = typeof(UFGroup);
            uFrameBindingType.ICommandType           = typeof(ISignal);
            foreach (var property in Ctx.Data.Element.PersistedItems.OfType <ITypedItem>())
            {
                var type = InvertApplication.FindTypeByNameExternal(property.RelatedTypeName);
                if (type == null)
                {
                    continue;
                }

                Ctx.TryAddNamespace(type.Namespace);
            }

            if (Ctx.IsDesignerFile && Ctx.Data.BaseNode == null)
            {
                Ctx.SetBaseType(typeof(ViewBase));
            }
            // Add namespaces based on the types used for properties
            Ctx.AddIterator("ViewComponentProperty", _ => _.OutputsTo <ViewComponentNode>());
            // Add the iterators for template method/property
            if (Ctx.Data.BaseNode == null)
            {
                Ctx.AddIterator("ExecuteCommand",
                                _ => _.Element.InheritedCommandsWithLocal.Where(p => !p.HasArgument));
                Ctx.AddIterator("ExecuteCommandOverload", _ => _.Element.InheritedCommandsWithLocal);
                Ctx.AddIterator("ExecuteCommandWithArg",
                                _ =>
                                _.Element.InheritedCommandsWithLocal.Where(
                                    p => p.HasArgument && p.OutputCommand == null));
            }
            else
            {
                Ctx.AddIterator("ExecuteCommand",
                                _ => _.Element.LocalCommands.Where(p => !p.HasArgument));
                Ctx.AddIterator("ExecuteCommandOverload", _ => _.Element.LocalCommands);
                Ctx.AddIterator("ExecuteCommandWithArg",
                                _ =>
                                _.Element.LocalCommands.Where(
                                    p => p.HasArgument && p.OutputCommand == null));
            }

            Ctx.AddIterator("ResetProperty", _ => _.SceneProperties);
            Ctx.AddIterator("CalculateProperty", _ => _.SceneProperties);
            Ctx.AddIterator("GetPropertyObservable", _ => _.SceneProperties);
            Ctx.AddCondition("ViewModelProperty", _ => !_.IsDerivedOnly);
            Ctx.AddCondition("DefaultIdentifier", _ => !_.IsDerivedOnly);
            Ctx.AddCondition("ViewModelType", _ => !_.IsDerivedOnly);
            if (Ctx.IsDesignerFile)
            {
                return;
            }

            // For each binding lets do some magic
            foreach (var item in Ctx.Data.Bindings)
            {
                // Cast the source of our binding (ie: Property, Collection, Command..etc)
                var source = item.SourceItem as ITypedItem;
                if (source == null)
                {
                    continue;
                }

                // Grab the uFrame Binding Type
                var bindingType = item.BindingType;
                // Create the binding signature based on the Method Info
                bindingType.CreateBindingSignature(new CreateBindingSignatureParams(
                                                       Ctx.CurrentDeclaration, _ => source.RelatedTypeName.ToCodeReference(), Ctx.Data, source)
                {
                    Ctx = Ctx,
                    BindingsReference = item,
                    DontImplement     = true
                });
            }
        }