Exemple #1
0
        public static IScript GetScript(string scriptID, string scriptCollection)
        {
            IScript         script     = null;
            MongoCollection collection = MongoUtils.MongoData.GetCollection("Scripts", scriptCollection);
            BsonDocument    doc        = collection.FindOneAs <BsonDocument>(Query.EQ("_id", scriptID));

            if (doc != null && doc["Bytes"].AsBsonBinaryData != null)
            {
                ScriptTypes scriptType = (ScriptTypes)Enum.Parse(typeof(ScriptTypes), doc["Type"].ToString());
                switch (scriptType)
                {
                case ScriptTypes.Lua:
                    script = new LuaScript((byte[])doc["Bytes"].AsBsonBinaryData);
                    break;

                case ScriptTypes.Roslyn:
                    script = new RoslynScript((byte[])doc["Bytes"].AsBsonBinaryData);
                    break;

                default:
                    break;
                }
            }

            return(script);
        }
Exemple #2
0
        public static IScript CreateScript(ScriptTypes type) {
            IScript newScript;

            switch (type) {
                case ScriptTypes.Roslyn:
                    newScript = new RoslynScript();
                    break;
                case ScriptTypes.Lua:
                default:
                    newScript = new LuaScript();
                    break;
            }

            return newScript;
        }
Exemple #3
0
        public static IScript GetScript(byte[] scriptBytes, ScriptTypes scriptType) {
            IScript script = null;
            
            if (scriptBytes != null) {
                switch (scriptType) {
                    case ScriptTypes.Lua:
                        script = new LuaScript(scriptBytes);
                        break;
                    case ScriptTypes.Roslyn:
                        script = new RoslynScript(scriptBytes);
                        break;
                    default:
                        break;
                }
            }

            return script;
        }
Exemple #4
0
        public static IScript GetScript(string scriptID, string scriptCollection)
        {
            IScript script = null;
            MongoCollection collection = MongoUtils.MongoData.GetCollection("Scripts", scriptCollection);
            BsonDocument doc = collection.FindOneAs<BsonDocument>(Query.EQ("_id", scriptID));

            if (doc != null && doc["Bytes"].AsBsonBinaryData != null) {
                ScriptTypes scriptType = (ScriptTypes)Enum.Parse(typeof (ScriptTypes), doc["Type"].ToString());
                switch (scriptType) {
                case ScriptTypes.Lua:
                    script = new LuaScript((byte[])doc["Bytes"].AsBsonBinaryData);
                    break;
                case ScriptTypes.Roslyn:
                    script = new RoslynScript((byte[])doc["Bytes"].AsBsonBinaryData);
                    break;
                default:
                    break;
                }
            }

            return script;
        }