/// <summary>
        ///     Returns a type from a name.  For example: System.Collections or System.Collections.ArrayList
        /// </summary>
        /// <param name="name">The name</param>
        /// <returns>The type or null if its not a valid type</returns>
        protected Type TryGetType(string name)
        {
            if (ImportedTypes.ContainsKey(name))
            {
                return(ImportedTypes[name]);
            }

            if (VariableTypes.ContainsKey(name))
            {
                return(VariableTypes[name]);
            }

            string  tryGetType = name + ".GetType()";
            dynamic type       = null;

            try
            {
                type = scope.Engine.CreateScriptSourceFromString(tryGetType, SourceCodeKind.Expression).Execute(scope);
            }
            catch (Exception e)
            {
                Log(e.ToString());
                Log("Failed to look up type");
            }
            return(type as Type);
        }
Example #2
0
        public void LoadVariableTypes(Assembly assembly)
        {
            var varRegisters = assembly.GetCustomAttributes(typeof(VariableRegisterAttribute), false);

            foreach (VariableRegisterAttribute attr in varRegisters)
            {
                if (!VariableTypes.ContainsKey(attr.VariableType) || attr.EditorType != null)
                {
                    VariableTypes[attr.VariableType] = attr.EditorType;
                }
                if (attr.Hidden)
                {
                    HiddenVariables.Add(attr.VariableType);
                }
            }
        }