Esempio n. 1
0
        internal static bool BuildUiPreview(string uiCode)
        {
            builtEffect = null;

            const string FileName = "UiPreviewEffect";

            uiCode = "#region UICode\r\n" + uiCode + "\r\n#endregion\r\n";

            UIElement[] UserControls = UIElement.ProcessUIControls(uiCode, ProjectType.Effect);

            string SourceCode =
                ScriptWriter.UsingPartCode(ProjectType.Effect) +
                ScriptWriter.NamespacePart(FileName, ProjectType.Effect) +
                ScriptWriter.EffectPart(UserControls, FileName, string.Empty, "UI PREVIEW - Does NOT Render to canvas", string.Empty, EffectFlags.None, EffectRenderingSchedule.DefaultTilesForCpuRendering) +
                ScriptWriter.PropertyPart(UserControls, FileName, string.Empty, HelpType.None, string.Empty, ProjectType.Effect) +
                ScriptWriter.RenderLoopPart(UserControls) +
                uiCode +
                ScriptWriter.EmptyCode +
                ScriptWriter.EndPart();

            Assembly assembly = CreateAssembly(SourceCode, false);

            if (assembly == null)
            {
                return(false);
            }

            foreach (Type type in assembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(PropertyBasedEffect)) && !type.IsAbstract)
                {
                    builtEffect = (Effect)type.GetConstructor(Type.EmptyTypes).Invoke(null);
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        internal static bool BuildFileType(string fileTypeCode, bool debug)
        {
            builtFileType = null;

            const string projectName = "MyFileType";

            UIElement[] userControls = UIElement.ProcessUIControls(fileTypeCode, ProjectType.FileType);

            string sourceCode =
                ScriptWriter.UsingPartCode(ProjectType.FileType) +
                ScriptWriter.NamespacePart(projectName, ProjectType.FileType) +
                ScriptWriter.FileTypePart(projectName, "\".foo\"", "\".foo\"", false, projectName) +
                ScriptWriter.ConstructorPart(debug) +
                ScriptWriter.PropertyPart(userControls, projectName, string.Empty, HelpType.None, string.Empty, ProjectType.FileType) +
                ScriptWriter.FileTypePart2(userControls) +
                ScriptWriter.UserEnteredPart(fileTypeCode) +
                ScriptWriter.EndPart();

            Assembly assembly = CreateAssembly(sourceCode, debug);

            if (assembly == null)
            {
                return(false);
            }

            Intelli.UserDefinedTypes.Clear();

            foreach (Type type in assembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(PropertyBasedFileType)) && !type.IsAbstract)
                {
                    builtFileType = (FileType)type.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)[0].Invoke(null);
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 3
0
        internal static bool Build(string scriptText, bool debug)
        {
            builtEffect = null;

            string SourceCode =
                ScriptWriter.UsingPartCode(ProjectType.Effect) +
                ScriptWriter.prepend_code +
                ScriptWriter.ConstructorPart(debug) +
                ScriptWriter.SetRenderPart(Array.Empty <UIElement>(), false, preRenderRegex.IsMatch(scriptText)) +
                ScriptWriter.UserEnteredPart(scriptText) +
                ScriptWriter.append_code;

            Assembly assembly = CreateAssembly(SourceCode, debug);

            if (assembly == null)
            {
                return(false);
            }

            Intelli.UserDefinedTypes.Clear();

            foreach (Type type in assembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(Effect)) && !type.IsAbstract)
                {
                    builtEffect        = (Effect)type.GetConstructor(Type.EmptyTypes).Invoke(null);
                    Intelli.UserScript = type;
                }
                else if (type.DeclaringType != null && type.DeclaringType.FullName.StartsWith(Intelli.UserScriptFullName, StringComparison.Ordinal) && !Intelli.UserDefinedTypes.ContainsKey(type.Name))
                {
                    Intelli.UserDefinedTypes.Add(type.Name, type);
                }
            }

            return(builtEffect != null);
        }
Esempio n. 4
0
        internal static bool BuildFullPreview(string scriptText)
        {
            builtEffect = null;

            const string FileName = "PreviewEffect";

            UIElement[] UserControls = UIElement.ProcessUIControls(scriptText, ProjectType.Effect);

            string SourceCode =
                ScriptWriter.UsingPartCode(ProjectType.Effect) +
                ScriptWriter.NamespacePart(FileName, ProjectType.Effect) +
                ScriptWriter.EffectPart(UserControls, FileName, string.Empty, FileName, string.Empty, EffectFlags.None, EffectRenderingSchedule.DefaultTilesForCpuRendering) +
                ScriptWriter.PropertyPart(UserControls, FileName, "FULL UI PREVIEW - Temporarily renders to canvas", HelpType.None, string.Empty, ProjectType.Effect) +
                ScriptWriter.SetRenderPart(UserControls, true, preRenderRegex.IsMatch(scriptText)) +
                ScriptWriter.RenderLoopPart(UserControls) +
                ScriptWriter.UserEnteredPart(scriptText) +
                ScriptWriter.EndPart();

            Assembly assembly = CreateAssembly(SourceCode, false);

            if (assembly == null)
            {
                return(false);
            }

            foreach (Type type in assembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(PropertyBasedEffect)) && !type.IsAbstract)
                {
                    builtEffect = (Effect)type.GetConstructor(Type.EmptyTypes).Invoke(null);
                    return(true);
                }
            }

            return(false);
        }