public void Calling_DeferRefresh_Inside_BeginInit_EndInite_Does_Not_Calls_Refresh_WhenProviderStateIsUpdated() { ISupportInitialize isi = this.provider; Exception ex = null; try { isi.BeginInit(); using (provider.DeferRefresh()) { this.provider.AddPendingChangeToProvider(); provider.BlockUntilRefreshCompletes(); Assert.AreEqual(0, this.provider.RefreshCallCount); } provider.BlockUntilRefreshCompletes(); Assert.AreEqual(0, this.provider.RefreshCallCount); isi.EndInit(); } catch (Exception e) { ex = e; } Assert.IsNull(ex); Assert.AreEqual(1, this.provider.RefreshCallCount); }
protected virtual void InitializeEditor(IInputEditor activeEditor) { GridCellElement currentCell = this.gridViewElement.CurrentView.CurrentCell; if (currentCell == null) { return; } ISupportInitialize supportInitialize = activeEditor as ISupportInitialize; supportInitialize?.BeginInit(); EventDispatcher eventDispatcher = this.GridViewElement.Template.EventDispatcher; eventDispatcher.SuspendEvent(EventDispatcher.ValueChanging); eventDispatcher.SuspendEvent(EventDispatcher.ValueChanged); currentCell.ColumnInfo.InitializeEditor(activeEditor); activeEditor.Initialize((object)currentCell, currentCell.Value); eventDispatcher.ResumeEvent(EventDispatcher.ValueChanging); eventDispatcher.ResumeEvent(EventDispatcher.ValueChanged); GridViewCellEventArgs args = new GridViewCellEventArgs(currentCell.RowInfo, currentCell.ColumnInfo, activeEditor); this.gridViewElement.Template.EventDispatcher.RaiseEvent <GridViewCellEventArgs>(EventDispatcher.CellEditorInitialized, (object)this, args); if (TelerikHelper.IsMaterialTheme(this.gridViewElement.GridControl.ThemeName)) { BaseInputEditor activeEditor1 = args.ActiveEditor as BaseInputEditor; if (activeEditor1 != null) { activeEditor1.EditorElement.StretchVertically = true; } } supportInitialize?.EndInit(); }
public override void InitializationGuard(XamlType xamlType, object obj, bool begin) { try { ISupportInitialize initialize = obj as ISupportInitialize; if (initialize != null) { if (begin) { initialize.BeginInit(); } else { initialize.EndInit(); } } } catch (Exception exception) { if (CriticalExceptions.IsCriticalException(exception)) { throw; } throw this.CreateException(System.Xaml.SR.Get("InitializationGuard", new object[] { xamlType }), exception); } }
/// <summary> /// Adds the controls to the screensaver form. /// </summary> /// <param name="url">The URL to show</param> private void AddControls(string url) { PreviewKeyDown += HandleCloseEvent; //Create a new fixed web browser var browser = new WebView() { Bounds = Bounds, Dock = DockStyle.Fill }; ISupportInitialize initalisableBrowser = browser; initalisableBrowser.BeginInit(); browser.IsScriptNotifyAllowed = true; browser.Click += HandleCloseEvent; browser.PreviewKeyDown += HandleCloseEvent; browser.DOMContentLoaded += HandleBrowserLoadEvent; browser.ScriptNotify += ScriptNotify; initalisableBrowser.EndInit(); browser.Navigate(new Uri(url)); //Add the controls to the form Controls.Add(browser); }
/// <summary> /// Allow to use using() construct for initialization scope. /// </summary> public static IDisposable InitScope(this ISupportInitialize component) { component.BeginInit(); // ReSharper disable ConvertClosureToMethodGroup return(Disposable.Create(() => component.EndInit())); // ReSharper restore ConvertClosureToMethodGroup }
public override void InitializationGuard(XamlType xamlType, object obj, bool begin) { try { ISupportInitialize supportInit = obj as ISupportInitialize; if (supportInit != null) { if (begin) { supportInit.BeginInit(); } else { supportInit.EndInit(); } } } catch (Exception e) { if (CriticalExceptions.IsCriticalException(e)) { throw; } throw CreateException(SR.Get(SRID.InitializationGuard, xamlType), e); } }
private GlyphRun BuildGlyphRun(int column, int line, char c) { var paddingTop = FontSize / 3; var glyphs = new GlyphRun(); ISupportInitialize isi = glyphs; isi.BeginInit(); glyphs.GlyphTypeface = glyphFace; glyphs.FontRenderingEmSize = FontSize; var chars = new[] { c }; glyphs.Characters = chars; var codePoint = (int)c; var glyphIndex = glyphFace.CharacterToGlyphMap[codePoint]; var glyphWidth = glyphFace.AdvanceWidths[glyphIndex]; glyphs.GlyphIndices = new ushort[] { glyphIndex }; glyphs.AdvanceWidths = new double[] { glyphWidth *FontSize }; _cellWidth = glyphWidth * FontSize; _cellHeight = (glyphFace.Baseline * FontSize) + (paddingTop); glyphs.BaselineOrigin = new Point( glyphWidth * FontSize * column, (glyphFace.Baseline * FontSize * (line + 1)) + (paddingTop * line)); isi.EndInit(); return(glyphs); }
private void Deserialise(object o, Type type, RegistryKey key, bool ignorePropertyErrors) { ISupportInitialize supportInitialize = o as ISupportInitialize; if (supportInitialize != null) { supportInitialize.BeginInit(); } IRegistryKeySerialisable registryKeySerialisable = o as IRegistryKeySerialisable; if (registryKeySerialisable != null && !registryKeySerialisable.BeforeDeserialise(this, key)) { return; } foreach (PropertyInfo propertyInfo in o.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { object[] customAttributes = propertyInfo.GetCustomAttributes(typeof(RegistryValueAttribute), true); if (customAttributes.Length > 0) { string name = ((RegistryValueAttribute)customAttributes[0]).Name ?? propertyInfo.Name; object obj = key.GetValue(name); if (obj != null) { try { if (!propertyInfo.PropertyType.IsAssignableFrom(obj.GetType())) { obj = Convert.ChangeType(obj, propertyInfo.PropertyType); } propertyInfo.SetValue(o, obj, (object[])null); } catch (Exception ex) { if (!ignorePropertyErrors) { throw; } else { Trace.TraceError("Error converting property {0}.{1}: {2} Registry key is: {3}, Value is: {4}", (object)type.FullName, (object)propertyInfo.Name, (object)ex.Message, (object)key.Name, (object)obj.ToString()); } } } } else if (propertyInfo.GetCustomAttributes(typeof(RegistryKeyNameAttribute), true).Length > 0) { propertyInfo.SetValue(o, (object)key.Name.Substring(key.Name.LastIndexOf('\\') + 1), (object[])null); } } if (registryKeySerialisable != null) { registryKeySerialisable.AfterDeserialise(this, key); } if (supportInitialize == null) { return; } supportInitialize.EndInit(); }
public static object FromStream(object message, MemoryStream stream) { // 这个message可以从池中获取,减少gc ((Google.Protobuf.IMessage)message).MergeFrom(stream.GetBuffer(), (int)stream.Position, (int)stream.Length); ISupportInitialize iSupportInitialize = message as ISupportInitialize; iSupportInitialize?.EndInit(); return(message); }
public static object FromStream(Type type, MemoryStream stream) { object message = Activator.CreateInstance(type); ((Google.Protobuf.IMessage)message).MergeFrom(stream.GetBuffer(), (int)stream.Position, (int)stream.Length); ISupportInitialize iSupportInitialize = message as ISupportInitialize; iSupportInitialize?.EndInit(); return(message); }
public static object FromBytes(object instance, byte[] bytes, int index, int count) { object message = instance; ((Google.Protobuf.IMessage)message).MergeFrom(bytes, index, count); ISupportInitialize iSupportInitialize = message as ISupportInitialize; iSupportInitialize?.EndInit(); return(message); }
protected override void OnDispose(bool inIsDisposing) { if (inIsDisposing) { if (_supportInitialize != null) { _supportInitialize.EndInit(); } } }
public void Dispose() { _supportInitialize.EndInit(); // ReSharper disable once SuspiciousTypeConversion.Global if (_supportInitialize is Freezable freezable) { freezable.Freeze(); } }
protected override void InitializeEditor( BaseListViewVisualItem visualItem, ISupportInitialize initializable, IInputEditor editor) { this.ActiveEditor.Initialize((object)visualItem, this.SelectedItem[this.CurrentColumn]); initializable?.EndInit(); this.OnEditorInitialized(new ListViewItemEditorInitializedEventArgs(visualItem, (IValueEditor)editor)); this.ActiveEditor.BeginEdit(); this.cachedOldValue = this.SelectedItem[this.CurrentColumn]; }
public static System.Object Decode(object msgObj, byte[] msgBytes) { ((Google.Protobuf.IMessage)msgObj).MergeFrom(msgBytes, 0, msgBytes.Length); ISupportInitialize iSupportInitialize = msgObj as ISupportInitialize; if (iSupportInitialize != null) { iSupportInitialize.EndInit(); } return(msgObj); }
public static System.Object Decode(object hotfixMsg, byte[] bodyData) { ((Google.Protobuf.IMessage)hotfixMsg).MergeFrom(bodyData, 0, bodyData.Length); ISupportInitialize iSupportInitialize = hotfixMsg as ISupportInitialize; if (iSupportInitialize != null) { iSupportInitialize.EndInit(); } return(hotfixMsg); }
public static object FromStream(Type type, Stream stream) { object t = Serializer.NonGeneric.Deserialize(type, stream); ISupportInitialize iSupportInitialize = t as ISupportInitialize; if (iSupportInitialize == null) { return(t); } iSupportInitialize.EndInit(); return(t); }
public static T FromJson <T>(string str) { T t = JsonMapper.ToObject <T>(str); ISupportInitialize iSupportInitialize = t as ISupportInitialize; if (iSupportInitialize == null) { return(t); } iSupportInitialize.EndInit(); return(t); }
public static object FromJson(Type type, string str) { object t = JsonMapper.ToObject(type, str); ISupportInitialize iSupportInitialize = t as ISupportInitialize; if (iSupportInitialize == null) { return(t); } iSupportInitialize.EndInit(); return(t); }
public static System.Object Decode(System.Type msgType, byte[] bodyData) { object message = Activator.CreateInstance(msgType); ((Google.Protobuf.IMessage)message).MergeFrom(bodyData, 0, bodyData.Length); ISupportInitialize iSupportInitialize = message as ISupportInitialize; if (iSupportInitialize != null) { iSupportInitialize.EndInit(); } return(message); }
public static object Deserialize(object message, MemoryStream stream) { // 这个message可以从池中获取,减少gc ((Google.Protobuf.IMessage)message).MergeFrom(stream.GetBuffer(), (int)stream.Position, (int)(stream.Length - stream.Position)); ISupportInitialize iSupportInitialize = message as ISupportInitialize; if (iSupportInitialize == null) { return(message); } iSupportInitialize.EndInit(); return(message); }
static void EndPopulate(IList target, ISupportInitialize supportInitialize) { ILockable lockable = target as ILockable; if (lockable != null) { lockable.EndUpdate(); } if (supportInitialize != null) { supportInitialize.EndInit(); } }
public static IList <T> CreateOrUpdate <T>(IEnumerable destinationItemsSource, IEnumerable <T> source) { ObservableCollection <T> observableCollection = destinationItemsSource as ObservableCollection <T>; if (observableCollection == null && destinationItemsSource != null) { throw new ArgumentException("destinationItemsSource must be ObservableCollection<T> or null"); } if (observableCollection == null) { if (source == null) { return((IList <T>)null); } return((IList <T>) new ObservableCollectionSupportingInitialization <T>(source)); } if (source == null) { observableCollection.Clear(); return((IList <T>)observableCollection); } ISupportInitialize supportInitialize = observableCollection as ISupportInitialize; if (supportInitialize != null) { supportInitialize.BeginInit(); } int index = 0; foreach (T obj in source) { if (index < observableCollection.Count) { observableCollection[index] = obj; } else { observableCollection.Add(obj); } ++index; } while (index < observableCollection.Count) { observableCollection.RemoveAt(observableCollection.Count - 1); } if (supportInitialize != null) { supportInitialize.EndInit(); } return((IList <T>)observableCollection); }
public static T FromBytes <T>(byte[] bytes) where T : Google.Protobuf.IMessage { object message = Activator.CreateInstance(typeof(T)); ((Google.Protobuf.IMessage)message).MergeFrom(bytes);//, 0, bytes.Length); ISupportInitialize iSupportInitialize = message as ISupportInitialize; if (iSupportInitialize == null) { return((T)message); } iSupportInitialize.EndInit(); return((T)message); }
public static object FromBytes(Type type, byte[] bytes, int index, int count) { object message = Activator.CreateInstance(type); ((Google.Protobuf.IMessage)message).MergeFrom(bytes, index, count); ISupportInitialize iSupportInitialize = message as ISupportInitialize; if (iSupportInitialize == null) { return(message); } iSupportInitialize.EndInit(); return(message); }
private static void InitializeProviders() { foreach (ReportProviderAttribute attr in typeof(ReportGenerator).GetCustomAttributes(typeof(ReportProviderAttribute), false)) { IReportProvider provider = (IReportProvider)Activator.CreateInstance(attr.ProviderType); if (provider is ISupportInitialize) { ISupportInitialize supportInit = provider as ISupportInitialize; supportInit.BeginInit(); supportInit.EndInit(); } s_Providers.Add(provider); } }
public static T FromBytes<T>(byte[] bytes, int index, int length) { T t; using (MemoryStream ms = new MemoryStream(bytes, index, length)) { t = Serializer.Deserialize<T>(ms); } ISupportInitialize iSupportInitialize = t as ISupportInitialize; if (iSupportInitialize == null) { return t; } iSupportInitialize.EndInit(); return t; }
public static T FromBytes <T>(byte[] bytes, int index, int length) { T t; using (MemoryStream ms = recyclableMemoryStreamManager.GetStream("protobuf", bytes, index, length)) { t = Serializer.Deserialize <T>(ms); } ISupportInitialize iSupportInitialize = t as ISupportInitialize; if (iSupportInitialize == null) { return(t); } iSupportInitialize.EndInit(); return(t); }
public static object FromBytes(Type type, byte[] bytes) { object t; using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length)) { t = Serializer.NonGeneric.Deserialize(type, ms); } ISupportInitialize iSupportInitialize = t as ISupportInitialize; if (iSupportInitialize == null) { return(t); } iSupportInitialize.EndInit(); return(t); }
public static object FromBytes(Type type, byte[] bytes, int index, int length) { object t; using (MemoryStream ms = recyclableMemoryStreamManager.GetStream("protobuf", bytes, index, length)) { t = Serializer.NonGeneric.Deserialize(type, ms); } ISupportInitialize iSupportInitialize = t as ISupportInitialize; if (iSupportInitialize == null) { return(t); } iSupportInitialize.EndInit(); return(t); }