Simpl.Serialization.Types.CompositeType.SimplEquals C# (CSharp) Method

SimplEquals() public method

public SimplEquals ( object left, object right ) : bool
left object
right object
return bool
        public override bool SimplEquals(object left, object right)
        {
            var leftList = new List<object>();
            var rightList = new List<object>();
            return RecursiveSimplEquals(left, right, leftList, rightList);
        }

Same methods

CompositeType::SimplEquals ( object left, object right, List leftCompared, List rightCompared ) : bool

Usage Example

Exemplo n.º 1
0
        private bool RecursiveSimplEquals(object left, object right, List <object> leftCompared, List <object> rightCompared)
        {
            leftCompared.Add(left);
            rightCompared.Add(right);

            if (left.GetType().Equals(right.GetType()))
            {
                foreach (var fieldDescriptor in this.Type.AllFieldDescriptors)
                {
                    var leftDescribedValue  = fieldDescriptor.GetValue(left);
                    var rightDescribedValue = fieldDescriptor.GetValue(right);

                    if (fieldDescriptor.IsComposite)
                    {
                        if (object.ReferenceEquals(leftDescribedValue, left) || Object.ReferenceEquals(rightDescribedValue, right))
                        {
                            // Circular refernces are fine, skip them / move on.
                            continue;
                        }

                        if (leftCompared.Contains(leftDescribedValue) || rightCompared.Contains(rightDescribedValue))
                        {
                            // Skip cycles.
                            continue;
                        }

                        var composite = new CompositeType(leftDescribedValue.GetType());
                        return(composite.SimplEquals(leftDescribedValue, rightDescribedValue, leftCompared, rightCompared));
                    }
                    else
                    {
                        if (!fieldDescriptor.ContextSimplEquals(left, right))
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
All Usage Examples Of Simpl.Serialization.Types.CompositeType::SimplEquals