public override ISymbolValue this[DVariable variable] { get { ISymbolValue v; if (Locals.TryGetValue(variable, out v)) return v; // Assign a default value to the variable var t = TypeResolution.TypeDeclarationResolver.HandleNodeMatch(variable, base.ResolutionContext) as MemberSymbol; if (t != null) { if (t.Base is PrimitiveType) v= new PrimitiveValue(0M, t.Base as PrimitiveType); else v = new NullValue(t.Base as DSymbol); } else v = new NullValue(); Locals[variable] = v; return v; } set { if (variable == null) throw new CtfeException("variable must not be null"); Locals[variable] = value; } }
/// <summary> /// Clones the storage returning a new DictionaryStorage object. /// </summary> public override DictionaryStorage Clone() { lock (this) { if (_buckets == null) { if (_nullValue != null) { return new CommonDictionaryStorage(null, 1, _keyType, _hashFunc, _eqFunc, new NullValue(_nullValue.Value)); } return new CommonDictionaryStorage(); } Bucket[] resBuckets = new Bucket[_buckets.Length]; for (int i = 0; i < _buckets.Length; i++) { if (_buckets[i].Key != null) { resBuckets[i] = _buckets[i]; } } NullValue nv = null; if (_nullValue != null) { nv = new NullValue(_nullValue.Value); } return new CommonDictionaryStorage(resBuckets, _count, _keyType, _hashFunc, _eqFunc, nv); } }
private bool TryRemoveNull(out object value) { if (_nullValue != null) { value = _nullValue.Value; _nullValue = null; return true; } else { value = null; return false; } }
private CommonDictionaryStorage(SerializationInfo info, StreamingContext context) { // remember the serialization info, we'll deserialize when we get the callback. This // enables special types like DBNull.Value to successfully be deserialized inside of us. We // store the serialization info in a special bucket so we don't have an extra field just for // serialization _nullValue = new DeserializationNullValue(info); }
void IDeserializationCallback.OnDeserialization(object sender) { DeserializationNullValue bucket = GetDeserializationBucket(); if (bucket == null) { // we've received multiple OnDeserialization callbacks, only // deserialize after the 1st one return; } SerializationInfo info = bucket.SerializationInfo; _buckets = null; _nullValue = null; var buckets = (List<KeyValuePair<object, object>>)info.GetValue("buckets", typeof(List<KeyValuePair<object, object>>)); foreach (KeyValuePair<object, object> kvp in buckets) { Add(kvp.Key, kvp.Value); } NullValue nullVal = (NullValue)info.GetValue("nullvalue", typeof(NullValue)); if (nullVal != null) { _nullValue = new NullValue(nullVal); } }
/// <summary> /// Build tooltip for data row /// </summary> /// <param name="dri">Data row index</param> /// <returns></returns> internal SuperToolTip BuildDataRowTooltip( TooltipDimensionDef ttDim, int dri) { ColumnMapMsx cm; QueryTable qt; QueryColumn qc; MetaTable mt; MetaColumn mc; int i1, i2; if (BaseQuery == null || BaseQuery.Tables.Count == 0 || Dtm == null) { return(null); } qt = BaseQuery.Tables[0]; SuperToolTip s = new SuperToolTip(); s.MaxWidth = 200; s.AllowHtmlText = DefaultBoolean.True; ToolTipItem i = new ToolTipItem(); i.AllowHtmlText = DefaultBoolean.True; i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; ColumnMapCollection cml2 = new ColumnMapCollection(); // list of fields we'll actually display int strPos = -1; ColumnMapCollection cml = ttDim.Fields; if (cml.Count == 0) { return(s); } for (i1 = 0; i1 < cml.Count; i1++) { cm = cml[i1]; qc = cm.QueryColumn; if (qc == null || !cm.Selected) { continue; } //if (qc.IsKey) continue; if (qc.MetaColumn.DataType == MetaColumnType.Structure) { strPos = i1; } for (i2 = 0; i2 < cml2.Count; i2++) // see if already have the column { if (qc == cml2[i2].QueryColumn) { break; } } if (i2 < cml2.Count) { continue; } cml2.Add(cm); } if (cml2.Count == 0) { return(null); // no fields } if (strPos < 0 && ttDim.IncludeStructure) { // include str if requested & not already included qc = qt.FirstStructureQueryColumn; strPos = cml2.Count; // put str at end //strPos = keyPos + 1; // place str after key if (qc != null && qc.Selected) // regular selected Qc? { cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc)); } else // look in root table for a structure { mt = qt.MetaTable.Root; if (mt.FirstStructureMetaColumn != null) { qt = new QueryTable(mt); qc = new QueryColumn(); // add qc with no vo pos as indicator that must be selected qc.MetaColumn = mt.FirstStructureMetaColumn; qc.Selected = true; qt.AddQueryColumn(qc); cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc)); } } } string keyVal = ""; foreach (ColumnMapMsx fli0 in cml2.ColumnMapList) // format each field { qc = fli0.QueryColumn; mc = qc.MetaColumn; i.Text += "<b>"; // build label if (!Lex.IsNullOrEmpty(fli0.ParameterName)) { i.Text += fli0.ParameterName; } else { i.Text += fli0.QueryColumn.ActiveLabel; } i.Text += ": </b>"; if (qc.VoPosition >= 0) { int ti = qc.QueryTable.TableIndex; int dri2 = Dtm.AdjustDataRowToCurrentDataForTable(dri, ti, true); DataRowMx dr = Qm.DataTable.Rows[dri2]; if (dr == null) { continue; } ResultsTable rt = Rf.Tables[ti]; object fieldValue = dr[qc.VoPosition]; if (!NullValue.IsNull(fieldValue)) { if (qc.IsKey) { keyVal = fieldValue.ToString(); } MobiusDataType mdt = MobiusDataType.ConvertToMobiusDataType(qc.MetaColumn.DataType, fieldValue); FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatField(qc, mdt); if (mc.DataType != MetaColumnType.Structure) { i.Text += ffi.FormattedText; i.Text += "<br>"; } else { i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap); } } else { i.Text += "<br>"; // no data } } else if (!Lex.IsNullOrEmpty(keyVal)) // select structure from db (may already have) { MoleculeMx cs = MoleculeUtil.SelectMoleculeForCid(keyVal, qc.MetaColumn.MetaTable); if (cs != null) { int width = ResultsFormatFactory.QcWidthInCharsToDisplayColWidthInMilliinches(mc.Width, ResultsFormat); FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatStructure(cs, new CellStyleMx(), 's', 0, width, -1); i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap); } } } if (i.Text.Length > 0) { s.Items.Add(i); } if (s.Items.Count == 0) { // show something by default i = new ToolTipItem(); i.Text = "No fields selected"; i.LeftIndent = 6; i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; s.Items.Add(i); } //ToolTipTitleItem ti = new ToolTipTitleItem(); //ti.Text = "Dude"; //s.Items.Add(ti); //ToolTipItem i = new ToolTipItem(); //i.Text = "Subtext that is fairly long longer longest"; //i.LeftIndent = 6; //i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; //s.Items.Add(i); //i = new ToolTipItem(); //Image img = Bitmap.FromFile(@"C:\Mobius_OpenSource\Mobius-3.0\ClientComponents\Resources\Mobius76x76DkBlueBack.bmp"); //i.Image = img; //s.Items.Add(i); //ToolTipSeparatorItem si = new ToolTipSeparatorItem(); return(s); //ChartPanel.ToolTipController.ToolTipLocation = ToolTipLocation.TopCenter; //ChartPanel.ToolTipController.AllowHtmlText = true; //string s = point.SeriesPointID.ToString(); //s = "This <b>SuperToolTip</b> supports <i>HTML formatting</i>"; }
/// <summary cref="IValueVisitor.Visit(NullValue)"/> public void Visit(NullValue value) => CodeGenerator.GenerateCode(value);
/// <summary> /// Assign class to result /// </summary> /// <returns></returns> StringMx AssignClass() { if (Vo == null || ActivityClassVoi < 0) { return(null); } StringMx sx = new StringMx(); try { Vo[ActivityClassVoi] = null; if (NullValue.IsNull(ValNbr) && NullValue.IsNull(ValTxt)) { return(null); // need a numeric or text value } if (NullValue.IsNull(MethodId)) { throw new Exception("MethodId not defined"); } if (NullValue.IsNull(ResultTypeId)) { throw new Exception("ResultTypeId not defined"); } string actClass = ""; // Default SP/CRC activity class assignment if (NullValue.IsNull(ValNbr)) { return(null); // valid for numeric results only } // SP if (Lex.Eq(ResultSpCrc, "SP")) { if (Lex.Eq(ValPrefix, "<")) { actClass = "Fail"; } else if (ValNbr < 70) { actClass = "Fail"; } else if (ValNbr < 90) { actClass = "BorderLine"; } else if (ValNbr >= 90) { actClass = "Pass"; } } // CRC else if (Lex.Eq(ResultSpCrc, "CRC")) { double factor = 1.0; // normalize to uM units if (Lex.Eq(Units, "uM")) { factor = 1; } else if (Lex.Eq(Units, "mM")) { factor = 1000; } else if (Lex.Eq(Units, "nM")) { factor = 0.001; } else { return(null); } double v = ValNbr * factor; if (Lex.Eq(ValPrefix, ">")) { actClass = "Fail"; } else if (v > 5) { actClass = "Fail"; } else if (v > 0.1) { actClass = "BorderLine"; } else { actClass = "Pass"; } } else { return(null); } sx.Value = actClass; //todo: apply coloring... } catch (Exception ex) // if exception, store exception message in class result { sx = new StringMx(); sx.Value = ex.Message; } Vo[ActivityClassVoi] = sx; // store class info return(sx); }
public void Visit(NullValue value) { }
public static IJsonValue Wrap(object value) { if (value is JValue) { value = ((JValue)value).Value; } FieldDataType dataType = JSONType.GetJSONType(value); IJsonValue jsonValue = null; switch (dataType) { case FieldDataType.Array: var values = new List <IJsonValue>(); if (value is System.Collections.ArrayList) { var array = (System.Collections.ArrayList)value; foreach (var obj in array) { values.Add(Wrap(obj)); } } else { var array = (Array)value; foreach (var obj in array) { values.Add(Wrap(obj)); } } jsonValue = new ArrayJsonValue(values.ToArray()); break; case FieldDataType.Bool: jsonValue = new BooleanJsonValue((bool)value); break; case FieldDataType.DateTime: jsonValue = new DateTimeJsonValue((DateTime)value); break; case FieldDataType.Null: jsonValue = new NullValue(); break; case FieldDataType.Number: jsonValue = new NumberJsonValue(value); break; case FieldDataType.Object: if (value.GetType() == typeof(JArray)) { var arr = (JArray)value; var vals = new List <IJsonValue>(); foreach (var obj in arr) { vals.Add(Wrap(obj)); } jsonValue = new ArrayJsonValue(vals.ToArray()); } else if (value.GetType() == typeof(IJsonValue[])) { var arr = (IJsonValue[])value; //var vals = new List<IJsonValue>(); //foreach (var obj in arr) //{ // vals.Add(Wrap(obj)); //} jsonValue = new ArrayJsonValue(arr); //vals.ToArray()); } else { jsonValue = new ObjectJsonValue(Serialize(value)); } break; case FieldDataType.String: jsonValue = new StringJsonValue((string)value); break; } return(jsonValue); }
/// <summary> /// Create a field base from a fieldinfo object /// Verify the settings against the actual field to ensure it will work. /// </summary> /// <param name="fi">Field Info Object</param> protected FieldBase(FieldInfo fi, string delimiter) : this() { FieldInfo = fi; FieldType = FieldInfo.FieldType; MemberInfo attibuteTarget = fi; FieldFriendlyName = AutoPropertyName(fi); if (string.IsNullOrEmpty(FieldFriendlyName) == false) { var prop = fi.DeclaringType.GetProperty(FieldFriendlyName); if (prop == null) { FieldFriendlyName = null; } else { IsAutoProperty = true; attibuteTarget = prop; } } FieldTypeInternal = FieldType.IsArray ? FieldType.GetElementType() : FieldType; IsStringField = FieldTypeInternal == typeof(string); var attributes = attibuteTarget.GetCustomAttributes(typeof(FieldConverterAttribute), true); foreach (var attribute in attributes) { var fc = attribute as FieldConverterAttribute; if (fc != null) { fc.Delimiter = delimiter; } #if DEBUG var del = attribute as DelimitedRecordAttribute; if (del != null) { Debug.Assert(del.Delimiter == delimiter); } #endif } if (attributes.Length > 0) { var conv = (FieldConverterAttribute)attributes[0]; Converter = conv.Converter; conv.ValidateTypes(FieldInfo); } else { Converter = ConverterFactory.GetDefaultConverter(FieldFriendlyName ?? fi.Name, FieldType); } if (Converter != null) { if (Converter.Type == null) { throw new ArgumentNullException(nameof(IFieldConverter.Type), $"Converter type [{Converter.GetType().Name}] can not be null!"); } if (Converter.Type != FieldTypeInternal) { throw new TypeMismatchException(Converter.Type, $"{Converter.GetType().Name} destination type {Converter.Type} != expected type {FieldTypeInternal}"); } //Converter.mDestinationType = FieldTypeInternal; } attributes = attibuteTarget.GetCustomAttributes(typeof(FieldNullValueAttribute), true); if (attributes.Length > 0) { NullValue = ((FieldNullValueAttribute)attributes[0]).NullValue; // mNullValueOnWrite = ((FieldNullValueAttribute) attribs[0]).NullValueOnWrite; if (NullValue != null) { if (!FieldTypeInternal.IsAssignableFrom(NullValue.GetType())) { throw new BadUsageException( $"The NullValue is of type: {NullValue.GetType().Name} which is not asignable to the field {FieldInfo.Name} Type: {FieldTypeInternal.Name}"); } } } IsNullableType = FieldTypeInternal.IsValueType && FieldTypeInternal.IsGenericType && FieldTypeInternal.GetGenericTypeDefinition() == typeof(Nullable <>); }
public ObjectValue VisitNullValue(NullValue v) { throw new NotImplementedException(); }
private string PrintNullValue(NullValue node) { return("null"); }
public void SendCommandReport(string id, DateTime startTime, DateTime endTime, string state) { var logData = new Dictionary <string, IValue>(); var encoder = new JsonEncoder(); logData["tag"] = new StringValue("function"); logData["depth"] = new IntValue(1); logData["time"] = new StringValue(startTime.ToString("yyyy-M-d HH:mm:ss")); logData["data"] = new DictionaryValue(_reportDict); var callArgs = new Dictionary <string, IValue>(); IValue value = new DictionaryValue(callArgs); if (!_reportDict.TryGetValue("call_args", out value)) { _reportDict["call_args"] = new DictionaryValue(callArgs); } _reportDict["end_time"] = new DoubleValue(UnixTime(endTime)); _reportDict["start_time"] = new DoubleValue(UnixTime(startTime)); if (_screenshotReport) { var screenLogData = new Dictionary <string, IValue>(); screenLogData["tag"] = new StringValue("function"); screenLogData["depth"] = new IntValue(1); screenLogData["time"] = new StringValue(startTime.ToString("yyyy-M-d HH:mm:ss")); var dataScreen = new Dictionary <string, IValue>(); screenLogData["data"] = new DictionaryValue(dataScreen); var callArgsScreen = new Dictionary <string, IValue>(); dataScreen["call_args"] = new DictionaryValue(callArgsScreen); dataScreen["ret"] = new StringValue(CaptureScreenshot(id, endTime)); dataScreen["start_time"] = new DoubleValue(UnixTime(startTime)); dataScreen["end_time"] = new DoubleValue(UnixTime(endTime)); dataScreen["name"] = new StringValue("try_log_screen"); var screenBytes = encoder.Encode(new DictionaryValue(screenLogData)); string screenResult = Encoding.UTF8.GetString(screenBytes); _reportData.Add(screenResult); _screenshotReport = false; } else { _reportDict["ret"] = new NullValue(); } _reportDict["name"] = new StringValue(id); var bytes = encoder.Encode(new DictionaryValue(logData)); string result = Encoding.UTF8.GetString(bytes); _reportData.Add(result); var reportData = new Dictionary <string, IValue>(); reportData["time"] = new StringValue(startTime.ToString("yyyy-M-d HH:mm:ss")); reportData["name"] = new StringValue($"step_{id,-20}"); var duration = endTime.Subtract(startTime); reportData["duration"] = new StringValue(duration.ToString(@"mm\:ss")); var list = new List <IValue>(); foreach (var arg in _reportArgs) { list.Add(new StringValue(arg.Value)); } reportData["arg"] = new ListValue(list); bytes = encoder.Encode(new DictionaryValue(reportData)); result = Encoding.UTF8.GetString(bytes); string channelStr = "<color=#4EB32D>[STEPS]</color> " + result; Debug.Log(channelStr); _logData.Add(result); }
protected virtual void ExitNullValue(TContext context, NullValue nullValue) { }
public DeleteMethod(DbDao dbDao) { this._dbDao = dbDao; this._list = new List<string>(); this._nullValue = new NullValue(); }
/// <summary> /// The equals. /// </summary> /// <param name="other"> /// The other. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Equals(NullValue other) { return ReferenceEquals(this, other); }
public GetSingleMethod(DbDao dbDao) { this._dbDao = dbDao; this._list = new List <string>(); this._nullValue = new NullValue(); }
/// <summary> /// Creates a new dictionary storage with the given set of buckets /// and size. Used when cloning the dictionary storage. /// </summary> private CommonDictionaryStorage(Bucket[] buckets, int count, Type keyType, Func <object, int> hashFunc, Func <object, object, bool> eqFunc, NullValue nullValue) { _buckets = buckets; _count = count; _keyType = keyType; _hashFunc = hashFunc; _eqFunc = eqFunc; _nullValue = nullValue; }
/// <summary> /// Converts the properties of <paramref name="document"/> into an equivalent /// <see cref="ApplicationValueList"/>. /// </summary> /// <param name="document">The BsonDocument to create an <see cref="ApplicationValueList"/> from.</param> /// <returns>An <see cref="ApplicationValueList"/> equivalent to <paramref name="document"/>.</returns> private ApplicationValueList ToApplicationValueList(BsonDocument document) { ApplicationValueList list = new ApplicationValueList(); foreach (var element in document.Elements) { ApplicationValue value; switch (element.Value.BsonType) { case BsonType.Null: value = new NullValue(); break; case BsonType.Array: value = this.CreateArrayValue(element.Value); break; case BsonType.Document: // Likert value = this.ToApplicationValueListArrayValue(new List<BsonDocument> { element.Value as BsonDocument }); break; default: // TODO: Handle signature pad. value = new StringValue { Value = element.Value.AsString }; break; } value.Field = element.Name; list.Add(value); } return list; }
private void FindNext_Click(object sender, EventArgs e) { string findText, cellText; bool matches; string s = FindText.Text.Trim(); if (s == "") { return; } if (InFindNext_Click) { return; // avoid recursion } InFindNext_Click = true; if (MatchCase.Checked) { findText = s; } else { findText = s.ToLower(); } int startRow = Grid.Row; // where we are now if (startRow < 0) { startRow = 0; } int startCol = Grid.Col; if (startCol < 0) { startCol = 0; } int row = startRow; // where we will start to search int col = startCol; Progress.Text = "Searching row " + row.ToString() + "..."; Progress.Visible = true; FindNext.Enabled = false; CloseButton.Text = "Cancel"; int t0 = TimeOfDay.Milliseconds(); bool [] checkColumn = new bool[Grid.V.Columns.Count]; // get list of columns to check for (int ci = 0; ci < Grid.V.Columns.Count; ci++) { GridColumn gc = Grid.V.Columns[ci]; ColumnInfo cInf = Grid.GetColumnInfo(gc); if (cInf == null || cInf.Mc == null || cInf.Mc.IsGraphical) { checkColumn[ci] = false; } else { checkColumn[ci] = true; } } int iteration = -1; // Loop through grid checking cells while (true) { iteration++; if (iteration > 0 && row == startRow && col == startCol) { // if back at start then not found MessageBoxMx.Show(UmlautMobius.String + " cannot find the data you're searching for.", UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Information); break; } if (!Visible) { break; // cancelled by user } col++; // go to next column if (col >= Grid.V.Columns.Count) { col = 1; // start at 1st col past check mark col row++; if (TimeOfDay.Milliseconds() - t0 > 500) // update display periodically { Progress.Text = "Searching row " + row.ToString() + "..."; this.Refresh(); Application.DoEvents(); t0 = TimeOfDay.Milliseconds(); } } if (row >= Grid.V.RowCount) // past end of grid? { if (Dtm.RowRetrievalComplete) // end of grid & have all data { row = col = 0; // cycle back to top } else // need to read more data { int chunkSize = 100; Dtm.StartRowRetrieval(chunkSize); Progress.Text = "Retrieving data..."; while (true) // loop until requested rows have been read, no more rows or cancel requested { Thread.Sleep(250); Application.DoEvents(); if (row < Grid.V.RowCount) // have data for next row? { break; } else if (Dtm.RowRetrievalState != RowRetrievalState.Running) // must be at end of query { row = 0; break; } else if (!Visible) // cancelled by user { Progress.Text = ""; FindNext.Enabled = true; CloseButton.Text = "Close"; InFindNext_Click = false; return; } } Progress.Text = "Searching row " + row.ToString() + "..."; // restore search message } } if (!checkColumn[col]) { continue; } object vo = Grid[row, col]; if (NullValue.IsNull(vo)) { continue; } else if (vo is MobiusDataType && (vo as MobiusDataType).FormattedText != null) { cellText = (vo as MobiusDataType).FormattedText; // use existing formatted value } else // need to format value { CellInfo cInf = Grid.GetCellInfo(row, col); cellText = Grid.Helpers.FormatFieldText(cInf); } if (String.IsNullOrEmpty(cellText)) { continue; } if (!MatchCase.Checked) { cellText = cellText.ToLower(); } if (MatchEntireCell.Checked) { matches = (cellText == findText); } else { matches = (cellText.IndexOf(findText) >= 0); } if (matches) { //Grid.Focus(); Grid.SelectCell(row, col); Grid.FocusCell(row, col); // put focus on cell found, may cause scroll event Grid.NotFocusedRowToHighlight = row; Grid.NotFocusedColToHighlight = col; // Reposition search box out of the way if necessary (above current cell) Rectangle findRect = // rectangle for find dialog new Rectangle(Instance.Left, Instance.Top, Instance.Width, Instance.Height); Rectangle cellRect = Grid.GetCellRect(row, col); // get rectangle relative to control Point p = Grid.PointToScreen(new Point(cellRect.Left, cellRect.Top)); // get coords relative to screen cellRect = new Rectangle(p.X, p.Y, cellRect.Width, cellRect.Height); if (findRect.IntersectsWith(cellRect)) { Instance.Top = cellRect.Top - Instance.Height - 4; } break; } } Progress.Text = ""; FindNext.Enabled = true; CloseButton.Text = "Close"; InFindNext_Click = false; return; }
public void ForNull() { this.null_value = NullValue.null_vaule; }
public SCCNullValue(NullValue o, ITree antlr) : base(o, antlr) { }
private void BindPostEdit() { Debug.Assert(PostId != null, "PostId Should not be null when we call this"); SetConfirmation(); Entry entry = GetEntryForEditing(PostId.Value); if (entry == null) { ReturnToOrigin(null); return; } txbTitle.Text = entry.Title; if (!NullValue.IsNull(entry.DateSyndicated) && entry.DateSyndicated > Config.CurrentBlog.TimeZone.Now) { txtPostDate.Text = entry.DateSyndicated.ToString(CultureInfo.CurrentCulture); } VirtualPath entryUrl = Url.EntryUrl(entry); if (entryUrl != null) { hlEntryLink.NavigateUrl = entryUrl; hlEntryLink.Text = entryUrl.ToFullyQualifiedUrl(Config.CurrentBlog).ToString(); hlEntryLink.Attributes.Add("title", "view: " + entry.Title); } else { hlEntryLink.Text = "This post has not been published yet, so it doesn't have an URL"; } PopulateMimeTypeDropDown(); //Enclosures if (entry.Enclosure != null) { Enclosure.Collapsed = false; txbEnclosureTitle.Text = entry.Enclosure.Title; txbEnclosureUrl.Text = entry.Enclosure.Url; txbEnclosureSize.Text = entry.Enclosure.Size.ToString(); if (ddlMimeType.Items.FindByText(entry.Enclosure.MimeType) != null) { ddlMimeType.SelectedValue = entry.Enclosure.MimeType; } else { ddlMimeType.SelectedValue = "other"; txbEnclosureOtherMimetype.Text = entry.Enclosure.MimeType; } ddlAddToFeed.SelectedValue = entry.Enclosure.AddToFeed.ToString().ToLower(); ddlDisplayOnPost.SelectedValue = entry.Enclosure.ShowWithPost.ToString().ToLower(); } chkComments.Checked = entry.AllowComments; chkCommentsClosed.Checked = entry.CommentingClosed; SetCommentControls(); if (entry.CommentingClosedByAge) { chkCommentsClosed.Enabled = false; } chkDisplayHomePage.Checked = entry.DisplayOnHomePage; chkMainSyndication.Checked = entry.IncludeInMainSyndication; chkSyndicateDescriptionOnly.Checked = entry.SyndicateDescriptionOnly; chkIsAggregated.Checked = entry.IsAggregated; // Advanced Options txbEntryName.Text = entry.EntryName; txbExcerpt.Text = entry.Description; SetEditorText(entry.Body); ckbPublished.Checked = entry.IsActive; BindCategoryList(); for (int i = 0; i < cklCategories.Items.Count; i++) { cklCategories.Items[i].Selected = false; } ICollection <Link> postCategories = Repository.GetLinkCollectionByPostId(PostId.Value); if (postCategories.Count > 0) { foreach (Link postCategory in postCategories) { ListItem categoryItem = cklCategories.Items.FindByValue(postCategory.CategoryId.ToString(CultureInfo.InvariantCulture)); if (categoryItem == null) { throw new InvalidOperationException( string.Format(Resources.EntryEditor_CouldNotFindCategoryInList, postCategory.CategoryId, cklCategories.Items.Count)); } categoryItem.Selected = true; } } SetEditorMode(); Advanced.Collapsed = !Preferences.AlwaysExpandAdvanced; var adminMasterPage = Page.Master as AdminPageTemplate; if (adminMasterPage != null) { string title = string.Format(CultureInfo.InvariantCulture, Resources.EntryEditor_EditingTitle, CategoryType == CategoryType.StoryCollection ? Resources.Label_Article : Resources.Label_Post, entry.Title); adminMasterPage.Title = title; } if (entry.HasEntryName) { Advanced.Collapsed = false; txbEntryName.Text = entry.EntryName; } }
/// <summary> /// Creates a new dictionary storage with the given set of buckets /// and size. Used when cloning the dictionary storage. /// </summary> private CommonDictionaryStorage(Bucket[] buckets, int count, Type keyType, Func<object, int> hashFunc, Func<object, object, bool> eqFunc, NullValue nullValue) { _buckets = buckets; _count = count; _keyType = keyType; _hashFunc = hashFunc; _eqFunc = eqFunc; _nullValue = nullValue; }
private void UpdatePost() { DateTime postDate = NullValue.NullDateTime; vCustomPostDate.IsValid = string.IsNullOrEmpty(txtPostDate.Text) || DateTime.TryParse(txtPostDate.Text, out postDate); EnableEnclosureValidation(EnclosureEnabled()); if (Page.IsValid) { string successMessage = Constants.RES_SUCCESSNEW; try { Entry entry; if (PostId == null) { ValidateEntryTypeIsNotNone(EntryType); entry = new Entry(EntryType); } else { entry = GetEntryForEditing(PostId.Value); if (entry.PostType != EntryType) { EntryType = entry.PostType; } } entry.Title = txbTitle.Text; entry.Body = richTextEditor.Xhtml; entry.Author = Config.CurrentBlog.Author; entry.Email = Config.CurrentBlog.Email; entry.BlogId = Config.CurrentBlog.Id; //Enclosure int enclosureId = 0; if (entry.Enclosure != null) { enclosureId = entry.Enclosure.Id; } if (EnclosureEnabled()) { if (entry.Enclosure == null) { entry.Enclosure = new Enclosure(); } Enclosure enc = entry.Enclosure; enc.Title = txbEnclosureTitle.Text; enc.Url = txbEnclosureUrl.Text; enc.MimeType = ddlMimeType.SelectedValue.Equals("other") ? txbEnclosureOtherMimetype.Text : ddlMimeType.SelectedValue; long size; Int64.TryParse(txbEnclosureSize.Text, out size); enc.Size = size; enc.AddToFeed = Boolean.Parse(ddlAddToFeed.SelectedValue); enc.ShowWithPost = Boolean.Parse(ddlDisplayOnPost.SelectedValue); } else { entry.Enclosure = null; } // Advanced options entry.IsActive = ckbPublished.Checked; entry.AllowComments = chkComments.Checked; entry.CommentingClosed = chkCommentsClosed.Checked; entry.DisplayOnHomePage = chkDisplayHomePage.Checked; entry.IncludeInMainSyndication = chkMainSyndication.Checked; entry.SyndicateDescriptionOnly = chkSyndicateDescriptionOnly.Checked; entry.IsAggregated = chkIsAggregated.Checked; entry.EntryName = txbEntryName.Text.NullIfEmpty(); entry.Description = txbExcerpt.Text.NullIfEmpty(); entry.Categories.Clear(); ReplaceSelectedCategoryNames(entry.Categories); if (!NullValue.IsNull(postDate)) { entry.DateSyndicated = postDate; } if (PostId != null) { successMessage = Constants.RES_SUCCESSEDIT; entry.DateModified = Config.CurrentBlog.TimeZone.Now; entry.Id = PostId.Value; var entryPublisher = SubtextContext.ServiceLocator.GetService <IEntryPublisher>(); entryPublisher.Publish(entry); if (entry.Enclosure == null && enclosureId != 0) { Enclosures.Delete(enclosureId); } else if (entry.Enclosure != null && entry.Enclosure.Id != 0) { Enclosures.Update(entry.Enclosure); } else if (entry.Enclosure != null && entry.Enclosure.Id == 0) { entry.Enclosure.EntryId = entry.Id; Enclosures.Create(entry.Enclosure); } UpdateCategories(); } else { var entryPublisher = SubtextContext.ServiceLocator.GetService <IEntryPublisher>(); _postId = entryPublisher.Publish(entry); NotificationServices.Run(entry, Blog, Url); if (entry.Enclosure != null) { entry.Enclosure.EntryId = PostId.Value; Enclosures.Create(entry.Enclosure); } UpdateCategories(); AddCommunityCredits(entry); } } catch (Exception ex) { Messages.ShowError(String.Format(Constants.RES_EXCEPTION, Constants.RES_FAILUREEDIT, ex.Message)); successMessage = string.Empty; } //Prepared success messages were reset in the catch block because of some error on posting the content if (!String.IsNullOrEmpty(successMessage)) { ReturnToOrigin(successMessage); } } }
private void AddNull(object value) { if (_nullValue != null) { _nullValue.Value = value; } else { _nullValue = new NullValue(value); } }
public Binding BindControl(Control control, IColumn column, string property, NullValue nullValue) { return(BindControl(control, column, property, nullValue, Findable.NO)); }
public void Clear() { lock (this) { if (_buckets != null) { _version++; _buckets = new Bucket[8]; _count = 0; } _nullValue = null; } }
public Binding BindControl(Control control, IColumn column, NullValue nullValue, Findable findable) { return(BindControl(control, column, GetProperty(control), nullValue, findable)); }
public override NullValue CreateNullValue(NullValue o, Antlr.Runtime.Tree.ITree antlr) { return new SCCNullValue(o, antlr); }
/// <summary> /// Create a field base from a fieldinfo object /// Verify the settings against the actual field to ensure it will work. /// </summary> /// <param name="fi">Field Info Object</param> internal FieldBase(FieldInfo fi) : this() { FieldInfo = fi; FieldType = FieldInfo.FieldType; MemberInfo attibuteTarget = fi; this.FieldFriendlyName = AutoPropertyName(fi); if (string.IsNullOrEmpty(FieldFriendlyName) == false) { var prop = fi.DeclaringType.GetProperty(this.FieldFriendlyName); if (prop == null) { this.FieldFriendlyName = null; } else { this.IsAutoProperty = true; attibuteTarget = prop; } } if (FieldType.IsArray) { FieldTypeInternal = FieldType.GetElementType(); } else { FieldTypeInternal = FieldType; } IsStringField = FieldTypeInternal == typeof(string); object[] attribs = attibuteTarget.GetCustomAttributes(typeof(FieldConverterAttribute), true); if (attribs.Length > 0) { var conv = (FieldConverterAttribute)attribs[0]; this.Converter = conv.Converter; conv.ValidateTypes(FieldInfo); } else { this.Converter = ConvertHelpers.GetDefaultConverter(FieldFriendlyName ?? fi.Name, FieldType); } if (this.Converter != null) { this.Converter.mDestinationType = FieldTypeInternal; } attribs = attibuteTarget.GetCustomAttributes(typeof(FieldNullValueAttribute), true); if (attribs.Length > 0) { NullValue = ((FieldNullValueAttribute)attribs[0]).NullValue; // mNullValueOnWrite = ((FieldNullValueAttribute) attribs[0]).NullValueOnWrite; if (NullValue != null) { if (!FieldTypeInternal.IsAssignableFrom(NullValue.GetType())) { throw new BadUsageException("The NullValue is of type: " + NullValue.GetType().Name + " that is not asignable to the field " + FieldInfo.Name + " of type: " + FieldTypeInternal.Name); } } } IsNullableType = FieldTypeInternal.IsValueType && FieldTypeInternal.IsGenericType && FieldTypeInternal.GetGenericTypeDefinition() == typeof(Nullable <>); }
/// <summary> /// The equals. /// </summary> /// <param name="nullValue"> /// The null value. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> private bool Equals(NullValue nullValue) { if (nullValue == null) { return false; } return Cardinality == 0; }
/// <summary> /// Create a field base from a fieldinfo object /// Verify the settings against the actual field to ensure it will work. /// </summary> /// <param name="fi">Field Info Object</param> internal FieldBase(FieldInfo fi) { IsNullableType = false; TrimMode = TrimMode.None; FieldOrder = null; InNewLine = false; NextIsOptional = false; IsOptional = false; TrimChars = null; NullValue = null; TrailingArray = false; IsLast = false; IsFirst = false; IsArray = false; CharsToDiscard = 0; FieldInfo = fi; FieldType = FieldInfo.FieldType; if (FieldType.IsArray) { FieldTypeInternal = FieldType.GetElementType(); } else { FieldTypeInternal = FieldType; } IsStringField = FieldTypeInternal == typeof(string); object[] attribs = fi.GetCustomAttributes(typeof(FieldConverterAttribute), true); if (attribs.Length > 0) { var conv = (FieldConverterAttribute)attribs[0]; this.Converter = conv.Converter; conv.ValidateTypes(FieldInfo); } else { this.Converter = ConvertHelpers.GetDefaultConverter(fi.Name, FieldType); } if (this.Converter != null) { this.Converter.mDestinationType = FieldTypeInternal; } attribs = fi.GetCustomAttributes(typeof(FieldNullValueAttribute), true); if (attribs.Length > 0) { NullValue = ((FieldNullValueAttribute)attribs[0]).NullValue; // mNullValueOnWrite = ((FieldNullValueAttribute) attribs[0]).NullValueOnWrite; if (NullValue != null) { if (!FieldTypeInternal.IsAssignableFrom(NullValue.GetType())) { throw new BadUsageException("The NullValue is of type: " + NullValue.GetType().Name + " that is not asignable to the field " + FieldInfo.Name + " of type: " + FieldTypeInternal.Name); } } } IsNullableType = FieldTypeInternal.IsValueType && FieldTypeInternal.IsGenericType && FieldTypeInternal.GetGenericTypeDefinition() == typeof(Nullable <>); }
private static IRValueNode CreateConstant(ParseContext context) { TokenStream<RToken> tokens = context.Tokens; RToken currentToken = tokens.CurrentToken; IRValueNode term = null; switch (currentToken.TokenType) { case RTokenType.NaN: case RTokenType.Infinity: case RTokenType.Number: term = new NumericalValue(); break; case RTokenType.Complex: term = new ComplexValue(); break; case RTokenType.Logical: term = new LogicalValue(); break; case RTokenType.String: term = new StringValue(); break; case RTokenType.Null: term = new NullValue(); break; case RTokenType.Missing: term = new MissingValue(); break; } Debug.Assert(term != null); term.Parse(context, null); return term; }
public ColumnComboBox() { InitializeComponent(); columnNullValues.Collection = NullValue.GetValues(NullValueText); }