public void TestAppendFieldSimple() { var workspace = new Workspace(); var block = new Block(workspace); var input = new Input(Define.EConnection.DummyInput, "INPUT", block); var field1 = new FieldLabel("first", "#1"); var field2 = new FieldLabel("second", "#2"); Assert.AreEqual(0, input.FieldRow.Count); //actual test input.AppendField(field1); Assert.AreEqual(1, input.FieldRow.Count); Assert.AreEqual(field1, input.FieldRow[0]); Assert.AreEqual("first", input.FieldRow[0].Name); Assert.AreEqual(block, field1.SourceBlock); input.AppendField(field2); Assert.AreEqual(2, input.FieldRow.Count); Assert.AreEqual(field2, input.FieldRow[1]); Assert.AreEqual("second", input.FieldRow[1].Name); Assert.AreEqual(block, field2.SourceBlock); workspace = null; }
public FieldNode(string name, FieldLabel label, FieldType type, int tag) { Label = label; Type = type; Name = name; Tag = tag; }
public void TestInsertFieldAtSimple() { var workspace = new Workspace(); var block = new Block(workspace); var input = new Input(Define.EConnection.DummyInput, "INPUT", block); var before = new FieldLabel(null, "before"); var after = new FieldLabel(null, "after"); var between = new FieldLabel("name", "between"); input.AppendField(before); input.AppendField(after); //preconditions Assert.AreEqual(2, input.FieldRow.Count); Assert.AreEqual(before, input.FieldRow[0]); Assert.AreEqual(after, input.FieldRow[1]); input.InsertFieldAt(1, between); Assert.AreEqual(3, input.FieldRow.Count); Assert.AreEqual(before, input.FieldRow[0]); Assert.AreEqual(between, input.FieldRow[1]); Assert.AreEqual("name", input.FieldRow[1].Name); Assert.AreEqual(after, input.FieldRow[2]); }
public void TestInsertFieldAtString() { var workspace = new Workspace(); var block = new Block(workspace); var input = new Input(Define.EConnection.DummyInput, "INPUT", block); var before = new FieldLabel(null, "before"); var after = new FieldLabel(null, "after"); string labelText = "label"; input.AppendField(before); input.AppendField(after); //preconditions Assert.AreEqual(2, input.FieldRow.Count); Assert.AreEqual(before, input.FieldRow[0]); Assert.AreEqual(after, input.FieldRow[1]); input.InsertFieldAt(1, labelText, "name"); Assert.AreEqual(3, input.FieldRow.Count); Assert.AreEqual(before, input.FieldRow[0]); Assert.AreEqual(typeof(FieldLabel), input.FieldRow[1].GetType()); Assert.AreEqual(labelText, input.FieldRow[1].GetValue()); Assert.AreEqual("name", input.FieldRow[1].Name); Assert.AreEqual(after, input.FieldRow[2]); }
void ReleaseDesignerOutlets() { if (FieldLabel != null) { FieldLabel.Dispose(); FieldLabel = null; } if (ValueLabel != null) { ValueLabel.Dispose(); ValueLabel = null; } }
public void TestAppendFieldPrefix() { var workspace = new Workspace(); var block = new Block(workspace); var input = new Input(Define.EConnection.DummyInput, "INPUT", block); var prefix = new FieldLabel(null, "prefix"); var field = new FieldLabel(null, "field"); //field.PrefixField = prefix; //todo workspace = null; }
public static string FieldLabelToString(FieldLabel label, bool proto3) { switch (label) { case FieldLabel.OPTIONAL: // Proto3 syntax has an implicit OPTIONAL label! return((proto3 == true) ? "" : "optional"); case FieldLabel.REPEATED: return("repeated"); case FieldLabel.REQUIRED: // Proto3 syntax does not allow REQUIRED label! return((proto3 == true) ? "" : "required"); default: return(""); } }
void ReleaseDesignerOutlets() { if (AlertButton != null) { AlertButton.Dispose(); AlertButton = null; } if (DialogButton != null) { DialogButton.Dispose(); DialogButton = null; } if (Field != null) { Field.Dispose(); Field = null; } if (FieldLabel != null) { FieldLabel.Dispose(); FieldLabel = null; } if (NotificationButton != null) { NotificationButton.Dispose(); NotificationButton = null; } if (ResultLabel != null) { ResultLabel.Dispose(); ResultLabel = null; } }
public static string GetFieldName(CallInfo info, FieldLabel label) { // Extract the name of the field. var name = ""; if (label == FieldLabel.REPEATED) { name = info.Conditions.First(x => x.Lhs.Contains("get_Count()")).Lhs; name = name.Substring(name.IndexOf(".get_") + 5); name = name.Substring(0, name.Length - 14); } else { name = info.Arguments[1].ToString(); if (name.StartsWith("Encoding.get_UTF8()")) { name = name.Substring(31, name.Length - 32); } name = name.Substring(name.IndexOf(".get_") + 5); name = name.Substring(0, name.Length - 2); } return(name); }
// Get all properties from the type we are analyzing. public static List <IRClassProperty> ExtractClassProperties(TypeDefinition _subjectClass, out List <TypeDefinition> references) { // Contains all references (TypeDefinitions) that are referenced by this class. references = new List <TypeDefinition>(); // All properties for the given class. List <IRClassProperty> properties = new List <IRClassProperty>(); // Propertye != field; see SilentOrbitInspector.ExtractClassproperties(..) foreach (var property in _subjectClass.Properties) { // Default to OPTIONAL label. The Google protobuffer compiler is written for // proto3 syntax, which does not allow REQUIRED. // Everything is implicitly OPTIONAL, but OPTIONAL fields who have the default value // will not be written onto the wire. // CARE MUST BE TAKEN to provide all necessary values when using these decompiled proto files. FieldLabel label = FieldLabel.OPTIONAL; // Each schema related property must have a set method, but repeated fields don't have // a set method. We must figure out if the property is lib related or schema related! if (property.SetMethod == null) { // Repeated field have propertyType RepeatedField<X>. if (property.PropertyType.Name.Contains("RepeatedField") == true && property.PropertyType.IsGenericInstance) { // This field must be analyzed. label = FieldLabel.REPEATED; } else { continue; } } // Object which the current property references. TypeDefinition refDefinition; // Field options (directly related to protobuf schema) IRClassProperty.ILPropertyOptions opts = new IRClassProperty.ILPropertyOptions(); // Add label to the property options. opts.Label = label; // Fetch the IR type of the property. - Doesn't actually matter, the Serialize handler will overwrite this. PropertyTypeKind propType = InspectorTools.DefaultTypeMapper(property, out refDefinition); // Construct IR reference placeholder. IRTypeNode irReference = null; if (propType == PropertyTypeKind.TYPE_REF) { irReference = InspectorTools.ConstructIRType(refDefinition); // And save the reference TYPEDEFINITION for the caller to process. references.Add(refDefinition); } // Fetch the fieldNumber for this property. var tag = ExtractFieldNumber(_subjectClass, property.Name); // Add it to the options. opts.PropertyOrder = tag; // Construct the IR property and store it. var prop = new IRClassProperty() { Name = property.Name, Type = propType, ReferencedType = irReference, Options = opts, }; properties.Add(prop); } return(properties); }
public virtual QueryParser GetQueryParser() { return(new QueryParser(LuceneIndexDefaults.IndexVersion, FieldLabel.ToString(), Analyzer)); }
protected override void CreateChildControls() { SPList targetList = _targetLibrary; if (targetList != null) { using(SPWeb web = targetList.ParentWeb.Site.OpenWeb(targetList.ParentWeb.ID)) { SPFieldCollection listFields = targetList.Fields; foreach (SPField listField in listFields) { if (listField.Hidden || !listField.ShowInVersionHistory) { continue; } if ((false == listField.ReadOnlyField)) { // create label container Label labelContainer = new Label(); // create the list form FieldLabel FieldLabel fieldLabel = new FieldLabel(); fieldLabel.FieldName = listField.InternalName; fieldLabel.ListId = targetList.ID; //always a new item fieldLabel.ControlMode = SPControlMode.New; labelContainer.Controls.Add(fieldLabel); // create the input field from the list BaseFieldControl fieldControl = listField.FieldRenderingControl; fieldControl.ListId = targetList.ID; fieldControl.ID = string.Format("Field_{0}", listField.InternalName); fieldControl.EnableViewState = true; //always a new item fieldControl.ControlMode = SPControlMode.New; fieldLabel.RenderContext = SPContext.GetContext(this.Context); fieldControl.RenderContext = SPContext.GetContext(this.Context); // associate the label control with the input control labelContainer.AssociatedControlID = fieldControl.ID; fieldControl.DisableInputFieldLabel = false; fieldControl.InputFieldLabel = listField.Title; listPanelContainer.Controls.Add(labelContainer); listPanelContainer.Controls.Add(fieldControl); _fieldControls.Add(fieldControl); } } } } System.Web.UI.WebControls.LinkButton submitPhotoButton = new System.Web.UI.WebControls.LinkButton(); submitPhotoButton.ID = "PhotoSubmitButton"; submitPhotoButton.Text = "Submit Photo"; submitPhotoButton.CssClass = "submitButton"; submitPhotoButton.Click += new EventHandler(PhotoSubmitButton_OnClick); listPanelContainer.Controls.Add(submitPhotoButton); ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(submitPhotoButton); }