public Vector3i(OVector v) { ArgAssert.Equal(v.Dimension, "v.Dimension", 3, "3"); _x = ((int)Math.Round(v[0])); _y = ((int)Math.Round(v[1])); _z = ((int)Math.Round(v[2])); }
// See parent doc public string ReadTextFile(FileSystemPath path, Encoding encoding) { ArgAssert.NotNull(path, "path"); byte[] binData = ReadBinaryFile(path); return(ResolveEncoding(encoding).GetString(binData)); }
public PeriodicReportFileThread(PeriodicReportFile periodicReportFile, double period_sec) : base(1.0 / period_sec, PeriodicThreadTightness.Low) { ArgAssert.NotNull(periodicReportFile, "periodicReportFile"); Thread.Priority = ThreadPriority.Lowest; _periodicReportFile = periodicReportFile; }
public Vector3f(OVector v) { ArgAssert.Equal(v.Dimension, "v.Dimension", 3, "3"); _x = ((float)v[0]); _y = ((float)v[1]); _z = ((float)v[2]); }
public Vector3(OVector v) { ArgAssert.Equal(v.Dimension, "v.Dimension", 3, "3"); _x = v[0]; _y = v[1]; _z = v[2]; }
public Vector4L(OVector v) { ArgAssert.Equal(v.Dimension, "v.Dimension", 4, "4"); _x = ((long)Math.Round(v[0])); _y = ((long)Math.Round(v[1])); _z = ((long)Math.Round(v[2])); _t = ((long)Math.Round(v[3])); }
/// <summary> /// Asserts that the path does not exists. /// </summary> /// <param name="fileSystem">The extended object</param> /// <param name="path">The path to assert</param> /// <exception cref="FileSystemPathAlreadyExistsException">Thrown if the path already exists.</exception> public static void AssertNotExists(this IFileSystem fileSystem, FileSystemPath path) { ArgAssert.NotNull(path, "path"); if (fileSystem.Exists(path)) { throw new FileSystemPathAlreadyExistsException(path); } }
public Vector4f(OVector v) { ArgAssert.Equal(v.Dimension, "v.Dimension", 4, "4"); _x = ((float)v[0]); _y = ((float)v[1]); _z = ((float)v[2]); _t = ((float)v[3]); }
public Vector4(OVector v) { ArgAssert.Equal(v.Dimension, "v.Dimension", 4, "4"); _x = v[0]; _y = v[1]; _z = v[2]; _t = v[3]; }
/// <summary> /// 从给定的类型上解析泛型参数表,并指定解析参数时所使用的泛型类型定义。 /// </summary> /// <param name="type">从此类型上解析泛型参数表。</param> /// <param name="genericTypeDefinition">泛型类型定义。可以是接口,也可以是非接口类型。</param> /// <returns>类型的泛型参数的数组,其元素顺序与类型定义的顺序一致。</returns> /// <exception cref="ArgumentNullException"><paramref name="type"/>为<c>null</c>。</exception> /// <exception cref="ArgumentNullException"><paramref name="genericTypeDefinition"/>为<c>null</c>。</exception> /// <exception cref="ArgumentException"><paramref name="genericTypeDefinition"/>不是泛型类型定义。</exception> /// <example> /// 一个类型可以继承多个泛型类型,例如: /// GenericClass{T} : IDictionary{T, int}, ICollection{string} /// 此时,对于GenericClass{long},使用泛型定义IDictionary{,},获取参数表类型是 [long, int]; /// 而对于泛型定义ICollection{}则结果是 [string]; /// </example> public static Type[] GetGenericArguments(Type type, Type genericTypeDefinition) { ArgAssert.NotNull(type, "type"); ArgAssert.NotNull(genericTypeDefinition, "genericTypeDefinition"); if (!genericTypeDefinition.IsGenericTypeDefinition) { var msg = string.Format( "The type {0} is not a generic type definition.", genericTypeDefinition.Name); throw new ArgumentException(msg, "genericTypeDefinition"); } if (genericTypeDefinition.IsInterface) { if (type.IsGenericType && type.GetGenericTypeDefinition() == genericTypeDefinition) { return(type.GetGenericArguments()); } foreach (var interfaceType in type.GetInterfaces()) { if (!interfaceType.IsGenericType) { continue; } if (interfaceType.GetGenericTypeDefinition() != genericTypeDefinition) { continue; } return(interfaceType.GetGenericArguments()); } } else { var baseType = type; do { if (!baseType.IsGenericType) { continue; } if (baseType.GetGenericTypeDefinition() != genericTypeDefinition) { continue; } return(baseType.GetGenericArguments()); } while ((baseType = baseType.BaseType) != null); } return(null); }
public KalmanFilter(IStochasticProcess processModel, StochasticManifoldPoint initialEstimate, double initialTime) { ArgAssert.NotNull(processModel, "processModel"); ArgAssert.Equal(processModel.StateSpace.Dimension, "processModel.StateSpace.Dimension", initialEstimate.Dimension, "initialEstimate.Dimension"); _time = initialTime; _estimate = initialEstimate; _processModel = processModel; }
// See parent doc public void WriteTextFile(FileSystemPath path, string data, Encoding encoding, bool append) { ArgAssert.NotNull(path, "path"); ArgAssert.NotNull(data, "data"); this.AssertFileOrNotExsits(path); var binData = ResolveEncoding(encoding).GetBytes(data); WriteBinaryFile(path, binData, append); }
public StatisticsReporter(IClock clock) { ArgAssert.NotNull(clock, "clock"); _clock = clock; _entries = null; _lastReportTime = _clock.Time; }
// See parent doc public void CopyFile(FileSystemPath from, FileSystemPath to) { ArgAssert.NotNull(from, "from"); ArgAssert.NotNull(to, "to"); this.AssertFile(from); this.AssertFileOrNotExsits(to); InnerCopyFile(from, to); }
public Image(TDepth[,,] data) // shallow copy { var channelsCount = Singleton <TType> .Instance.ChannelsCount; ArgAssert.Equal(data.GetLength(2), "data.GetLength(2)", channelsCount); _data = data; _dimensions = new Vector2i(_data.GetLength(1), _data.GetLength(0)); _step = channelsCount * new Vector2i(1, _dimensions.X); }
public static IReadOnlyList <T> AsReadOnlyList <T>(this List <T> @this) { ArgAssert.NotNull(@this, "this"); #if NET35 || NET40 return(AsReadOnlyList <T>((IList <T>)@this)); #else return(@this); #endif }
public FiniteFunctionGraph(IReadOnlyList <T1> domain, IReadOnlyList <T2> codomain, IReadOnlyList <int> function) { ArgAssert.NotNull(domain, "domain"); ArgAssert.NotNull(codomain, "codomain"); ArgAssert.NotNull(function, "function"); ArgAssert.Equals(domain.Count, function.Count); _domain = domain; _codomain = codomain; _function = function; }
/// <summary> /// Adds the provided path parts to the path creating a new path. The original path is unaffected. /// The parts may contian path delimiters or be empty (but can't be null). The resulting path will be canonized. /// </summary> /// <param name="parts">The path parts to add to this path. Must not be null or contain nulls.</param> /// <returns>The resulting path</returns> public FileSystemPath Join(params string[] parts) { ArgAssert.NoNullIn(parts, "parts"); if (parts.Length == 0) { return(this); } return(new FileSystemPath(JoinPathParts(PathString, JoinPathParts(parts)))); }
public PeriodicReportFile(IDateTimeProvider dateTimeProvider, IFileSystem fileSystem, FileSystemPath reportFilePath) { ArgAssert.NotNull(dateTimeProvider, "dateTimeProvider"); ArgAssert.NotNull(fileSystem, "fileSystem"); ArgAssert.NotNull(reportFilePath, "reportFilePath"); _dateTimeProvider = dateTimeProvider; _fileSystem = fileSystem; _reportFilePath = reportFilePath; _reporters = new List <ReporterDelegate>(); }
/// <summary> /// Concatinates all the enumerables into one enumerable. /// </summary> /// <typeparam name="T">The type of the enumerated object</typeparam> /// <param name="enumerables">The enumerables to concatinate. Must not be null or contain null enumerables</param> /// <returns>The concatinated enumerable</returns> public static IEnumerable <T> Concat <T>(IEnumerable <IEnumerable <T> > enumerables) { ArgAssert.NoNullIn(enumerables, "enumerables"); var result = Enumerable.Empty <T>(); foreach (var enumerable in enumerables) { result = result.Concat(enumerable); } return(result); }
public MultiFile(IFileSystem fileSystem, FileSystemPath mainFilePath) : base(fileSystem) { ArgAssert.NotNull(mainFilePath, "mainFilePath"); FileSystem.AssertFile(mainFilePath); _directoryPath = mainFilePath.Parent; _prefix = mainFilePath.GetLastPartWithoutExtension(); _files = new List <MultiFileFile>(); Populate(); }
public static IList <T> Reverse <T>(this IReadOnlyList <T> @this) { ArgAssert.NotNull(@this, "this"); var answer = new List <T>(@this.Count); for (var j = @this.Count - 1; j >= 0; j--) { answer.Add(@this[j]); } return(answer); }
public InjectionEnumerator(int domainCount, int codomainCount) { ArgAssert.AtMost(domainCount, "domainCount", codomainCount, "codomainCount"); ArgAssert.AtLeast(domainCount, "domainCount", 1); _domainCount = domainCount; _codomainCount = codomainCount; _reset = true; _counters = new int[_domainCount]; _free = new bool[_codomainCount]; }
/// <summary> /// Asserts that the path points to a file. /// </summary> /// <param name="fileSystem">The extended object</param> /// <param name="path">The path to assert</param> /// <exception cref="FileSystemPathDoesNotExistException">Thrown if the path does not exists.</exception> /// <exception cref="FileExpectedException">Thrown if the path does not point to a file.</exception> public static void AssertFile(this IFileSystem fileSystem, FileSystemPath path) { ArgAssert.NotNull(path, "path"); if (!fileSystem.Exists(path)) { throw new FileSystemPathDoesNotExistException(path, "File does not exist"); } if (!fileSystem.IsFile(path)) { throw new FileExpectedException(path); } }
public AffineIntegralStochasticProcess(IStochasticProcess baseProcess, IManifold fiber, OMatrix gain, OVector offset) : base(baseProcess, fiber) { if (!(baseProcess.StateSpace is AffineSpace)) { throw new ArgumentException("Expected process in affine space", "baseProcess"); } ArgAssert.Equal(baseProcess.StateSpace.Dimension, "baseProcess.StateSpace.Dimension", gain.ColumnCount, "gain.ColumnCount"); ArgAssert.Equal(fiber.Dimension, "fiber.Dimension", gain.RowCount, "gain.RowCount"); ArgAssert.Equal(offset.Dimension, "offset.Dimension", gain.RowCount, "gain.RowCount"); _gain = gain; _offset = offset; }
public static IDbClient GetClient(string dbName, DatabaseType databaseType, string connectionString = null) { ArgAssert.NotNullOrEmpty(dbName, "dbName"); var id = new DbIdentity(dbName, databaseType); var client = KnownClients.GetOrAdd(id, x => { var conn = connectionString ?? GetConnectionString(dbName, databaseType); return(databaseType == DatabaseType.MySql ? (IDbClient) new MysqlDbClient(conn) : (IDbClient) new SqlDbClient(conn)); }); return(client); }
public SymmetricMatrix(double[][] values) : base(values.Length) { for (int i = 0; i < this.RowCount; i++) { ArgAssert.Equal(values[i].Length, "values[i].Length", i + 1, "i + 1"); _data[i, i] = values[i][i]; for (int j = 0; j < i; j++) { _data[i, j] = values[i][j]; _data[j, i] = values[i][j]; } } }
public MultiFile(IFileSystem fileSystem, FileSystemPath directoryPath, string prefix) : base(fileSystem) { ArgAssert.NotNull(directoryPath, "directoryPath"); ArgAssert.NotNull(prefix, "prefix"); ArgAssert.That(prefix != "", "prefix", "not be empty"); FileSystem.AssertDirectory(directoryPath); _directoryPath = directoryPath; _prefix = prefix; _files = new List <MultiFileFile>(); Populate(); }
private IRuleRef Create() { ArgAssert.NotNull(nameof(_grammarBuilderAdapter), _grammarBuilderAdapter); ArgAssert.NotNull(nameof(Factory), Factory); var rule = Factory(this); var ruleRef = rule is IRuleRef ? (IRuleRef)rule : _grammarBuilderAdapter.Define(rule); if (RefName != null) { ruleRef.As(RefName); } return(ruleRef); }
/// <summary> /// Checks whether the provided path points to a valid DirectoryBasedObjectWithConfiguration. A valid path should point to /// a directory and to contains a configuration file with the provided name. /// </summary> /// <param name="fileSystem">The file system to use. Must not be null.</param> /// <param name="path">The path to check.</param> /// <param name="configurationFileName">The file name of the configuration file.</param> /// <returns>True if the path points to a valid DirectoryBasedObjectWithConfiguration</returns> protected static bool IsPathToSuchObject(IFileSystem fileSystem, FileSystemPath path, string configurationFileName) { ArgAssert.NotNull(fileSystem, "fileSystem"); ArgAssert.NotNull(path, "path"); ArgAssert.NotNull(configurationFileName, "configurationFileName"); if (!fileSystem.IsDirectory(path)) { return(false); } var configurationPath = path.Join(configurationFileName); return(fileSystem.IsFile(configurationPath)); }