private PhpValue(TypeTable type) { _type = type; _value = default(ValueField); _obj = null; Debug.Assert(IsNull || !IsSet); }
public void MapFields(string[] fields) { if (fields == null || fields.Length == 0) { ResetMap(); } else { indexMaps = new int[fields.Length]; names = fields; // 对照 for (int i = 0; i < fields.Length; i++) { if (KeyField.Equals(fields[i])) { indexMaps[i] = 0; } else if (ValueField.Equals(fields[i])) { indexMaps[i] = 1; } else { indexMaps[i] = -1; } } } }
/// <summary>Serializes value type sequences accessible through <see cref="IEnumerable{T}"/> /// using the default <see cref="Field{T, F}"/> instance registered for that type.</summary> /// <typeparam name="T">Type of sequence elements - must be value type.</typeparam> /// <param name="value"><see cref="IEnumerable{T}"/> sequence to serialize.</param> /// <returns>A properly initialized <see cref="DbEntry"/> instance containing /// the serialized collection.</returns> public DbEntry ValuesToDbEntry <T>(IEnumerable <T> value) where T : struct { ValueField <T, Formatter> field = (ValueField <T, Formatter>)GetField <T>(); return(ValuesToDbEntry(value, field)); }
/// <summary>Deserializes a nullable value type from a <see cref="DbEntry"/> instance /// using the default <see cref="Field{T, F}"/> instance registered for that type.</summary> /// <typeparam name="T">Value type to deserialize.</typeparam> /// <param name="entry"><see cref="DbEntry"/> instance containing the serialized data.</param> /// <returns>Deserialized struct instance, or <c>null</c>.</returns> public T?FromDbEntry <T>(ref DbEntry entry) where T : struct { ValueField <T, Formatter> field = (ValueField <T, Formatter>)GetField <T>(); return(FromDbEntry(ref entry, field)); }
/// <summary>Serializes a value type into a <see cref="DbEntry"/> instance /// using the default <see cref="Field{T, F}"/> instance registered for that type.</summary> /// <remarks>Passing the value type by reference avoids copy overhead. /// However, this does not allow to pass <c>nulls</c>. Therefore the companion /// method <see cref="NullToDbEntry"/> is provided.</remarks> /// <typeparam name="T">Value type to serialize.</typeparam> /// <param name="value">Struct instance to serialize.</param> /// <returns>A properly initialized <see cref="DbEntry"/> instance containing /// the serialized object graph.</returns> public DbEntry ToDbEntry <T>(ref T value) where T : struct { ValueField <T, Formatter> field = (ValueField <T, Formatter>)GetField <T>(); return(ToDbEntry(ref value, field)); }
private PhpValue(PhpString.Blob blob) { Debug.Assert(blob != null); _type = TypeTable.MutableStringTable; _value = default(ValueField); _obj = blob; }
/// <summary> /// 得到选项值 /// </summary> /// <param name="valueField"></param> /// <param name="dictionary"></param> /// <returns></returns> private string GetOptionValue(ValueField valueField, Model.Dictionary dictionary) { string value = string.Empty; switch (valueField) { case ValueField.Id: value = dictionary.Id.ToString(); break; case ValueField.Code: value = dictionary.Code; break; case ValueField.Note: value = dictionary.Note; break; case ValueField.Other: value = dictionary.Other; break; case ValueField.Title: value = GetLanguageTitle(dictionary, Tools.GetCurrentLanguage()); break; case ValueField.Value: value = dictionary.Value; break; } return(value ?? string.Empty); }
public async Task <List <int> > GetSponsorIdsAsync(IEnumerable <Select2Option> sponsors) { var sponsorIds = new List <int>(); if (sponsors == null) { return(sponsorIds); } foreach (var sponsor in sponsors) { int.TryParse(sponsor.Id, out int sponsorId); if (sponsorId > 0) { sponsorIds.Add(sponsorId); } else { var valueField = new ValueField { TypeId = ValueFieldTypes.SPONSORS, Name = sponsor.Text, Description = sponsor.Desc }; await _valueFieldsRepository.AddAsync(valueField); sponsorIds.Add(valueField.Id); } } return(sponsorIds); }
private PhpValue(PhpArray array) { Debug.Assert(array != null); _type = TypeTable.ArrayTable; _value = default(ValueField); _obj = array; }
/// <summary>Deserializes a value type from a <see cref="DbEntry"/> instance /// using the default <see cref="Field{T, F}"/> instance registered for that type.</summary> /// <remarks>Passing the value type by reference avoids copy overhead.</remarks> /// <typeparam name="T">Value type to deserialize.</typeparam> /// <param name="value">Struct instance to deserialize.</param> /// <param name="isNull">Returns <c>true</c> if a <c>null</c> is deserialized, /// in which case the <c>value</c> parameter is ignored.</param> /// <param name="entry"><see cref="DbEntry"/> instance containing the serialized data.</param> public void FromDbEntry <T>(ref T value, out bool isNull, ref DbEntry entry) where T : struct { ValueField <T, Formatter> field = (ValueField <T, Formatter>)GetField <T>(); FromDbEntry(ref value, out isNull, ref entry, field); }
/// <summary> /// 得到radio或checkbox选项 /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="type">0 radio 1 checkbox</param> /// <param name="valueField"></param> /// <param name="value"></param> /// <param name="attr"></param> /// <param name="isAllChild"></param> /// <returns></returns> private string GetRadioOrCheckBox(Guid id, string name, int type, ValueField valueField = ValueField.Id, string value = "", string attr = "", bool isAllChild = false) { if (id.IsEmptyGuid()) { return(""); } var childs = isAllChild ? GetAllChilds(id) : GetChilds(id); StringBuilder options = new StringBuilder(childs.Count * 60); foreach (var child in childs) { string value1 = GetOptionValue(valueField, child); options.Append("<input type=\"" + (0 == type ? "radio" : "checkbox") + "\" value=\"" + value1 + "\""); if (value1.Equals(value)) { options.Append(" checked=\"checked\""); } options.Append(" id=\"" + name + "_" + child.Id.ToString("N") + "\" name=\"" + name + "\""); if (!attr.IsNullOrWhiteSpace()) { options.Append(" " + attr); } options.Append(" style=\"vertical-align:middle\"/>"); options.Append("<label style=\"vertical-align:middle\" for=\"" + name + "_" + child.Id.ToString("N") + "\">" + GetLanguageTitle(child) + "</label>"); } return(options.ToString()); }
protected void PerformSelectAction() { // https://stackoverflow.com/questions/34922331/getting-and-setting-cursor-position-of-uitextfield-and-uitextview-in-swift UITextPosition start = ValueField.BeginningOfDocument; UITextPosition end = ValueField.EndOfDocument; switch (_EntryCell.OnSelectAction) { case AiEntryCell.SelectAction.None: break; case AiEntryCell.SelectAction.Start: ValueField.SelectedTextRange = ValueField.GetTextRange(start, start); ValueField.Select(ValueField); break; case AiEntryCell.SelectAction.End: ValueField.SelectedTextRange = ValueField.GetTextRange(end, end); ValueField.Select(ValueField); break; case AiEntryCell.SelectAction.All: ValueField.SelectedTextRange = ValueField.GetTextRange(start, end); ValueField.Select(ValueField); //ValueField.SelectAll(ValueField); break; default: throw new ArgumentOutOfRangeException(); } }
internal void HandleValueField(ValueField valueField, IPropertySymbol property, ImmutableArray <AttributeData> propertyAttributes) { AddKeyAttribute(property, propertyAttributes, valueField); AddIndexAttribute(property, propertyAttributes, valueField); AddMaxLengthAttribute(property, propertyAttributes, valueField); AddDatabaseGeneratedAttribute(property, propertyAttributes, valueField); }
public virtual void CreateControlProperties(CodeWriter output, ClassFolder folder, bool instantiate, bool enableViewState, string addControlFormat) { foreach (object item in folder.Items) { if (item is ValueField) { ValueField f = (ValueField)item; f.Builder.CreateControlProperties(output, f, instantiate, enableViewState, addControlFormat); output.WriteLine(); } else if (item is ReferenceField) { ReferenceField f = (ReferenceField)item; f.Builder.CreateControlProperties(output, f, instantiate, enableViewState, addControlFormat); output.WriteLine(); } else if (item is EnumField) { EnumField f = (EnumField)item; f.Builder.CreateControlProperties(output, f, instantiate, enableViewState, addControlFormat); output.WriteLine(); } } }
public Action BuildSearchLogix(RefID query) { Slot logix = mainSlot.AddSlot("Search logix"); Network.GET_String getString = logix.AttachComponent <Network.GET_String>(); ValueRegister <string> url = logix.AttachComponent <ValueRegister <string> >(); url.Value.Value = "https://better-lightning-crate.glitch.me/"; FormatString formatString = logix.AttachComponent <FormatString>(); ValueField <string> type = logix.AttachComponent <ValueField <string> >(); ValueField <string> format = logix.AttachComponent <ValueField <string> >(); format.Value.Value = "{0}/{1}/{2}"; formatString.Format.Value = format.Value.ReferenceID; formatString.Parameters.Add(); formatString.Parameters.Add(); formatString.Parameters.Add(); formatString.Parameters[0].Value = url.Value.ReferenceID; formatString.Parameters[1].Value = type.Value.ReferenceID; formatString.Parameters[2].Value = query; getString.URL.Value = formatString.Str.ReferenceID; Actions.WriteValueNode <string> writeResponse = logix.AttachComponent <Actions.WriteValueNode <string> >(); ValueRegister <string> response = logix.AttachComponent <ValueRegister <string> >(); searchResponse = response; writeResponse.Value.Value = getString.Content.ReferenceID; writeResponse.Target.Value = response.Value.ReferenceID; getString.OnResponse.Target = writeResponse.Write; //writeResponse.Target.OwnerNode.RemoveAllLogixBoxes(); //LogixHelper.MoveUnder(writeResponse.Target.OwnerNode, logix, true); //getString.Request(); return(getString.Request); }
/// <summary>Deserializes any kind of nullable value type collection through call-backs /// using the default <see cref="Field{T, F}"/> instance registered for that type.</summary> /// <typeparam name="T">Type of sequence elements - must be value type.</typeparam> /// <param name="initSequence">Call-back delegate to instantiate/initialize collection. /// Returns another delegate to add sequence elements to the collection.</param> /// <param name="entry"><see cref="DbEntry"/> instance containing the serialized data.</param> public void ValuesFromDbEntry <T>(InitSequence <T?> initSequence, ref DbEntry entry) where T : struct { ValueField <T, Formatter> field = (ValueField <T, Formatter>)GetField <T>(); ValuesFromDbEntry(initSequence, ref entry, field); }
/// <summary>Deserializes arrays of nullable value types from a <see cref="DbEntry"/> instance /// using the default <see cref="Field{T, F}"/> instance registered for that type.</summary> /// <typeparam name="T">Type of sequence elements - must be value type.</typeparam> /// <param name="value">Value type to deserialize. Passed by reference /// to avoid copying overhead - suitable for large value types.</param> /// <param name="entry"><see cref="DbEntry"/> instance containing the serialized data.</param> public void ValuesFromDbEntry <T>(ref T?[] value, ref DbEntry entry) where T : struct { ValueField <T, Formatter> field = (ValueField <T, Formatter>)GetField <T>(); ValuesFromDbEntry(ref value, ref entry, field); }
//საქონლის ძებნა კოდით private void SearchByCode_Click(object sender, EventArgs e) { try { if (ValueField.Text != "") { dgv1.Rows.Add(); dgv1.Rows[i].Cells[0].Value = ValueField.Text; dgv1.Rows[i].Cells[1].Value = db.Products.FirstOrDefault(x => x.mid.ToString() == ValueField.Text).mname; var uname = db.MUnits.FirstOrDefault(x => x.mucode == (db.Products.FirstOrDefault(z => z.mname == name.ToString()).mid)).muname; dgv1.Rows[i].Cells[2].Value = uname; dgv1.Rows[i].Cells[3].Value = 1; dgv1.Rows[i].Cells[4].Value = db.Products.FirstOrDefault(x => x.mid == Convert.ToInt32(ValueField.Text)).mprice; dgv1.Rows[i].Cells[5].Value = Convert.ToDouble(dgv1.Rows[i].Cells[3].Value) * Convert.ToDouble(dgv1.Rows[i].Cells[4].Value); DocumentSum(); ValueField.Clear(); i++; ValueField.Focus(); } else { MessageBox.Show("შეიყვანეთ კოდი ან შტრიხკოდი და სცადეთ კიდევ ერთხელ", "შეცდომა", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal PhpValue(string value) { Debug.Assert(value != null); _type = TypeTable.StringTable; _value = default(ValueField); _obj = value; }
public void WriteParameterLines(string objectInstance, ValueField f, string commandInstance, bool commentsEnabled, string sprocPrefix) { if (commentsEnabled) { WriteLine("// {0} Parameters", f.Name); } if (f.IsNullable & f.ValueType.NullValue != string.Empty) { WriteLine("if({0}.{1} == {2})", objectInstance, f.PrivateName, f.ValueType.NullValue); Indent++; WriteLine("{0}.Parameters.Add(\"{1}{2}\", {3}).Value = DBNull.Value;", commandInstance, sprocPrefix, f.Name, f.ValueType.DotNetDbType); Indent--; WriteLine("else"); Indent++; WriteLine("{0}.Parameters.Add(\"{1}{2}\", {3}).Value = {4}.{5};", commandInstance, sprocPrefix, f.Name, f.ValueType.DotNetDbType, objectInstance, string.Format(f.ValueType.DataWriterFormat, f.PrivateName)); Indent--; } else { WriteLine("{0}.Parameters.Add(\"{1}{2}\", {3}).Value = {4}.{5};", commandInstance, sprocPrefix, f.Name, f.ValueType.DotNetDbType, objectInstance, string.Format(f.ValueType.DataWriterFormat, f.PrivateName)); } }
public static BaseSegment SetSegmentOrdinal(this BaseSegment segment, int?ordinal) { List <BaseField> fieldList = segment.FieldList.ToList(); fieldList[0] = new ValueField(ordinal.HasValue ? ordinal.Value.ToString() : string.Empty, segment.Encoding); //NOTE add logic here if we have other segment types return(new Segment(segment.Encoding, segment.Name, fieldList)); }
private bool OnShouldReturn(UITextField view) { _HasFocus = false; ValueField.ResignFirstResponder(); _EntryCell.SendCompleted(); return(true); }
public void AddValueField(ExpressionBase func, string name, ValueFormat format) { _valueFields[name] = new ValueField { Func = func, Format = format }; }
/// <summary>Deserializes a value type from a <see cref="DbEntry"/> instance /// using a specific <see cref="Field{T, F}"/> instance.</summary> /// <remarks>Passing the value type by reference avoids copy overhead.</remarks> /// <typeparam name="T">Value type to deserialize.</typeparam> /// <param name="value">Struct instance to deserialize.</param> /// <param name="isNull">Returns <c>true</c> if a <c>null</c> is deserialized, /// in which case the <c>value</c> parameter is ignored.</param> /// <param name="entry"><see cref="DbEntry"/> instance containing the serialized data.</param> /// <param name="field"><see cref="ValueField{T, Formatter}"/> instance that /// deserializes the <c>entry</c>argument.</param> public void FromDbEntry <T>(ref T value, out bool isNull, ref DbEntry entry, ValueField <T, Formatter> field) where T : struct { int index = entry.Start; InitDeserialization(entry.Buffer, index); field.Deserialize(ref value, out isNull); index = FinishDeserialization(); }
/// <summary>Deserializes arrays of nullable value types from a <see cref="DbEntry"/> /// instance using a specific <see cref="Field{T, F}"/> instance.</summary> /// <typeparam name="T">Type of sequence elements - must be value type.</typeparam> /// <param name="value">Value type to deserialize. Passed by reference /// to avoid copying overhead - suitable for large value types.</param> /// <param name="entry"><see cref="DbEntry"/> instance containing the serialized data.</param> /// <param name="field"><see cref="ValueField{T, Formatter}"/> instance that /// deserializes the <c>entry</c>argument.</param> public void ValuesFromDbEntry <T>(ref T?[] value, ref DbEntry entry, ValueField <T, Formatter> field) where T : struct { int index = entry.Start; InitDeserialization(entry.Buffer, index); DeserializeValues(ref value, field); index = FinishDeserialization(); }
protected override void OnProcessOutputSchema(MutableObject newSchema) { foreach (var entry in ValueField.GetEntries(newSchema)) { Proportion.SetValue(.5f, entry); } Router.TransmitAllSchema(newSchema); }
public ValueField CreateAutoGeneratedValField(string FieldId) { ValueField vField = new ValueField(); vField.FieldId = FieldId; vField.Values = new FieldValue[1]; vField.Values[0] = new SingleFieldValue(); return(vField); }
public static async Task FetchForeignKeysForViewModelAsync <T>(this GridViewModel <T> result, GenericForeignKeyRepository genericFKRepo) { var keys = typeof(T).GetProperties().Where(e => e.CustomAttributes.Any(y => y.AttributeType.FullName.Contains("RemoteForeignKeyAttribute"))); foreach (var key in keys) { string Repository, Endpoint, IDField, ValueField, Delimiter, Lookup = null; string StringLiteral = "true"; /* * Get Fields from VM required for FK data calls */ Repository = key.GetCustomAttributesData().First().NamedArguments.Where(asd => asd.MemberName == "Repository").Select(u => u.TypedValue.Value).FirstOrDefault() as string; Endpoint = key.GetCustomAttributesData().First().NamedArguments.Where(asd => asd.MemberName == "Endpoint").Select(u => u.TypedValue.Value).FirstOrDefault() as string; IDField = key.GetCustomAttributesData().First().NamedArguments.Where(asd => asd.MemberName == "IDField").Select(u => u.TypedValue.Value).FirstOrDefault() as string; ValueField = key.GetCustomAttributesData().First().NamedArguments.Where(asd => asd.MemberName == "ValueField").Select(u => u.TypedValue.Value).FirstOrDefault() as string; StringLiteral = key.GetCustomAttributesData().First().NamedArguments.Where(asd => asd.MemberName == "StringLiteral").Select(u => u.TypedValue.Value).FirstOrDefault() as string; Delimiter = key.GetCustomAttributesData().First().NamedArguments.Where(asd => asd.MemberName == "Delimiter").Select(u => u.TypedValue.Value).FirstOrDefault() as string; Lookup = key.GetCustomAttributesData().First().NamedArguments.Where(asd => asd.MemberName == "Lookup").Select(u => u.TypedValue.Value).FirstOrDefault() as string; /* * Loop through the filtered dataset and go get the required * remote data using the configuration properties gathered * from above */ foreach (T item in result.Data) { var propertyInfo = item.GetType().GetProperty(key.Name); if (propertyInfo != null && propertyInfo.CanWrite) { var setter = propertyInfo.SetMethod; if (StringLiteral == "true" && IDField != null) { var id = Int32.Parse((item.GetType().GetProperty(IDField).GetValue(item).ToString())); var results = await genericFKRepo.GetGenericForeignKeyByIdAsync(id, Repository, Endpoint); setter.Invoke(item, new object[] { ValueField.ConcatValues(results, Delimiter) }); } if (Lookup == "true" && StringLiteral == "false") { /* * Loop through the filtered dataset and go get the required * remote data using the configuration properties gathered * from above */ var results = await genericFKRepo.GetGenericRemoteLookupsAsync(Repository, Endpoint); setter.Invoke(item, new object[] { ValueField.ConcatValuesForLookup(results, Delimiter, IDField) }); // var a = await genericFKRepo.GetSectionPOCCostCodeByIdObjAsync(id); // setter.Invoke(item, new object[] { a.Value }); } } } } }
public void CreateClassField(CodeWriter output, ValueField f, bool isInternal, bool instantiate) { ValueType vt = typeCache[f.Builder][f.ValueType.Name]; output.WriteLine( (isInternal ? "internal" : "private") + " {0} {1}" + (instantiate ? " = new {0};" : ";"), vt.ProgramType, f.PrivateName); }
private void ViewValueAsCommand_Executed(object sender, ExecutedRoutedEventArgs e) { ValueField field = GetValueField(e.Source); if (field != null) { IList <MetaField> viewValueAsFields = LoadViewValueAsPlugin(); var offset = (uint)_cache.MetaArea.PointerToOffset(field.FieldAddress); MetroViewValueAs.Show(_cache, _buildInfo, _fileManager, viewValueAsFields, offset); } }