AmazedSaint.Elastic.Lib.ElasticObject.TryBinaryOperation C# (CSharp) Method

TryBinaryOperation() public method

Interpret the invocation of a binary operation
public TryBinaryOperation ( BinaryOperationBinder binder, object arg, object &result ) : bool
binder System.Dynamic.BinaryOperationBinder
arg object
result object
return bool
        public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result)
        {
            if (binder.Operation == ExpressionType.LeftShiftAssign && nodeType==NodeType.Element)
            {
                InternalContent = arg;
                result = this;
                return true;
            }
            else if (binder.Operation == ExpressionType.LeftShiftAssign  && nodeType == NodeType.Attribute)
            {
                InternalValue = arg;
                result = this;
                return true;
            }

            else if (binder.Operation == ExpressionType.LeftShift)
            {
                if (arg is string)
                {
                    var exp = new ElasticObject(arg as string, null) { nodeType = NodeType.Element };
                    AddElement(exp);
                    result = exp;
                    return true;
                }

                else if (arg is ElasticObject)
                {
                    var eobj = arg as ElasticObject;
                    if (!Elements.Contains(eobj))
                        AddElement(eobj);
                    result = eobj;
                    return true;
                }
            }

            else if (binder.Operation == ExpressionType.LessThan)
            {
                string memberName = arg as string;
                if (arg is string)
                {
                    if (!HasAttribute(memberName))
                    {
                        var att = new ElasticObject(memberName, null);
                        AddAttribute(memberName, att);
                        result = att;
                        return true;
                    }
                    else
                    {
                        throw new InvalidOperationException("An attribute with name" + memberName +  " already exists");
                    }
                }
                else if (arg is ElasticObject)
                {
                    var eobj = arg as ElasticObject;
                    AddAttribute(memberName, eobj);
                    result = eobj;
                    return true;
                }
            }
            else if (binder.Operation == ExpressionType.GreaterThan)
            {
                if (arg is FormatType)
                {
                    result = this.ToXElement();
                    return true;
                }
            }
            return base.TryBinaryOperation(binder, arg, out result);
        }