Exemple #1
0
        public static void sendValueBool(ValueBool item)
        {
            var context = GlobalHost.ConnectionManager.GetHubContext <TradeHub>();

            context.Clients.All.addValueBool(item);
            //Console.WriteLine(String.Format("{0:dd/MM/yyyy H:mm:ss.fff}, {1}, сигнал {2}", item.DateTime, item.Value, item.Name));
        }
        public string ValueToString(string DateTimeFormat = null)
        {
            if (ActionParameter.ParameterType.UnderlyingTypeEnum == PARAMETER_TYPE_UNDERLYING.Bool)
            {
                return(ValueBool.ToString());
            }
            else if (ActionParameter.ParameterType.UnderlyingTypeEnum == PARAMETER_TYPE_UNDERLYING.DateTime)
            {
                return(((DateTime)ValueDateTime).ToString(DateTimeFormat));
            }
            else if (ActionParameter.ParameterType.UnderlyingTypeEnum == PARAMETER_TYPE_UNDERLYING.Guid)
            {
                return(ValueGuid.ToString());
            }
            else if (ActionParameter.ParameterType.UnderlyingTypeEnum == PARAMETER_TYPE_UNDERLYING.Integer)
            {
                return(ValueInteger.ToString());
            }
            else if (ActionParameter.ParameterType.UnderlyingTypeEnum == PARAMETER_TYPE_UNDERLYING.Decimal)
            {
                return(ValueDecimal.ToString());
            }

            return(ValueString);
        }
Exemple #3
0
        private void readValueArray(BinaryReader br)
        {
            if (ValueLength == 0)
            {
                return;
            }

            Value[] Values = new Value[ArrayCount];

            for (int i = 0; i < ArrayCount; i++)
            {
                switch (Type)
                {
                case ShaderParameterType.@int:
                    Values[i] = new ValueInt(br);
                    break;

                case ShaderParameterType.@float:
                    Values[i] = new ValueFloat(br);
                    break;

                case ShaderParameterType.float2:
                    Values[i] = new ValueFloat2(br);
                    break;

                case ShaderParameterType.float3:
                    Values[i] = new ValueFloat3(br);
                    break;

                case ShaderParameterType.float4:
                    Values[i] = new ValueFloat4(br);
                    break;

                case ShaderParameterType.@bool:
                    Values[i] = new ValueBool(br);
                    break;

                case ShaderParameterType.float4x3:
                    Values[i] = new ValueFloat4x3(br);
                    break;

                case ShaderParameterType.float4x4:
                    Values[i] = new ValueFloat4x4(br);
                    break;

                case ShaderParameterType.sampler:
                    int len = ValueLength / ArrayCount;
                    Values[i] = new ValueSamplerState(br, len);
                    break;
                }
            }
            Value = new ValueList(Values);
        }
Exemple #4
0
        private void readValue(BinaryReader br)
        {
            if (ValueLength == 0)
            {
                return;
            }

            switch (Type)
            {
            case ShaderParameterType.@int:
                Value = new ValueInt(br);
                break;

            case ShaderParameterType.@float:
                Value = new ValueFloat(br);
                break;

            case ShaderParameterType.float2:
                Value = new ValueFloat2(br);
                break;

            case ShaderParameterType.float3:
                Value = new ValueFloat3(br);
                break;

            case ShaderParameterType.float4:
                Value = new ValueFloat4(br);
                break;

            case ShaderParameterType.@bool:
                Value = new ValueBool(br);
                break;

            case ShaderParameterType.float4x3:
                Value = new ValueFloat4x3(br);
                break;

            case ShaderParameterType.float4x4:
                Value = new ValueFloat4x4(br);
                break;

            case ShaderParameterType.sampler:
                Value = new ValueSamplerState(br, ValueLength);
                break;
            }
        }
Exemple #5
0
        public override void ApplyPropertyValues()
        {
            PropertyInfo[] instanceProperties = GetType().GetProperties(PropertyFlags);
            foreach (PropertyInfo prop in instanceProperties)
            {
                if (prop.GetCustomAttribute <PropertyAttribute>() == null)
                {
                    continue;
                }

                PropertyMixedAttribute mixedAttr = prop.GetCustomAttribute <PropertyMixedAttribute>();

                if (prop.PropertyType == typeof(ValueInt))
                {
                    if (mixedAttr == null)
                    {
                        prop.SetValue(this, PropertySet.GetValue <ValueInt>(prop.Name));
                    }
                    else
                    {
                        ValueBool mixed = PropertySet.GetValue <ValueBool>(prop.Name + "_mixed");
                        prop.SetValue(this, PropertySet.GetValue <ValueInt>(prop.Name + ((bool)mixed ? "_enum" : "_int")));
                    }
                }
                else if (prop.PropertyType == typeof(ValueBool))
                {
                    prop.SetValue(this, PropertySet.GetValue <ValueBool>(prop.Name));
                }
                else if (prop.PropertyType == typeof(ValueChar))
                {
                    prop.SetValue(this, PropertySet.GetValue <ValueChar>(prop.Name));
                }
                else if (prop.PropertyType.IsGenericType)
                {
                    Type type = typeof(ValueEnum <>).MakeGenericType(prop.PropertyType.GetGenericArguments()[0]);
                    prop.SetValue(this, Convert.ChangeType(PropertySet.GetValue <ValueInt>(prop.Name), type));
                }
            }
        }
Exemple #6
0
    //public static implicit operator WorldStateProp(bool state) { return new WorldStateProp(state);}

    public bool GetBool()
    {
        ValueBool b = PropValue as ValueBool; return(b != null ? b.Bool : false);
    }
 internal ValueFunctionOverload(ValueFunction function)
 {
     WritableMetadata[keyIsOverload] = new ValueBool(true);
     Add(function);
 }
        public void TestSingleTypeless()
        {
            Value pattern = PatternData.Single("a");
            Value match = null, leftover = null;

            {	// single item - match
                Value input = new ValueBool(true);
                Assert.IsTrue(PatternChecker.Do(input, pattern, false/*bShortPat*/, out match, out leftover));
                Assert.IsTrue(match.AsBool);
                Assert.AreEqual(null, leftover);
            }
        }
        public void TestMap()
        {
            Map map = new Map();
            map["do?"] = PatternData.Single("do?", ValueType.Bool);
            map["body"] = PatternData.Body();
            ValueMap pattern = new ValueMap(map);
            Value match = null, leftover = null;

            {	// single object - not a match
                Value input = PatternData.Single("a");
                Assert.IsFalse(PatternChecker.Do(input, pattern, false/*bShortPat*/, out match, out leftover));
            }

            {	// input is a map w/ fewer keys - match w/ leftover
                map = new Map();
                map["do?"] = new ValueBool(true);
                ValueMap input = new ValueMap(map);

                Assert.IsTrue(PatternChecker.Do(input, pattern, false/*bShortPat*/, out match, out leftover));
                Assert.AreEqual(1, match.AsMap.Count);
                Assert.AreEqual(true, match.AsMap["do?"].AsBool);
                Assert.AreEqual(1, leftover.AsMap.Count);
                Assert.AreEqual("l3.body", leftover.AsMap["body"].AsString);
            }

            {	// map w/ same keys - match
                map = new Map();
                map["do?"] = new ValueBool(true);
                map["body"] = PatternData.Body();
                ValueMap input = new ValueMap(map);

                Assert.IsTrue(PatternChecker.Do(input, pattern, false/*bShortPat*/, out match, out leftover));
                Assert.AreEqual(2, match.AsMap.Count);
                Assert.AreEqual(true, match.AsMap["do?"].AsBool);
                Assert.AreEqual("l3.body", match.AsMap["body"].AsString);
                Assert.AreEqual(null, leftover);
            }

            {	// map w/ extra keys - not a match
                map = new Map();
                map["do?"] = new ValueBool(true);
                map["body"] = PatternData.Body();
                map["something"] = new ValueInt(42);
                ValueMap input = new ValueMap(map);

                Assert.IsFalse(PatternChecker.Do(input, pattern, false/*bShortPat*/, out match, out leftover));
            }
        }
Exemple #10
0
        public void TestBool()
        {
            Value pattern = PatternData.Single("a", ValueType.Bool);
            Value match = null, leftover = null;

            {	// single bool type - match
                Value input = new ValueBool(true);
                Assert.IsTrue(PatternChecker.Do(input, pattern, false/*bShortPat*/, out match, out leftover));
                Assert.IsTrue(match.AsBool);
                Assert.AreEqual(null, leftover);
            }

            {	// single int type - not a match
                Value input = new ValueInt(42);
                Assert.IsFalse(PatternChecker.Do(input, pattern, false/*bShortPat*/, out match, out leftover));
            }
        }