protected BaseType Promote(BaseType a, BaseType b)
 {
     if (a == BaseType.Double || b == BaseType.Double)
         return BaseType.Double;
     if (a == BaseType.Float || b == BaseType.Float)
         return BaseType.Float;
     if (a == BaseType.ULong || b == BaseType.ULong)
         return BaseType.ULong;
     int aSize = Types.GetBaseTypeSize(a);
     int bSize = Types.GetBaseTypeSize(b);
     if (Types.IsUnsigned(a) && Types.IsSigned(b))
     {
         if (aSize < bSize)
             return b;
         else
             Types.GetIntegralTypeBySize(Math.Max(aSize, bSize), false);
     }
     if (Types.IsSigned(a) && Types.IsUnsigned(b))
     {
         if (bSize < aSize)
             return a;
         else
             return Types.GetIntegralTypeBySize(Math.Max(aSize, bSize), false);
     }
     else
     {
         bool isSigned = Types.IsSigned(a);
         return Types.GetIntegralTypeBySize(Math.Max(aSize, bSize), isSigned);
     }
 } 
Example #2
0
    public static void Main()
    {
        test_is();

        DerivedType derivedObj = new DerivedType();
        BaseType baseObj1 = new BaseType();
        BaseType baseObj2 = derivedObj;

        DerivedType derivedObj2 = baseObj2 as DerivedType;
        if( derivedObj2 != null ) {
            Console.WriteLine( "Conversion Succeeded" );
        } else {
            Console.WriteLine( "Conversion Failed" );
        }

        derivedObj2 = baseObj1 as DerivedType;
        if( derivedObj2 != null ) {
            Console.WriteLine( "Conversion Succeeded" );
        } else {
            Console.WriteLine( "Conversion Failed" );
        }

        BaseType baseObj3 = derivedObj as BaseType;
        if( baseObj3 != null ) {
            Console.WriteLine( "Conversion Succeeded" );
        } else {
            Console.WriteLine( "Conversion Failed" );
        }

        System.Console.WriteLine("Press any key to continue...");
        System.Console.ReadKey();
    }
Example #3
0
 public void Can_create_with_complex_type()
 {
     var Complex = new BaseType();
     var a = Immutable.Build<HazAComplexType>(new {Complex});
     Assert.IsNotNull(a.Complex);
     Assert.AreSame(Complex,a.Complex);
 }
        protected override void Because_of()
        {
            var baseType = new BaseType();
            var baseTypeDto = new BaseTypeDto();

            Mapper.Map(baseType, baseTypeDto);
        }
Example #5
0
 public ReferenceType(BaseType value)
     : base(false)
 {
     referencedValue = value;
     value.Changed += new EventHandler<ValueChangedEventArgs>(value_Changed);
     DoAllocation();
 }
Example #6
0
 /// <summary>
 /// Returns true if the value is numerical.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static bool IsNumeric(BaseType value)
 {
     TypeEnum type = value.Type;
     return type == TypeEnum.Decimal ||
            type == TypeEnum.Float ||
            type == TypeEnum.Integer;
 }
Example #7
0
 public override void Insert(BaseType value)
 {
     if (!Contains(value))
     {
         base.Insert(value);
     }
 }
        public static MvcHtmlString GetAuthorizerScripts(this HtmlHelper helper, BaseType libraryBase, CommonResources includedResources)
        {
            UrlHelper Urls = new UrlHelper(helper.ViewContext.RequestContext);
            List<TagBuilder> LibrarySupportingElements = new List<TagBuilder>();

            TagBuilder OpenIdLibrary = new TagBuilder("script");
            OpenIdLibrary.Attributes.Add(new KeyValuePair<string,string>( "type", "text/javascript"));

            switch(libraryBase)
            {
                case BaseType.Jquery:
                    OpenIdLibrary.Attributes.Add(new KeyValuePair<string, string>("src", Urls.RouteUrl("AuthorizationResources", new {resourceType = "Scripts", resourceName = "openid-jquery.js"})));
                    TagBuilder LanguageFile = new TagBuilder("script");
                    LanguageFile.Attributes.Add(new KeyValuePair<string, string>("type", "text/javascript"));
                    LanguageFile.Attributes.Add(new KeyValuePair<string, string>("src", Urls.RouteUrl("AuthorizationResources", new { resourceType = "Scripts", resourceName = "openid-en.js" })));

                    LibrarySupportingElements.Add(LanguageFile);
                    break;
                default:
                    throw new InvalidOperationException();
            }

            string RawResult = OpenIdLibrary.ToString(TagRenderMode.Normal);
            LibrarySupportingElements.ForEach(Lib => RawResult += Lib.ToString(TagRenderMode.Normal));
            return MvcHtmlString.Create(RawResult);
        }
Example #9
0
 public NetObject(string ip, string dns, string name, BaseType type, int position)
 {
     _ip = ip;
     _dns = dns;
     _name = name;
     _type = type;
     _position = position;
 }
Example #10
0
 /// <summary>
 /// Converts a basetype value to the given type.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="targetType"></param>
 /// <returns></returns>
 public static BaseType Convert(BaseType value, TypeIdentifier targetType)
 {
     if (targetType.TypeEnum == TypeEnum.Undefined || targetType == value.Type)
     {
         return value;
     }
     var target = CreateValue(targetType);
     target.Assign(value);
     return target;
 }
Example #11
0
 public NetObject(string ip, string dns, string name, BaseType type, int position, ConditionType state, int threadId)
 {
     _ip = ip;
         _dns = dns;
         _name = name;
         _type = type;
         _position = position;
         _state = state;
         _threadId = threadId;
 }
Example #12
0
 /// <summary>
 /// Returns true if the value is a type of scalar.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static bool IsScalar(BaseType value)
 {
     TypeEnum type = value.Type;
     return type == TypeEnum.Boolean ||
         type == TypeEnum.Character ||
         type == TypeEnum.Decimal ||
         type == TypeEnum.Float ||
         type == TypeEnum.Integer ||
         type == TypeEnum.String;
 }
Example #13
0
 public static QueryExec Create(BaseType baseType)
 {
     switch (baseType)
     {
         case BaseType.PDA:
             return new QueryExecPDA();
         case BaseType.Oracle:
             return new QueryExecOracle();
     }
     throw new ArgumentException("Base not implemented");
 }
Example #14
0
 /// <summary>
 /// Returns true if the value is a type of scalar.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static bool IsContainer(BaseType value)
 {
     TypeEnum type = value.Type;
     return type == TypeEnum.Array ||
            type == TypeEnum.LinkedList ||
            type == TypeEnum.List ||
            type == TypeEnum.Matrix ||
            type == TypeEnum.PriorityQueue ||
            type == TypeEnum.Queue ||
            type == TypeEnum.Set ||
            type == TypeEnum.Stack;
 }
Example #15
0
        public Base(int playerNum, int teamNum, BaseType baseType, Tile tile)
        {
            PlayerNum = playerNum;
            TeamNum = teamNum;
            this.Scale = 2.75f;
            this.Tile = tile;
            this.Position = tile.Position;

            this.model = ScreenManager.Game.Content.Load<Model>("Objects\\Base\\oilRig");
            SetupModel(Position);
            SetupCamera();
        }
Example #16
0
 public GunEmplacement(VL.TrackType trackType, VL.GunType gunType, Vector2 positionOffset, float radius, float depthOffset, BaseType baseType, Monster srcMonster)
 {
     this.gunType = gunType;
     this.trackType = trackType;
     this.positionOffset = positionOffset;
     this.radius = radius;
     this.baseRadius = .75f * radius;
     this.depthOffset = depthOffset;
     this.baseType = baseType;
     this.gunLine = srcMonster.position.direction;
     this.gunNormal = Vector3.Cross(gunLine, srcMonster.position.normal);
     this.position = srcMonster.position;
 }
Example #17
0
 /// <summary>
 /// Pushes the value converted to the given type.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="type"></param>
 public Push(object value, TypeEnum type)
 {
     AccessMode = ValueAccessModes.Constant;
     this.type = type;
     if (type == TypeEnum.Undefined)
     {
         this.value = ValueFactory.Create(value);
     }
     else
     {
         this.value = ValueFactory.CreateValue(type);
         BaseType param = ValueFactory.Create(value);
         this.value.Assign(param);
     }
 }
Example #18
0
 public GunEmplacement(GunEmplacement g)
 {
     trackType = g.trackType;
     currentAngle = g.currentAngle;
     fireCooldown = g.fireCooldown;
     //position = new Vertex(g.position);
     positionOffset = g.positionOffset;
     gunLine = g.gunLine;
     gunNormal = g.gunNormal;
     gunType = g.gunType;
     radius = g.radius;
     position = new Vertex();
     depthOffset = g.depthOffset;
     baseType = g.baseType;
     baseRadius = g.baseRadius;
 }
Example #19
0
        public ScalarGraphics(BaseType value)
            : base()
        {
            this.value = value;
            label = new Label();
            label.VerticalContentAlignment = VerticalAlignment.Center;
            label.HorizontalContentAlignment = HorizontalAlignment.Center;
            label.IsHitTestVisible = true;
            Content = label;
            value.Changed += value_Changed;

            this.MouseUp += new MouseButtonEventHandler(ScalarGraphics_MouseUp);

            currentMode = Mode.Display;

            Update();
        }
        public static GraphicsElement Produce(BaseType value)
        {
            if (value == null)
                return new ScalarGraphics(new VapeTeam.Psimulex.Core.Types.String("NULL"));
            switch (value.Type.TypeEnum)
            {
                case TypeEnum.Integer:
             					return new ScalarGraphics(value);
                case TypeEnum.Array:
                    return new ArrayGraphics(value.ToArray());
                case TypeEnum.Tree:
                    return new TreeGraphics(value.ToTree());
                case TypeEnum.BinaryTree:
                    return new TreeGraphics(value.ToBinaryTree());

                default:
                    if (TypeHierarchy.IsContainer(value))
                    {
                        return new ArrayGraphics(value as AbstractCollection);
                    }
                    return new ScalarGraphics(value);
            }
        }
 public override bool ResetMembers(MetaOperations metaOperation, AgentType agentType, BaseType baseType, MethodDef method, PropertyDef property)
 {
     // This function should be empty here, so don't remove it.
     return(false);
 }
Example #22
0
 public override uint GetPhysicalLength()
 {
     return(sizeof(byte) +
            BaseType.GetPhysicalLength());
 }
Example #23
0
        public BaseTypeDto Get(int id)
        {
            BaseType baseType = _baseTypeRepository.Select.Where(a => a.Id == id).ToOne();

            return(_mapper.Map <BaseTypeDto>(baseType));
        }
        protected override IEnumerable <object> EnumerateReferences(BaseType record)
        {
            yield return(record.Identifier);

            yield return(record.TypeArgumentList);
        }
Example #25
0
File: ILType.cs Project: zwinter/ET
        public IMethod GetMethod(string name, List <IType> param, IType [] genericArguments, IType returnType = null, bool declaredOnly = false)
        {
            if (methods == null)
            {
                InitializeMethods();
            }
            List <ILMethod> lst;
            IMethod         genericMethod = null;

            if (methods.TryGetValue(name, out lst))
            {
                for (var idx = 0; idx < lst.Count; idx++)
                {
                    var i    = lst [idx];
                    int pCnt = param != null ? param.Count : 0;
                    if (i.ParameterCount == pCnt)
                    {
                        bool match = true;
                        if (genericArguments != null && i.GenericParameterCount == genericArguments.Length && genericMethod == null)
                        {
                            genericMethod = CheckGenericParams(i, param, genericArguments, ref match);
                        }
                        else
                        {
                            match = CheckGenericArguments(i, genericArguments);
                            if (!match)
                            {
                                continue;
                            }
                            for (int j = 0; j < pCnt; j++)
                            {
                                if (param [j] != i.Parameters [j])
                                {
                                    match = false;
                                    break;
                                }
                            }
                            if (match)
                            {
                                match = returnType == null || i.ReturnType == returnType;
                            }
                            if (match)
                            {
                                return(i);
                            }
                        }
                    }
                }
            }
            if (genericArguments != null && genericMethod != null)
            {
                var m = genericMethod.MakeGenericMethod(genericArguments);
                lst.Add(( ILMethod )m);
                return(m);
            }
            if (declaredOnly)
            {
                return(null);
            }
            else
            {
                if (BaseType != null)
                {
                    return(BaseType.GetMethod(name, param, genericArguments, returnType, false));
                }
                else
                {
                    return(null);
                }
            }
        }
Example #26
0
 public override string SemanticError(BaseType leftType, BaseType rightType)
 {
     return($"Comparison is not supported between {leftType} and {rightType} types.");
 }
        /// <summary>
        /// generate geometry for GeoSphere
        /// </summary>
        /// <param name="mesh">mesh to be generated</param>
        /// <param name="radius">radius of sphere</param>
        /// <param name="subdivision">number of subdivision</param>
        /// <param name="baseType">type of generation primitive</param>
        /// <param name="normalsType">type of normals to be generated</param>
        /// <param name="pivotPosition">position of the model pivot</param>
        public static float GenerateGeometry(Mesh mesh, float radius, int subdivision, BaseType baseType, NormalsType normalsType, PivotPosition pivotPosition)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            radius      = Mathf.Clamp(radius, 0, 100);
            subdivision = Mathf.Clamp(subdivision, 0, 6);

            mesh.Clear();

            var sharedVertices = normalsType == NormalsType.Vertex;

            var verticesNum  = GetVertCount(baseType, subdivision, sharedVertices);
            var trianglesNum = GetTriCount(baseType, subdivision);

            // fix for too much vertices
            while (verticesNum > 60000)
            {
                subdivision -= 1;

                verticesNum  = GetVertCount(baseType, subdivision, sharedVertices);
                trianglesNum = GetTriCount(baseType, subdivision);
            }

            var pivotOffset = Vector3.zero;

            switch (pivotPosition)
            {
            case PivotPosition.Botttom: pivotOffset = new Vector3(0.0f, radius, 0.0f);
                break;

            case PivotPosition.Top: pivotOffset = new Vector3(0.0f, -radius, 0.0f);
                break;
            }

            var triangles    = new int[trianglesNum * 3];
            var trianglesTmp = new int[trianglesNum * 3];
            var vertices     = new Vector3[verticesNum];
            var uvs          = new Vector2[verticesNum];

            Vector3[] normals = null;

            // initialize basic primitive
            InitBasePrimitive(radius, baseType, vertices, uvs, triangles);

            var indexLookup = new Dictionary <int, int>();

            var vertIndex = GetVertCount(baseType, 0, sharedVertices);

            for (int i = 0; i < subdivision; i++)
            {
                var newTriIdx = 0;
                var triCount  = GetTriCount(baseType, i) * 3;

                for (int triIdx = 0; triIdx < triCount; triIdx += 3)
                {
                    // get triangle
                    var v1 = triangles[triIdx + 0];
                    var v2 = triangles[triIdx + 1];
                    var v3 = triangles[triIdx + 2];

                    // split each edge in half
                    var va = AddMidPoint(vertices, radius, vertIndex++, v1, v2, indexLookup);
                    var vb = AddMidPoint(vertices, radius, vertIndex++, v2, v3, indexLookup);
                    var vc = AddMidPoint(vertices, radius, vertIndex++, v3, v1, indexLookup);

                    // create 4 new triangles
                    trianglesTmp[newTriIdx + 0] = v1;
                    trianglesTmp[newTriIdx + 1] = va;
                    trianglesTmp[newTriIdx + 2] = vc;

                    trianglesTmp[newTriIdx + 3] = v2;
                    trianglesTmp[newTriIdx + 4] = vb;
                    trianglesTmp[newTriIdx + 5] = va;

                    trianglesTmp[newTriIdx + 6] = v3;
                    trianglesTmp[newTriIdx + 7] = vc;
                    trianglesTmp[newTriIdx + 8] = vb;

                    trianglesTmp[newTriIdx + 9]  = va;
                    trianglesTmp[newTriIdx + 10] = vb;
                    trianglesTmp[newTriIdx + 11] = vc;

                    newTriIdx += 12;
                }

                var swapTmp = trianglesTmp;
                trianglesTmp = triangles;
                triangles    = swapTmp;
            }

            // duplicate shared vertices if we are dealing with faces normals
            if (normalsType == NormalsType.Face)
            {
                MeshUtils.DuplicateSharedVertices(ref vertices, ref uvs, triangles, -1);
            }

            // generate spherical uv mapping
            for (int i = 0; i < verticesNum; i++)
            {
                uvs[i] = GetSphericalUV(ref vertices[i]);
            }

            var verticesList = new List <Vector3>(vertices);
            var uvList       = new List <Vector2>(uvs);
            var triangleList = new List <int>(triangles);

            CorrectSeam(verticesList, uvList, triangleList);
            CorrectPoles(verticesList, uvList, ref triangleList, radius);

            vertices  = verticesList.ToArray();
            triangles = triangleList.ToArray();

            if (normalsType == NormalsType.Vertex)
            {
                CalculateNormals(vertices, out normals);
            }
            else
            {
                MeshUtils.ComputeVertexNormals(vertices, triangles, out normals);
            }

            CorrectPivot(verticesList, pivotPosition, ref pivotOffset);

            trianglesTmp = null;

            if (verticesList.Count > 60000)
            {
                Debug.LogError("Too much vertices!");
                return(0.0f);
            }

            mesh.vertices  = verticesList.ToArray();
            mesh.uv        = uvList.ToArray();
            mesh.triangles = triangleList.ToArray();
            mesh.normals   = normals;

            mesh.RecalculateBounds();
            MeshUtils.CalculateTangents(mesh);
            ;

            stopWatch.Stop();
            return(stopWatch.ElapsedMilliseconds);
        }
        /// <summary>
        /// set vertices and triangles for base geosphere primitive
        /// </summary>
        /// <param name="radius">radius of geosphere</param>
        /// <param name="baseType">base type of geosphere</param>
        /// <param name="vertices">vertices array</param>
        /// <param name="uvs">uv array</param>
        /// <param name="triangles">triangle indices array</param>
        static void InitBasePrimitive(float radius, BaseType baseType, Vector3[] vertices, Vector2[] uvs, int[] triangles)
        {
            switch (baseType)
            {
            case BaseType.Tetrahedron:
            {
                var b = 1.0f / Mathf.Sqrt(2);
                var c = 1.0f / Mathf.Sqrt(1.0f + 0.5f);
                var a = 0.67f * radius / c;
                b = 0.67f * radius * b / c;

                // 4 vertices
                SetVertices(vertices, new Vector3(a, 0, -b), new Vector3(-a, 0, -b),
                            new Vector3(0, a, b), new Vector3(0, -a, b));

                // 4 triangles
                SetTriangles(triangles, 0, 1, 2, 1, 3, 2, 0, 2, 3, 0, 3, 1);
            }
            break;

            case BaseType.Octahedron:
            {
                // 6 vertices
                SetVertices(vertices, new Vector3(0, -radius, 0),      //0
                            new Vector3(-radius, 0, 0),                //1
                            new Vector3(0, 0, -radius),                //2
                            new Vector3(radius, 0, 0),                 //3
                            new Vector3(0, 0, radius),                 //4
                            new Vector3(0, radius, 0));                //5

                // 8 triangles
                SetTriangles(triangles, 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 1,
                             5, 2, 1, 5, 3, 2, 5, 4, 3, 5, 1, 4);
            }
            break;

            case BaseType.Icosahedron:
            {
                var a     = 1.0f;
                var b     = (1.0f + Mathf.Sqrt(5.0f)) / 2.0f;
                var scale = radius / Mathf.Sqrt(a * a + b * b);
                a = a * scale;
                b = b * scale;

                // 12 vertices
                SetVertices(vertices, new Vector3(-a, b, 0), new Vector3(a, b, 0),
                            new Vector3(-a, -b, 0), new Vector3(a, -b, 0),
                            new Vector3(0, -a, b), new Vector3(0, a, b),
                            new Vector3(0, -a, -b), new Vector3(0, a, -b),
                            new Vector3(b, 0, -a), new Vector3(b, 0, a),
                            new Vector3(-b, 0, -a), new Vector3(-b, 0, a));

                // 20 triangles
                SetTriangles(triangles, 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10,
                             0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2,
                             10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2,
                             3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5,
                             2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1);
            }
            break;

            case BaseType.Icositetrahedron:
            {
                float c = radius;
                float r = radius / Mathf.Sqrt(3);

                // 14 vertices
                SetVertices(vertices, new Vector3(0, c, 0), new Vector3(0, -c, 0),
                            new Vector3(c, 0, 0), new Vector3(-c, 0, 0),
                            new Vector3(0, 0, c), new Vector3(0, 0, -c),
                            new Vector3(-r, r, r), new Vector3(-r, r, -r),
                            new Vector3(r, r, -r), new Vector3(r, r, r),
                            new Vector3(-r, -r, r), new Vector3(-r, -r, -r),
                            new Vector3(r, -r, -r), new Vector3(r, -r, r));

                // 24 triangles
                SetTriangles(triangles, 0, 7, 6, 0, 8, 7, 0, 9, 8, 0, 6, 9,
                             1, 10, 11, 1, 11, 12, 1, 12, 13, 1, 13, 10,
                             2, 8, 9, 2, 9, 13, 2, 13, 12, 2, 12, 8,
                             3, 6, 7, 3, 7, 11, 3, 11, 10, 3, 10, 6,
                             4, 9, 6, 4, 13, 9, 4, 10, 13, 4, 6, 10,
                             5, 7, 8, 5, 8, 12, 5, 12, 11, 5, 11, 7);
            }
            break;
            }
        }
Example #29
0
 public BaseType EchoBaseType(BaseType param_BaseType)
 {
     return(param_BaseType);
 }
Example #30
0
 public Argument(string name, BaseType type, string description = null)
 {
     _name        = name;
     _type        = type;
     _description = description;
 }
Example #31
0
 public bool Resolve(ICollection <IEntity> resultingSet, string name, EntityType typesToConsider)
 {
     return(BaseType.Resolve(resultingSet, name, typesToConsider));
 }
Example #32
0
        public override bool ResetMembers(MetaOperations metaOperation, AgentType agentType, BaseType baseType, MethodDef method, PropertyDef property)
        {
            bool bReset = false;

            if (this.Opl != null)
            {
                bReset |= this.Opl.ResetMembers(metaOperation, agentType, baseType, method, property);
            }

            if (this.Opr1 != null)
            {
                bReset |= this.Opr1.ResetMembers(metaOperation, agentType, baseType, method, property);
            }

            if (this.Opr2 != null)
            {
                bReset |= this.Opr2.ResetMembers(metaOperation, agentType, baseType, method, property);
            }

            foreach (TransitionEffector effector in Effectors)
            {
                bReset |= effector.ResetMembers(metaOperation, agentType, baseType, method, property);
            }

            bReset |= base.ResetMembers(metaOperation, agentType, baseType, method, property);

            if (bReset && metaOperation != MetaOperations.CheckProperty && metaOperation != MetaOperations.CheckMethod)
            {
                OnPropertyValueChanged(false);
            }

            return(bReset);
        }
Example #33
0
 public void Generate_StructHasFields_GeneratesPropertiesWithCorrectTypes(
     BaseType type)
 {
     // Arrange
     var input =
Example #34
0
		static private string getTypeName(BaseType value)
		{
		    return value.Type.TypeName;
		}
 protected override Expression <Func <BaseType, bool> > FindExisting(BaseType record)
 => existing
 => existing.IdentifierId == record.IdentifierId &&
 ((existing.TypeArgumentListId == null && record.TypeArgumentListId == null) || (existing.TypeArgumentListId == record.TypeArgumentListId));
Example #36
0
 public override void Assign(BaseType value)
 {
     if (value.GetType() == typeof(Struct) && StructuralEquals(value as Struct))
     {
         foreach (var item in (value as Struct).Attributes.Values)
             this[item.Name] = item.Clone();
     }
     else
     {
         throw new UserDefinedTypeException(
             string.Format("Struct {0} is structural unequivalent with struct {1} !",
             Name, (value as Struct).Name));
     }
 }
Example #37
0
 public override bool IsAssignable(BaseType otherType)
 {
     return(otherType is RealType || otherType is IntegerType);
 }
 public void ShouldDiscardNonDeclaredParameters() {
   var base_type = new BaseType();
   try {
     object obj = RuntimeTypeFactory<ITestFactory>
       .CreateInstance(node_, base_type, string.Empty);
   } catch {
     Assert.Fail("Non declared parameters should be discarded");
   }
 }
Example #39
0
 private void FixOldItems()
 {
     if ((BaseType.EndsWith("Crude Bow") || BaseType.EndsWith("Short Bow") || BaseType.EndsWith("Grove Bow") || BaseType.EndsWith("Thicket Bow")) && Height == 4)
     {
         Height = 3;
     }
     if (GearGroup == GearGroup.Chest && Height == 4)
     {
         Height = 3;
     }
 }
Example #40
0
        // Parses RestrictionField fields
        // Now only set up to recognize arrays
        private void ParseRestrictionField(URTNamespace parsingNamespace,
                                           BaseType parsingType)
        {
            Util.Log("WsdlParser.ParseRestrictionField Enter NS "+parsingNamespace+" type "+parsingType);
            // Lookup field name

            String attrName = LookupAttribute(s_baseString, null, true);
            String baseNS = ParseQName(ref attrName, parsingNamespace);
            //if (MatchingStrings(baseNS, s_soapEncodingString) && MatchingStrings(attrName, s_arrayString))
            {
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                // Parse the type
                String elementName;
                String arrayNS;
                String arrayType;
                int enumFacetNum = 0;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    Util.Log("WsdlParser.ParseRestrictionField elementName "+elementName);
                    if (MatchingStrings(elementName, s_attributeString))
                    {
                        String refValue = LookupAttribute(s_refString, null, true);
                        String refNS = ParseQName(ref refValue, parsingNamespace);
                        if (MatchingStrings(refNS, s_soapEncodingString) && MatchingStrings(refValue, s_arrayTypeString))
                        {
                            URTComplexType parsingComplexType = (URTComplexType)parsingType;
                            arrayType = LookupAttribute(s_arrayTypeString, s_wsdlNamespaceString, true);
                            Util.Log("WsdlParser.ParseRestrictionField arrayType "+arrayType);
                            URTNamespace arrayNamespace = null;
                            arrayNS = ParseQName(ref arrayType, null, out arrayNamespace);

                            parsingComplexType.AddArray(arrayType, arrayNamespace);
                            //Add array to the array namespace
                            arrayNamespace.AddComplexType(parsingComplexType); 
                            parsingComplexType.IsPrint = false;
                        }
                    }
                    else if (MatchingStrings(elementName, s_enumerationString))
                    {
                        URTSimpleType parsingSimpleType = (URTSimpleType)parsingType;
                        ParseEnumeration(parsingSimpleType, enumFacetNum);
                        ++enumFacetNum;
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                    }
                    ReadNextXmlElement();
                }
            }
            // else
            // SkipXmlElement();

            Util.Log("WsdlParser.ParseRestrictionField Exit NS "+parsingNamespace+" type "+parsingType);
            return;
        }
Example #41
0
        public static bool DecodeChunk(Stream inputStream, ref DataFrame instance)
        {
            // 3. DataSetFlags1
            instance.Flags1.RawValue = (byte)inputStream.ReadByte();

            // 4. DataSetFlags2
            if (instance.Flags1.Flags1.HasFlag(DataSetFlags1Enum.DataSetFlags2Enabled))
            {
                instance.Flags2.RawValue = (byte)inputStream.ReadByte();
            }

            // 5. Message Sequence Number
            if (instance.Flags1.Flags1.HasFlag(DataSetFlags1Enum.DataSetSequenceNumberEnabled))
            {
                ushort?sequence = BaseType.ReadUInt16(inputStream);
                if (sequence != null)
                {
                    instance.DataSetMessageSequenceNumber = sequence.Value;
                }
                else
                {
                    // ToDo: Log error
                    return(false);
                }
            }

            // evaluate the following options only if DataSetFlags2 field is provided
            if (instance.Flags1.Flags1.HasFlag(DataSetFlags1Enum.DataSetFlags2Enabled))
            {
                // Timestamp
                if (instance.Flags2.Flags2.HasFlag(DataSetFlags2Enum.TimeStampEnabled))
                {
                    long?timestamp = BaseType.ReadInt64(inputStream);
                    if (timestamp != null)
                    {
                        instance.Timestamp = DateTime.FromFileTimeUtc(timestamp.Value);

                        //instance.Timestamp = DateTime.FromBinary(timestamp.Value);
                    }
                    else
                    {
                        // ToDo: Log error
                        return(false);
                    }
                }
            }

            // 6. Major & Minor
            //
            // we always expect both, minor and major version; ensure that both
            // bits are set in DataSetFlags1
            //
            if (instance.Flags1.Flags1.HasFlag(DataSetFlags1Enum.ConfigurationVersionMajorVersion))
            {
                if (instance.Flags1.Flags1.HasFlag(DataSetFlags1Enum.ConfigurationVersionMinorVersion))
                {
                    // read minor and major version, must both exist
                    instance.ConfigurationVersion = ConfigurationVersion.Decode(inputStream);
                }
                else
                {
                    throw new Exception("DataSetMessageHeader: Minor Configuration Version not present.");
                }
            }
            else
            {
                if (instance.Flags1.Flags1.HasFlag(DataSetFlags1Enum.ConfigurationVersionMinorVersion))
                {
                    throw new Exception("DataSetMessageHeader: Major Configuration Version not present.");
                }
            }
            return(true);
        }
Example #42
0
 public ItemType(BaseType baseItemType, int subItemType)
 {
     this.itemBaseType = baseItemType;
     this.subItemType = subItemType;
 }
Example #43
0
 public override void Write(MetadataBuffer buffer, IBinaryStreamWriter writer)
 {
     writer.WriteByte((byte)ElementType);
     BaseType.Write(buffer, writer);
 }
Example #44
0
        /// <summary>
        /// Matches all methods that can be overriden (non-static, public or protected, abstract or virtual)
        /// within this type sub-tree (this type, its base and interfaces)
        /// with its override.
        /// Methods without an override are either abstract or a ghost stup has to be synthesized.
        /// </summary>
        /// <param name="diagnostics"></param>
        internal OverrideInfo[] ResolveOverrides(DiagnosticBag diagnostics)
        {
            if (_lazyOverrides != null)
            {
                // already resolved
                return(_lazyOverrides);
            }

            // TODO: ignore System.Object ?

            // inherit abstracts from base type
            var overrides = new List <OverrideInfo>();

            if (BaseType != null)
            {
                overrides.AddRange(BaseType.ResolveOverrides(diagnostics));
            }

            // collect this type declared methods including synthesized methods
            var methods       = this.GetMembers().OfType <MethodSymbol>();
            var methodslookup = methods.Where(OverrideHelper.CanOverride).ToLookup(m => m.RoutineName);

            // resolve overrides of inherited members
            for (int i = 0; i < overrides.Count; i++)
            {
                var m = overrides[i];
                if (m.HasOverride == false)
                {
                    // update override info of the inherited member
                    overrides[i] = new OverrideInfo(m.Method, OverrideHelper.ResolveMethodImplementation(m.Method, methodslookup[m.RoutineName]));
                }
                else
                {
                    // clear the interface flag of inherited override info
                    m.ImplementsInterface = false;
                    overrides[i]          = m;
                }
            }

            // resolve overrides of interface methods
            foreach (var iface in Interfaces)
            {
                if (BaseType != null && BaseType.ImplementsInterface(iface))
                {
                    // iface is already handled within overrides => skip
                    // note: iface can be ignored in metadata at all actually
                    continue;
                }

                var iface_abstracts = iface.ResolveOverrides(diagnostics);
                foreach (var m in iface_abstracts)
                {
                    if (BaseType != null && m.Method.ContainingType != iface && BaseType.ImplementsInterface(m.Method.ContainingType))
                    {
                        // iface {m.Method.ContainingType} already handled within overrides => skip
                        continue;
                    }

                    // add interface member,
                    // resolve its override
                    overrides.Add(new OverrideInfo(m.Method, OverrideHelper.ResolveMethodImplementation(m.Method, this))
                    {
                        ImplementsInterface = true
                    });
                }
            }

            // add overrideable routines from this type
            foreach (var m in methods)
            {
                if (m.IsOverrideable())
                {
                    overrides.Add(new OverrideInfo(m));
                }
            }

            // report unresolved abstracts
            if (!this.IsInterface && !this.IsAbstract)
            {
                foreach (var m in overrides)
                {
                    if (m.IsUnresolvedAbstract)
                    {
                        // TODO: diagnostics.Add()
                    }
                }
            }

            // cache & return
            return(_lazyOverrides = overrides.ToArray());
        }
Example #45
0
 public virtual bool ResetMembers(MetaOperations metaOperation, AgentType agentType, BaseType baseType, MethodDef method, PropertyDef property)
 {
     return(false);
 }
Example #46
0
        public HExpr Cast(BaseType type, HExpr a)
        {
            var src = GetExpression(a);

            return(MapToHandle(m.Convert(src, src.DataType, Interop.DataTypes[type])));
        }
 public override string GetTypeName(BaseType type)
 {
     return($"{type.Name}QueryHandler");
 }
 internal override string FormatType(NdrFormatter context)
 {
     return($"{context.FormatComment("FC_PIPE")} {BaseType.FormatType(context)}");
 }
Example #49
0
        public void ValidateValue(ref object value, string keyword = null, bool isXProtocol = false)
        {
            bool b;

            if (value == null)
            {
                return;
            }
            string typeName  = BaseType.Name;
            Type   valueType = value.GetType();

            if (valueType.Name == "String")
            {
                if (BaseType == valueType)
                {
                    return;
                }
                else if (BaseType == typeof(bool))
                {
                    if (string.Compare("yes", (string)value, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        value = true;
                    }
                    else if (string.Compare("no", (string)value, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        value = false;
                    }
                    else if (Boolean.TryParse(value.ToString(), out b))
                    {
                        value = b;
                    }
                    else
                    {
                        throw new ArgumentException(String.Format(Resources.ValueNotCorrectType, value));
                    }
                    return;
                }
            }

            if (typeName == "Boolean" && Boolean.TryParse(value.ToString(), out b))
            {
                value = b; return;
            }

            UInt64 uintVal;

            if (typeName.StartsWith("UInt64") && UInt64.TryParse(value.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out uintVal))
            {
                value = uintVal; return;
            }

            UInt32 uintVal32;

            if (typeName.StartsWith("UInt32") && UInt32.TryParse(value.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out uintVal32))
            {
                value = uintVal32; return;
            }

            Int64 intVal;

            if (typeName.StartsWith("Int64") && Int64.TryParse(value.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out intVal))
            {
                value = intVal; return;
            }

            Int32 intVal32;

            if (typeName.StartsWith("Int32") && Int32.TryParse(value.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out intVal32))
            {
                value = intVal32; return;
            }

            object objValue;
            Type   baseType = BaseType.GetTypeInfo().BaseType;

            if (baseType != null && baseType.Name == "Enum" && ParseEnum(value.ToString(), out objValue))
            {
                value = objValue;
                return;
            }

            if (!string.IsNullOrEmpty(keyword) && isXProtocol)
            {
                switch (keyword)
                {
                case "compression":
                    throw new ArgumentException(string.Format(ResourcesX.CompressionInvalidValue, value));
                }
            }

            throw new ArgumentException(String.Format(Resources.ValueNotCorrectType, value));
        }
 public override int GetSize()
 {
     return(BaseType.GetSize());
 }
Example #51
0
 public VariableGraphics(string name, BaseType value)
     : base(String.Format("{0} {1} : ", getTypeName(value), name),
         Graphics.Factories.GraphicsElementFactory.Produce(value))
 {
 }
Example #52
0
 public static void AddTypeWithRecipe(BaseType type)
 {
     TypesThatHaveRecipes.Add(type);
 }
 public void ShouldRecognizeDerivedTypes() {
   var base_type = new BaseType();
   try {
     object obj = RuntimeTypeFactory<ITestFactory>
       .CreateInstance(node_, base_type);
   } catch {
     Assert.Fail(
       "Derived type should be accepted as argument for base type parameter");
   }
 }
Example #54
0
 public override BaseObject FromTileType(BaseType tileType, StageData.Stage stage, FruitData fruitData)
 {
     return(new Switch());
 }
 public static void RunFromBase(BaseType obj)
 {
     obj.MethodFromBaseType();
     obj.Method();
 }
Example #56
0
 public ScalarType(BaseType baseType, Span span, string asString) : base(span, asString)
 {
     BaseType = baseType;
 }
Example #57
0
            internal void AddNestedType(BaseType ct)
            {
                if (_nestedTypes == null)
                    _nestedTypes = new ArrayList(10);

                _nestedTypes.Add(ct);
            }
Example #58
0
 public ScalarType(BaseType baseType) : this(baseType, new Span(), "")
 {
 }
Example #59
0
 //for item db purposes
 public ItemType(BaseType baseItemType, int subItemType, EquipSlot equipSlot)
 {
     this.itemBaseType = baseItemType;
     this.subItemType = subItemType;
     this.itemSlot = equipSlot;
 }
Example #60
0
 public override void Bind(TypeDefinition tdef)
 {
     base.Bind(tdef);
     BaseType.SelectedOperand = tdef != null ? tdef.BaseType : null;
     BaseType.Refresh(tdef);
 }