public override void Initialize(CodeFileGenerator codeFileGenerator)
        {
            var nodeConfig = InvertApplication.Container.GetNodeConfig <TData>();

            if (!nodeConfig.TypeGeneratorConfigs.ContainsKey(this.GetType()))
            {
                return;
            }

            GeneratorConfig = nodeConfig.TypeGeneratorConfigs[this.GetType()] as NodeGeneratorConfig <TData>;
            if (GeneratorConfig == null)
            {
                return;
            }
            if (GeneratorConfig.Condition != null && !GeneratorConfig.Condition(Data))
            {
                return;
            }
            base.Initialize(codeFileGenerator);


            Decleration = new CodeTypeDeclaration(IsDesignerFile ? NameAsDesignerClass : NameAsClass)
            {
                IsPartial = true
            };
            Compose();
        }
        public override void Initialize(CodeFileGenerator codeFileGenerator)
        {
            base.Initialize(codeFileGenerator);
            _unit = codeFileGenerator.Unit;
            _ns   = codeFileGenerator.Namespace;

            TryAddNamespace("System");
            TryAddNamespace("System.Collections");
            TryAddNamespace("System.Collections.Generic");
            TryAddNamespace("System.Linq");
        }
예제 #3
0
        public override void Initialize(CodeFileGenerator codeFileGenerator)
        {
            base.Initialize(codeFileGenerator);
            //if (!string.IsNullOrEmpty(TemplateType.Namespace))
            //    TryAddNamespace(TemplateType.Namespace);
            Decleration = TemplateType.ToClassDecleration();

            var inheritable = Data as GenericInheritableNode;

            if (!Attribute.AutoInherit)
            {
                inheritable = null;
            }
            if (IsDesignerFile && Attribute.Location != TemplateLocation.DesignerFile)
            {
                Decleration.Name = ClassNameBase(Data as IDiagramNodeItem);
                if (inheritable != null && inheritable.BaseNode != null)
                {
                    Decleration.BaseTypes.Clear();
                    Decleration.BaseTypes.Add(ClassName(inheritable.BaseNode));
                }
            }
            else
            {
                Decleration.Name = ClassName(Data as IDiagramNodeItem);
                if (Attribute.Location != TemplateLocation.DesignerFile)
                {
                    Decleration.BaseTypes.Clear();
                    Decleration.BaseTypes.Add(ClassNameBase(Data as IDiagramNodeItem));
                }
            }

            Namespace.Types.Add(Decleration);

            ProcessTemplate();
            return; // Skip the stuff below for now

            if (IsDesignerFile)
            {
                // base.Initialize(fileGenerator);

                if (IsDesignerFile)
                {
                    InitializeDesignerFile();
                }
                else
                {
                    InitializeEditableFile();
                }
            }
        }
        public static void GenerateFile(FileInfo fileInfo, CodeFileGenerator codeFileGenerator)
        {
            // Get the path to the directory
            var directory = Path.GetDirectoryName(fileInfo.FullName);

            // Create it if it doesn't exist
            if (directory != null && !Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            try
            {
                // Write the file
                File.WriteAllText(fileInfo.FullName, codeFileGenerator.ToString());
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                Debug.Log("Coudln't create file " + fileInfo.FullName);
            }
        }
예제 #5
0
 public void Initialize(CodeFileGenerator codeFileGenerator, Predicate <IDiagramNodeItem> itemFilter = null)
 {
 }
예제 #6
0
 public virtual void Initialize(CodeFileGenerator codeFileGenerator)
 {
 }