private void AddUsage(object parameter) { var usage = new HourUsage(); Week.AddUsage(usage); Usages.Add(new HourUsageViewModel(_hourCodeProvider, this, usage)); }
public virtual void AddUsage(HourUsage hourUsage) { if (hourUsage != null) { Usages.Add(hourUsage); } }
public async Task MainAsync(TraceWriter ll) { var docDB = new DocDBClass(); var httpClient = new HttpClient(); HttpResponseMessage response; Usages usages = new Usages(); var azureServiceTokenProvider = new AzureServiceTokenProvider(); var accessToken = azureServiceTokenProvider.GetAccessTokenAsync("https://management.core.windows.net/").Result; string[] subscrArray = { "0245be41-c89b-4b46-a3cc-a705c90cd1e8" }; var canceltoken = new CancellationToken(); var httpRequestMessage = new HttpRequestMessage(); foreach (var subscr in subscrArray) { httpRequestMessage.Method = new HttpMethod("GET"); httpRequestMessage.RequestUri = new Uri($"https://management.azure.com/subscriptions/{subscr}/providers/Microsoft.Compute/locations/west-europe/usages?api-version=2015-06-15"); httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); httpRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); response = httpClient.SendAsync(httpRequestMessage, canceltoken).Result; //Console.WriteLine("Received Log {0}", response.Content.AsString()); //Console.ReadKey(); await docDB.DocumentDB(subscr, await response.Content.ReadAsStringAsync(), ll); } }
public HelpCommandEmbeddable(CommandInfo subject, IEnumerable <CallInfo> permitted, string name, ICommandContext context) { Name = name; Command = subject; Permitted = permitted; Context = context; foreach (var call in Permitted) { Usages.Add(new RawString("`{0}{1} {2} {3} {4}` - {5}", Context.Prefix, Name, call.SubCall, string.Join(" ", call.GetParameters()), call.GetFlags(), (LocalisedString)call.Usage)); } if (Usages.Count == 0) { Usage = (LocalisedString)SINGLE_NOUSAGE; } else { Usage = new DynamicString(tr => string.Join("\n", Usages.Select(u => u.Localise(tr).RegexReplace(" +", " ")))); } Notes = (LocalisedString)Command.Note; NotesFooter = (LocalisedString)SINGLE_USAGE_FOOTER; Aliases = Command.Alias.Length == 0 ? "" : string.Join(", ", Command.Alias.ToList()); Group = (RawString)Command.Group ?? (LocalisedString)SINGLE_NOGROUP; Flags.AddRange(Permitted.SelectMany(c => c.Flags) .GroupBy(f => f.ShortKey) .Select(g => g.First())); Flag = LocalisedString.JoinEnumerable("\n", Flags); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="Rest.ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Usages != null) { Usages.Validate(); } }
public void WriteUsages(string appName) { if (!Usages.Any()) { Console.WriteLine("No documentation for this command"); return; } Console.WriteLine(" Usages for '{0}' ({1})", _commandName, _description); if (Usages.Count() == 1) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(" " + Usages.Single().ToUsage(appName, _commandName)); Console.ResetColor(); } else { writeMultipleUsages(appName); } if (Arguments.Any()) { writeArguments(); } if (!Flags.Any()) { return; } writeFlags(); }
static void Main(string[] args) { Video video1 = new Video(); Video video2 = new Video(); //Request video1.Link = "https://www.youtube.com/watch?v=IKRVX3c8HuU"; video2.Link = "https://www.facebook.com/watch/?v=361268888540894"; //Handlers YoutubHandler youtubHandler = new YoutubHandler(); FacebookHandler facebookHandler = new FacebookHandler(); InstagramHandler instagramHandler = new InstagramHandler(); //chain youtubHandler.setNextHandler(facebookHandler); facebookHandler.setNextHandler(instagramHandler); youtubHandler.HandleRequest(video2); Console.WriteLine(); Console.WriteLine(); facebookHandler.HandleRequest(video2); //Usages Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("--------------------------------------------------------------------"); Usages.tryCatchBloks(); Console.WriteLine(); Console.WriteLine(); }
//--------------------------------------------------------------------------------------------- public void FillFromDataRow(DataRow row) { foreach (PropertyInfo pInfo in this.GetType().GetProperties()) { ParameterAttribute attrParam = (ParameterAttribute)this.GetAttribute(pInfo, typeof(ParameterAttribute)); if (attrParam != null) { Usages defaultUsage = Usages.Add | Usages.Load | Usages.Save; UsageAttribute usage = (UsageAttribute)this.GetAttribute(pInfo, typeof(UsageAttribute)); if (usage != null) { defaultUsage = usage.Usage; } if ((defaultUsage & Usages.Load) == Usages.Load) { object value = (row.Table.Columns.Contains(attrParam.Name)) ? Utils.DBNullToNull(row[attrParam.Name]) : null; if (pInfo.PropertyType.GetInterface("Caleb.Library.CAL.ICalBusiness") != null) { ICalBusiness business = (ICalBusiness)pInfo.GetValue(this, null); business.ID = CalBusiness.ToID(value); } else { pInfo.SetValue(this, value, null); } } } } }
/// <summary> /// Gets an object that wraps the current Model information for Serialization /// </summary> /// <returns></returns> public object RepresentedContext() { object retval = null; if (!Usages.Any()) { retval = Children.ToDictionary(k => k.Key, v => v.Value.RepresentedContext()); } else if (Usages.Contains(UsedAs.Scalar) && Usages.Count == 1) { retval = Key + "_Value"; } else { if (Usages.Contains(UsedAs.Collection)) { if (Children.Any()) { retval = new[] { Children.ToDictionary(k => k.Key, v => v.Value.RepresentedContext()) }; } else { retval = Enumerable.Range(1, 3).Select(k => Key + "_" + k).ToArray(); } } else { retval = Children.ToDictionary(k => k.Key, v => v.Value.RepresentedContext()); } } return(retval); }
public virtual void RemoveUsage(HourUsage hourUsage) { if (hourUsage != null) { Usages.Remove(hourUsage); } }
public void UpdateUsage(AppPage newExample) { var timeNow = DateTime.UtcNow; if (_exampleAppPage != null) { if (Usages.ContainsKey(_exampleAppPage.Title)) { Usages[_exampleAppPage.Title].VisitCount++; Usages[_exampleAppPage.Title].SecondsSpent += (int)(timeNow - _lastNavigationTime).TotalSeconds; } else { Usages[_exampleAppPage.Title] = new ExampleUsage { ExampleID = _exampleAppPage.Title, VisitCount = 1, SecondsSpent = (int)(timeNow - _lastNavigationTime).TotalSeconds, }; } } _lastNavigationTime = timeNow; _exampleAppPage = newExample as ExampleAppPage; }
public virtual void RemoveUsage(HourUsage usage) { if (Usages.Contains(usage)) { Usages.Remove(usage); usage.Week = null; } }
public virtual void AddUsage(HourUsage usage) { if (!Usages.Contains(usage)) { usage.Week = this; Usages.Add(usage); } }
public JsonWebKey(string kid, Usages use, IEnumerable <KeyOperations> keyOperations) : this(kid) { Use = use; KeyOperationLst = keyOperations.Select(s => new JsonWebKeyKeyOperation { Operation = s }).ToList(); }
public static bool Equals(Usages a, Usages b) { if (a == null || b == null) { return((a == null) == (b == null)); } return(a.Files.SequenceEqual(b.Files)); }
public ObjectUnderTestBuilder WithUsages(DateTime start, DateTime end, float firstValue, float step) { var usages = new Usages(start, end, firstValue, step); _objectUnderTest.SetUsagesForLastUtilityAccount(usages); return(this); }
public static Usages Union(Usages a, Usages b) { return(new Usages { Files = a.Files.Union(b.Files).OrderBy(f => f).ToList(), AllFiles = a.AllFiles.Equals(b.AllFiles) || a.AllFiles.SequenceEqual(b.AllFiles) ? a.AllFiles : new List <string>(), }); }
public Task <List <JsonWebKey> > FindJsonWebKeys(Usages usage, string alg, KeyOperations[] operations, CancellationToken cancellationToken) { var currentDateTime = DateTime.UtcNow; int nbOperations = operations.Count(); return(GetJsonWebKeys().Where(j => (j.ExpirationDateTime == null || currentDateTime < j.ExpirationDateTime) && (j.Use == usage && j.Alg == alg && j.KeyOperationLst.Where(k => operations.Contains(k.Operation)).Count() == nbOperations) ).ToListAsync(cancellationToken)); }
public Task <List <JsonWebKey> > FindJsonWebKeys(Usages usage, string alg, KeyOperations[] operations, CancellationToken cancellationToken) { var currentDateTime = DateTime.UtcNow; var result = LstData.Where(j => (j.ExpirationDateTime == null || currentDateTime < j.ExpirationDateTime) && (j.Use == usage && j.Alg == alg && operations.All(o => j.KeyOps.Contains(o))) ).Select(j => (JsonWebKey)j.Clone()).ToList(); return(Task.FromResult(result)); }
public override void visit(Generated.StructureElement obj, bool visitSubNodes) { Types.StructureElement element = (Types.StructureElement)obj; if (element.Type == Target) { Usages.Add(element); } base.visit(obj, visitSubNodes); }
private void SectionUsageDetails(Usages usages) { if (usages == null) { sb.AppendLine($"<p class=\"sectionusage usageinfo sectionunused\">Unused</p>"); } else { sb.AppendLine($"<p class=\"sectionusage usageinfo\">Used in {usages}</p>"); } }
/// <summary> /// Take care of all conditions /// </summary> /// <param name="obj"></param> /// <param name="visitSubNodes"></param> public override void visit(Generated.RuleCondition obj, bool visitSubNodes) { RuleCondition ruleCondition = (RuleCondition)obj; if (ruleCondition.Uses(Target)) { Usages.Add(ruleCondition); } base.visit(obj, visitSubNodes); }
public CommandReport ToReport(string appName) { return(new CommandReport { Name = _commandName, Description = _description, Arguments = Arguments.Select(x => x.ToReport()).ToArray(), Flags = Flags.Select(x => new FlagReport(x)).ToArray(), Usages = Usages.Select(x => x.ToReport(appName, _commandName)).ToArray() }); }
public override void visit(Generated.Variable obj, bool visitSubNodes) { Variables.Variable variable = (Variables.Variable)obj; if (variable.Type == Target) { Usages.Add(variable); } base.visit(obj, visitSubNodes); }
/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>true if semantical analysis should be performed</returns> public virtual bool SemanticAnalysis(INamable instance = null) { bool retVal = !SemanticalAnalysisDone; if (retVal) { StaticUsage = new Usages(); SemanticalAnalysisDone = true; } return(retVal); }
public ExampleUsage GetUsage(Example example) { if (!Usages.ContainsKey(example.Title)) { Usages[example.Title] = new ExampleUsage { ExampleID = example.Title, VisitCount = 0, SecondsSpent = 0 }; } return(Usages[example.Title]); }
private void AddExtendedKeyUsage() { if (Usages != null && Usages.Any()) { var usages = Usages.Select(x => extendedUsagesMap[x]); certificateGenerator.AddExtension(X509Extensions.ExtendedKeyUsage.Id, false, new ExtendedKeyUsage(usages)); } if (Usages.Contains("ocsp")) { certificateGenerator.AddExtension(OcspObjectIdentifiers.PkixOcspNocheck.Id, false, new byte[0]); } }
private void writeMultipleUsages(string appName) { var usageReport = new TwoColumnReport("Usages") { SecondColumnColor = ConsoleColor.Cyan }; Usages.OrderBy(x => x.Arguments.Count()).ThenBy(x => x.ValidFlags.Count()).Each(u => { usageReport.Add(u.Description, u.ToUsage(appName, _commandName)); }); usageReport.Write(); }
public override int GetHashCode() { unchecked { var hashCode = Number; hashCode = (hashCode * 397) ^ Priority; hashCode = (hashCode * 397) ^ (Logograph != null ? Logograph.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Pronunciation != null ? Pronunciation.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReviewTime != null ? ReviewTime.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Definitions != null ? Definitions.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Usages != null ? Usages.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Phrases != null ? Phrases.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Idioms != null ? Idioms.GetHashCode() : 0); return(hashCode); } }
public static Usages UnionAll(IEnumerable <Usages> allUsages) { Usages usages = null; foreach (Usages subUsages in allUsages) { if (usages == null) { usages = subUsages; } else if (subUsages != null) { usages = Union(usages, subUsages); } } return(usages); }
/// <summary> /// Performs the semantic analysis of the statement /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <returns>true if semantical analysis should be performed</returns> public virtual bool SemanticAnalysis(INamable instance = null) { bool retVal = !SemanticalAnalysisDone; if (retVal) { StaticUsage = new Usages(); SemanticalAnalysisDone = true; } return retVal; }
/// <summary> /// Performs the semantic analysis of the term /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <param name="expectation">Indicates the kind of element we are looking for</param> /// <param name="lastElement">Indicates that this element is the last one in a dereference chain</param> /// <returns>True if semantic analysis should be continued</returns> public void SemanticAnalysis(INamable instance, BaseFilter expectation, bool lastElement) { ReturnValue tmp = GetReferences(instance, expectation, lastElement); if (Image != ThisKeyword && Image != EnclosingKeyword) { tmp.Filter(expectation); } if (tmp.IsUnique) { Ref = tmp.Values[0].Value; } if (StaticUsage == null) { StaticUsage = new Usages(); StaticUsage.AddUsage(Ref, Root, null); } }
/// <summary> /// Performs the semantic analysis of the expression /// </summary> /// <param name="instance">the reference instance on which this element should analysed</param> /// <param name="expectation">Indicates the kind of element we are looking for</param> /// <returns>True if semantic analysis should be continued</returns> public virtual bool SemanticAnalysis(INamable instance, BaseFilter expectation) { bool retVal = !SemanticAnalysisDone; if (retVal) { StaticUsage = new Usages(); SemanticAnalysisDone = true; } return retVal; }