コード例 #1
0
 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;
 }
コード例 #2
0
 /// <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();
 }
コード例 #3
0
        /// <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();
            }
        }
コード例 #4
0
 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);
 }
コード例 #5
0
ファイル: SharpProp.cs プロジェクト: MihaMarkic/SharpReact
 /// <summary>
 /// Un-mounts a single component.
 /// </summary>
 /// <param name="prop"></param>
 protected static void UnmountComponent(ISharpProp prop)
 {
     ((ISharpInternal)prop)?.UnmountComponent();
 }
コード例 #6
0
 void ISharpNativeComponent.AssignProperties(ISharpRenderer renderer, int level, NewState newState, ISharpProp previous, ISharpProp nextProps)
 {
     AssignProperties((ISharpRenderer <TRootElement>)renderer, level, newState, (TProps)previous, (TProps)nextProps);
 }
コード例 #7
0
 void ISharpStatefulComponent.UpdateElement(ISharpRenderer renderer, object element, ISharpProp props)
 {
     UpdateElement(renderer, (TElement)element, (TProps)props);
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
        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);
        }
コード例 #10
0
 public TElement ProcessPair(int level, NewState newState, ISharpProp previous, ISharpProp next)
 {
     if (ReferenceEquals(next, null))
     {
         return(default);
コード例 #11
0
 public void UpdateExistingElement(object element, ISharpProp prop)
 {
     UpdateExistingElement((TElement)element, prop);
 }