Пример #1
0
        public void FindPropertiesWithAttributeOfType()
        {
            // Arrange

            // Act

            // Assert
            NullType.FindPropertiesWithAttributeOfType <ReflectionTestAttribute>(false).Should().BeEmpty();
            NullType.FindPropertiesWithAttributeOfType(typeof(ReflectionTestAttribute), false).Should().BeEmpty();
            NullType.FindPropertiesWithAttributeOfType <ReflectionTestAttribute>(false, BindingFlags.Instance | BindingFlags.NonPublic)
            .Should()
            .BeEmpty();

            NullType.FindPropertiesWithAttributeOfType(typeof(ReflectionTestAttribute), false, BindingFlags.Instance | BindingFlags.NonPublic)
            .Should()
            .BeEmpty();

            TestType.FindPropertiesWithAttributeOfType <ReflectionTestAttribute>(false).Should().HaveCount(3);
            TestType.FindPropertiesWithAttributeOfType(typeof(ReflectionTestAttribute), false).Should().HaveCount(3);

            TestType.FindPropertiesWithAttributeOfType <ReflectionTestAttribute>(false, BindingFlags.Instance | BindingFlags.NonPublic)
            .Should()
            .HaveCount(3);

            TestType.FindPropertiesWithAttributeOfType(typeof(ReflectionTestAttribute), false, BindingFlags.Instance | BindingFlags.NonPublic)
            .Should()
            .HaveCount(3);
        }
Пример #2
0
        public TypeManager()
        {
            _predefTypes = null; // Initialized via the Init call.
            _BSymmgr = null; // Initialized via the Init call.
            _typeFactory = new TypeFactory();
            _typeTable = new TypeTable();

            // special types with their own symbol kind.
            _errorType = _typeFactory.CreateError(null, null, null, null, null);
            _voidType = _typeFactory.CreateVoid();
            _nullType = _typeFactory.CreateNull();
            _typeUnit = _typeFactory.CreateUnit();
            _typeAnonMeth = _typeFactory.CreateAnonMethod();
            _typeMethGrp = _typeFactory.CreateMethodGroup();
            _argListType = _typeFactory.CreateArgList();

            InitType(_errorType);
            _errorType.SetErrors(true);

            InitType(_voidType);
            InitType(_nullType);
            InitType(_typeUnit);
            InitType(_typeAnonMeth);
            InitType(_typeMethGrp);

            _stvcMethod = new StdTypeVarColl();
            _stvcClass = new StdTypeVarColl();
        }
Пример #3
0
        /// <summary>
        /// 处理可空类型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static Type GetNicePropertyInfo(Type type)
        {
            NullType nullType = new NullType();

            if (type.ToString() == "System.Nullable`1[System.Int32]")
            {
                type = nullType.NullInt.GetType();
            }
            if (type.ToString() == "System.Nullable`1[System.Decimal]")
            {
                type = nullType.NullDecimal.GetType();
            }
            if (type.ToString() == "System.Nullable`1[System.Double]")
            {
                type = nullType.NullDoublel.GetType();
            }
            if (type.ToString() == "System.Nullable`1[System.Long]")
            {
                type = nullType.NullLong.GetType();
            }
            if (type.ToString() == "System.Nullable`1[System.DateTime]")
            {
                type = nullType.NullDateTime.GetType();
            }
            return(type);
        }
 /// <summary>
 ///  First operand is NullType Expression, the method return a type expressión
 ///  if the second operand is promotable to StringType and the operator is PLUS
 /// </summary>
 /// <param name="firstOperand">a NullType TypeExpression</param>
 /// <returns>return a type expressión if the second operand is promotable to StringType
 /// and the operator is PLUS. False otherwise.</returns>
 public override object Exec(NullType firstOperand, object arg)
 {
     if (this.binaryOperator.Equals(ArithmeticOperator.Plus) && (bool)this.secondOperand.AcceptOperation(new EquivalentOperation(StringType.Instance), arg))
     {
         return(StringType.Instance);
     }
     if (showErrorMessage)
     {
         ErrorManager.Instance.NotifyError(new TypePromotionError(this.secondOperand.FullName, firstOperand.FullName, this.binaryOperator.ToString(), this.location));
     }
     return(null);
 }
Пример #5
0
        public override bool check(CodeContext context)
        {
            if (is_checked)
            {
                return(!error);
            }

            is_checked = true;

            value_type = new NullType(source_reference);

            return(!error);
        }
Пример #6
0
        public void IsSubclassOf()
        {
            // Arrange

            // Act

            // Assert
            NullType.IsSubclassOf <object>().Should().BeFalse();

            TestType.IsSubclassOf <object>().Should().BeTrue();

            typeof(ArgumentNullException).IsSubclassOf <ArgumentException>().Should().BeTrue();
            typeof(Exception).IsSubclassOf <ArgumentException>().Should().BeFalse();
        }
        public override object Exec(NullType firstOperand, object arg)
        {
            // * Built-in types: no promotion, except string
            if (this.secondOperand is BoolType || this.secondOperand is CharType || this.secondOperand is DoubleType || this.secondOperand is IntType || this.secondOperand is VoidType)
            {
                return(-1);
            }
            // * BCL Value Types (structs): No promotion
            BCLClassType bclClass = TypeExpression.As <BCLClassType>(this.secondOperand);

            if (bclClass != null)
            {
                if (bclClass.TypeInfo.IsValueType)
                {
                    return(-1);
                }
                // * Correct promotion to classes that are not value types
                return(0);
            }
            // * WriteType variable
            TypeVariable typeVariable = this.secondOperand as TypeVariable;

            if (typeVariable != null)
            {
                if (typeVariable.Substitution != null)
                {
                    // * If the variable is bounded, the promotion is the one of its substitution
                    return(firstOperand.AcceptOperation(new PromotionLevelOperation(typeVariable.EquivalenceClass.Substitution), arg));
                }
                // * A free variable is complete promotion
                return(0);
            }
            // * Union type
            UnionType unionType = TypeExpression.As <UnionType>(this.secondOperand);

            if (unionType != null)
            {
                return(unionType.SuperType(firstOperand));
            }
            // * Field type and bounded type variable
            FieldType fieldType = TypeExpression.As <FieldType>(this.secondOperand);

            if (fieldType != null)
            {
                return(firstOperand.AcceptOperation(new PromotionLevelOperation(fieldType.FieldTypeExpression), arg));
            }
            // * Correct Promotion
            return(0);
        }
Пример #8
0
        public static Expression CreateParenthesized(Context cx, VarPatternSyntax varPattern, ParenthesizedVariableDesignationSyntax designation, IExpressionParentEntity parent, int child)
        {
            var type  = NullType.Create(cx); // Should ideally be a corresponding tuple type
            var tuple = new Expression(new ExpressionInfo(cx, type, cx.Create(varPattern.GetLocation()), ExprKind.TUPLE, parent, child, false, null));

            cx.Try(null, null, () =>
            {
                var child0 = 0;
                foreach (var variable in designation.Variables)
                {
                    switch (variable)
                    {
                    case ParenthesizedVariableDesignationSyntax paren:
                        CreateParenthesized(cx, varPattern, paren, tuple, child0++);
                        break;

                    case SingleVariableDesignationSyntax single:
                        if (cx.GetModel(variable).GetDeclaredSymbol(single) is ILocalSymbol local)
                        {
                            var decl     = Create(cx, variable, Entities.Type.Create(cx, local.GetAnnotatedType()), true, tuple, child0++);
                            var id       = single.Identifier;
                            var location = cx.Create(id.GetLocation());
                            LocalVariable.Create(cx, local, decl, true, location);
                        }
                        else
                        {
                            throw new InternalError(single, "Failed to access local variable");
                        }
                        break;

                    case DiscardDesignationSyntax discard:
                        new Discard(cx, discard, tuple, child0++);
                        break;

                    default:
                        throw new InternalError(variable, "Unhandled designation type");
                    }
                }
            });

            return(tuple);
        }
Пример #9
0
        static VariableDeclaration CreateSingle(Context cx, DeclarationExpressionSyntax node, SingleVariableDesignationSyntax designation, IExpressionParentEntity parent, int child)
        {
            bool isVar = node.Type.IsVar;

            var variableSymbol = cx.GetModel(designation).GetDeclaredSymbol(designation) as ILocalSymbol;

            if (variableSymbol == null)
            {
                cx.ModelError(node, "Failed to determine local variable");
                return(Create(cx, node, NullType.Create(cx), isVar, parent, child));
            }

            var type     = Entities.Type.Create(cx, variableSymbol.GetAnnotatedType());
            var location = cx.Create(designation.GetLocation());

            var ret = Create(cx, designation, type, isVar, parent, child);

            cx.Try(null, null, () => LocalVariable.Create(cx, variableSymbol, ret, isVar, location));
            return(ret);
        }
Пример #10
0
        private static Expression Create(Context cx, DeclarationExpressionSyntax node, VariableDesignationSyntax designation, IExpressionParentEntity parent, int child)
        {
            switch (designation)
            {
            case SingleVariableDesignationSyntax single:
                return(CreateSingle(cx, node, single, parent, child));

            case ParenthesizedVariableDesignationSyntax paren:
                return(CreateParenthesized(cx, node, paren, parent, child));

            case DiscardDesignationSyntax discard:
                var ti   = cx.GetType(discard);
                var type = Entities.Type.Create(cx, ti);
                return(Create(cx, node, type, parent, child));

            default:
                cx.ModelError(node, "Failed to determine designation type");
                return(Create(cx, node, NullType.Create(cx), parent, child));
            }
        }
Пример #11
0
        public void FindPropertiesOfType()
        {
            // Arrange

            // Act

            // Assert
            NullType.FindPropertiesOfType <string>().Should().BeEmpty();
            NullType.FindPropertiesOfType(typeof(string)).Should().BeEmpty();
            NullType.FindPropertiesOfType <string>(BindingFlags.NonPublic).Should().BeEmpty();
            NullType.FindPropertiesOfType(typeof(string), BindingFlags.NonPublic).Should().BeEmpty();

            TestType.FindPropertiesOfType <string>().Should().HaveCount(2);
            TestType.FindPropertiesOfType(typeof(string)).Should().HaveCount(2);
            TestType.FindPropertiesOfType <string>(BindingFlags.Instance | BindingFlags.NonPublic).Should().HaveCount(3);
            TestType.FindPropertiesOfType(typeof(string), BindingFlags.Instance | BindingFlags.NonPublic).Should().HaveCount(3);

            TestType.FindPropertiesOfType <Gender>().Should().HaveCount(1);
            TestType.FindPropertiesOfType(typeof(Gender)).Should().HaveCount(1);
            TestType.FindPropertiesOfType <Gender>(BindingFlags.Instance | BindingFlags.NonPublic).Should().HaveCount(0);
            TestType.FindPropertiesOfType(typeof(Gender), BindingFlags.Instance | BindingFlags.NonPublic).Should().HaveCount(0);
        }
Пример #12
0
 public virtual TReturn Visit(NullType node, TParam param) => throw new NotImplementedException();
Пример #13
0
        public void Read(TProtocol iprot)
        {
            TField field;

            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.I32)
                    {
                        this.nVal         = (NullType)iprot.ReadI32();
                        this.__isset.nVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Bool)
                    {
                        this.bVal         = iprot.ReadBool();
                        this.__isset.bVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 3:
                    if (field.Type == TType.I64)
                    {
                        this.iVal         = iprot.ReadI64();
                        this.__isset.iVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 4:
                    if (field.Type == TType.Double)
                    {
                        this.fVal         = iprot.ReadDouble();
                        this.__isset.fVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 5:
                    if (field.Type == TType.String)
                    {
                        this.sVal         = iprot.ReadBinary();
                        this.__isset.sVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 6:
                    if (field.Type == TType.Struct)
                    {
                        this.dVal = new Date();
                        this.dVal.Read(iprot);
                        this.__isset.dVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 7:
                    if (field.Type == TType.Struct)
                    {
                        this.tVal = new Time();
                        this.tVal.Read(iprot);
                        this.__isset.tVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 8:
                    if (field.Type == TType.Struct)
                    {
                        this.dtVal = new DateTime();
                        this.dtVal.Read(iprot);
                        this.__isset.dtVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 9:
                    if (field.Type == TType.Struct)
                    {
                        this.vVal = new Vertex();
                        this.vVal.Read(iprot);
                        this.__isset.vVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 10:
                    if (field.Type == TType.Struct)
                    {
                        this.eVal = new Edge();
                        this.eVal.Read(iprot);
                        this.__isset.eVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 11:
                    if (field.Type == TType.Struct)
                    {
                        this.pVal = new Path();
                        this.pVal.Read(iprot);
                        this.__isset.pVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 12:
                    if (field.Type == TType.Struct)
                    {
                        this.lVal = new List();
                        this.lVal.Read(iprot);
                        this.__isset.lVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 13:
                    if (field.Type == TType.Struct)
                    {
                        this.mVal = new Map();
                        this.mVal.Read(iprot);
                        this.__isset.mVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 14:
                    if (field.Type == TType.Struct)
                    {
                        this.uVal = new Set();
                        this.uVal.Read(iprot);
                        this.__isset.uVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 15:
                    if (field.Type == TType.Struct)
                    {
                        this.gVal = new DataSet();
                        this.gVal.Read(iprot);
                        this.__isset.gVal = true;
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
Пример #14
0
 public virtual TReturn Visit(NullType node, TParam param)
 {
     return(DefaultReturn);
 }
Пример #15
0
 public void WithNullSourceType_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           NullType.GetMethod(Flags, _methodName, _genericTypes, _parameterTypes));
 }
Пример #16
0
 public void WithNullType_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => NullType.IsCollection());
 }
Пример #17
0
 public void WithNullType_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => NullType.IsIEnumerable());
 }
Пример #18
0
 public void WithNullType_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => NullType.GetDefault());
 }
Пример #19
0
 public void NullHandler(NullType n)
 => Assert.True(false);
Пример #20
0
 ArrayInitializer(ExpressionNodeInfo info) : base(info.SetType(NullType.Create(info.Context)).SetKind(ExprKind.ARRAY_INIT))
 {
 }
Пример #21
0
 public GenericValueType(object value)
 {
     if (value == null)
     {
         Item            = new NullType();
         ItemElementName = ItemChoiceType.Null;
     }
     else
     {
         Type valueType = value.GetType();
         if (valueType == typeof(byte[]))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Base64Binary;
         }
         else if (valueType == typeof(bool))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Boolean;
         }
         else if (valueType == typeof(sbyte))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Byte;
         }
         else if (valueType == typeof(ushort))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Character;
         }
         else if (valueType == typeof(DateTime))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.DateTime;
         }
         else if (valueType == typeof(float))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Float;
         }
         else if (valueType == typeof(decimal))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Decimal;
         }
         else if (valueType == typeof(double))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Double;
         }
         else if (valueType == typeof(int))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Int;
         }
         else if (valueType == typeof(long))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Long;
         }
         else if (valueType == typeof(short))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Short;
         }
         else if (valueType == typeof(string))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.String;
         }
         else if (valueType == typeof(Uri))
         {
             Item            = value.ToString();
             ItemElementName = ItemChoiceType.URI;
         }
         else if (valueType == typeof(Guid))
         {
             Item            = value.ToString();
             ItemElementName = ItemChoiceType.UUID;
         }
         else if (valueType == typeof(TimeSpan))
         {
             Item            = value.ToString();
             ItemElementName = ItemChoiceType.Duration;
         }
         else if (valueType.GetInterface("IDictionary`2") != null)
         {
             Item            = new TypedMapType((IDictionary)value);
             ItemElementName = ItemChoiceType.TypedMap;
         }
         else if (typeof(IDictionary).IsAssignableFrom(valueType))
         {
             Item            = new MapType((IDictionary)value);
             ItemElementName = ItemChoiceType.Map;
         }
         else if (valueType.GetInterface("ICollection`1") != null)
         {
             Item            = new TypedMultipleValueType((ICollection)value);
             ItemElementName = ItemChoiceType.TypedList;
         }
         else if (typeof(ICollection).IsAssignableFrom(valueType))
         {
             Item            = new MultipleValueType((ICollection)value);
             ItemElementName = ItemChoiceType.List;
         }
         else if (valueType == typeof(XmlQualifiedName))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.QName;
         }
         else if (valueType == typeof(ObjectName))
         {
             Item            = ObjectNameSelector.CreateEndpointAddress((ObjectName)value);
             ItemElementName = ItemChoiceType.EndpointReference;
         }
         else if (valueType == typeof(RoleInfo))
         {
             Item            = new ManagedResourceRoleInfo((RoleInfo)value);
             ItemElementName = ItemChoiceType.ManagedResourceRoleInfo;
         }
         else if (valueType == typeof(RoleResult))
         {
             Item            = new ManagedResourceRoleResult((RoleResult)value);
             ItemElementName = ItemChoiceType.ManagedResourceRoleResult;
         }
         else if (typeof(ITabularData).IsAssignableFrom(valueType))
         {
             Item            = new TabularDataValueType((ITabularData)value);
             ItemElementName = ItemChoiceType.TabularDataValue;
         }
         else if (typeof(ICompositeData).IsAssignableFrom(valueType))
         {
             Item            = new CompositeDataValueType((ICompositeData)value);
             ItemElementName = ItemChoiceType.CompositeDataValue;
         }
         else if (typeof(OpenType).IsAssignableFrom(valueType))
         {
             Item = OpenDataType_Type.Serialize(value, out itemElementNameField);
         }
         else
         {
             throw new NotSupportedException("Not supported type in serialization: " + valueType);
         }
     }
 }
Пример #22
0
        public void NullCompareInIfBlock()
        {
            const string block = "#if( $str == null )GOOO#{else}STOPPPPP#{end}";
            var s = State();

            s["str"] = new NullType();
            var result1 = Template.ImmediateApply(s, block);
            Assert.False(result1.Errors.ContainsError());
            Assert.False(result1.Errors.ContainsWarning());
            Assert.AreEqual("GOOO", result1.Output);

            var result2 = Template.CompileAndRun("test", block, s);
            Assert.False(result2.Errors.ContainsError());
            Assert.False(result2.Errors.ContainsWarning());
            Assert.AreEqual("GOOO", result2.Output);
        }
 /// <summary>
 /// It performs a an assigment operation with a NullType as left operand. The operaton can only be done if op attribute is set to Attribute.Assign.
 /// </summary>
 /// <param name="leftOperand">A NullType as left Operarand</param>
 /// <returns>The right operand, if the op == AssignmentOperator.Assign. raises and error in other case.</returns>
 public override object Exec(NullType leftOperand, object arg)
 {
     return(op == AssignmentOperator.Assign ? this.rightOperand : ReportError(leftOperand));
 }
Пример #24
0
 public void GetMemberValues(string prefix, Object properties, JSONPROXY dict,
                             List<Object> exceptFor)
 {
     if (properties == null)
     {
         return;
     }
     var o0 = properties;
     bool neededDecode;
     if (o0 is IJSONPROXY)
     {
         foreach (var kv in (IJSONPROXY) o0)
         {
             string joinedName = JoinedName(prefix, kv.Key);
             AddValue(joinedName, DecodeValue(joinedName + "_", kv.Value, out neededDecode), dict);
         }
         return;
     }
     else if (o0 is IDictionary)
     {
         foreach (DictionaryEntry kv in (IDictionary) o0)
         {
             string joinedName = JoinedName(prefix, "" + kv.Key);
             AddValue(joinedName, kv.Value, dict);
         }
         return;
     }
     Type t = properties.GetType();
     KeyValuePair<List<PropertyInfo>, List<FieldInfo>> vvv = GetPropsForTypes(t);
     List<string> lowerProps = new List<string>();
     BindingFlags flags = BindingFlags.Instance | BindingFlags.Public; //BindingFlags.NonPublic
     foreach (PropertyInfo o in vvv.Key)
     {
         try
         {
             Type pt = o.PropertyType;
             if (!IsOKType(pt)) continue;
             var v = o.GetValue(properties, null);
             if (v == null)
             {
                 v = new NullType(properties, o);
             }
             pt = v.GetType();
             if (!IsOKType(pt)) continue;
             if (exceptFor.Contains(v)) continue;
             AddValue(JoinedName(prefix, o.Name), v, dict);
         }
         catch (Exception e)
         {
             DLRConsole.DebugWriteLine("" + e);
         }
     }
     foreach (FieldInfo o in vvv.Value)
     {
         try
         {
             Type pt = o.FieldType;
             if (!IsOKType(pt)) continue;
             var v = o.GetValue(properties);
             if (v == null)
             {
                 v = new NullType(properties, o);
             }
             if (!IsOKType(pt)) continue;
             if (exceptFor.Contains(v)) continue;
             AddValue(JoinedName(prefix, o.Name), v, dict);
         }
         catch (Exception e)
         {
             DLRConsole.DebugWriteLine("" + e);
         }
     }
 }
Пример #25
0
 public GenericValueType(object value)
 {
     if (value == null)
      {
     Item = new NullType();
     ItemElementName = ItemChoiceType.Null;
      }
      else
      {
     Type valueType = value.GetType();
     if (valueType == typeof(byte[]))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Base64Binary;
     }
     else if (valueType == typeof(bool))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Boolean;
     }
     else if (valueType == typeof(sbyte))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Byte;
     }
     else if (valueType == typeof(ushort))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Character;
     }
     else if (valueType == typeof(DateTime))
     {
        Item = value;
        ItemElementName = ItemChoiceType.DateTime;
     }
     else if (valueType == typeof(float))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Float;
     }
     else if (valueType == typeof(decimal))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Decimal;
     }
     else if (valueType == typeof(double))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Double;
     }
     else if (valueType == typeof(int))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Int;
     }
     else if (valueType == typeof(long))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Long;
     }
     else if (valueType == typeof(short))
     {
        Item = value;
        ItemElementName = ItemChoiceType.Short;
     }
     else if (valueType == typeof(string))
     {
        Item = value;
        ItemElementName = ItemChoiceType.String;
     }
     else if (valueType == typeof(Uri))
     {
        Item = value.ToString();
        ItemElementName = ItemChoiceType.URI;
     }
     else if (valueType == typeof(Guid))
     {
        Item = value.ToString();
        ItemElementName = ItemChoiceType.UUID;
     }
     else if (valueType == typeof(TimeSpan))
     {
        Item = value.ToString();
        ItemElementName = ItemChoiceType.Duration;
     }
     else if (valueType.GetInterface("IDictionary`2") != null)
     {
        Item = new TypedMapType((IDictionary)value);
        ItemElementName = ItemChoiceType.TypedMap;
     }
     else if (typeof(IDictionary).IsAssignableFrom(valueType))
     {
        Item = new MapType((IDictionary)value);
        ItemElementName = ItemChoiceType.Map;
     }
     else if (valueType.GetInterface("ICollection`1") != null)
     {
        Item = new TypedMultipleValueType((ICollection)value);
        ItemElementName = ItemChoiceType.TypedList;
     }
     else if (typeof(ICollection).IsAssignableFrom(valueType))
     {
        Item = new MultipleValueType((ICollection)value);
        ItemElementName = ItemChoiceType.List;
     }
     else if (valueType == typeof(XmlQualifiedName))
     {
        Item = value;
        ItemElementName = ItemChoiceType.QName;
     }
     else if (valueType == typeof(ObjectName))
     {
        Item = ObjectNameSelector.CreateEndpointAddress((ObjectName)value);
        ItemElementName = ItemChoiceType.EndpointReference;
     }
     else if (valueType == typeof(RoleInfo))
     {
        Item = new ManagedResourceRoleInfo((RoleInfo) value);
        ItemElementName = ItemChoiceType.ManagedResourceRoleInfo;
     }
     else if (valueType == typeof(RoleResult))
     {
        Item = new ManagedResourceRoleResult((RoleResult) value);
        ItemElementName = ItemChoiceType.ManagedResourceRoleResult;
     }
     else if (typeof(ITabularData).IsAssignableFrom(valueType))
     {
        Item = new TabularDataValueType((ITabularData)value);
        ItemElementName = ItemChoiceType.TabularDataValue;
     }
     else if (typeof(ICompositeData).IsAssignableFrom(valueType))
     {
        Item = new CompositeDataValueType((ICompositeData)value);
        ItemElementName = ItemChoiceType.CompositeDataValue;
     }
     else if (typeof(OpenType).IsAssignableFrom(valueType))
     {
        Item = OpenDataType_Type.Serialize(value, out itemElementNameField);
     }
     else throw new NotSupportedException("Not supported type in serialization: "+valueType);
      }
 }
Пример #26
0
 public override object Exec(NullType firstOperand, object arg)
 {
     return(AddTypeExpression(firstOperand));
 }
 public SpecialNullabilityNode(NullType nullType)
 {
     this.NullType = nullType;
 }
Пример #28
0
 public NullType CreateNull()
 {
     NullType type = new NullType();
     type.SetTypeKind(TypeKind.TK_NullType);
     return type;
 }
 public virtual object Exec(NullType n, object arg)
 {
     return(Exec((TypeExpression)n, arg));
 }
Пример #30
0
 /// <summary>
 ///  Writes the intialization of a with a NullType
 /// </summary>
 /// <param name="n">Type Expression representing a NullType</param>
 /// <returns>null</returns>
 public override object Exec(NullType n, object arg)
 {
     this.codeGenerator.WriteLNFieldInitialization(" = nullref");
     return(null);
 }
 public SemanticCheckResult()
 {
     Errors = new List <Error>();
     Type   = new NullType();
 }