public DuplicateKeyException(ISharpProp property, string sourceProperty, string sourceType) : base($"Key {property.Key} is a duplicate in property list {sourceProperty} for {sourceType}") { Property = property; SourceProperty = sourceProperty; SourceType = sourceType; }
/// <summary> /// Updates existing element properties. /// </summary> /// <remarks>Used with template based rendering.</remarks> /// <param name="element"></param> /// <param name="prop"></param> public void UpdateExistingElement(TElement element, ISharpProp prop) { prop.Init(); prop.Component.WillMount(); // UpdateElement expects all sub-elements to be created and be in proper position in list. prop.Component.UpdateElement(this, element, prop); prop.Component.DidMount(); }
/// <summary> /// Removes element from components. /// </summary> /// <remarks>Used with template based rendering.</remarks> /// <param name="prop"></param> public void RemoveElement(TElement element, ISharpProp prop) { var query = from p in prop.AllChildren.Union(new ISharpProp[] { prop }) where !ReferenceEquals(p, null) && ReferenceEquals(p.Component?.Element, element) let n = p.Component as ISharpNativeComponent where n != null select n; foreach (var p in query) { p.RemoveElement(); } }
public void UpdateComponent(int level, NewState newState, ISharpProp previous, ISharpProp next, ISharpStatefulComponent statefulComponent, object newComponentState) { statefulComponent.WillReceiveProps(next); // assign properties to one or the another, perhaps an if should do better if (statefulComponent is ISharpNativeComponent nativeComponent) { nativeComponent.AssignProperties(this, level, newState, previous, next); } else if (statefulComponent is ISharpComponent component) { component.AssignProperties(next); } else { throw new NotImplementedException("Unknown component type or null"); } statefulComponent.DidUpdate(next, newComponentState); }
/// <summary> /// Un-mounts a single component. /// </summary> /// <param name="prop"></param> protected static void UnmountComponent(ISharpProp prop) { ((ISharpInternal)prop)?.UnmountComponent(); }
void ISharpNativeComponent.AssignProperties(ISharpRenderer renderer, int level, NewState newState, ISharpProp previous, ISharpProp nextProps) { AssignProperties((ISharpRenderer <TRootElement>)renderer, level, newState, (TProps)previous, (TProps)nextProps); }
void ISharpStatefulComponent.UpdateElement(ISharpRenderer renderer, object element, ISharpProp props) { UpdateElement(renderer, (TElement)element, (TProps)props); }
/// <summary> /// Run time update of the existing element /// </summary> /// <param name="element"></param> void ISharpStatefulComponent <TElement> .UpdateElement(ISharpRenderer <TElement> renderer, TElement element, ISharpProp props) { UpdateElement(renderer, element, (TProps)props); }
public (ISharpStatefulComponent Stateful, ISharpNativeComponent Native) CreateNewComponent(ISharpProp next) { next.Init(); var statefulComponent = next.Component; statefulComponent.Renderer = this; var nativeCurrent = statefulComponent as ISharpNativeComponent; statefulComponent.WillMount(); if (nativeCurrent != null) { CreateElement(nativeCurrent); } statefulComponent.DidMount(); return(statefulComponent, nativeCurrent); }
public TElement ProcessPair(int level, NewState newState, ISharpProp previous, ISharpProp next) { if (ReferenceEquals(next, null)) { return(default);
public void UpdateExistingElement(object element, ISharpProp prop) { UpdateExistingElement((TElement)element, prop); }