public NickNameAndPasswordGenerator(string[] Dictionary) { if(Dictionary==null) throw new ArgumentNullException(); if (Dictionary.GetLength(0)<2) throw new ArgumentException(); m_Dic=Dictionary; generatorType = GeneratorTypes.normalGenerator; }
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(); }
/// <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(); } }
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(); } } }
/// <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"); } } }
/// <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; } }
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; } }
public NickNameAndPasswordGenerator(string webURL, int flag) { webSource = webURL; generatorType = GeneratorTypes.webLoader; }
public static string ToString(this GeneratorTypes genType) { return(genType.ToString().Replace('_', '.')); }
/// <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)); }
/// <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); }
/// <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("Нет такого генератора."); } }