protected void cmdDelete_Click(object sender, EventArgs e) { OperatorDefinition DB = new OperatorDefinition(); try { //using (myConnection) //{ lblResults.Text = DB.DeleteOperator(txtOperatorId.Text); // Define the ADO.NET objects. string connectionString = connectionString = WebConfigurationManager.ConnectionStrings["FleetConnectionString"].ConnectionString; string selectSQL = "SELECT branch FROM Operator_definition"; SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(selectSQL, con); SqlDataAdapter adapter = new SqlDataAdapter(cmd); // Fill the DataSet. DataSet ds = new DataSet(); adapter.Fill(ds, "Operator_definition"); // Perform the binding. GridView1.DataSource = null; // GridView1.DataSource = ds; // GridView1.DataBind(); GridView1.Visible = true; Response.Redirect("frmSuccess.aspx"); //} } catch (FormatException err) { throw err; } }
internal static Operator CreateBinary(OperatorDefinition definition, Token token, AssignmentOperatorBehavior assignmentOperatorBehavior) { return(definition switch { StandardOperatorDefinition standardOperator => new StandardOperator(token, standardOperator.OperatorType, assignmentOperatorBehavior), SpecialOperatorDefinition specialOperator => new SpecialOperator(token, specialOperator.OperatorType), _ => throw new NotImplementedException(), });
public override PropertyTreeMetaObject BindConstructor(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { if (definition.Parameters.Count != 0) { // TODO This is an error because we can't do construction inside template throw new NotImplementedException(); } return(this); }
public override PropertyTreeMetaObject BindAddChild(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { var result = definition.Apply(component, component, arguments); if (result == null) { return(PropertyTreeMetaObject.Null); } return(this.CreateChild(result)); }
public override PropertyTreeMetaObject Process(PropertyTreeBinderImpl parent, PropertyTreeMetaObject target, PropertyTreeNavigator self, NodeList children) { QualifiedName name = self.QualifiedName; var ctor = PropertyTreeDefinition.FromType(target.ComponentType).Constructor; if (target.ShouldConstruct && ctor != null) { OperatorDefinition op = ctor; var args = parent.ExtractParameterDictionary(op, target, parent.GetBasicServices(self), children); target = target.BindConstructor(ctor, args); } return(target); }
public override PropertyTreeMetaObject BindConstructor(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { var op = definition; object component = null; object parent = null; var value = op.Apply(component, parent, arguments); if (this.Parent == null) { return(Create(value)); } else { return(this.Parent.CreateChild(value)); } }
internal PropertyTreeMetaObject SetProviderMember(MemberInfo member) { if (member == null) { return(this); } if (member.MemberType == MemberTypes.TypeInfo) { this.componentType = ((TypeInfo)member).AsType(); return(this); } else if (member.MemberType == MemberTypes.Method) { this.factoryDefinition = ReflectedProviderFactoryDefinitionBase.Create(this.componentType, member); this.componentType = ((MethodInfo)member).ReturnType; return(this); } else { var component = ((FieldInfo)member).GetValue(null); return(this.Parent.CreateChild(component)); } }
protected void cmdEdit_Click(object sender, EventArgs e) { OperatorDefinition DB = new OperatorDefinition(); try { if (txtOperatorId.Text == null) { lblResults.Text = "Please enter the operator id"; return; } if (txtOperatorName.Text == null) { lblResults.Text = "Please enter the operator name"; return; } if (txtPassword.Text == null) { lblResults.Text = "Please enter the password"; return; } if (txtFirstName.Text == null) { lblResults.Text = "Please enter the first name"; return; } if (txtLastName.Text == null) { lblResults.Text = "Please enter the last name"; return; } if (txtLimit.Text == null) { lblResults.Text = "Please enter the limit"; return; } if (txtLimit.GetType() != typeof(Decimal)) { lblResults.Text = "Enter a valid limit"; return; } int reccount = 0; reccount = DB.FindRecKount(txtOperatorId.Text); if (reccount > 0) { lblResults.Text = "Record already exists!!!"; return; } DB.EditOperator(txtOperatorId.Text, txtOperatorName.Text, txtPassword.Text, txtFirstName.Text, txtLastName.Text, decimal.Parse(txtLimit.Text), DateTime.Parse(dtExpiryDate.ToString())); // Fill the DataSet. DataSet ds = new DataSet(); ds = DB.FindTable(); //adapter.Fill(ds, "tb_Customer"); // Perform the binding. GridView1.DataSource = ds; GridView1.DataBind(); lblResults.Text = "Operation successful"; txtOperatorId.Text = ""; txtOperatorName.Text = ""; txtPassword.Text = ""; txtFirstName.Text = ""; txtLastName.Text = ""; txtLimit.Text = "0"; return; } catch (FormatException err) { EventLog log = new EventLog(); log.Source = "Milorry Frontend"; log.WriteEntry(err.Message, EventLogEntryType.Error); } }
private PropertyTreeMetaObject DoOperatorBind(PropertyTreeBinderImpl parent, PropertyTreeMetaObject target, PropertyTreeNavigator navigator, OperatorDefinition op) { OperatorDefinition addon = op; if (addon.DefaultParameter != null) { Type itemType = addon.OutputType; // TODO Use service activation (we have the output type) var item = target.CreateChild(itemType); var model = parent.Bind(item, navigator, null); var args = new Dictionary <string, PropertyTreeMetaObject> { { addon.DefaultParameter.Name, model } }; try { target.BindAddChild(op, args); } catch (PropertyTreeException) { throw; } catch (Exception ex) { if (ex.IsCriticalException()) { throw; } parent._errors.BadAddChild(target.ComponentType, ex, navigator.FileLocation); } } else { // TODO The number and kinds of arguments are constrained. This should probably // be enforced within schema operator reflection (spec) Action <IReadOnlyDictionary <string, PropertyTreeMetaObject> > func; var children = NodeList.Create(SelectChildren(navigator)); switch (addon.OperatorType) { case OperatorType.Add: func = args => { var child = target.BindAddChild(addon, args); if (child.ShouldBindChildren) { parent.BindChildNodes(child, navigator, children); } }; break; case OperatorType.Remove: func = args => target.BindRemoveChild(addon, args); break; case OperatorType.Clear: default: func = args => target.BindClearChildren(addon, args); break; } var services = parent.GetBasicServices(navigator); var args2 = parent.ExtractParameterDictionary(op, target, services, children); func(args2); } return(target); }
public override void BindRemoveChild(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { definition.Apply(null, component, arguments); }
public virtual PropertyTreeMetaObject BindConstructor(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { return(this); }
public virtual void BindClearChildren(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { }
public virtual PropertyTreeMetaObject BindAddChild(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { return(null); }
public override PropertyTreeMetaObject BindAddChild(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { AppendCommand(new AddChildCommand(definition, arguments)); return(FromInstanceType(definition.ReturnType)); }
public override PropertyTreeMetaObject BindConstructor(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { return(new BuilderMetaObject(inner.BindConstructor(definition, arguments))); }
public override void BindClearChildren(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { definition.Apply(Component, null, arguments); }
public void RequiredPropertiesMissing(IEnumerable <string> requiredMissing, OperatorDefinition op, FileLocation loc) { throw PropertyTreesFailure.RequiredPropertiesMissing(requiredMissing, op.ToString(), loc.LineNumber, loc.LinePosition); }
public Dictionary <string, PropertyTreeMetaObject> ExtractParameterDictionary( OperatorDefinition op, PropertyTreeMetaObject target, IServiceProvider serviceProvider, NodeList children) { // Named constructor arguments var duplicates = new HashSet <QualifiedName>(); var mapped = new Dictionary <QualifiedName, PropertyTreeNavigator>(); foreach (var child in children) { // Implicitly map default NS to real var impliedName = ImpliedName(child, target); if (duplicates.Contains(impliedName)) { // Duplicates can't bind to parameters (only to param arrays) } else if (mapped.ContainsKey(impliedName)) { // Detected a duplicate duplicates.Add(impliedName); mapped.Remove(impliedName); } else { mapped.Add(impliedName, child); } } var args = new Dictionary <string, PropertyTreeMetaObject>(op.Parameters.Count); PropertyDefinition myParam = null; List <string> requiredMissing = new List <string>(); foreach (PropertyDefinition p in op.Parameters) { // Fallback to empty ns PropertyTreeNavigator nav; QualifiedName impliedName = p.QualifiedName; if (p.QualifiedName.Namespace.IsDefault) { impliedName = impliedName.ChangeNamespace(op.Namespace); } if (mapped.TryGetValue(impliedName, out nav)) { // Binds a parameter required for activating an instance // TODO Should we supply/use attributes from the parameter // and/or corresponding property descriptor? var childContext = target.CreateChild(p.PropertyType); args[p.Name] = Bind(childContext, nav, serviceProvider); children.Remove(nav); } else if (p.IsOptional) { PropertyTreeMetaObject defaultValue; if (p.DefaultValue == null) { defaultValue = PropertyTreeMetaObject.Create(p.PropertyType); } else { defaultValue = PropertyTreeMetaObject.Create(p.DefaultValue); } args[p.Name] = defaultValue; } else if (p.IsParamArray) { myParam = p; } else if (TypeHelper.IsParameterRequired(p.PropertyType)) { requiredMissing.Add(Utility.DisplayName(p.QualifiedName)); } } if (requiredMissing.Count > 0) { _errors.RequiredPropertiesMissing(requiredMissing, op, FindFileLocation(serviceProvider)); } if (myParam == null && !target.GetDefinition().DefaultProperties.Any() && duplicates.Any(t => target.SelectProperty(t) != null)) { _errors.DuplicatePropertyName(duplicates, FindFileLocation(serviceProvider)); } // Try param array if (myParam != null) { var all = new List <object>(); var elementType = myParam.PropertyType.GetElementType(); foreach (var kvp in children) { // Bind child nodes so tha latebound applies var childrenList = NodeList.Create(PropertyTreeBinderImpl.SelectChildren(kvp)); var inline = BindChildNodes(PropertyTreeMetaObject.Create(elementType), kvp, childrenList); var inlineVal = inline.Component; all.Add(inlineVal); } children.Clear(); var array = Array.CreateInstance(elementType, all.Count); ((System.Collections.ICollection)all).CopyTo(array, 0); args[myParam.Name] = PropertyTreeMetaObject.Create(array); } return(args); }
public AddChildCommand(OperatorDefinition definition, IReadOnlyDictionary <string, PropertyTreeMetaObject> arguments) { this.definition = definition; this.arguments = arguments.ToDictionary(t => t.Key, t => t.Value.Component); }