Esempio n. 1
0
        /// <summary>
        /// Lists classes in a specified extension.
        /// </summary>
        /// <param name="module">The extension name.</param>
        static void ListClasses(string module)
        {
            ICollection classes = null;

            try
            {
                classes = Externals.GetClassesByModule(module, false);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to get class list.");
                Console.WriteLine(e.ToString());
                return;
            }

            if (classes == null)
            {
                Console.WriteLine("Unable to get class list. Extension not loaded.");
                return;
            }

            Console.WriteLine("Classes in " + module + ":");
            foreach (string item in classes)
            {
                Console.WriteLine(item);
            }
        }
Esempio n. 2
0
        static DataItemFactory()
        {
            // dynamic types support
            var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
                new AssemblyName(DynamicAssemblyName), AssemblyBuilderAccess.RunAndSave);

            moduleBuilder = assemblyBuilder.DefineDynamicModule(DynamicAssemblyName);

            // MEF
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            catalog.Catalogs.Add(new ApplicationCatalog());
            var compositionContainer = new CompositionContainer(catalog);

            // externals
            var externals = new Externals();

            compositionContainer.SatisfyImportsOnce(externals);

            // type handlers
            typeHandlers = new Dictionary <string, MethodInfo>(StringComparer.OrdinalIgnoreCase);
            if (externals.Handlers != null)
            {
                foreach (var handler in externals.Handlers)
                {
                    var handlerType = handler.GetType();
                    foreach (var attr in handlerType.GetCustomAttributes <TypeHandlerAttribute>())
                    {
                        typeHandlers[attr.TypeName] = handler.ConverterInfo;
                    }
                }
            }
        }
Esempio n. 3
0
        static public RGBA FromHexa(string hexa)
        {
            string value = hexa;

            if (value.StartsWith("#"))
            {
                value = value.Substr(1);
            }

            if (value.Length == 3)
            {
                value = $"{value[0]}{value[0]}{value[1]}{value[1]}{value[2]}{value[2]}FF";
            }

            if (value.Length == 4)
            {
                value = $"{value[0]}{value[0]}{value[1]}{value[1]}{value[2]}{value[2]}{value[3]}{value[3]}";
            }

            if (value.Length == 6)
            {
                value += "FF";
            }

            byte r = Externals.NumberToByte("0x" + value.Substring(0, 2));
            byte g = Externals.NumberToByte("0x" + value.Substring(2, 2));
            byte b = Externals.NumberToByte("0x" + value.Substring(4, 2));
            byte a = Externals.NumberToByte("0x" + value.Substring(6, 2));

            return(FromRGB(r, g, b, a));
        }
Esempio n. 4
0
        /// <summary>
        /// Lists functions in a specified extension.
        /// </summary>
        /// <param name="module">The extension name.</param>
        static void ListFunctions(string module)
        {
            ICollection functions = null;

            try
            {
                functions = Externals.GetFunctionsByModule(module, false);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to get function list.");
                Console.WriteLine(e.ToString());
                return;
            }

            if (functions == null)
            {
                Console.WriteLine("Unable to get function list. Extension not loaded.");
                return;
            }

            Console.WriteLine("Functions in " + module + ":");
            foreach (string item in functions)
            {
                Console.WriteLine(item);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Calls <paramref name="cb"/> for each loaded extension.
        /// </summary>
        /// <param name="cb">The callback.</param>
        static void DoForAllExtensions(Callback cb)
        {
            ICollection modules;

            try
            {
                modules = Externals.GetModules(false);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to get extension list.");
                Console.WriteLine(e.ToString());
                return;
            }

            if (modules != null)
            {
                foreach (string item in modules)
                {
                    if (!item.StartsWith("#"))
                    {
                        cb(item);
                        Console.WriteLine();
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes the script context for a web request.
        /// </summary>
        /// <param name="appContext">Application context.</param>
        /// <param name="context">HTTP context of the request.</param>
        /// <returns>A instance of <see cref="ScriptContext"/> to be used by the request.</returns>
        /// <exception cref="System.Configuration.ConfigurationErrorsException">
        /// Web configuration is invalid. The context is not initialized then.
        /// </exception>
        internal static ScriptContext /*!*/ InitWebRequest(ApplicationContext /*!*/ appContext, HttpContext /*!*/ context)
        {
            Debug.Assert(appContext != null && context != null);

            // reloads configuration of the current thread from ASP.NET caches or web.config files;
            // cached configuration is reused;
            Configuration.Reload(appContext, false);

            // takes a writable copy of a global configuration (may throw ConfigurationErrorsException):
            LocalConfiguration config = (LocalConfiguration)Configuration.DefaultLocal.DeepCopy();

            // following initialization statements shouldn't throw an exception:    // can throw on Integrated Pipeline, events must be attached within HttpApplication.Init()

            ScriptContext result = new ScriptContext(appContext, config, context.Response.Output, context.Response.OutputStream);

            result.IsOutputBuffered      = config.OutputControl.OutputBuffering;
            result.ThrowExceptionOnError = true;
            result.WorkingDirectory      = Path.GetDirectoryName(context.Request.PhysicalPath);
            if (config.OutputControl.ContentType != null)
            {
                context.Response.ContentType = config.OutputControl.ContentType;
            }
            if (config.OutputControl.CharSet != null)
            {
                context.Response.Charset = config.OutputControl.CharSet;
            }

            result.AutoGlobals.Initialize(config, context);

            ScriptContext.CurrentContext = result;

            Externals.BeginRequest();

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes the script context for a PHP console application.
        /// </summary>
        /// <param name="appContext">Application context.</param>
        /// <param name="mainScript">The main script's type or a <B>null</B> reference for a pure application.</param>
        /// <param name="relativeSourcePath">A path to the main script source file.</param>
        /// <param name="sourceRoot">A source root within which an application has been compiler.</param>
        /// <returns>
        /// A new instance of <see cref="ScriptContext"/> with its own copy of local configuration
        /// to be used by the application.
        /// </returns>
        /// <exception cref="System.Configuration.ConfigurationErrorsException">
        /// Web configuration is invalid. The context is not initialized then.
        /// </exception>
        /// <remarks>
        /// Use this method if you want to initialize application in the same way the PHP console/Windows
        /// application is initialized. The returned script context is initialized as follows:
        /// <list type="bullet">
        ///   <term>The application's source root is set.</term>
        ///   <term>The main script of the application is defined.</term>
        ///   <term>Output and input streams are set to standard output and input, respectively.</term>
        ///   <term>Current culture it set to <see cref="CultureInfo.InvariantCulture"/>.</term>
        ///   <term>Auto-global variables ($_GET, $_SET, etc.) are initialized.</term>
        ///   <term>Working directory is set tothe current working directory.</term>
        /// </list>
        /// </remarks>
        public static ScriptContext /*!*/ InitApplication(ApplicationContext /*!*/ appContext, Type mainScript,
                                                          string relativeSourcePath, string sourceRoot)
        {
            // loads configuration into the given application context
            // (applies only if the config has not been loaded yet by the current thread):
            Configuration.Load(appContext);

            ApplicationConfiguration app_config = Configuration.Application;

            if (mainScript != null)
            {
                if (relativeSourcePath == null)
                {
                    throw new ArgumentNullException("relativeSourcePath");
                }

                if (sourceRoot == null)
                {
                    throw new ArgumentNullException("sourceRoot");
                }

                // overrides source root configuration if not explicitly specified in config file:
                if (!app_config.Compiler.SourceRootSet)
                {
                    app_config.Compiler.SourceRoot = new FullPath(sourceRoot);
                }
            }

            // takes a writable copy of a global configuration:
            LocalConfiguration config = (LocalConfiguration)Configuration.DefaultLocal.DeepCopy();

            // sets invariant culture as a default one:
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            ScriptContext result = new ScriptContext(appContext, config, Console.Out, Console.OpenStandardOutput());

            result.IsOutputBuffered = result.config.OutputControl.OutputBuffering;
            result.AutoGlobals.Initialize(config, null);
            result.WorkingDirectory                 = Directory.GetCurrentDirectory();
            result.ThrowExceptionOnError            = true;
            result.config.ErrorControl.HtmlMessages = false;

            if (mainScript != null)
            {
                // converts relative path of the script source to full canonical path using source root from the configuration:
                PhpSourceFile main_source_file = new PhpSourceFile(
                    app_config.Compiler.SourceRoot,
                    new FullPath(relativeSourcePath, app_config.Compiler.SourceRoot)
                    );

                result.DefineMainScript(new ScriptInfo(mainScript), main_source_file);
            }

            ScriptContext.CurrentContext = result;

            Externals.BeginRequest();

            return(result);
        }
Esempio n. 8
0
        static PhpLibraryDescriptor LoadExtension(string /*!*/ nativeFileName)
        {
            Assembly assembly = Assembly.LoadFrom(Externals.GetWrapperPath(nativeFileName));

            // TODO: ApplicationContext.AddConstants(assembly);
            //return ApplicationContext.Loa(assembly, null);
            return(null);
        }
Esempio n. 9
0
        public static string GetLongPathName(string shortPathName)
        {
            StringBuilder output = new StringBuilder(1024);

            Externals.GetLongPathName(String.Concat(@"\\?\", shortPathName), output, 1024);
            output.Remove(0, 4);
            return(output.ToString());
        }
Esempio n. 10
0
 public static ILifetimeScope GetContainer()
 {
     if (_container == null)
     {
         Debug.WriteLine(">> Creating Lifetime Scope...");
         _container = Externals.BeginLifetimeScope();
     }
     return(_container);
 }
Esempio n. 11
0
        private static void RegisterExternals(IServiceCollection services, IConfiguration configuration)
        {
            var serviceConfigurationSection = configuration.GetSection("Externals");

            var serviceConfiguration =
                new Externals(serviceConfigurationSection["Account"], serviceConfigurationSection["Tweet"]);

            services.AddSingleton(serviceConfiguration);
        }
Esempio n. 12
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Externals.Register <IAuthManager>(() => new AuthManager(), true);
            Externals.Register <ISafeUI>(() => new SafeUI());
            Externals.Register <IDialog>(() => new Dialog());
            Externals.Lock();

            base.OnStartup(e);
        }
Esempio n. 13
0
        public override void OnCreate()
        {
            base.OnCreate();
            RegisterActivityLifecycleCallbacks(this);

            Externals.Register <IAuthManager>(() => new AuthManager(), true);
            Externals.Register <ISafeUI>(() => new SafeUI());
            Externals.Register <IDialog>(() => new Dialog());
            Externals.Lock();
        }
Esempio n. 14
0
        public Assembly Check()
        {
            var context = new ValidationContext(this);

            context.ValidationError += ValidationError;
            Validate(context);
            // TODO: This should be done elsewhere, but add externals
            Externals = Externals.Concat(FindAllExternalsUsed()).Distinct().ToList();
            return(new Assembly(this));
        }
Esempio n. 15
0
        public override void RefreshElement(SVGRectElement element)
        {
            base.RefreshElement(element);
            var el = Externals.Untype <Bridge.Html5.HTMLElement>(element);

            el.SetAttributeNS(null, "x", $"{StartX}px");
            el.SetAttributeNS(null, "y", $"{StartY}px");
            el.SetAttributeNS(null, "width", $"{Width}px");
            el.SetAttributeNS(null, "height", $"{Height}px");
        }
Esempio n. 16
0
        void FinallyDispose()
        {
            DeleteTemporaryFiles();
            Externals.EndRequest();

            // updates session cookie expiration stamp:
            UpdateSessionCookieExpiration();

            this.httpContext = null;
            currentContext   = null;
        }
Esempio n. 17
0
 public double RadianToDegree(double radian, int i)
 {
     if (i < 6)
     {
         return(Robot.RadianToDegree(radian, i));
     }
     else
     {
         return(Externals.First(x => x.Joints.Contains(Joints.First(y => y.Number == i))).RadianToDegree(radian, i));
     }
 }
Esempio n. 18
0
 public double DegreeToRadian(double degree, int i)
 {
     if (i < 6)
     {
         return(Robot.DegreeToRadian(degree, i));
     }
     else
     {
         return(Externals.First(x => x.Joints.Contains(Joints.First(y => y.Number == i))).DegreeToRadian(degree, i));
     }
 }
Esempio n. 19
0
 /// <summary>
 /// Forces the Task Designer to get the current task from the Server
 /// This is used when in playback mode
 /// </summary>
 public void GetCurrentTaskFromServer()
 {
     _currentTask = _remote_DataManager.Task;
     try
     {
         m_objectsToDraw.ObjectsToDraw = _currentTask.ObjectList;
     }
     catch
     {
         Externals.LoadVisualiser(m_objectsToDraw);
         MessageBox.Show("Loading Visualiser...\nPress Ok when Done.");
         m_objectsToDraw.ObjectsToDraw = _currentTask.ObjectList;
     }
 }
Esempio n. 20
0
        private void Form_TaskDesigner_Load(object sender, EventArgs e)
        {
            comboBxObjectToAdd.Text          = "<Select>";
            comboBxObjectToAdd.SelectedIndex = 1;
            pictureBxTextureImage.Visible    = checkBoxUseTexture.Checked;
            numericUpDownImageNumber.Enabled = checkBoxUseTexture.Checked;
            labelImage.Enabled = checkBoxUseTexture.Checked;

            string        textureFilesPath;
            DirectoryInfo dInfoTextures = new DirectoryInfo(Environment.CurrentDirectory);

            dInfoTextures    = dInfoTextures.Parent;
            textureFilesPath = dInfoTextures.FullName + @"\Textures";

            string[] textureFiles = new string[20];
            if (Directory.Exists(textureFilesPath))
            {
                textureFiles = Directory.GetFiles(textureFilesPath, "*.bmp");
            }

            foreach (string currentFile in textureFiles)
            {
                try
                {
                    Bitmap currentImage = new Bitmap(currentFile);
                    currentImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    imageList.Images.Add(currentImage);
                }
                catch (ArgumentNullException ex)
                {
                    System.Windows.Forms.MessageBox.Show("Cannot find texture files. Please ensure that the \"Textures\" folder is in the executable parent directory. Exception message: " + ex.Message, "Cannot Find Texture Files");
                    Environment.Exit(-1);
                }
            }

            this.numericUpDownImageNumber.Maximum = (imageList.Images.Count - 1);

            pictureBxTextureImage.Image = imageList.Images[(int)this.numericUpDownImageNumber.Value];


            Externals.LoadVisualiser(m_objectsToDraw);

            //if (Externals.VisualiserLoaded())
            {
                WindowAlignment.BringVisualiserToFrontAndAlignWindows();
            }

            Externals.SendNotification("TDSOK");
        }
Esempio n. 21
0
        /// <summary>
        /// Tries to get, set, or restore an option given its PHP name and value.
        /// </summary>
        /// <param name="name">The option name.</param>
        /// <param name="value">The option new value if applicable.</param>
        /// <param name="action">The action to be taken.</param>
        /// <param name="error"><B>true</B>, on failure.</param>
        /// <returns>The option old value.</returns>
        /// <exception cref="PhpException">The option not supported (Warning).</exception>
        /// <exception cref="PhpException">The option is read only but action demands write access (Warning).</exception>
        internal static object TryGetSetRestore(string name, object value, IniAction action, out bool error)
        {
            Debug.Assert(name != null);
            error = true;

            IniOptions.OptionDefinition option = GetOption(name);

            // option not found:
            if (option == null)
            {
                // check for options in native extensions:
                string result = null;
                switch (action)
                {
                case IniAction.Get: error = !Externals.IniGet(name, out result); break;

                case IniAction.Set: error = !Externals.IniSet(name, Convert.ObjectToString(value), out result); break;

                case IniAction.Restore: error = !Externals.IniRestore(name); break;
                }
                if (error)
                {
                    PhpException.Throw(PhpError.Warning, LibResources.GetString("unknown_option", name));
                }
                return(result);
            }

            // the option is known but not supported:
            if ((option.Flags & IniFlags.Supported) == 0)
            {
                PhpException.Throw(PhpError.Warning, LibResources.GetString("option_not_supported", name));
                return(null);
            }

            // the option is global thus cannot be changed:
            if ((option.Flags & IniFlags.Local) == 0 && action != IniAction.Get)
            {
                PhpException.Throw(PhpError.Warning, LibResources.GetString("option_readonly", name));
                return(null);
            }

            error = false;
            return(option.Gsr(Configuration.Local, name, value, action));
        }
Esempio n. 22
0
            private void DistributeExtensionOptions()
            {
                string[] opt_names = new string[Options.Count];
                Options.Keys.CopyTo(opt_names, 0);

                foreach (string option in opt_names)
                {
                    foreach (DictionaryEntry ext_entry in Extensions)
                    {
                        PhpLibraryDescriptor descriptor  = (PhpLibraryDescriptor)ext_entry.Key;
                        Hashtable            ext_options = (Hashtable)ext_entry.Value;
                        string ext_name = Path.ChangeExtension(descriptor.RealAssembly.GetName().Name, null);

                        if (Externals.IniOptionExists(ext_name, option))
                        {
                            ext_options.Add(option, Options[option]);
                            Options.Remove(option);
                        }
                    }
                }
            }
Esempio n. 23
0
        /// <summary>
        /// Generates managed wrapper of a specified extension.
        /// </summary>
        /// <param name="module">The extension name.</param>
        static void GenerateWrapper(string module)
        {
            Console.WriteLine("Generating managed wrapper for " + module);
            string message = null;

            try
            {
                message = Externals.GenerateManagedWrapper(module);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to generate managed wrapper.");
                Console.WriteLine(e.ToString());
                return;
            }

            if (message != null && message.Length > 0)
            {
                Console.WriteLine(message);
            }
        }
Esempio n. 24
0
 public AuthenticationController(Externals externals)
 {
     this.externals = externals;
 }
Esempio n. 25
0
 public AccountController(Externals externals)
 {
     this.externals = externals;
 }
Esempio n. 26
0
        /// <summary>
        /// Writes all information about Phalanger and external PHP modules to output.
        /// </summary>
        /// <param name="output">An output where to write information.</param>
        /// <param name="sections">A mask of sections which to write.</param>
        public static void Write(Sections /*!*/ sections, TextWriter /*!*/ output)
        {
            output.Write(htmlPrologue);
            output.Write(htmlStyle, htmlCss);

            if ((sections & Sections.General) != 0)
            {
                WriteLogo(output);
            }

            if ((sections & (Sections.Configuration | Sections.General)) != 0)
            {
                output.Write("<h2>");
                output.Write(CoreResources.GetString("info_config"));
                output.Write("</h2>");
                WriteConfiguration(output);
            }

            if ((sections & Sections.Credits) != 0)
            {
                output.Write("<h2>");
                output.Write(CoreResources.GetString("info_credits"));
                output.Write("</h2>");
                WriteCredits(output);
            }

#if !SILVERLIGHT
            if ((sections & Sections.Extensions) != 0)
            {
                output.Write("<h2>");
                output.Write(CoreResources.GetString("info_loaded_extensions"));
                output.Write("</h2>");
                output.Write(Externals.PhpInfo());
            }
#endif

            if ((sections & Sections.Environment) != 0)
            {
                output.Write("<h2>");
                output.Write(CoreResources.GetString("info_environment_variables"));
                output.Write("</h2>");
                WriteEnvironmentVariables(output);
            }

            if ((sections & Sections.Variables) != 0)
            {
                output.Write("<h2>");
                output.Write(CoreResources.GetString("info_global_variables"));
                output.Write("</h2>");
                WriteGlobalVariables(output);
            }

            if ((sections & Sections.License) != 0)
            {
                output.Write("<h2>");
                output.Write(CoreResources.GetString("info_license"));
                output.Write("</h2>");
                WriteLicense(output);
            }

            output.Write(htmlEpilogue);
        }
Esempio n. 27
0
 public bool InjectX86(string processName)
 {
     return(Externals.Inject(processName, Utils.AssemblyDirectory + @"\InjX86.dll"));
 }
Esempio n. 28
0
        private void Form_TaskDesigner_Load(object sender, EventArgs e)
        {
            comboBxObjectToAdd.Text          = "<Select>";
            comboBxObjectToAdd.SelectedIndex = 1;
            pictureBxTextureImage.Visible    = checkBoxUseTexture.Checked;
            numericUpDownImageNumber.Enabled = checkBoxUseTexture.Checked;
            labelImage.Enabled = checkBoxUseTexture.Checked;

            string        textureFilesPath;
            DirectoryInfo dInfoTextures = new DirectoryInfo(Environment.CurrentDirectory);

            dInfoTextures    = dInfoTextures.Parent;
            textureFilesPath = dInfoTextures.FullName + @"\Textures";

            string[] textureFiles = new string[20];

            foreach (string currentTextureFilePath in Textures.ListOfTextureFilePaths("bmp"))
            {
                Bitmap currentBitmap = new Bitmap(currentTextureFilePath);
                currentBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                imageList.Images.Add(currentBitmap);
                this.numericUpDownImageNumber.Maximum = (imageList.Images.Count - 1);
                pictureBxTextureImage.Image           = imageList.Images[(int)this.numericUpDownImageNumber.Value];
            }

            //if (Directory.Exists(textureFilesPath))
            //{
            //    textureFiles = Directory.GetFiles(textureFilesPath, "*.bmp");
            //}

            //if (textureFiles[0] == null)
            //{
            //    if (System.Windows.Forms.MessageBox.Show("Cannot find texture files. Navigate to directory?", "Cannot Find Texture Files", MessageBoxButtons.YesNo) == DialogResult.Yes)
            //    {
            //        FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
            //        folderBrowser.Description = "Select texture files folder for Task Designer.";
            //        folderBrowser.ShowDialog();
            //        textureFilesPath = folderBrowser.SelectedPath;
            //        textureFiles = Directory.GetFiles(textureFilesPath, "*.bmp");
            //    }
            //    else
            //    {
            //        Environment.Exit(-1);
            //    }
            //}
            //    foreach (string currentFile in textureFiles)
            //    {
            //        try
            //        {
            //            Bitmap currentImage = new Bitmap(currentFile);
            //            currentImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
            //            imageList.Images.Add(currentImage);
            //            this.numericUpDownImageNumber.Maximum = (imageList.Images.Count - 1);
            //            pictureBxTextureImage.Image = imageList.Images[(int)this.numericUpDownImageNumber.Value];
            //        }
            //        catch (ArgumentNullException ex)
            //        {
            //            //                    System.Windows.Forms.MessageBox.Show("Cannot find texture files. Please ensure that the \"Textures\" folder is in the executable parent directory. Exception message: " + ex.Message, "Cannot Find Texture Files");
            //            if (System.Windows.Forms.MessageBox.Show("Cannot find texture files. Navigate to directory?", "Cannot Find Texture Files", MessageBoxButtons.YesNo) == DialogResult.Yes)
            //            {
            //                FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
            //                folderBrowser.ShowDialog();
            //                textureFilesPath = folderBrowser.SelectedPath;
            //            }
            //            else
            //            {
            //                Environment.Exit(-1);
            //            }
            //        }

            //}



            Externals.LoadVisualiser(m_objectsToDraw);



            Externals.SendNotification("TDSOK");
        }
Esempio n. 29
0
 public void AddExtern(string func)
 {
     Externals.Add(func);
 }
Esempio n. 30
0
 public AuthManager()
 {
     _dialog = Externals.Resolve <IDialog>();
 }