コード例 #1
0
		public HtmlElementContext(HtmlElementRule rule, 
			IValueSet parameters) 
			: base(parameters)
		{
			Precondition.Require(rule, () => Error.ArgumentNull("rule"));
			_rule = rule;
		}
コード例 #2
0
        public DbCommandDescriptor(string text, CommandType type, IValueSet parameters)
        {
			_text = text;
			_type = type;
			_timeout = DEFAULT_TIMEOUT;
			_parameters = CreateParameters(parameters);
        }
コード例 #3
0
		public RouteVariableAssigner(IValueSet variables)
		{
			Precondition.Require(variables, () => 
				Error.ArgumentNull("variables"));

			_variables = new ValueDictionary(variables);
		}
コード例 #4
0
		private static ValueDictionary CreateDefaults(IValueSet defaults)
		{
			ValueDictionary values = new ValueDictionary(defaults);
			values.Remove("controller");
			values.Remove("action");

			return values;
		}
コード例 #5
0
        /// <summary>
        /// Processes an input string using the specified 
        /// parsing and typographic rules.
        /// </summary>
		public string Execute(string htmlString, IValueSet parameters)
        {
            Precondition.Require(htmlString, () => Error.ArgumentNull("htmlString"));
            using (StringReader reader = new StringReader(
				"<html>".Append(htmlString).Append("</html>").ToString()))
            {
				return Execute(reader, parameters);
            }
        }
コード例 #6
0
        public HttpStatusResult(int statusCode, string message, IValueSet headers)
        {
			Precondition.Require(statusCode > 0,
				() => Error.ArgumentOutOfRange("statusCode"));

            _statusCode = statusCode;
            _message = message;
			_headers = new ValueDictionary(headers);
        }
コード例 #7
0
		public DictionaryValueProvider(IValueSet values, CultureInfo culture)
			: base(culture)
		{
			_values = new ValueDictionary(values);
			_prefixes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

			foreach (string key in _values.Keys)
				_prefixes.UnionWith(GetPrefixes(key));
		}
コード例 #8
0
		public RouteDescriptor(string url,
			string type, IValueSet attributes, 
			Type handlerType)
		{
			_url = url;
			_type = type;
			_attributes = attributes;
			_handlerType = handlerType;
		}
コード例 #9
0
		protected HttpValueProvider(ControllerContext context, CultureInfo culture)
			: base(culture)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));

			_prefixes = new HashSet<string>(
				StringComparer.OrdinalIgnoreCase);
			_values = EnsureValues(GetDataSource(context));

			Initialize();
		}
コード例 #10
0
        /// <summary>
        /// Initializes the current 
        /// <see cref="Radischevo.Wahha.Web.Mvc.AssemblyResourceViewEngine"/> instance 
        /// using the specified <paramref name="settings"/>.
        /// </summary>
        /// <param name="settings">A settings list for the current instance.</param>
        protected override void Init(IValueSet settings)
        {
            Precondition.Require(settings, () => Error.ArgumentNull("settings"));
            base.Init(settings);

            Provider.AssemblyName = settings.GetValue<string>("assembly");
            Provider.BaseNamespace = settings.GetValue<string>("baseNamespace");
            Provider.VirtualPath = settings.GetValue<string>("virtualPath");

            HostingEnvironment.RegisterVirtualPathProvider(Provider);
        }
コード例 #11
0
ファイル: Support.cs プロジェクト: XiBeichuan/hydronumerics
    /// <summary>
    /// GetVal will get the index´th number of the axisNumber´th component of the 
    /// ValueSet.
    /// </summary>
    /// <param name="values">ValueSet to read the value from.</param>
    /// <param name="index">Index of the value in the ValueSet.</param>
    /// <param name="axisNumber">Relevant for VectorSets only. 1: x, 2: y, 3: z.</param>
    /// <returns>The index´th number of the axisNumber´th component</returns>
    public static double GetVal(IValueSet values, int index, int axisNumber)
    {
      try
      {
        double x;
        if (index > values.Count-1)
        {
          throw new System.Exception("Index exceeds dimension of ValueSet.");
        }
        if (values is IScalarSet)
        {
          if (axisNumber != 1)
          {
            throw new System.Exception("Illigal axisNumber for ScalarSet.");
          }

          x = ((IScalarSet)values).GetScalar(index);
        }

        else if (values is IVectorSet)
        {
          if (axisNumber == 1)
          {
            x = ((IVectorSet) values).GetVector(index).XComponent;
          }
          else if (axisNumber == 2)
          {
            x = ((IVectorSet) values).GetVector(index).YComponent;
          }
          else if (axisNumber == 3)
          {
            x = ((IVectorSet) values).GetVector(index).ZComponent;
          }
          else
          {
            throw new System.Exception("Illigal axisNumber for VectorSet.");
          }
        }
        else
        {
          throw new System.Exception("Illigal value type.");
        }

        return x;
      }
      catch (System.Exception e)
      {
        throw new System.Exception("GetVal failed",e);
      }
    }
コード例 #12
0
 internal NintValueSet(bool hasSmall, IValueSet <int> values, bool hasLarge)
 {
     _hasSmall = hasSmall;
     _values   = values;
     _hasLarge = hasLarge;
 }
コード例 #13
0
ファイル: TestEngine.cs プロジェクト: KangChaofan/OOC
 public void SetValues(string QuantityID, string ElementSetID, IValueSet values)
 {
     for (int i = 0; i < _values.Length; i++)
     {
         _values[i] = ((ScalarSet)values).GetScalar(0);
     }
 }
コード例 #14
0
        public void SetValues(string QuantityID, string ElementSetID, IValueSet values)
        {
            this.values = ((ScalarSet)values).data;

            var sb = new StringBuilder();
            foreach (var nextValue in this.values)
            {
                sb.AppendFormat("{0},", nextValue);
            }

            traceFile.Append("SetValues: " + QuantityID + "/" + ElementSetID + "/" + currentTime + " (" + sb + ")");
        }
コード例 #15
0
		public DbCommandDescriptor(string text, IValueSet parameters)
			: this(text, CommandType.Text, parameters)
		{
		}
コード例 #16
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
		/// <summary>
		/// Gets the typed value with the specified key.
		/// </summary>
		/// <typeparam name="TValue">The type of value.</typeparam>
		/// <param name="key">The key to find.</param>
		/// <param name="provider">An <see cref="IFormatProvider" /> interface implementation that 
		/// supplies culture-specific formatting information.</param>
		public static TValue GetValue<TValue>(this IValueSet values, string name, IFormatProvider provider)
		{
			Precondition.Require(values, () => Error.ArgumentNull("values"));
			return values.GetValue<TValue>(name, default(TValue), provider);
		}
コード例 #17
0
 private static ValueSetApiModel MapToValueSetApiModel(IValueSet vs, IReadOnlyCollection <Guid> codeSystemGuids)
 {
     return(vs.ToValueSetApiModel(codeSystemGuids));
 }
コード例 #18
0
        public void SetValues(string QuantityID, string ElementSetID, IValueSet values)
        {
            if (QuantityID == qtdDischargeFlow.ID)
            {
                double flow = ((ScalarSet)values).data[0];
                MohidWaterEngine.SetDischargeFlow(dischargeInstanceID, Convert.ToInt32(ElementSetID), flow);
            }
            else //Set discharge concentrations
            {
                
                double concentration = ((ScalarSet)values).data[0];

                int dischargeID = Convert.ToInt32(ElementSetID);
                int propertyID = Convert.ToInt32(QuantityID);
                
                MohidWaterEngine.SetDischargeConcentration(dischargeInstanceID, dischargeID, propertyID, concentration);
            }
        }
コード例 #19
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
		public static bool ContainsAny(this IValueSet values)
		{
			Precondition.Require(values, () => Error.ArgumentNull("values"));
			return values.Keys.Any();
		}
コード例 #20
0
        public IValueSet GetValues(ITime time, string linkID)
        {
            // ----------------------------------------------------------------------------------------------------
            // The method queries a HydroDesktop database and builds an IValueSet object for the given a time
            // and link.
            // ----------------------------------------------------------------------------------------------------
            Link l = (Link)_links[linkID];

            IValueSet values;

            if (_exactMatch)
            {
                //
                // Perform Exact Match Routine
                //

                // covert ITime to a DateTime data type
                TimeStamp timestamp = (TimeStamp)time;
                DateTime  dt        = CalendarConverter.ModifiedJulian2Gregorian(
                    (double)timestamp.ModifiedJulianDay);

                //check to see if the buffer contains this time
                if (_times[linkID].Contains(timestamp.ModifiedJulianDay))
                {
                    values = new ScalarSet(new double[_elementCount[linkID]]);
                    values = _buffer[linkID].GetValues(time);
                    //convert the values to the correct units
                    values = ConvertUnit(values, l);
                }
                else
                {
                    values = new ScalarSet(new double[0]);
                }
            }
            else if (_range != -999)
            {
                //
                // Perform Range Searching Routine
                //

                List <ScalarSet> FoundVals = new List <ScalarSet>();

                // covert ITime to a DateTime data type
                TimeStamp timestamp = (TimeStamp)time;
                DateTime  dt        = CalendarConverter.ModifiedJulian2Gregorian(
                    (double)timestamp.ModifiedJulianDay);

                values = new ScalarSet(new double[_elementCount[linkID]]);

                //check to see if the current time is within the known time span
                if (timestamp.ModifiedJulianDay <= _endTimes[linkID].ModifiedJulianDay)
                {
                    TimeStamp currTime = (TimeStamp)time;
                    DateTime  dateTime = CalendarConverter.ModifiedJulian2Gregorian(currTime.ModifiedJulianDay);
                    //dateTime = dateTime.AddSeconds(_range);
                    //get the earliest and latest times based on the specified time range
                    TimeStamp latestTime   = new TimeStamp(CalendarConverter.Gregorian2ModifiedJulian(dateTime.AddSeconds(_range / 2)));
                    TimeStamp earliestTime = new TimeStamp(CalendarConverter.Gregorian2ModifiedJulian(dateTime.AddSeconds(-1 * _range / 2)));

                    //check to make sure tht the latest time is less than the last time in the buffer
                    if (latestTime.ModifiedJulianDay > ((TimeStamp)_buffer[linkID].GetTimeAt(_buffer[linkID].TimesCount - 1)).ModifiedJulianDay)
                    {
                        values = new ScalarSet(new double[0]);
                    }

                    //check to make sure tht the earliest time is greater than the first time in the buffer
                    else if (earliestTime.ModifiedJulianDay < ((TimeStamp)_buffer[linkID].GetTimeAt(0)).ModifiedJulianDay)
                    {
                        values = new ScalarSet(new double[0]);
                    }


                    else
                    {
                        for (int i = _lastIndex[linkID]; i <= _buffer[linkID].TimesCount - 1; i++)
                        {
                            ////loop through the times to find the start and end indices
                            if (((TimeStamp)_buffer[linkID].GetTimeAt(i)).ModifiedJulianDay >= earliestTime.ModifiedJulianDay &&
                                ((TimeStamp)_buffer[linkID].GetTimeAt(i)).ModifiedJulianDay <= latestTime.ModifiedJulianDay)
                            {
                                ScalarSet ss = (ScalarSet)_buffer[linkID].GetValues(_buffer[linkID].GetTimeAt(i));
                                if (ss.data.Length > 0)
                                {
                                    FoundVals.Add(ss);
                                }
                            }
                            //if the latest time has been passed then break
                            else if (((TimeStamp)_buffer[linkID].GetTimeAt(i)).ModifiedJulianDay > latestTime.ModifiedJulianDay)
                            {
                                //save the index that should be used to start with on the next iteration
                                _lastIndex[linkID] = Convert.ToInt32(Math.Floor(Convert.ToDouble(i) - Convert.ToDouble(_lastIndex[linkID]) / 2.0));
                                break;
                            }
                        }
                        if (FoundVals.Count == 1)
                        {
                            values = new ScalarSet(FoundVals[0].data);

                            //convert the values to the correct units
                            values = ConvertUnit(values, l);
                        }
                        else if (FoundVals.Count > 1)
                        {
                            double[] ave     = FoundVals[0].data;
                            int[]    divider = new int[ave.Length];

                            for (int i = 0; i <= ave.Length - 1; i++)
                            {
                                if (ave[i] != 0)
                                {
                                    divider[i]++;
                                }
                            }

                            //HACK:  I'm taking the average of all the values.  Probably should do this smarter.
                            for (int i = 0; i <= FoundVals[0].data.Length - 1; i++)
                            {
                                for (int j = 1; j <= FoundVals.Count - 1; j++)
                                {
                                    if (FoundVals[j].data[i] != 0)
                                    {
                                        ave[i] += FoundVals[j].data[i];
                                        divider[i]++;
                                    }
                                }
                            }

                            for (int i = 0; i <= ave.Length - 1; i++)
                            {
                                if (divider[i] != 0)
                                {
                                    ave[i] = ave[i] / (divider[i]);
                                }
                            }

                            values = new ScalarSet(ave);

                            //convert the values to the correct units
                            values = ConvertUnit(values, l);
                        }
                        else
                        {
                            values = new ScalarSet(new double[0]);
                        }
                    }
                }
                else
                {
                    values = new ScalarSet(new double[0]);
                }
            }
            else
            {
                //
                //Perform Relaxation Interpolation Routine
                //

                // covert ITime to a DateTime data type
                TimeStamp timestamp = (TimeStamp)time;
                DateTime  dt        = CalendarConverter.ModifiedJulian2Gregorian(
                    (double)timestamp.ModifiedJulianDay);



                values = new ScalarSet(new double[_elementCount[linkID]]);

                //check to see if the current time is within the known time span
                if (timestamp.ModifiedJulianDay <= _endTimes[linkID].ModifiedJulianDay)
                {
                    //get scalar set
                    //IValueSet values =  _smartBuffer.GetValues(time);
                    values = _buffer[linkID].GetValues(time);

                    //convert the values to the correct units
                    values = ConvertUnit(values, l);
                }
            }

            #region Map Values
            if (mapper.Count > 0)
            {
                if (mapper.ContainsKey(linkID))
                {
                    IValueSet mappedValues = mapper[linkID].MapValues(values);
                    // return values
                    return(mappedValues);
                }
            }
            #endregion

            //else return unmapped values (i.e. index based)
            return(values);
        }
コード例 #21
0
		public DictionaryValueProvider(IValueSet values)
			: this(values, CultureInfo.CurrentCulture)
		{
		}
コード例 #22
0
 public static IEnumerable <IValueSetCode> ContainsCodesNotIn(this IValueSet source, IEnumerable <Guid> codeGuids)
 {
     return(source.ValueSetCodes.Where(vsc => codeGuids.All(cg => cg != vsc.CodeGuid)));
 }
コード例 #23
0
 public static IEnumerable <IValueSetCode> ContainsCodesNotIn(this IValueSet source, IValueSet compare)
 {
     return(source.ContainsCodesNotIn(compare.ValueSetCodes.Select(vss => vss.CodeGuid)));
 }
        static TimeRecord<Vector3d<double>> ToTimeRecord(ITime2 time2, IValueSet vs, Vector3d<double> missingValue)
        {
            var vectorSet = vs as IVectorSet;

            if (vectorSet == null)
                throw new Exception("Scalar set should be using ValueSetConverterTimeEngineDoubleStandard1");

            var values = new Vector3d<double>[vectorSet.Count];

            for (int n = 0; n < vectorSet.Count; ++n)
            {
                if (vectorSet.IsValid(n))
                {
                    var vector = vectorSet.GetVector(n);

                    values[n] = new Vector3d<double>(
                        vector.XComponent,
                        vector.YComponent,
                        vector.ZComponent);
                }
                else
                    values[n] = missingValue;
            }

            return new TimeRecord<Vector3d<double>>(time2, values);
        }
コード例 #25
0
 /// <summary>
 /// MapValues calculates a IValueSet through multiplication of an inputValues IValueSet
 /// vector or matrix (ScalarSet or VectorSet) on to the mapping maprix. IScalarSets maps
 /// to IScalarSets and IVectorSets maps to IVectorSets.
 /// </summary>
 /// 
 /// <remarks>
 /// Mapvalues is called every time a georeferenced link is evaluated.
 /// </remarks>
 /// 
 /// <param name="inputValues">IValueSet of values to be mapped.</param>
 /// 
 /// <returns>
 /// A IValueSet found by mapping of the inputValues on to the toElementSet.
 /// </returns>
 public IValueSet MapValues(IValueSet inputValues)
 {
   if (!_isInitialised)
   {
     throw new System.Exception("ElementMapper objects needs to be initialised before the MapValue method can be used");
   }
   if (!inputValues.Count.Equals(_numberOfColumns))
   {
     throw new System.Exception("Dimension mismatch between inputValues and mapping matrix");
   }
   if (inputValues is IScalarSet)
   {
     double[] outValues = new double[_numberOfRows];
     //--- Multiply the Values vector with the MappingMatrix ---
     for (int i = 0; i < _numberOfRows; i++)
     {
       outValues[i] = 0;
       for (int n = 0; n < _numberOfColumns; n++)
       {
         outValues[i] += _mappingMatrix[i,n] * ((IScalarSet) inputValues).GetScalar(n); //(remove)inValues[n];
       }
     }
     ScalarSet outputValues = new ScalarSet(outValues);
     return outputValues;
   }
   else if (inputValues is IVectorSet)
   {
     Vector[] outValues = new Vector[_numberOfRows];
     //--- Multiply the Values vector with the MappingMatrix ---
     for (int i = 0; i < _numberOfRows; i++)
     {            
       for (int n = 0; n < _numberOfColumns; n++)
       {
         outValues[i] = new Vector(); // Need this as Initialisation only valid for value types!
       
         outValues[i].XComponent += _mappingMatrix[i,n] * ((IVectorSet) inputValues).GetVector(n).XComponent;
         outValues[i].YComponent += _mappingMatrix[i,n] * ((IVectorSet) inputValues).GetVector(n).YComponent;
         outValues[i].ZComponent += _mappingMatrix[i,n] * ((IVectorSet) inputValues).GetVector(n).ZComponent;
       }
     }
     VectorSet outputValues = new VectorSet(outValues);
     return outputValues;
   }
   else
   {
     throw new System.Exception("Invalid datatype used for inputValues parameter. MapValues failed");
   }
 }
コード例 #26
0
 internal NuintValueSet(IValueSet <uint> values, bool hasLarge)
 {
     _values   = values;
     _hasLarge = hasLarge;
 }
コード例 #27
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
		public static IValueSet Subset(this IValueSet values, string prefix)
		{
			return Subset (values, prefix, true);
		}
コード例 #28
0
 void ICacheProvider.Init(IValueSet settings)
 {
     Init(settings);
 }
コード例 #29
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
		public static bool ContainsAny(this IValueSet values, params string[] keys)
		{
			return ContainsAny(values, StringComparer.OrdinalIgnoreCase, keys);
		}
コード例 #30
0
 private void Init(IValueSet settings)
 {
 }
コード例 #31
0
        /// <summary>
        /// Processes an input string using the specified 
        /// parsing and typographic rules.
        /// </summary>
		public virtual string Execute(TextReader reader, IValueSet parameters)
        {
            Precondition.Require(reader, () => Error.ArgumentNull("reader"));
			using (StringWriter writer = new StringWriter())
			{
				using (HtmlFilter parser = new HtmlFilter(reader, writer, Filter))
				{
					parser.Typographics = Typographics;
					parser.Parameters = parameters;
					parser.Execute();

					return writer.ToString();
				}
			}
        }
コード例 #32
0
		/// <summary>
		/// Convert the units according the what is specified in the link
		/// </summary>
		/// <param name="values">The values</param>
		/// <returns>The unit converted values</returns>
        private IValueSet ConvertUnit(IValueSet values)
		{
			double aSource = link.SourceQuantity.Unit.ConversionFactorToSI;
			double bSource = link.SourceQuantity.Unit.OffSetToSI;
			double aTarget = link.TargetQuantity.Unit.ConversionFactorToSI;
			double bTarget = link.TargetQuantity.Unit.OffSetToSI;

			if (aSource != aTarget || bSource != bTarget)
			{
				if (values is IScalarSet) 
				{
					double[] x = new double[values.Count];

					for (int i = 0; i < values.Count; i++)
					{
						x[i] = (((IScalarSet) values).GetScalar(i) * aSource + bSource - bTarget) / aTarget;
					}

					return new ScalarSet(x);
				}
				else if (values is IVectorSet) 
				{
					ArrayList vectors = new ArrayList();

					for (int i = 0; i < values.Count; i++)
					{
						double x = (((IVectorSet) values).GetVector(i).XComponent * aSource + bSource - bTarget) / aTarget;
						double y = (((IVectorSet) values).GetVector(i).YComponent * aSource + bSource - bTarget) / aTarget;
						double z = (((IVectorSet) values).GetVector(i).ZComponent * aSource + bSource - bTarget) / aTarget;

						Vector newVector = new Vector(x, y, z);
						vectors.Add (newVector);
					}

					return new VectorSet((Vector[]) vectors.ToArray(typeof(Vector)));
				}
				else 
				{
					throw new Exception ("Type " + values.GetType().FullName + " not suppported for unit conversion");
				}
			}

			return values;
		}
コード例 #33
0
 protected virtual void Init(IValueSet settings)
 {
 }
コード例 #34
0
 private static IValueSet EnsureValues(IValueSet values)
 {
     Precondition.Require(values, () => Error.ArgumentNull("values"));
     return(values);
 }
コード例 #35
0
 private FloatingValueSet(IValueSet <TFloating> numbers, bool hasNaN)
 {
     RoslynDebug.Assert(numbers is NumericValueSet <TFloating, TFloatingTC>);
     (_numbers, _hasNaN) = (numbers, hasNaN);
 }
コード例 #36
0
        public override IValueSet GetValues(ITime time, string LinkID)
        {
            if (!isComputing)
            {
                isComputing = true;

                KeepAllStates();

                int iterCount;

                for (iterCount = 0; iterCount < maxIter; iterCount++)
                {
                    RestoreAllStates();

                    ILink[] links = GetAcceptingLinks();

                    double change = 0.0;

                    for (int i = 0; i < links.Length; i++)
                    {
                        ILink     link     = links[i];
                        IValueSet valueSet = link.SourceComponent.GetValues(time, link.ID);
                        string    targetID = link.TargetElementSet.ID;
                        if (valueSet != null && valueSet.Count > 0)
                        {
                            IValueSet bufferSet = buffer.Get(targetID);
                            if (bufferSet == null)
                            {
                                buffer.Add(targetID, valueSet);
                                change = 10;
                            }
                            else
                            {
                                double[] values = new double[bufferSet.Count];
                                for (int j = 0; j < bufferSet.Count; j++)
                                {
                                    values[j] = ((IScalarSet)bufferSet).GetScalar(j);
                                }
                                double[] newValues = new double[valueSet.Count];
                                for (int j = 0; j < valueSet.Count; j++)
                                {
                                    newValues[j] = ((IScalarSet)valueSet).GetScalar(j);
                                }
                                for (int j = 0; j < values.Length; j++)
                                {
                                    double diff = values[j] - newValues[j];
                                    change   += diff * diff;
                                    values[j] = relaxation * values[j] + (1 - relaxation) * newValues[j];
                                }
                                buffer.Add(targetID, new ScalarSet(values));
                            }
                        }
                    }

                    if (change < eps)
                    {
                        break;
                    }
                }

                isComputing = false;
            }

            ILink outputLink = GetLink(LinkID);

            return(buffer.Get(outputLink.SourceElementSet.ID));
        }
コード例 #37
0
		private static IValueSet EnsureValues(IValueSet values)
		{
			Precondition.Require(values, () => Error.ArgumentNull("values"));
			return values;
		}
コード例 #38
0
 public BufferElement(string ID, IValueSet valueSet)
 {
     _ID       = ID;
     _valueSet = valueSet;
 }
コード例 #39
0
 public bool CanBeDeleted(IValueSet valueSet)
 {
     return(valueSet.IsCustom && valueSet.StatusCode == ValueSetStatus.Draft);
 }
コード例 #40
0
        public IValueSet Intersect(IValueSet other)
        {
            AllOrNoneValueSet OtherValueSet = this.CheckCompatibility(other);

            return(new AllOrNoneValueSet(this.Type, this._All && OtherValueSet._All));
        }
コード例 #41
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="time">ITime object</param>
 /// <param name="valueSet">IValuesSet object</param>
 public TimeValueSet(ITime time, IValueSet valueSet)
 {
     _time     = time;
     _valueSet = valueSet;
 }
コード例 #42
0
        public IValueSet Union(IValueSet other)
        {
            AllOrNoneValueSet OtherValueSet = this.CheckCompatibility(other);

            return(new AllOrNoneValueSet(this.Type, this._All || OtherValueSet._All));
        }
コード例 #43
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
        public static IValueSet Subset(this IValueSet values, Func<string, bool> keySelector)
        {
			return new SubsetWrapper(values, keySelector);
        }
コード例 #44
0
ファイル: SortedRangeSet.cs プロジェクト: iodes/PrestoClient
 public bool Overlaps(IValueSet other)
 {
     return(!this.Intersect(other).IsNone());
 }
コード例 #45
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
 public static IValueSet Transform(this IValueSet values, Func<string, string> keyTransformer)
 {
     return new TransformWrapper(values, keyTransformer);
 }
コード例 #46
0
		public void SetValues(string QuantityID, string ElementSetID, IValueSet values)
		{
			for (int i = 0; i < _storage.Length; i++)
			{
				_storage[i] = ((IScalarSet) values).GetScalar(i);
			}
		}
コード例 #47
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
		public static bool ContainsAny(this IValueSet values, 
			IEqualityComparer<string> comparer, string key)
		{
			Precondition.Require(values, () => Error.ArgumentNull("values"));
			return values.Keys.Contains(key, comparer);
		}
        static TimeRecord<double> ToTimeRecord(ITime2 time2, IValueSet vs, double missingValue)
        {
            var scalarSet = vs as IScalarSet;

            if (scalarSet == null)
                throw new Exception("Vector set should be using ValueSetConverterTimeEngineDoubleVector3dStandard1");

            var values = new double[scalarSet.Count];

            for (int n = 0; n < scalarSet.Count; ++n)
                values[n] = scalarSet.IsValid(n)
                    ? scalarSet.GetScalar(n)
                    : missingValue;

            return new TimeRecord<double>(time2, values);
        }
コード例 #49
0
ファイル: ValueSet.cs プロジェクト: ProstoA/Radischevo.Wahha
		/// <summary>
		/// Gets the typed value with the specified key.
		/// </summary>
		/// <typeparam name="TValue">The type of value.</typeparam>
		/// <param name="key">The key to find.</param>
		/// <param name="defaultValue">The default value of the variable.</param>
		public static TValue GetValue<TValue>(this IValueSet values, string name, TValue defaultValue)
		{
			Precondition.Require(values, () => Error.ArgumentNull("values"));
			return values.GetValue<TValue>(name, defaultValue, CultureInfo.CurrentCulture);
		}
コード例 #50
0
		/// <summary>
		/// The ValueSet is converted. This method does not support VectorSet, so if the ValueSet is a Vectorset
		/// an exception will be thrown. The parameters passed in this method is not used, since all needed information
		/// is already assigned in the Prepare method.
		/// </summary>
		/// <param name="values">argumens but not used in this method</param>
		/// <returns>The converted ValueSet</returns>
        public IValueSet PerformDataOperation(IValueSet values)
		{
			if (_isActivated)
			{
				if (!(values is IScalarSet))
				{
					throw new Exception("The Oatc.OpenMI.Sdk.Wrapper packages only supports ScalarSets (Not VectorSets)");
				}

				double[] x = new double[values.Count];

				for (int i = 0; i < values.Count; i++)
				{
					x[i] = ((IScalarSet) values).GetScalar(i) * _a + _b;
				}

				return ((IValueSet) new ScalarSet(x));
			}

			return values; // return the values unchanged.
		}
コード例 #51
0
		private static DbParameterCollection CreateParameters(IValueSet values)
		{
			if (values == null)
				return null;

			DbParameterCollection collection = new DbParameterCollection();
			foreach (string key in values.Keys)
			{
				collection.Add(new DbParameterDescriptor(
					BuildParameterName(key), values[key]));
			}
			return collection;
		}
コード例 #52
0
 protected virtual void Init(IValueSet settings)
 {
 }
コード例 #53
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="time">ITime object</param>
 /// <param name="valueSet">IValuesSet object</param>
 public TimeValueSet(ITime time, IValueSet valueSet)
 {
     _time     = time;
     _valueSet = valueSet;
 }
コード例 #54
0
 void IControllerFactory.Init(IValueSet settings)
 {
     Init(settings);
 }
コード例 #55
0
 void IViewEngine.Init(IValueSet settings)
 {
     Init(settings);
 }
コード例 #56
0
        public override IValueSet GetValues(ITime time, string LinkID)
        {
            if (!initializeWasInvoked)
            {
                throw new Exception("Method \"GetValues\" in LinkableTimeSeriesGroup class was invoked before the Initialize method was invoked");
            }

            ILink link = this.GetLink(LinkID);

            SendSourceAfterGetValuesCallEvent(time, link);

            // -- handle incoming links (where this component is the target)
            if (!isBusy) //avoiding deadlocks
            {
                isBusy = true;
                foreach (ILink acceptingLink in _acceptingLinks)
                {
                    if (((TsQuantity)acceptingLink.TargetQuantity).BaseTimeSeries is TimestampSeries)
                    {
                        TimestampSeries timestampSeries = (TimestampSeries)((TsQuantity)acceptingLink.TargetQuantity).BaseTimeSeries;
                        foreach (TimestampValue timestampValue in timestampSeries.Items)
                        {
                            TimeStamp getValuesTime = new TimeStamp(timestampValue.Time);
                            SendTargetBeforeGetValuesCall(getValuesTime, acceptingLink);
                            IValueSet valueSet = acceptingLink.SourceComponent.GetValues(getValuesTime, acceptingLink.ID);
                            timestampValue.Value = ((IScalarSet)valueSet).GetScalar(0);
                            SendTargetAfterGetValuesReturn(timestampValue.Value, acceptingLink);
                        }
                    }
                    else if (((TsQuantity)acceptingLink.TargetQuantity).BaseTimeSeries is TimespanSeries)
                    {
                        TimespanSeries timespanSeries = (TimespanSeries)((TsQuantity)acceptingLink.TargetQuantity).BaseTimeSeries;
                        foreach (TimespanValue timespanValue in timespanSeries.Items)
                        {
                            HydroNumerics.OpenMI.Sdk.Backbone.TimeSpan timeSpan = new HydroNumerics.OpenMI.Sdk.Backbone.TimeSpan(new HydroNumerics.OpenMI.Sdk.Backbone.TimeStamp(timespanValue.StartTime), new HydroNumerics.OpenMI.Sdk.Backbone.TimeStamp(timespanValue.EndTime));
                            SendTargetBeforeGetValuesCall(timeSpan, acceptingLink);
                            IValueSet valueSet = acceptingLink.SourceComponent.GetValues(timeSpan, acceptingLink.ID);
                            timespanValue.Value = ((IScalarSet)valueSet).GetScalar(0);
                            SendTargetAfterGetValuesReturn(timespanValue.Value, acceptingLink);
                        }
                    }
                    else
                    {
                        throw new Exception("Unexpected exception : Undefined timeseries type (occured in HydroNumerics.Time.OpenMI.LinkableTimeSeriesGroup class)");
                    }
                }
                isBusy = false;
            }

            // -- handle outgoing links (where this component is the source)
            HydroNumerics.Core.Unit toUnit = new HydroNumerics.Core.Unit();
            toUnit.ConversionFactorToSI = link.TargetQuantity.Unit.ConversionFactorToSI;
            toUnit.OffSetToSI           = link.TargetQuantity.Unit.OffSetToSI;

            if (time is ITimeStamp)
            {
                HydroNumerics.OpenMI.Sdk.Backbone.TimeStamp t = new TimeStamp((ITimeStamp)time);

                double    x         = ((TsQuantity)link.SourceQuantity).BaseTimeSeries.GetValue(t.ToDateTime(), toUnit);
                ScalarSet scalarSet = new ScalarSet(new double[] { x });
                SendSourceBeforeGetValuesReturn(x, link);
                return(scalarSet);
            }
            else
            {
                HydroNumerics.OpenMI.Sdk.Backbone.TimeStamp start = new TimeStamp(((ITimeSpan)time).Start);
                HydroNumerics.OpenMI.Sdk.Backbone.TimeStamp end   = new TimeStamp(((ITimeSpan)time).End);

                double    x         = ((TsQuantity)link.SourceQuantity).BaseTimeSeries.GetValue(start.ToDateTime(), end.ToDateTime(), toUnit);
                ScalarSet scalarSet = new ScalarSet(new double[] { x });
                SendSourceBeforeGetValuesReturn(x, link);
                return(scalarSet);
            }
        }
コード例 #57
0
ファイル: SortedRangeSet.cs プロジェクト: iodes/PrestoClient
 public bool Contains(IValueSet other)
 {
     return(this.Union(other).Equals(this));
 }
コード例 #58
0
		protected HtmlParsingContext(IValueSet parameters)
		{
			_parameters = parameters;
		}
コード例 #59
0
		public virtual void Init(IValueSet settings)
		{
			_useCache = settings.GetValue<bool>("useCache", false);
		}
コード例 #60
0
ファイル: SortedRangeSet.cs プロジェクト: iodes/PrestoClient
 public IValueSet Subtract(IValueSet other)
 {
     return(this.Intersect(other.Complement()));
 }