Esempio n. 1
0
 public NickNameAndPasswordGenerator(string[] Dictionary)
 {
     if(Dictionary==null) throw new ArgumentNullException();
     if (Dictionary.GetLength(0)<2) throw new ArgumentException();
     m_Dic=Dictionary;
     generatorType = GeneratorTypes.normalGenerator;
 }
Esempio n. 2
0
 public void Init(Action <Type> callback, GeneratorTypes type)
 {
     m_Target           = callback.Target as Object;
     m_MethodName.value = callback.Method.Name;
     m_MethodAssemblyQualifiedName.value = callback.Method.DeclaringType.AssemblyQualifiedName;
     m_GeneratorType = type;
     PopulateTypes();
 }
Esempio n. 3
0
        /// <summary>
        /// This function takes System.Type and a Generator Type and write a new class. It
        /// first checks to see if the type meets all the conditions then asks the user to
        /// where they would like to save it.
        /// </summary>
        /// <param name="type">The type of class that you want to create an Editor for.</param>
        /// <param name="editorType">The type of Editor you want to create.</param>
        public static void CreateEditor(Type type, GeneratorTypes editorType, string path = "")
        {
            if (editorType == GeneratorTypes.CustomEditor && !IsValidForCustomEditor(type))
            {
                //We can't make an Editor for this class.
                return;
            }
            else if (editorType == GeneratorTypes.PropertyDrawer && !IsValidForPropertyDrawer(type))
            {
                //We can't make an Property Drawer for this type.
                return;
            }

            if (type != null)
            {
                string assetPath = EditorUtility.SaveFilePanelInProject("Save Location", type.Name + "Editor", "cs", "The location you want to save your Editor", path);

                if (string.IsNullOrEmpty(assetPath))
                {
                    //They cancelled selecting a path.
                    return;
                }

                string assetName = Path.GetFileNameWithoutExtension(assetPath);

                Essence essence = ScriptableObject.CreateInstance <Essence>();
                essence.classType        = type;
                essence.outputEditorType = editorType;
                essence.className        = assetName;

                var processor = new JiffyGeneratorPreprocessor(essence);

                string @class = processor.TransformText();


                File.WriteAllText(assetPath, @class);

                AssetDatabase.ImportAsset(assetPath);

                Debug.Log(string.Format("Jiffy | {0}.cs was created for {1}.cs. The script is located {2}", type.Name, assetName, assetPath));

                Object script = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object));

                if (script != null)
                {
                    EditorGUIUtility.PingObject(script);
                }

                AssetDatabase.Refresh();
            }
        }
Esempio n. 4
0
 private void DrawTypeSelector()
 {
     if (m_GeneratorNames != null)
     {
         int id = (int)m_GeneratorType;
         EditorGUI.BeginChangeCheck();
         {
             id = GUILayout.Toolbar(id, m_GeneratorNames, EditorStyles.toolbarButton);
         }
         if (EditorGUI.EndChangeCheck())
         {
             m_GeneratorType = (GeneratorTypes)id;
             PopulateTypes();
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// This function takes MonoScript and a Generator Type and write a new class. It
        /// first checks to see if the type meets all the conditions then asks the user to
        /// where they would like to save it.
        /// </summary>
        /// <param name="script">The script file you want to create your Editor for.</param>
        /// <param name="editorType">The type of Editor you want to create.</param>
        public static void CreateEditor(MonoScript script, GeneratorTypes editorType)
        {
            if (script != null)
            {
                Assembly asm = Assembly.Load("Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");

                if (asm != null)
                {
                    string path = AssetDatabase.GetAssetPath(script);

                    Type type = asm.GetType(script.name);

                    CreateEditor(type, editorType, Path.GetDirectoryName(path) + "/");
                }
                else
                {
                    Debug.Log("Assembly count not be found");
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Constructor which auto fills the properties.
        /// </summary>
        /// <param name="type"> GeneratorType of the Generator. </param>
        /// <param name="text"> The "name" of the Generator. </param>
        /// <param name="toolTipText"> ToolTip Text for the Generator. </param>
        public GeneratorInfo(GeneratorTypes type, Func <Generator> createFunc, string text = null, string toolTipText = null)
        {
            // Set the type, name and tooltiptext of the GeneratorType.
            GenType     = type;
            Create      = createFunc;
            Text        = text;
            ToolTipText = toolTipText;


            // If there is no specific text use the generator Type name.
            if (Text == null)
            {
                Text = GenType.ToString("f");
            }
            ;

            // If there is no ToolTip use the name of the Generator.
            if (toolTipText == null)
            {
                ToolTipText = Text;
            }
        }
Esempio n. 7
0
            public Info(GeneratorTypes type, string text = null, string toolTipText = null)
            {
                // Get the name of the GeneratorType
                GenType = type;

                Text = text;

                ToolTipText = toolTipText;


                // If there is no specific text use the generator Type name
                if (Text == null)
                {
                    Text = GenType.ToString("f");
                }
                ;

                if (toolTipText == null)
                {
                    ToolTipText = Text;
                }
            }
Esempio n. 8
0
 public NickNameAndPasswordGenerator(string webURL, int flag)
 {
     webSource = webURL;
     generatorType = GeneratorTypes.webLoader;
 }
Esempio n. 9
0
 public static string ToString(this GeneratorTypes genType)
 {
     return(genType.ToString().Replace('_', '.'));
 }
Esempio n. 10
0
 /// <summary>
 /// Returns the GeneratorInfo object associated to the given GeneratorType.
 /// </summary>
 /// <param name="type"> The generatorType the Info is for. </param>
 /// <returns> The GeneratorInfo for the GeneratorType. </returns>
 public static GeneratorInfo GetInfo(this GeneratorTypes type)
 {
     // Try to get the info object
     return(InfosList.Single(x => x.GenType == type));
 }
Esempio n. 11
0
        /// <summary>
        /// Shows the Type Search Window and uses a callback to send the result.
        /// </summary>
        public static void ShowTypeSerachWindow(Action <Type> onTypeSelected, GeneratorTypes type)
        {
            var typeWindow = EditorWindow.GetWindow <TypeSearchWindow>(true);

            typeWindow.Init(onTypeSelected, type);
        }
Esempio n. 12
0
 /// <summary>
 /// Инициализирует генератор в соответствии с переданным типом.
 /// </summary>
 /// <param name="type">Желаемый тип генератора.</param>
 /// <returns>Объект, представляющий конкретную реализацию абстрактного класса TestDataGenerator.</returns>
 private TestDataGenerator GetGeneratorFromType(GeneratorTypes type)
 {
     switch (type)
     {
         case GeneratorTypes.Names:
             var tg = new TextGenerator("RussianMaleNames.txt");
             //tg.UniqueValues = true;
             //tg.EmptyValues = 20;
             return tg;
         case GeneratorTypes.Surnames:
             return new TextGenerator("RussianMaleSurnames.txt");
         case GeneratorTypes.GUID:
             return new GuidGenerator();
         case GeneratorTypes.Int:
             return new IntegerGenerator();
         case GeneratorTypes.Date:
             return new DateTimeGenerator(new DateTime(1960, 12, 15), new DateTime(2000, 12, 20));
         case GeneratorTypes.Text:
             return new RandomTextGenerator(100);
         default:
             throw new Exception("Нет такого генератора.");
     }
 }