コード例 #1
0
 internal SignalWonderware(string signalInf, string code, DataType dataType, IProvider provider, int idInClone)
     : base(signalInf, code, dataType, provider, idInClone)
 {
     TagName = Inf["TagName"];
     Bit     = Inf.GetInt("Bit", -1);
     Value   = new SingleValue(SingleType.List);
 }
コード例 #2
0
ファイル: TemplateBuilder.cs プロジェクト: retahc/old-code
        // If we need to access our owning structure, record the fact.

        void CheckStructRel(SingleValue <string> val)
        {
            if (val.IsTarget)
            {
                UseStructure();
            }
        }
コード例 #3
0
            public VmEqVar(VmEquations parent, SingleValue singleValue, bool isCalculated, bool refreshNow = false)
            {
                try
                {
                    DefineCommands();

                    _parent      = parent;
                    _singleValue = singleValue;

                    _IsCalculated = isCalculated;

                    _knownUOM = _parent.ContentManager.DefaultUOMSet.FindFromParamType(singleValue.ParamType);

                    // ------------- Refresh items that will not change after this instance is created
                    OnPropertyChanged("IsCalculated");
                    OnPropertyChanged("CanChangeUom");

                    // ------------- Refresh other items if required
                    if (refreshNow)
                    {
                        RefreshThisData();
                    }
                }
                catch (Exception ex)
                {
                    Logging.LogException(ex);
                    throw;
                }
            }
コード例 #4
0
ファイル: XElementHelper.cs プロジェクト: rrajaguk/QOEParser
        public static XElement generateFromSingleValue(SingleValue SV)
        {
            XElement XE = generateFromValue(SV);

            XE.Name = "SingleValue";
            return(XE);
        }
コード例 #5
0
            static void Main(string[] args)
            {
                var single1 = new SingleValue();
                var single2 = new SingleValue();
                var many1   = new ManyValues();
                var many2   = new ManyValues();

                single1.Value = 1;
                single2.Value = 2;

                many1.Add(single1.Value);
                many1.Add(single2.Value);
                many2.Add(single2.Value);
                many2.Add(single2.Value);

                List <IValueContainer> x = new List <IValueContainer>();

                x.Add(many1);
                x.Add(many2);
                x.Add(single1);
                x.Add(single2);

                Console.WriteLine(x.Sum());
                Console.ReadLine();
            }
コード例 #6
0
ファイル: ValueExtensions.cs プロジェクト: vitek-karas/linker
        internal static string ValueToString(this SingleValue value, params object[] args)
        {
            if (value == null)
            {
                return("<null>");
            }

            StringBuilder sb = new ();

            sb.Append(value.GetType().Name);
            sb.Append("(");
            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if (i > 0)
                    {
                        sb.Append(",");
                    }
                    sb.Append(args[i] == null ? "<null>" : args[i].ToString());
                }
            }
            sb.Append(")");
            return(sb.ToString());
        }
コード例 #7
0
 public CalcValue(SingleValue value, CalcUnit signal = null)
 {
     Type        = CalcValueType.Single;
     SingleValue = value;
     Signal      = signal;
     Error       = value.Error;
 }
コード例 #8
0
ファイル: WrenchTarget.cs プロジェクト: emtees/old-code
	public void AddWaitTag (string name, SingleValue<string> value) 
	{
	    if (wait_tags == null)
		wait_tags = new Dictionary<string,SingleValue<string>> ();
	    
	    wait_tags[name] = value;
	}
コード例 #9
0
        public static void Run()
        {
            // ExStart:1
            CellsApi   cellsApi   = new CellsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            String fileName  = "Sample_Test_Book.xls";
            String sheetName = "Sheet1";
            String formula   = "SUM(A5:A10)";
            String storage   = "";
            String folder    = "";

            try
            {
                // Upload source file to aspose cloud storage
                storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));

                // Invoke Aspose.Cells Cloud SDK API to calculate formula in a worksheet
                SingleValueResponse apiResponse = cellsApi.GetWorkSheetCalculateFormula(fileName, sheetName, formula, storage, folder);

                if (apiResponse != null && apiResponse.Status.Equals("OK"))
                {
                    SingleValue resultValue = apiResponse.Value;
                    Console.WriteLine("Calculated value:" + resultValue.Value);
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
コード例 #10
0
        public void ConstructorSetsValue()
        {
            var value  = "a data value";
            var result = new SingleValue(value);

            Assert.AreEqual(value, result.Value);
        }
コード例 #11
0
        static void Main(string[] args)
        {
            var stringOpt = Maybe <string> .Some("Hello, World");

            Console.WriteLine($"The length of the given string is {stringOpt.Match(() => 0, _ => _.Length)}");
            Console.WriteLine($"The length of the given string is {stringOpt.Map(_ => _.Length).Fold(0, (_, x) => x)}");

            var lenOpt = from s in Maybe <string> .Some("Hello, World")
                         select s.Length;

            Console.WriteLine($"The length of the given string is {lenOpt.GetOrElse(0)}");


            var lenOpt2 = from s1 in Maybe <string> .None
                          select s1.Length;

            Console.WriteLine($"The length of the given string is {lenOpt2.GetOrElse(0)}");

            var userName1 = SingleValue <string> .Some("john");

            var userName2 = SingleValue <string> .Some("john");

            Console.WriteLine($"The two usernames are equal : {userName1 == userName2}");

            ((Maybe <string>)userName1).Match(() => null, _ => { Console.WriteLine("Call me Maybe!"); return(string.Empty); });
        }
コード例 #12
0
        public void Test_SingleValue_Definition_OK()
        {
            SingleValue expected = new SingleValue();

            expected.Name   = "ola testing ah";
            expected.Value  = "11223355";
            expected.Length = expected.Value.Length / 2;

            XElement XE = new XElement("SingleValue");

            XE.Add(new XAttribute("Length", expected.Length.ToString()));
            XE.Add(new XAttribute("Default", expected.Value));
            XE.Add(new XAttribute("Name", expected.Name));


            ValueItem result = xmlParser.getItem(XE);

            Assert.IsInstanceOfType(result, typeof(SingleValue));

            SingleValue res = (SingleValue)result;

            Assert.AreEqual(expected.Value, res.Value);
            Assert.AreEqual(expected.Length, res.Length);
            Assert.AreEqual(expected.Name, res.Name);
        }
コード例 #13
0
ファイル: SingleValueTests.cs プロジェクト: aib/MagicConfig
        public void SingleValueEqualsWorks()
        {
            {
                SingleValue <MyBoolean> sv1 = MyBoolean.TRUE;
                SingleValue <MyBoolean> sv2 = MyBoolean.TRUE;
                Assert.True(sv1.Equals(sv2));
            }

            {
                SingleValue <MyBoolean> sv1 = MyBoolean.TRUE;
                SingleValue <MyBoolean> sv2 = MyBoolean.FILE_NOT_FOUND;
                Assert.False(sv1.Equals(sv2));
            }

            {
                SingleValue <MyBoolean> sv1 = MyBoolean.FILE_NOT_FOUND;
                SingleValue <MyBoolean> sv2 = (MyBoolean)2;
                Assert.True(sv1.Equals(sv2));
            }

            {
                SingleValue <int> sv1 = 42;
                SingleValue <int> sv2 = 42;
                Assert.True(sv1.Equals(sv2));
            }
        }
コード例 #14
0
        // ------------------------

        private View DisplaySingleValue(SingleValue expr)
        {
            string      text = expr.Text;
            ResultLabel rLbl;

            if (expr is Constant)
            {
                rLbl = new ConstantResultLabel()
                {
                    Text              = Constant.RemovePrefix(text),
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    SingleResult      = expr,
                    FontAttributes    = FontAttributes.Italic,
                };
            }
            else
            {
                rLbl = new ValueResultLabel()
                {
                    Text              = expr.Text,
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    SingleResult      = expr
                };
            }

            return(rLbl);
        }
コード例 #15
0
ファイル: SingleValueTests.cs プロジェクト: aib/MagicConfig
        public void SingleValueInvalidAssignmentThrows()
        {
            SingleValue <int>    i1 = 4;
            MyFalseEquatableItem i2 = new MyFalseEquatableItem();

            Assert.Throws <ConfigItem.InvalidTypeAssignmentException>(() => i1.Assign(i2));
        }
コード例 #16
0
        public void TestCase_SingleValue()
        {
            var d = 1.4f;

            var value = new SingleValue();

            Assert.AreEqual(PropertyDefinitionType.Data, value.PropertyDefType);
            Assert.AreEqual(PropertyValueType.Single, value.Type);
            Assert.True(value.IsNull);
            Assert.Throws <Exception>(() => { var v = value.Value; });
            Assert.Throws <Exception>(() => { var v = value.ValueAsString(); });
            value.Value = d;
            Assert.NotNull(value.Value);
            Assert.AreEqual(d, value.Value);
            Assert.AreEqual("1.4", value.ValueAsString());
            Assert.False(value.IsNull);

            value = new SingleValue(d);
            Assert.False(value.IsNull);
            Assert.NotNull(value.Value);
            Assert.AreEqual(d, value.Value);

            value.SetNull();
            Assert.True(value.IsNull);
            Assert.Throws <Exception>(() => { var v = value.Value; });
        }
コード例 #17
0
        //Значение для записи в Value или Variables
        private static string SvToStr(SingleValue sv)
        {
            if (sv == null || sv.Type == SingleType.Void)
            {
                return("");
            }
            if (sv.Type == SingleType.Segments)
            {
                if (sv.Error != null)
                {
                    return("сегменты(Ошибка)");
                }
                return("сегменты");
            }
            var    mv = sv.LastMoment;
            string s  = "";

            if (mv.DataType != DataType.Value)
            {
                s = mv.DataType == DataType.Time ? mv.Date.ToStringWithMs() : mv.String;
            }
            if (mv.Error == null)
            {
                if (mv.Nd == 0)
                {
                    return(s);
                }
                return(s + "(Nd=" + mv.Nd + ")");
            }
            if (mv.Nd == 0)
            {
                return(s + "(Ошибка)");
            }
            return(s + "(Ошибка,Nd=" + mv.Nd + ")");
        }
コード例 #18
0
        public void Composer_SingleValue_OK()
        {
            // value in object
            SingleValue value1 = new SingleValue();

            value1.Name   = "val 1";
            value1.Value  = "0022";
            value1.Length = 2;

            SingleValue value2 = new SingleValue();

            value2.Name   = "val 2";
            value2.Value  = string.Empty;
            value2.Length = 2;


            // value definition in XML
            XElement definition = new XElement("Definition");

            definition.Add(XElementHelper.generateFromSingleValue(value1));
            definition.Add(XElementHelper.generateFromSingleValue(value2));


            Composer composer = new Composer();

            composer.ParseValueDefinition(definition);

            Assert.AreEqual(2, composer.Vals.Count);
            AreEqualSingleValue(value1, (SingleValue)composer.Vals[0]);
            AreEqualSingleValue(value2, (SingleValue)composer.Vals[1]);
        }
コード例 #19
0
 private void AreEqualSingleValue(SingleValue expected, SingleValue result)
 {
     Assert.IsInstanceOfType(result, typeof(SingleValue));
     Assert.AreEqual(expected.Length, result.Length);
     Assert.AreEqual(expected.Name, result.Name);
     Assert.AreEqual(expected.Value, result.Value);
 }
コード例 #20
0
            public void FullyConnectedLayerForwardPass()
            {
                var actual = _layer.PassForward(_input);

                var expected = new SingleValue(new double[] { 0.602190358, 0.535738948, 0.225901511 });

                Helper.CompareSingleValues(actual, expected);
            }
コード例 #21
0
 internal SignalOvation(string signalInf, string code, DataType dataType, IProvider provider, int idInClone)
     : base(signalInf, code, dataType, provider, idInClone)
 {
     Id      = Inf.GetInt("Id");
     Bit     = Inf.GetInt("Bit", -1);
     IsState = Inf["Prop"] == "STAT";
     Value   = new SingleValue(SingleType.List);
 }
コード例 #22
0
 public _(SingleValue parent, IObserver <TSource> observer)
     : base(observer)
 {
     _source    = parent._source;
     _value     = parent._value;
     _scheduler = parent.Scheduler;
     _append    = parent._append;
 }
コード例 #23
0
ファイル: DICOMData.cs プロジェクト: zoulianmp/Evil-DICOM
 /// <summary>
 /// Converts the data to a string separated value
 /// </summary>
 /// <param name="split">the separation character to use between the data elements (default is \)</param>
 /// <returns>the data as a string</returns>
 public string ToString(string split = "\\")
 {
     if (MultipicityValue.Count > 1)
     {
         return(string.Join(split, MultipicityValue.ToArray()));
     }
     return(SingleValue != null?SingleValue.ToString() : "");
 }
コード例 #24
0
        public void CreateIntegerValue()
        {
            var value = new SingleValue <int>(42);

            Assert.AreEqual(42, value.GetValue());
            Assert.AreEqual(0, value.Rank);
            Assert.AreEqual(0, value.Shape.Length);
        }
コード例 #25
0
ファイル: DICOMData.cs プロジェクト: top501/Evil-DICOM
 public override string ToString()
 {
     if (MultipicityValue.Count > 1)
     {
         return(string.Join(" | ", MultipicityValue.ToArray()));
     }
     return(SingleValue != null?SingleValue.ToString() : "");
 }
コード例 #26
0
 public override void Deserialize(XElement element)
 {
     if (element.HasAttribute("value"))
     {
         Value = new SingleValue();
         Value.Deserialize(element);
     }
 }
コード例 #27
0
ファイル: SingleValueTests.cs プロジェクト: aib/MagicConfig
        public void SingleValueAssignmentChangesValue()
        {
            SingleValue <MyBoolean> sv1 = MyBoolean.TRUE;
            SingleValue <MyBoolean> sv2 = MyBoolean.FILE_NOT_FOUND;

            sv1.Assign(sv2);
            Assert.Equal <MyBoolean>(MyBoolean.FILE_NOT_FOUND, sv2);
        }
コード例 #28
0
ファイル: ValueExtensions.cs プロジェクト: vitek-karas/linker
        internal static int?AsConstInt(this SingleValue value)
        {
            if (value is ConstIntValue constInt)
            {
                return(constInt.Value);
            }

            return(null);
        }
コード例 #29
0
ファイル: WrenchTarget.cs プロジェクト: retahc/old-code
        public void AddWaitTag(string name, SingleValue <string> value)
        {
            if (wait_tags == null)
            {
                wait_tags = new Dictionary <string, SingleValue <string> > ();
            }

            wait_tags[name] = value;
        }
コード例 #30
0
ファイル: SingleValueTests.cs プロジェクト: aib/MagicConfig
        public void SingleValueDoesNotEqualNull()
        {
            SingleValue <int> sv = 42;

            Assert.False(sv.Equals(null));
            Assert.False(sv.Equals((SingleValue <int>)null));
            Assert.False(sv.Equals((SingleValue <MyBoolean>)null));
            Assert.False(sv.Equals((ConfigItem)null));
        }
コード例 #31
0
        int CompileSingleValue(SingleValue <TargetBuilder> sv)
        {
            if (sv.IsTarget)
            {
                return(((WrenchTarget)(TargetBuilder)sv).Id);
            }

            return(RegisterResult((Result)sv));
        }
コード例 #32
0
 public void ValueIsPassedCorrectly()
 {
     var expected = "some test value";
     var original = new SingleValue
                        {
                            Value = expected
                        };
     var result = original.DoRoundTripTest();
     Assert.AreEqual(expected, result.Value);
 }
コード例 #33
0
ファイル: TemplateBuilder.cs プロジェクト: emtees/old-code
	public void AddDep (string arg, SingleValue<string> val)
	{
	    info.AddDep (arg, val);
	    CheckStructRel (val);
	}
コード例 #34
0
		public bool VisitDefaultValue (int arg, SingleValue<TargetBuilder> sv)
		{
		    default_vals[arg] = bsg.CompileSingleValue (sv);
		    return false;
		}
コード例 #35
0
ファイル: XmlGraphSerializer.cs プロジェクト: emtees/old-code
	    // Deps

	    public bool VisitUnnamed (SingleValue<TargetBuilder> sv)
	    {
		return WriteValue ("u", -1, sv);
	    }
コード例 #36
0
ファイル: XmlGraphSerializer.cs プロジェクト: emtees/old-code
	    public bool VisitDefaultValue (int aid, SingleValue<TargetBuilder> sv)
	    {
		return WriteValue ("D", aid, sv);
	    }
コード例 #37
0
ファイル: TemplateBuilder.cs プロジェクト: emtees/old-code
	public void AddDefault (string arg, SingleValue<string> val)
	{
	    info.SetDefault (arg, val);
	    CheckStructRel (val);
	}
コード例 #38
0
ファイル: TemplateBuilder.cs プロジェクト: emtees/old-code
	public void AddTag (string tag, SingleValue<string> val)
	{
	    info.AddTag (tag, val);
	    CheckStructRel (val);
	}
コード例 #39
0
ファイル: LocalNativeRecord.cs プロジェクト: kanbang/Colt
        public LocalNativeRecord(MgReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw)
        {
            for (int i = 0; i < reader.GetPropertyCount(); i++)
            {
                string name = reader.GetPropertyName(i);

                _ordinalMap[i] = name;

                var pt = (PropertyValueType)reader.GetPropertyType(name);
                switch (pt)
                {
                    case PropertyValueType.Blob:
                        _values[name] = new BlobValue();
                        break;
                    case PropertyValueType.Boolean:
                        _values[name] = new BooleanValue();
                        break;
                    case PropertyValueType.Byte:
                        _values[name] = new ByteValue();
                        break;
                    case PropertyValueType.Clob:
                        _values[name] = new ClobValue();
                        break;
                    case PropertyValueType.DateTime:
                        _values[name] = new DateTimeValue();
                        break;
                    case PropertyValueType.Double:
                        _values[name] = new DoubleValue();
                        break;
                    case PropertyValueType.Feature:
                        _values[name] = new FeatureValue();
                        break;
                    case PropertyValueType.Geometry:
                        _values[name] = new GeometryValue();
                        break;
                    case PropertyValueType.Int16:
                        _values[name] = new Int16Value();
                        break;
                    case PropertyValueType.Int32:
                        _values[name] = new Int32Value();
                        break;
                    case PropertyValueType.Int64:
                        _values[name] = new Int64Value();
                        break;
                    case PropertyValueType.Raster:
                        _values[name] = new RasterValue();
                        break;
                    case PropertyValueType.Single:
                        _values[name] = new SingleValue();
                        break;
                    case PropertyValueType.String:
                        _values[name] = new StringValue();
                        break;
                }
            }

            for (int i = 0; i < reader.GetPropertyCount(); i++)
            {
                string name = _ordinalMap[i];
                GetByteReaderMethod getblob = () => { return reader.GetBLOB(name); };
                GetByteReaderMethod getclob = () => { return reader.GetCLOB(name); };
                GetByteReaderMethod getgeom = () => { return reader.GetGeometry(name); };
                if (!reader.IsNull(name))
                {
                    var pt = (PropertyValueType)reader.GetPropertyType(name);
                    switch (pt)
                    {
                        case PropertyValueType.Blob:
                            ((BlobValue)_values[name]).Value = Utility.StreamAsArray(new MgReadOnlyStream(getblob));
                            break;
                        case PropertyValueType.Boolean:
                            ((BooleanValue)_values[name]).Value = reader.GetBoolean(name);
                            break;
                        case PropertyValueType.Byte:
                            ((ByteValue)_values[name]).Value = reader.GetByte(name);
                            break;
                        case PropertyValueType.Clob:
                            byte [] b = Utility.StreamAsArray(new MgReadOnlyStream(getclob));
                            ((ClobValue)_values[name]).Value = Encoding.UTF8.GetChars(b);
                            break;
                        case PropertyValueType.DateTime:
                            ((DateTimeValue)_values[name]).Value = Utility.ConvertMgDateTime(reader.GetDateTime(name));
                            break;
                        case PropertyValueType.Double:
                            ((DoubleValue)_values[name]).Value = reader.GetDouble(name);
                            break;
                        //case PropertyValueType.Feature:
                        case PropertyValueType.Geometry:
                            try
                            {
                                //TODO: See if SWIG issues come into play here
                                var geom = agfRw.Read(reader.GetGeometry(name));
                                var wkt = wktRw.Write(geom);
                                ((GeometryValue)_values[name]).Value = mgReader.Read(wkt);
                            }
                            catch //Invalid geometry fail!
                            {
                                ((GeometryValue)_values[name]).SetNull();
                            }
                            break;
                        case PropertyValueType.Int16:
                            ((Int16Value)_values[name]).Value = reader.GetInt16(name);
                            break;
                        case PropertyValueType.Int32:
                            ((Int32Value)_values[name]).Value = reader.GetInt32(name);
                            break;
                        case PropertyValueType.Int64:
                            ((Int64Value)_values[name]).Value = reader.GetInt64(name);
                            break;
                        case PropertyValueType.Single:
                            ((SingleValue)_values[name]).Value = reader.GetSingle(name);
                            break;
                        case PropertyValueType.String:
                            ((StringValue)_values[name]).Value = reader.GetString(name);
                            break;
                    }
                }
            }
        }
コード例 #40
0
		public bool VisitUnnamed (SingleValue<TargetBuilder> sv)
		{
		    unnamed_vals.Add (bsg.CompileSingleValue (sv));
		    return false;
		}
コード例 #41
0
		public bool VisitNamed (int arg, SingleValue<TargetBuilder> sv)
		{
		    if (!named_vals.ContainsKey (arg))
			named_vals[arg] = new List<int> ();

		    named_vals[arg].Add (bsg.CompileSingleValue (sv));
		    return false;
		}
コード例 #42
0
 private static DataValue ConvertSingle(SingleValue singleValue, DataType dataType, bool truncate)
 {
     switch (dataType)
     {
         case DataType.DataType_String:
             {
                 return new StringValue(singleValue.ToString());
             }
         case DataType.DataType_Double:
             {
                 return new DoubleValue(Convert.ToDouble(singleValue.Single));
             }
         case DataType.DataType_Decimal:
             {
                 return new DecimalValue(Convert.ToDouble(singleValue.Single));
             }
         case DataType.DataType_Int16:
             {
                 float f = singleValue.Single;
                 try
                 {
                     short sh = Convert.ToInt16(f);
                     return new Int16Value(sh);
                 }
                 catch (OverflowException)
                 {
                     if (truncate)
                     {
                         if (f > (float)short.MaxValue)
                             return new Int16Value(short.MaxValue);
                         else if (f < (float)short.MinValue)
                             return new Int16Value(short.MinValue);
                         else
                             return new Int16Value((short)f);
                     }
                 }
                 return null;
             }
         case DataType.DataType_Int32:
             {
                 if (truncate)
                     return new Int32Value(Convert.ToInt32(singleValue.Single));
                 else
                     return null;
             }
         case DataType.DataType_Int64:
             {
                 if (truncate)
                     return new Int64Value(Convert.ToInt64(singleValue.Single));
                 else
                     return null;
             }
         default:
             return null;
     }
 }
コード例 #43
0
ファイル: XmlGraphSerializer.cs プロジェクト: emtees/old-code
	    public bool VisitNamed (int aid, SingleValue<TargetBuilder> sv)
	    {
		return WriteValue ("n", aid, sv);
	    }
コード例 #44
0
ファイル: TemplateBuilder.cs プロジェクト: emtees/old-code
	// If we need to access our owning structure, record the fact.

	void CheckStructRel (SingleValue<string> val)
	{
	    if (val.IsTarget)
		UseStructure ();
	}
コード例 #45
0
        /// <summary>
        /// Gets the values.
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ValueExpression> GetValues()
        {
            Dictionary<string, ValueExpression> values = new Dictionary<string, ValueExpression>();
            foreach (DataGridViewRow row in grdProperties.Rows)
            {
                string name = row.Cells[0].Value.ToString();
                PropertyDefinition propDef = row.Cells[0].Tag as PropertyDefinition;
                if (row.Cells[1].Value != null)
                {
                    string str = row.Cells[1].Value.ToString();
                    if (!string.IsNullOrEmpty(str))
                    {
                        ValueExpression expr = null;
                        if (propDef.PropertyType == PropertyType.PropertyType_DataProperty)
                        {
                            DataPropertyDefinition dp = propDef as DataPropertyDefinition;
                            switch (dp.DataType)
                            {
                                case DataType.DataType_Boolean:
                                    expr = new BooleanValue(Convert.ToBoolean(str));
                                    break;
                                case DataType.DataType_Byte:
                                    expr = new ByteValue(Convert.ToByte(str));
                                    break;
                                case DataType.DataType_DateTime:
                                    expr = new DateTimeValue(Convert.ToDateTime(str));
                                    break;
                                case DataType.DataType_Decimal:
                                    expr = new DecimalValue(Convert.ToDouble(str));
                                    break;
                                case DataType.DataType_Double:
                                    expr = new DoubleValue(Convert.ToDouble(str));
                                    break;
                                case DataType.DataType_Int16:
                                    expr = new Int16Value(Convert.ToInt16(str));
                                    break;
                                case DataType.DataType_Int32:
                                    expr = new Int32Value(Convert.ToInt32(str));
                                    break;
                                case DataType.DataType_Int64:
                                    expr = new Int64Value(Convert.ToInt64(str));
                                    break;
                                case DataType.DataType_Single:
                                    expr = new SingleValue(Convert.ToSingle(str));
                                    break;
                                case DataType.DataType_String:
                                    expr = new StringValue(str);
                                    break;
                                default:
                                    throw new NotSupportedException("Unsupported data type: " + dp.DataType);
                            }
                        }
                        else if (propDef.PropertyType == PropertyType.PropertyType_GeometricProperty)
                        {
                            FdoGeometryFactory fact = FdoGeometryFactory.Instance;
                            OSGeo.FDO.Geometry.IGeometry geom = fact.CreateGeometry(str);
                            byte[] fgf = fact.GetFgf(geom);
                            expr = new GeometryValue(fgf);
                            geom.Dispose();
                        }

                        if (expr != null)
                            values.Add(name, expr);
                    }
                }
            }
            return values;
        }
コード例 #46
0
 public void ConstructorSetsValue()
 {
     var value = "a data value";
     var result = new SingleValue(value);
     Assert.AreEqual(value, result.Value);
 }
コード例 #47
0
ファイル: XmlGraphSerializer.cs プロジェクト: emtees/old-code
	    bool WriteValue (string elt, int aid, SingleValue<TargetBuilder> sv)
	    {
		if (sv.IsTarget)
		    return WriteTarget (elt + "t", aid, (WrenchTarget) (TargetBuilder) sv);
		else
		    return WriteResult (elt + "r", aid, (Result) sv);
	    }
コード例 #48
0
	void AddDictionaryValue (TargetBuilder tb, string key, SingleValue<string> val)
	{
	    cur_constructed.tb.AddDep ("keys", new MBString (key));
	    cur_constructed.tb.AddDep ("vals", val);
	}
コード例 #49
0
	    public LinkList (SingleValue<string> item, LinkList prev) 
	    {
		this.item = item;
		this.prev = prev;
	    }
コード例 #50
0
ファイル: XmlGraphSerializer.cs プロジェクト: emtees/old-code
	    public bool VisitDefaultOrdered (SingleValue<TargetBuilder> sv)
	    {
		return WriteValue ("do", -1, sv);
	    }
コード例 #51
0
	// Conditionals

	void SetupConditional (SingleValue<string> cond, SingleValue<string> ifyes, 
			       SingleValue<string> ifno)
	{
	    cur_constructed.tb.TemplateName = "Core.Switch";

	    cur_constructed.tb.AddDep ("cases", cond);
	    cur_constructed.tb.AddDefaultOrdered (ifyes);
	    cur_constructed.tb.AddDep ("cases", MBBool.True);
	    cur_constructed.tb.AddDefaultOrdered (ifno);
	}
コード例 #52
0
	int CompileSingleValue (SingleValue<TargetBuilder> sv)
	{
	    if (sv.IsTarget)
		return ((WrenchTarget) (TargetBuilder) sv).Id;

	    return RegisterResult ((Result) sv);
	}
コード例 #53
0
	    public LinkList (SingleValue<string> item) : this (item, null) {}
コード例 #54
0
        public void SingleValueTest()
        {
            SingleValue target = new SingleValue();
            target.InnerText = "NaN";

            Assert.True(target.HasValue);
            Assert.Equal(float.NaN, target.Value);

            target.InnerText = "INF";
            Assert.True(target.HasValue);
            Assert.Equal(float.PositiveInfinity, target.Value);

            target.InnerText = "-INF";
            Assert.True(target.HasValue);
            Assert.Equal(float.NegativeInfinity, target.Value);

            target.InnerText = "765.43211234E11";
            Assert.True(target.HasValue);
            Assert.Equal((float)765.43211234E11, target.Value);

            target.InnerText = "7E7";
            Assert.True(target.HasValue);
            Assert.Equal((float)7E7, target.Value);

            target.InnerText = "1.0";
            Assert.True(target.HasValue);
            Assert.Equal((float)1.0, target.Value);

            target.Value = (float)1.0;
            Assert.True(target.HasValue);
            Assert.Equal(((float)1.0).ToString(), target.InnerText);

            target.Value = (float)7E7;
            Assert.True(target.HasValue);
            Assert.Equal(((float)7E7).ToString(), target.InnerText);

            target.Value = (float)765.43211234E11;
            Assert.True(target.HasValue);
            Assert.Equal(((float)765.43211234E11).ToString(), target.InnerText);

            target.Value = float.NaN;
            Assert.True(target.HasValue);
            Assert.Equal("NaN", target.InnerText);

            target.Value = float.PositiveInfinity;
            Assert.True(target.HasValue);
            Assert.Equal("INF", target.InnerText);

            target.Value = float.NegativeInfinity;
            Assert.True(target.HasValue);
            Assert.Equal("-INF", target.InnerText);

            //target.InnerText = "Infinity";
            //Assert.True(target.HasValue);
            //Assert.Equal("INF", target.InnerText);

            //target.InnerText = "-Infinity";
            //Assert.True(target.HasValue);
            //Assert.Equal("-INF", target.InnerText);
        }
コード例 #55
0
        private void Prepare(PropertyValueCollection propVals)
        {
            propVals.Clear();
            currentValues.Clear();

            // I do not trust the long-term stability of the PropertyValueCollection
            //
            // So what we do is load it up once with LiteralValue references and manipulate these
            // outside of the collection (via a cached dictionary). We cache everything from the wrapper API 
            // that can be cached in the managed world so that we only have minimal contact with it

            // Omit read-only properties
            using (FdoFeatureService service = _conn.CreateFeatureService())
            {
                ClassDefinition c = service.GetClassByName(this.ClassName);
                foreach (PropertyDefinition p in c.Properties)
                {
                    string name = p.Name;
                    PropertyValue pv = new PropertyValue(name, null);
                    if (p.PropertyType == PropertyType.PropertyType_DataProperty)
                    {
                        DataPropertyDefinition d = p as DataPropertyDefinition;
                        if (!d.ReadOnly && !d.IsAutoGenerated) 
                        {
                            DataValue dv = null;
                            switch (d.DataType)
                            {
                                case DataType.DataType_BLOB:
                                    dv = new BLOBValue();
                                    break;
                                case DataType.DataType_Boolean:
                                    dv = new BooleanValue();
                                    break;
                                case DataType.DataType_Byte:
                                    dv = new ByteValue();
                                    break;
                                case DataType.DataType_CLOB:
                                    dv = new CLOBValue();
                                    break;
                                case DataType.DataType_DateTime:
                                    dv = new DateTimeValue();
                                    break;
                                case DataType.DataType_Decimal:
                                    dv = new DecimalValue();
                                    break;
                                case DataType.DataType_Double:
                                    dv = new DoubleValue();
                                    break;
                                case DataType.DataType_Int16:
                                    dv = new Int16Value();
                                    break;
                                case DataType.DataType_Int32:
                                    dv = new Int32Value();
                                    break;
                                case DataType.DataType_Int64:
                                    dv = new Int64Value();
                                    break;
                                case DataType.DataType_Single:
                                    dv = new SingleValue();
                                    break;
                                case DataType.DataType_String:
                                    dv = new StringValue();
                                    break;
                            }
                            if (dv != null)
                            {
                                pv.Value = dv;
                                propVals.Add(pv);
                            }
                        }
                    }
                    else if (p.PropertyType == PropertyType.PropertyType_GeometricProperty)
                    {
                        GeometricPropertyDefinition g = p as GeometricPropertyDefinition;
                        if (!g.ReadOnly)
                        {
                            GeometryValue gv = new GeometryValue();
                            pv.Value = gv;
                            propVals.Add(pv);
                        }
                    }
                }
                c.Dispose();
            }

            //Load property values into temp dictionary
            foreach (PropertyValue p in propVals)
            {
                currentValues[p.Name.Name] = p.Value as LiteralValue;
            }

            if (propertySnapshot == null)
            {
                propertySnapshot = new List<string>();
                foreach (PropertyValue p in propVals)
                {
                    propertySnapshot.Add(p.Name.Name);
                }
            }
        }
コード例 #56
0
        public void OpenXmlSimpleTypeConverterTest()
        {
            // 1. Base64BinaryValue
            Base64BinaryValue base64 = new Base64BinaryValue();
            base64 = "AA3322";
            Assert.True("AA3322" == base64);
            Assert.Equal("AA3322", base64.Value);
            base64 = Base64BinaryValue.FromString("1234");
            Assert.Equal("1234", base64.ToString());
            Assert.Equal("1234", Base64BinaryValue.ToString(base64));

            // 2. BooleanValue
            BooleanValue booleanValue = new BooleanValue();
            booleanValue = true;
            Assert.True(booleanValue);
            Assert.True(booleanValue.Value);
            booleanValue = BooleanValue.FromBoolean(false);
            Assert.False(booleanValue);
            Assert.Equal(false, BooleanValue.ToBoolean(booleanValue));

            // 3. ByteValue
            ByteValue byteValue = new ByteValue();
            Byte bt = 1;
            byteValue = bt;
            Assert.True(bt == byteValue);
            Assert.Equal(bt, byteValue.Value);
            bt = 2;
            byteValue = ByteValue.FromByte(bt);
            Assert.Equal(bt, ByteValue.ToByte(byteValue));

            // 4. DateTimeValue
            DateTimeValue dtValue = new DateTimeValue();
            DateTime dt = DateTime.Now;
            dtValue = dt;
            Assert.True(dt == dtValue);
            dt = DateTime.Now.AddDays(1);
            dtValue = DateTimeValue.FromDateTime(dt);
            Assert.Equal(dt, dtValue.Value);
            Assert.Equal(dt, DateTimeValue.ToDateTime(dt));

            // 5. DecimalValue
            DecimalValue decimalValue = new DecimalValue();
            decimal dcm = 10;
            decimalValue = dcm;
            Assert.True(dcm == decimalValue);
            decimalValue = DecimalValue.FromDecimal(20);
            Assert.Equal(20, decimalValue.Value);
            Assert.Equal(20, DecimalValue.ToDecimal(decimalValue));

            // 6. DoubleValue
            DoubleValue doubleValue = new DoubleValue();
            double dbl = 1.1;
            doubleValue = dbl;
            Assert.True(dbl == doubleValue);
            doubleValue = DoubleValue.FromDouble(2.2);
            Assert.Equal(2.2, doubleValue.Value);
            Assert.Equal(2.2, DoubleValue.ToDouble(doubleValue));

            // 7. HexBinaryValue
            HexBinaryValue hexBinaryValue = new HexBinaryValue();
            string hex = "0X99CCFF";
            hexBinaryValue = hex;
            Assert.True(hex == hexBinaryValue);
            hex = "111111";
            hexBinaryValue = HexBinaryValue.FromString(hex);
            Assert.Equal(hex, hexBinaryValue.Value);
            Assert.Equal(hex, HexBinaryValue.ToString(hexBinaryValue));

            // 8. Int16
            Int16Value int16Value = new Int16Value();
            Int16 int16 = 16;
            int16Value = int16;
            Assert.True(int16 == int16Value);
            int16 = 17;
            int16Value = Int16Value.FromInt16(int16);
            Assert.Equal(int16, int16Value.Value);
            Assert.Equal(int16, Int16Value.ToInt16(int16Value));

            // 9. Int32
            Int32Value int32Value = new Int32Value();
            Int32 int32 = 32;
            int32Value = int32;
            Assert.True(int32 == int32Value);
            int32 = 33;
            int32Value = Int32Value.FromInt32(int32);
            Assert.Equal(int32, int32Value.Value);
            Assert.Equal(int32, Int32Value.ToInt32(int32Value));

            // 10. Int64
            Int64Value int64Value = new Int64Value();
            Int64 int64 = 64;
            int64Value = int64;
            Assert.True(int64 == int64Value);
            int64 = 17;
            int64Value = Int64Value.FromInt64(int64);
            Assert.Equal(int64, int64Value.Value);
            Assert.Equal(int64, Int64Value.ToInt64(int64Value));

            // 11. IntegerValue
            IntegerValue integerValue = new IntegerValue();
            int integer = 64;
            integerValue = integer;
            Assert.True(integer == integerValue);
            integer = 17;
            integerValue = IntegerValue.FromInt64(integer);
            Assert.Equal(integer, integerValue.Value);
            Assert.Equal(integer, IntegerValue.ToInt64(integerValue));

            // 12. OnOffValue
            OnOffValue onOffValue = new OnOffValue();
            onOffValue = true;
            Assert.True(onOffValue);
            onOffValue = OnOffValue.FromBoolean(false);
            Assert.Equal(false, onOffValue.Value);
            Assert.Equal(false, OnOffValue.ToBoolean(onOffValue));

            // 13. SByteValue
            SByteValue sbyteValue = new SByteValue();
            SByte sbt = SByte.MaxValue;
            sbyteValue = sbt;
            Assert.True(sbt == sbyteValue);
            sbt = SByte.MinValue;
            sbyteValue = SByteValue.FromSByte(sbt);
            Assert.Equal(sbt, sbyteValue.Value);
            Assert.Equal(sbt, SByteValue.ToSByte(sbt));

            // 14. SingleValue
            SingleValue singleValue = new SingleValue();
            Single single = Single.MaxValue;
            singleValue = single;
            Assert.True(single == singleValue);
            single = Single.NaN;
            singleValue = SingleValue.FromSingle(single);
            Assert.Equal(single, singleValue.Value);
            Assert.Equal(single, SingleValue.ToSingle(singleValue));

            // 15. StringValue
            StringValue stringValue = new StringValue();
            String str = "Ethan";
            stringValue = str;
            Assert.True(str == stringValue);
            str = "Yin";
            stringValue = StringValue.FromString(str);
            Assert.Equal(str, stringValue.Value);
            Assert.Equal(str, stringValue.ToString());
            Assert.Equal(str, StringValue.ToString(stringValue));

            // 16. TrueFalseBlankValue
            TrueFalseBlankValue tfbValue = new TrueFalseBlankValue();
            tfbValue = true;
            Assert.True(tfbValue);
            tfbValue = TrueFalseBlankValue.FromBoolean(false);
            Assert.Equal(false, tfbValue.Value);
            Assert.Equal(false, TrueFalseBlankValue.ToBoolean(tfbValue));

            // 17. TrueFalseValue
            TrueFalseValue tfValue = new TrueFalseValue();
            tfValue = true;
            Assert.True(tfValue);
            tfValue = TrueFalseValue.FromBoolean(false);
            Assert.Equal(false, tfValue.Value);
            Assert.Equal(false, TrueFalseValue.ToBoolean(tfValue));

            // 18. UInt16Value
            UInt16Value uint16Value = new UInt16Value();
            UInt16 uint16 = UInt16.MaxValue;
            uint16Value = uint16;
            Assert.True(uint16 == uint16Value);
            uint16 = UInt16.MinValue;
            uint16Value = UInt16Value.FromUInt16(uint16);
            Assert.Equal(uint16, uint16Value.Value);
            Assert.Equal(uint16, UInt16Value.ToUInt16(uint16Value));

            // 19. UInt32Value
            UInt32Value uint32Value = new UInt32Value();
            UInt32 uint32 = UInt32.MaxValue;
            uint32Value = uint32;
            Assert.True(uint32 == uint32Value);
            uint32 = UInt32.MinValue;
            uint32Value = UInt32Value.FromUInt32(uint32);
            Assert.Equal(uint32, uint32Value.Value);
            Assert.Equal(uint32, UInt32Value.ToUInt32(uint32Value));

            // 20. UInt64Value
            UInt64Value uint64Value = new UInt64Value();
            UInt64 uint64 = UInt64.MaxValue;
            uint64Value = uint64;
            Assert.True(uint64 == uint64Value);
            uint64 = UInt64.MinValue;
            uint64Value = UInt64Value.FromUInt64(uint64);
            Assert.Equal(uint64, uint64Value.Value);
            Assert.Equal(uint64, UInt64Value.ToUInt64(uint64Value));
        }
コード例 #57
0
	void SetTargetAsValue (SingleValue<string> val)
	{
	    cur_targ.RuleType = typeof (CloneRule);
	    cur_targ.AddDep (val);
	}
コード例 #58
0
        public void Bug520719()
        {
            // the following test should pass without Assert() in debug version.
            
            var int8 = new SByteValue();
            int8.InnerText = "+10";
            Assert.Equal(10, int8.Value);
            Assert.Equal("+10", int8.InnerText);

            var int16 = new Int16Value();
            int16.InnerText = "+10";
            Assert.Equal(10, int16.Value);
            Assert.Equal("+10", int16.InnerText);

            var int32 = new Int32Value();
            int32.InnerText = "+10";
            Assert.Equal(10, int32.Value);
            Assert.Equal("+10", int32.InnerText);

            var int64 = new Int64Value();
            int64.InnerText = "+10";
            Assert.Equal(10, int64.Value);
            Assert.Equal("+10", int64.InnerText);

            var integer = new IntegerValue();
            integer.InnerText = "+10";
            Assert.Equal(10, integer.Value);
            Assert.Equal("+10", integer.InnerText);

            var dec = new DecimalValue();
            dec.InnerText = "+10";
            Assert.Equal(10, dec.Value);
            Assert.Equal("+10", dec.InnerText);

            var single = new SingleValue();
            single.InnerText = "+10";
            Assert.Equal(10, single.Value);
            Assert.Equal("+10", single.InnerText);

            var dble = new DoubleValue();
            dble.InnerText = "+10";
            Assert.Equal(10, dble.Value);
            Assert.Equal("+10", dble.InnerText);
        }
コード例 #59
0
ファイル: XmlRecord.cs プロジェクト: kanbang/Colt
        public XmlRecord(XmlProperty[] properties, FixedWKTReader wktReader, XmlNodeList propertyNodes, string nameElement, string valueElement)
        {
            for (int i = 0; i < properties.Length; i++)
            {
                string name = properties[i].Name;
                _ordinalMap[i] = name;

                switch (properties[i].Type)
                {
                    case PropertyValueType.Blob:
                        _values[name] = new BlobValue();
                        break;
                    case PropertyValueType.Boolean:
                        _values[name] = new BooleanValue();
                        break;
                    case PropertyValueType.Byte:
                        _values[name] = new ByteValue();
                        break;
                    case PropertyValueType.Clob:
                        _values[name] = new ClobValue();
                        break;
                    case PropertyValueType.DateTime:
                        _values[name] = new DateTimeValue();
                        break;
                    case PropertyValueType.Double:
                        _values[name] = new DoubleValue();
                        break;
                    case PropertyValueType.Feature:
                        _values[name] = new FeatureValue();
                        break;
                    case PropertyValueType.Geometry:
                        _values[name] = new GeometryValue();
                        break;
                    case PropertyValueType.Int16:
                        _values[name] = new Int16Value();
                        break;
                    case PropertyValueType.Int32:
                        _values[name] = new Int32Value();
                        break;
                    case PropertyValueType.Int64:
                        _values[name] = new Int64Value();
                        break;
                    case PropertyValueType.Raster:
                        _values[name] = new RasterValue();
                        break;
                    case PropertyValueType.Single:
                        _values[name] = new SingleValue();
                        break;
                    case PropertyValueType.String:
                        _values[name] = new StringValue();
                        break;
                }
            }

            foreach (XmlNode propNode in propertyNodes)
            {
                var name = propNode[nameElement].InnerText;
                var valueNode = propNode[valueElement];
                if (valueNode != null)
                {
                    var value = valueNode.InnerText;
                    switch (_values[name].Type)
                    {
                        case PropertyValueType.Blob:
                            ((BlobValue)_values[name]).Value = Encoding.UTF8.GetBytes(value);
                            break;
                        case PropertyValueType.Boolean:
                            ((BooleanValue)_values[name]).Value = XmlConvert.ToBoolean(value);
                            break;
                        case PropertyValueType.Byte:
                            ((ByteValue)_values[name]).Value = XmlConvert.ToByte(value);
                            break;
                        case PropertyValueType.Clob:
                            ((ClobValue)_values[name]).Value = value.ToCharArray();
                            break;
                        case PropertyValueType.DateTime:
                            var dt = ConvertToDateTime(value);
                            if (dt.HasValue)
                                ((DateTimeValue)_values[name]).Value = dt.Value;
                            break;
                        case PropertyValueType.Double:
                            ((DoubleValue)_values[name]).Value = XmlConvert.ToDouble(value);
                            break;
                        case PropertyValueType.Feature:
                            ((FeatureValue)_values[name]).Value = ConvertToFeatures(value);
                            break;
                        case PropertyValueType.Geometry:
                            ((GeometryValue)_values[name]).Value = wktReader.Read(value);
                            break;
                        case PropertyValueType.Int16:
                            ((Int16Value)_values[name]).Value = XmlConvert.ToInt16(value);
                            break;
                        case PropertyValueType.Int32:
                            ((Int32Value)_values[name]).Value = XmlConvert.ToInt32(value);
                            break;
                        case PropertyValueType.Int64:
                            ((Int64Value)_values[name]).Value = XmlConvert.ToInt64(value);
                            break;
                        case PropertyValueType.Raster:
                            ((RasterValue)_values[name]).Value = ConvertToRaster(value);
                            break;
                        case PropertyValueType.Single:
                            ((SingleValue)_values[name]).Value = XmlConvert.ToSingle(value);
                            break;
                        case PropertyValueType.String:
                            ((StringValue)_values[name]).Value = value;
                            break;
                    }
                }
            }
        }
コード例 #60
0
		public bool VisitDefaultOrdered (SingleValue<TargetBuilder> sv)
		{
		    deford_vals.Add (bsg.CompileSingleValue (sv));
		    return false;
		}