public IDictionary<string, double> GetAvailabilityFromNow(WorksheetEntry worksheet, IEnumerable<string> professionals = null) { var sectionLines = GetSectionLinesPosition(worksheet, "Disponibilidade de horas por profissional e dia"); var minLine = sectionLines.Select(sl => sl.Value).Min(); var maxLine = sectionLines.Select(sl => sl.Value).Max(); var today = DateTime.Now.ToShortDateString(); var dateLines = _spreadsheetFacade.GetCellsValues(worksheet, minLine - 1, minLine, 1, uint.MaxValue).ToList(); var colNow = dateLines.First(dl => dl.Value.Equals(today)).Column; var result = new Dictionary<string, double>(); for (var i = minLine; i <= maxLine; i++) { var i1 = i; var professional = sectionLines.Where(sl => sl.Value == i1).Select(sl => sl.Key).First().ToLower(); var enumerableProfessionals = professionals?.ToArray() ?? new string[0]; if (!enumerableProfessionals.Any() || enumerableProfessionals.Any(ep => ep.ToLower().Contains(professional) || professional.Contains(ep.ToLower()))) { var availability = _spreadsheetFacade.GetCellsValues(worksheet, i, i, colNow, uint.MaxValue).Sum(c => double.Parse(c.Value)); result.Add(professional, availability); } } return result; }
public void ComposeEmail( IEnumerable<string> to, IEnumerable<string> cc = null, string subject = null, string body = null, bool isHtml = false, IEnumerable<EmailAttachment> attachments = null, string dialogTitle = null) { if (!MFMailComposeViewController.CanSendMail) throw new MvxException("This device cannot send mail"); _mail = new MFMailComposeViewController(); _mail.SetMessageBody(body ?? string.Empty, isHtml); _mail.SetSubject(subject ?? string.Empty); if (cc != null) _mail.SetCcRecipients(cc.ToArray()); _mail.SetToRecipients(to?.ToArray() ?? new[] { string.Empty }); if (attachments != null) { foreach (var a in attachments) { _mail.AddAttachmentData(NSData.FromStream(a.Content), a.ContentType, a.FileName); } } _mail.Finished += HandleMailFinished; _modalHost.PresentModalViewController(_mail, true); }
//-------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="ParseResult" /> class. /// </summary> /// <param name="args">The original input arguments.</param> /// <param name="parsedArguments"> /// The <see cref="ParsedArguments"/>. Can be <see langword="null"/>. /// </param> /// <param name="unknownArguments"> /// The <see cref="UnknownArguments"/>. Can be <see langword="null"/>. /// </param> public ParseResult(string[] args, IEnumerable<ArgumentResult> parsedArguments, IEnumerable<string> unknownArguments) { RawArguments = args?.ToArray() ?? Array.Empty<string>(); ParsedArguments = new ArgumentResultCollection(parsedArguments?.ToList() ?? new List<ArgumentResult>()); UnknownArguments = unknownArguments?.ToArray() ?? Array.Empty<string>(); }
public ContainerRateLimit( ITaskParam Task, IEnumerable<ITaskRateLimit> SetRateLimit = null) : base(Task.Yield()) { this.SetRateLimit = SetRateLimit?.ToArray(); }
static public MotionResult KeyboardPressCombined( this IHostToScript Sanderling, IEnumerable<VirtualKeyCode> SetKey) => Sanderling?.MotionExecute(new Motor.MotionParam() { KeyDown = SetKey?.ToArray(), KeyUp = SetKey?.Reverse()?.ToArray(), });
public PipPackageManager( bool allowFileSystemWatchers = true, IEnumerable<string> extraInterpreterArgs = null ) { _packages = new List<PackageSpec>(); _extraInterpreterArgs = extraInterpreterArgs?.ToArray() ?? Array.Empty<string>(); if (allowFileSystemWatchers) { _libWatchers = new List<FileSystemWatcher>(); _refreshIsCurrentTrigger = new Timer(RefreshIsCurrentTimer_Elapsed); } }
public SerializerOptions(bool versionTolerance = false, IEnumerable<Surrogate> surrogates = null, bool preserveObjectReferences = false, IEnumerable<ValueSerializerFactory> serializerFactories = null) { VersionTolerance = versionTolerance; Surrogates = surrogates?.ToArray() ?? EmptySurrogates; //use the default factories + any user defined ValueSerializerFactories = DefaultValueSerializerFactories.Concat(serializerFactories?.ToArray() ?? EmptyValueSerializerFactories) .ToArray(); PreserveObjectReferences = preserveObjectReferences; }
public VplServiceContext(IEnumerable<IVplPlugin> plugins = null) { _plugins = plugins?.ToArray() ?? new IVplPlugin[] {}; _customResources = _plugins.SelectMany(p => p.Resources); var customFactories = _plugins.SelectMany(p => p.ElementFactories); _elementFactoryManager = new ElementFactoryManager(customFactories); //These are the "built-in" types var types = new List<IVplType> { new VplType(VplTypeId.Boolean, "Boolean", () => new BooleanValueCheckBoxView(), false, typeof(bool)), new VplType(VplTypeId.Float, "Float", () => new DoubleValueView(), 0.0, typeof(double)), new VplType(VplTypeId.Any, "Any", () => new TextValueView(), null, typeof(object)), new VplType(VplTypeId.String, "String", () => new TextValueView(), "", typeof(string)), new VplType(VplTypeId.Int, "Int", () => new Int32ValueView(), 0, typeof(int)), new VplType(VplTypeId.Byte, "Byte", () => new ByteValueView(), (byte)0, typeof(byte)), new VplType(VplTypeId.UInt16, "UInt16", () => new TextValueView(), (ushort)0, typeof(ushort)), new VplType(VplTypeId.UInt32, "UInt32", () => new TextValueView(), (uint)0, typeof(uint)), new VplType(VplTypeId.Single, "Single", () => new TextValueView(), (float)0, typeof(float)), new VplType(VplTypeId.SByte, "Int8", () => new TextValueView(), (sbyte)0, typeof(sbyte)), new VplType(VplTypeId.Int16, "Int16", () => new Int16ValueView(), (short)0, typeof(short)), new VplType(VplTypeId.DateTime, "DateTime", () => new DateTimeValueView(), DateTime.Now, typeof(DateTime)), new VplType(VplTypeId.UInt64, "UInt64", () => new TextValueView(), (ulong)0, typeof(ulong)), new VplType(VplTypeId.Int64, "Int64", () => new TextValueView(), (long)0, typeof(long)), new VplType(VplTypeId.Decimal, "Decimal", () => new TextValueView(), (decimal)0, typeof(decimal)) }; //Add the plugin types foreach (var plugin in _plugins) { types.AddRange(plugin.Types); } //Create the array of types _types = types .OrderBy(t => t.Name) .ToArray(); //Create the services _services = _plugins .SelectMany(p => p.Services) .ToArray(); //Create an element builder _elementBuilder = new ElementBuilder(_elementFactoryManager, this); }
public bool IsAuthorized(IEnumerable<SecurityGroup> securityGroups) { var authenticatedUser = GetAuthenticatedUser(); var secGroups = securityGroups as SecurityGroup[] ?? securityGroups?.ToArray(); if (secGroups == null || secGroups.Any()) return false; foreach (var secGroup in secGroups) if (authenticatedUser.IsInRole(secGroup.Name)) return true; return false; }
public static string Summarize(IEnumerable<IDeadline> deadlines) { IEnumerable<IDeadline> deadlinesEnumerated = deadlines?.ToArray(); if (deadlinesEnumerated == null || !deadlinesEnumerated.Any()) return Info.NotFound; var sb = new StringBuilder(); sb.Append("Крайние сроки сдачи работ:\n"); foreach (var deadline in deadlinesEnumerated) { sb.Append(deadline); sb.Append('\n'); } return sb.ToString(); }
private IQueryable<Person> GetVolunteersForDateQueryable(int disasterId, DateTime date, bool checkedInOnly, IEnumerable<int> inClusterIds) { if (disasterId <= 0) throw new ArgumentException("disasterId must be greater than zero", "disasterId"); var inClusterIdsArray = inClusterIds?.ToArray() ?? new int[0]; var hasClusters = inClusterIdsArray.Length == 0; var people = from p in _dataService.Persons join c in Commitment.FilteredByStatus(_dataService.Commitments, checkedInOnly) on p.Id equals c.PersonId where c.DisasterId == disasterId where date >= c.StartDate && date <= c.EndDate where hasClusters || inClusterIdsArray.Any(cid => cid == c.ClusterId) select p; return people.Distinct(); }
public SerializerOptions(bool versionTolerance = false, bool preserveObjectReferences = false, IEnumerable<Surrogate> surrogates = null, IEnumerable<ValueSerializerFactory> serializerFactories = null, IEnumerable<Type> knownTypes = null) { VersionTolerance = versionTolerance; Surrogates = surrogates?.ToArray() ?? EmptySurrogates; //use the default factories + any user defined ValueSerializerFactories = DefaultValueSerializerFactories.Concat(serializerFactories?.ToArray() ?? EmptyValueSerializerFactories) .ToArray(); KnownTypes = knownTypes?.ToArray() ?? new Type[] {}; for (var i = 0; i < KnownTypes.Length; i++) { KnownTypesDict.Add(KnownTypes[i],(ushort)i); } PreserveObjectReferences = preserveObjectReferences; }
/// <summary> /// Escapes given command line arguments using windows operating system specific rules. This method assumes that the /// arguments parameter is not null or empty. More information - http://stackoverflow.com/questions/5510343/escape-command-line-arguments-in-c-sharp /// </summary> /// <param name="arguments">Command line arguments.</param> /// <returns>Escaped command line arguments.</returns> public IEnumerable<string> Escape(IEnumerable<string> arguments) { var escapedArguments = new List<string>(); var argumentsArray = arguments?.ToArray() ?? new string[] {}; if (argumentsArray.Any()) { foreach (var argument in argumentsArray) { var escaped = Regex.Replace(argument, @"(\\*)" + "\"", @"$1\$0"); escaped = Regex.Replace(escaped, @"^(.*\s.*?)(\\*)$", "\"$1$2$2\""); escapedArguments.Add(escaped); } } return escapedArguments; }
public FakeItem( Guid id = default(Guid), string databaseName = "master", Guid parentId = default(Guid), string path = "/sitecore/content/test item", string name = "test item", Guid branchId = default(Guid), Guid templateId = default(Guid), IEnumerable<IItemFieldValue> sharedFields = null, IEnumerable<IItemVersion> versions = null, string serializedItemId = "0xDEADBEEF", IEnumerable<IItemData> children = null) : base(name, id, parentId, templateId, path, databaseName) { BranchId = branchId; SharedFields = sharedFields ?? new List<IItemFieldValue>(); Versions = versions ?? new List<IItemVersion>(); SerializedItemId = serializedItemId; SetProxyChildren(children?.ToArray() ?? new IItemData[0]); }
public RuleSetInformation(string projectFullName, string baselineRuleSet, string projectRuleSet, IEnumerable<string> ruleSetDirectories) { if (string.IsNullOrWhiteSpace(projectFullName)) { throw new ArgumentNullException(nameof(projectFullName)); } if (string.IsNullOrWhiteSpace(baselineRuleSet)) { throw new ArgumentNullException(nameof(baselineRuleSet)); } if (string.IsNullOrWhiteSpace(projectRuleSet)) { throw new ArgumentNullException(nameof(projectRuleSet)); } this.RuleSetProjectFullName = projectFullName; this.BaselineFilePath = baselineRuleSet; this.RuleSetFilePath = projectRuleSet; this.RuleSetDirectories = ruleSetDirectories?.ToArray() ?? new string[0]; }
private static object GenerateClassProxy( Type typeOfProxy, ProxyGenerationOptions options, IEnumerable<object> argumentsForConstructor, IInterceptor interceptor, IEnumerable<Type> allInterfacesToImplement) { var argumentsArray = argumentsForConstructor?.ToArray(); return ProxyGenerator.CreateClassProxy( typeOfProxy, allInterfacesToImplement.ToArray(), options, argumentsArray, interceptor); }
public AnalysisOnlyInterpreterFactory(Version version, IEnumerable<string> databasePaths, string description = null) : base(GetConfiguration(version, databasePaths?.ToArray() ?? Array.Empty<string>()), CreationOptions) { _actualDatabasePaths = databasePaths?.ToList(); }
public SuffixMatching(IEnumerable<string> chars, bool entireWord) { _charsArr = chars?.ToArray(); _entireWord = entireWord; }
internal static byte[] HmacSha1(IEnumerable<byte> key, IEnumerable<byte> message) { #if PCL var k = key.ToArray(); if(k.Length > 64) k = Sha1(k); if(k.Length != 64) { Debug.Assert(k.Length < 64); var tmp = new byte[64]; Buffer.BlockCopy(k, 0, tmp, 0, k.Length); k = tmp; } var k_ipad = new byte[64]; var k_opad = new byte[64]; for(var i = 0; i < 64; i++) { k_ipad[i] = (byte)(k[i] ^ 0x36); k_opad[i] = (byte)(k[i] ^ 0x5C); } var inner = Sha1(k_ipad.Concat(message ?? Enumerable.Empty<byte>())); var x = new byte[64 + 20]; Buffer.BlockCopy(k_opad, 0, x, 0, 64); Buffer.BlockCopy(inner, 0, x, 64, 20); return Sha1(x); #else var keyArray = key as byte[] ?? key.ToArray(); var messageArray = message as byte[] ?? (message?.ToArray() ?? new byte[] { }); #if WIN_RT var prov = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha1); var buffer = CryptographicEngine.Sign( prov.CreateKey(CryptographicBuffer.CreateFromByteArray(keyArray)), CryptographicBuffer.CreateFromByteArray(messageArray) ); byte[] result; CryptographicBuffer.CopyToByteArray(buffer, out result); return result; #else using (var hs1 = new HMACSHA1(keyArray)) return hs1.ComputeHash(messageArray); #endif #endif }
/// <summary> /// Get access token /// </summary> /// <param name="scopes">Requested OAuth2 scopes</param> /// <returns>OAuth2 access token</returns> public Task<string> GetAccessTokenAsync(IEnumerable<string> scopes) { return GetAccessTokenAsync(scopes?.ToArray()); }
public MultipleChoiceContentFilter(IEnumerable<string> items) { Items = items?.ToArray(); }
public MoveResult(ITransactionWithMoveSupport transaction, bool isSuccessful, IEnumerable<FollowUpEvent> followUpEvents) { Transaction = transaction; IsSuccessful = isSuccessful; FollowUpEvents = followUpEvents?.ToArray() ?? new FollowUpEvent[0]; }
internal RobotCellKinematics(RobotCell cell, IEnumerable<Target> targets, IEnumerable<double[]> prevJoints, bool displayMeshes) { this.Solutions = new List<KinematicSolution>(new KinematicSolution[cell.MechanicalGroups.Count]); if (targets.Count() != cell.MechanicalGroups.Count) throw new Exception(" Incorrect number of targets."); if (prevJoints != null && prevJoints.Count() != cell.MechanicalGroups.Count) throw new Exception(" Incorrect number of previous joint values."); var groups = cell.MechanicalGroups.ToList(); foreach (var target in targets) { var index = target.Frame.CoupledMechanicalGroup; if (index == -1) continue; var group = cell.MechanicalGroups[index]; groups.RemoveAt(index); groups.Insert(0, group); } var targetsArray = targets.ToArray(); var prevJointsArray = prevJoints?.ToArray(); foreach (var group in groups) { int i = group.Index; var target = targetsArray[i]; var prevJoint = prevJointsArray?[i]; Plane? coupledPlane = null; int coupledGroup = target.Frame.CoupledMechanicalGroup; if (coupledGroup != -1 && target.Frame.CoupledMechanism == -1) { if (coupledGroup == i) throw new Exception(" Can't couple a robot with itself."); coupledPlane = Solutions[coupledGroup].Planes[Solutions[coupledGroup].Planes.Length - 2] as Plane?; } else { coupledPlane = null; } var kinematics = group.Kinematics(target, prevJoint, coupledPlane, displayMeshes, cell.BasePlane); Solutions[i] = kinematics; } }
public EmbeddedProjectSample ToProjectSample(IEnumerable<string> extraReferences) { return new EmbeddedProjectSample { AdditionalSourcesToCopy = Framework.AdditionalSourceFiles .Select(f => new AdditionalSourceFile { SourcePath = f, TargetFileName = Path.GetFileName(f) }) .Concat(new[] { new AdditionalSourceFile { SourcePath = "$$SYS:BSP_ROOT$$/" + ParsedSDK.MainFileName, TargetFileName = ParsedSDK.MainFileName } }) .ToArray(), AdditionalIncludeDirectories = Framework.AdditionalIncludeDirs, PreprocessorMacros = Framework.AdditionalPreprocessorMacros, RequiredFrameworks = LoadedBSP.Combine(Framework.RequiredFrameworks, extraReferences?.ToArray()), Name = "Empty project for " + OriginalName, }; }
public CompositionParam(IEnumerable<ITaskParam> Component) { this.Component = Component?.ToArray(); }
public MessageViewModel ShowMessage(IChildViewModel parent, string message, string title, IEnumerable<string> buttons = null) { return ShowMessage(parent, message, title, buttons?.ToArray()); }
/// <summary> /// Sets the attachment with the given name. /// </summary> /// <remarks> /// Sets the <see cref="Couchbase.Lite.Attachment"/> with the given name. /// The <see cref="Couchbase.Lite.Attachment"/> data will be written to /// the <see cref="Couchbase.Lite.Database"/> when the /// <see cref="Couchbase.Lite.Revision"/> is saved. /// </remarks> /// <param name="name">The name of the <see cref="Couchbase.Lite.Attachment"/> to set.</param> /// <param name="contentType">The content-type of the <see cref="Couchbase.Lite.Attachment"/>.</param> /// <param name="content">The <see cref="Couchbase.Lite.Attachment"/> content.</param> public void SetAttachment(string name, string contentType, IEnumerable<byte> content) { var data = content?.ToArray(); if(data == null) { AddAttachment(null, name); return; } var stream = RecyclableMemoryStreamManager.SharedInstance.GetStream("UnsavedRevision", data, 0, data.Length); var attachment = new Attachment(stream, contentType); AddAttachment(attachment, name); }
internal static byte[] HmacSha1(IEnumerable<byte> key, IEnumerable<byte> message) { #if PCL var k = key.ToList(); if(k.Count > 64) k = Sha1(k).ToList(); k.AddRange(Enumerable.Repeat((byte)0, 64 - k.Count)); var ipad = Enumerable.Repeat((byte)0x36, 64); var opad = Enumerable.Repeat((byte)0x5C, 64); var inner = Sha1(k.Zip(ipad, (x, y) => (byte)(x ^ y)).Concat(message ?? Enumerable.Empty<byte>())); return Sha1(k.Zip(opad, (x, y) => (byte)(x ^ y)).Concat(inner)); #else var keyArray = key as byte[] ?? key.ToArray(); var messageArray = message as byte[] ?? (message?.ToArray() ?? new byte[] { }); #if WIN_RT var prov = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha1); var buffer = CryptographicEngine.Sign( prov.CreateKey(CryptographicBuffer.CreateFromByteArray(keyArray)), CryptographicBuffer.CreateFromByteArray(messageArray) ); byte[] result; CryptographicBuffer.CopyToByteArray(buffer, out result); return result; #else using (var hs1 = new HMACSHA1(keyArray)) return hs1.ComputeHash(messageArray); #endif #endif }
public PackageUpdateDataResult(string version, IEnumerable<PackageUpdate> updates, IEnumerable<Package> packages) { Version = version; Updates = updates?.ToArray(); Packages = packages?.ToArray(); }