Code Search for Developers
 
 
  

Engine.cs from p4shelf at Krugle


Show Engine.cs syntax highlighted

using System.Collections.Generic;

namespace NScriptEngine
{
    public class Engine
    {
        #region Public Interface
        ///////////////////////////////////////////////////////////////////////
        //// Public 
        ///////////////////////////////////////////////////////////////////////
        public Engine()
        {
            _scripts = new List<Script>();
            _references = new Dictionary<string, object>();
        }

        public void LoadScript(string file)
        {
            Script script = _ScriptFactory(file);
            if (null != script)
            {
                _scripts.Add(script);
            }
        }

        public void AddReference(string name, object objToRef)
        {
            _references.Add(name, objToRef);
            foreach (Script script in _scripts)
            {
                script.AddReference(name, objToRef);
            }
        }

        public void CastEvent(string eventName, object[] eventArgs)
        {
            foreach (Script script in _scripts)
            {
                script.CastEvent(eventName, eventArgs);
            }
        }

        #endregion

        #region Private Impl
        ///////////////////////////////////////////////////////////////////////
        //// Private
        ///////////////////////////////////////////////////////////////////////

        internal Script _ScriptFactory(string file)
        {
            string[] tokens = file.Split('.');
            if (tokens.Length < 2)
            {
                return null;
            }

            string fileExt = tokens[tokens.Length - 1].ToLower();
            if (PyScript.IsValidFileExtension(fileExt))
                return new PyScript(file, _references);
            
            if (VBScript.IsValidFileExtension(fileExt))
                return new VBScript(file, _references);
            
            if (CSharpScript.IsValidFileExtension(fileExt))
                return new CSharpScript(file, _references);

            return null;
        }

        internal List<Script> _scripts;
        internal Dictionary<string, object> _references;
        #endregion
    }

}




See more files for this project here

p4shelf

A feature in Visual Studio Team Studio that was immediately appealing to me was shelving. The goal of this tool is replicate that general functionality in Perforce.

Project homepage: http://code.google.com/p/p4shelf/
Programming language(s): C#,C++,Python
License: gpl2

  Impl/
    PyScript.cs
    ScriptAbstract.cs
  Properties/
    AssemblyInfo.cs
  bin/
    Debug/
      IronMath.dll
      IronPython.dll
      NScriptEngine.dll
  Engine.cs
  NScriptEngine.csproj