public override void OnInspectorGUI() { DrawDefaultInspector(); Constructor constructor_script = (Constructor)target; string load_blueprint_button_text; if (constructor_script.filename.Length > 0) { load_blueprint_button_text = "Load Blueprints from " + constructor_script.FULL_FILENAME + ".json"; } else { load_blueprint_button_text = "(Load unavailable; must have filename)"; } if (GUILayout.Button(load_blueprint_button_text)) { if (constructor_script.filename.Length > 0) { constructor_script.LoadBlueprint(); } } string construct_room_button_text; if (constructor_script.HasBlueprints()) { construct_room_button_text = "Construct Room From Blueprints"; } else { construct_room_button_text = "(Construct unavailable; must have blueprint)"; } if (GUILayout.Button(construct_room_button_text)) { if (constructor_script.HasBlueprints()) { constructor_script.Construct(); } } string save_blueprint_button_text; if (constructor_script.filename.Length > 0 && constructor_script.HasBlueprints()) { save_blueprint_button_text = "Save Blueprints to " + constructor_script.FULL_FILENAME + ".json"; } else { save_blueprint_button_text = "(Save unavailable; must have filename and blueprint)"; } if (GUILayout.Button(save_blueprint_button_text)) { if (constructor_script.filename.Length > 0 && constructor_script.HasBlueprints()) { constructor_script.SaveBlueprint(); } } }
public static Task GenerateSqlExceptionAsync(int errorNumber) { SqlException e = null; var collection = Constructor.Construct <SqlErrorCollection>(); if (collection != null) { var error = Constructor.Construct <SqlError>(errorNumber, 2, 3, "server name", "Gremlins generated SqlException.", "proc", 100); if (error != null) { typeof(SqlErrorCollection) .GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Instance) .Invoke(collection, new object[] { error }); e = typeof(SqlException) .GetMethod("CreateException", BindingFlags.NonPublic | BindingFlags.Static, null, CallingConventions.ExplicitThis, new[] { typeof(SqlErrorCollection), typeof(string) }, Array.Empty <ParameterModifier>()) .Invoke(null, new object[] { collection, "7.0.0" }) as SqlException; throw e; } } return(Task.CompletedTask); }
public override void Construct(string scriptName) { base.Construct(scriptName); Constructor.Construct(scriptName); SetUp(); }
// public static T Construct<T>(Path? path = null) { public static T Construct <T>(Path path = null) { if (IsStateType(typeof(T))) { return(Constructor <T> .Construct(path)); } else { // return default!; return(default);
public void Construct() { ISignableContract contract = new SignableContract(); contract.Describe(15); contract.Describe("hello"); var testClass = Constructor.Construct <TestClassWithConstructor>(contract.Sign()); Assert.AreEqual(15, testClass.Field1); Assert.AreEqual("hello", testClass.Field2); }
public override object Construct() { var textBlock = new Label().BuildStyledLabel(Owner, PropertyName); var label = new Label(); label.Content = PropertyName.SplitCamelCase(); label.HorizontalAlignment = HorizontalAlignment.Center; label.Target = textBlock; return(Constructor.Construct(BuildOrientation.Vertical, label, textBlock)); }
private void NewScriptable() { if (!ConfirmClose()) { return; } classSelector.Types = Constructor.RegisteredTypes.Where((t) => !t.IsAbstract && typeof(IScriptable).IsAssignableFrom(t)); classSelector.StartPosition = FormStartPosition.CenterParent; if (classSelector.ShowDialog() != DialogResult.OK) { return; } SetScriptable(Constructor.Construct(classSelector.SelectedType) as IScriptable, null); }
public override object Construct() { var comboBox = new ComboBox(); comboBox.DataContext = Owner; comboBox.SetBinding(ComboBox.ItemsSourceProperty, new Binding(PropertyName)); comboBox.SetBinding(ComboBox.SelectedItemProperty, new Binding(SelectedItemPropertyName)); comboBox.DisplayMemberPath = DisplayPath; var label = new Label(); label.Target = comboBox; label.HorizontalAlignment = HorizontalAlignment.Center; label.Content = PropertyName.SplitCamelCase(); return(Constructor.Construct(BuildOrientation.Vertical, label, comboBox)); }
public IEventPipeline Select(Message message) { var messageType = message.GetType(); var attr = messageType.GetTypeInfo().GetCustomAttribute <EventPipeline.Attribute.TypeofPipelineAttribute>() as TypeofPipelineAttribute; Type attrType = null; if (attr != null) { //attrType = attr.PipelineType; return(Constructor.Construct(attrType) as IEventPipeline); } var constructorAttrs = messageType.GetTypeInfo().GetCustomAttributes <EventPipeline.Attribute.PipelineConstructorAttribute>() as PipelineConstructorAttribute; if (constructorAttrs != null) { return(constructorAttrs.Construct(message)); } return(null); }
public object Initiate(Container container, List <object> parameters) { var output = new object(); if (Instance != null) { output = Instance; } else if (Initializer != null) { output = Initializer(container); } else { output = Constructor.Construct(parameters); //225 ms/million } return(output); }
private Json.DataObject CreateInstance(Type type, ClassSelector selector) { Json.DataObject obj = null; if (type.IsAbstract) { if (selector.Types == null) { selector.Types = Constructor.RegisteredTypes.Where((t) => !t.IsAbstract && type.IsAssignableFrom(t)); } selector.StartPosition = FormStartPosition.CenterParent; if (selector.ShowDialog() == DialogResult.OK && selector.SelectedType != null) { obj = Constructor.Construct(selector.SelectedType); } } else { obj = Constructor.Construct(type); } return(obj); }
public override object Construct() { var textBox = new TextBox(); textBox.DataContext = Owner; textBox.SetBinding(TextBox.TextProperty, new Binding(PropertyName)); textBox.SetValue(Grid.ColumnProperty, 1); textBox.HorizontalAlignment = HorizontalAlignment.Stretch; var label = new Label(); label.Target = textBox; label.HorizontalAlignment = HorizontalAlignment.Right; label.Content = PropertyName.SplitCamelCase() + ":"; label.SetValue(Grid.ColumnProperty, 0); var textBoxContainer = new Grid().BuildTwoColumnGrid(); textBoxContainer.Children.Add(textBox); textBoxContainer.Children.Add(label); return(Constructor.Construct(BuildOrientation.Vertical, textBoxContainer)); }
public override object Construct() { var slider = new Slider(); slider.Minimum = Min; slider.Maximum = Max; slider.Background = Colors.Transparent.ToBrush(); slider.DataContext = Owner; slider.SetBinding(Slider.ValueProperty, new Binding(PropertyName)); slider.Margin = new Thickness(0, 0, 0, 2); var label = new Label(); label.Target = slider; label.HorizontalAlignment = HorizontalAlignment.Left; label.Content = PropertyName.SplitCamelCase(); label.SetValue(Grid.ColumnProperty, 0); var labelBinding = new Binding("Value"); labelBinding.Converter = new DoubleToIntConverter(); var valueLabel = new Label(); valueLabel.DataContext = slider; valueLabel.HorizontalAlignment = HorizontalAlignment.Right; valueLabel.SetBinding(Label.ContentProperty, labelBinding); valueLabel.SetValue(Grid.ColumnProperty, 1); var grid = new Grid().BuildTwoColumnGrid(); grid.Children.Add(label); grid.Children.Add(valueLabel); return(Constructor.Construct(BuildOrientation.Vertical, grid, slider)); }
public static LazyFunctionDependency AsLazy(this CastedDependency dependency) => new LazyFunctionDependency(dependency.TranslateInfo, contract => Constructor.Construct(dependency.Description.ImplementTypes.Last(), contract));
public static void Read(IScriptable scriptable, string content) { if (scriptable == null) { return; } IContext context = JsonSerializer.createContext(scriptable); Stack <IScriptable> parents = new Stack <IScriptable>(); string[] lines = content.Split('\n'); string body = ""; for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (body.Length == 0 && line.Length == 0) { continue; } bool newId = line.StartsWith("<!-- ["); bool newAction = line.StartsWith("`") && line.EndsWith("`"); bool newAddition = line.StartsWith(">+"); if (body.Length > 0 && parents.Count > 0 && (newId || newAction || newAddition)) { body = body.Trim(); IScriptable obj = parents.Peek(); ReadObject(obj, body); body = ""; } if (newId) { int closeIndex = line.IndexOf("]"); int indent = int.Parse(line.Substring(6, closeIndex - 6)); while (parents.Count > indent) { parents.Pop(); } Guid guid = Guid.Parse(line.Substring(closeIndex + 2, 36)); parents.Push(context.GetObject <IScriptable>(guid)); continue; } else if (parents.Count > 1 && newAddition) { IScriptable sibling = parents.Pop(); IScriptable parent = parents.Peek(); IScriptable child = Constructor.Construct(sibling.GetType()) as IScriptable; parents.Push(child); line = line.Substring(2).Trim(); foreach (Accessor accessor in FieldAccessor.GetForObject(parent)) { IList list = accessor.Get() as IList; if (list == null) { continue; } int index = list.IndexOf(sibling); if (index < 0) { continue; } if (index + 1 < list.Count) { IScriptable nextSibling = list[index + 1] as IScriptable; if (nextSibling != null) { string text = WriteObject(nextSibling, new Indent()); if (text.Contains(line)) { break; } } } list.Insert(index + 1, child); break; } } else if (newAction) { continue; } else if (line.StartsWith("-->")) { line = line.Substring(3); } if (line.StartsWith("~~") && line.EndsWith("~~") && parents.Count > 1) { IScriptable child = parents.Pop(); IScriptable parent = parents.Peek(); parents.Push(child); foreach (Accessor accessor in FieldAccessor.GetForObject(parent)) { IList list = accessor.Get() as IList; if (list == null) { continue; } int index = list.IndexOf(child); if (index < 0) { continue; } list.RemoveAt(index); break; } } if (body.Length == 0) { // TODO: Make more robust while (line.StartsWith("#") || line.StartsWith(">")) { line = line.Substring(1); } int typeIndex = line.IndexOf(" `["); if (typeIndex >= 0) { line = line.Substring(0, typeIndex); } } body += line.Trim() + "\r\n"; } }
public override void Construct(string scriptName, IScript parentScript) { Constructor.Construct(scriptName, parentScript); SetUp(); }
public virtual void Construct(string scriptName, IScript parentScript) { Constructor.Construct(scriptName, parentScript); SetUp(); }