コード例 #1
0
        private void AddUsage(object parameter)
        {
            var usage = new HourUsage();

            Week.AddUsage(usage);
            Usages.Add(new HourUsageViewModel(_hourCodeProvider, this, usage));
        }
コード例 #2
0
 public virtual void AddUsage(HourUsage hourUsage)
 {
     if (hourUsage != null)
     {
         Usages.Add(hourUsage);
     }
 }
コード例 #3
0
ファイル: Function2.cs プロジェクト: mddazure/CoreLogger
        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);
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Usages != null)
     {
         Usages.Validate();
     }
 }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        //---------------------------------------------------------------------------------------------

        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);
                        }
                    }
                }
            }
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
 public virtual void RemoveUsage(HourUsage hourUsage)
 {
     if (hourUsage != null)
     {
         Usages.Remove(hourUsage);
     }
 }
コード例 #11
0
        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;
        }
コード例 #12
0
ファイル: Week.cs プロジェクト: colargol/dotnetprograms
 public virtual void RemoveUsage(HourUsage usage)
 {
     if (Usages.Contains(usage))
     {
         Usages.Remove(usage);
         usage.Week = null;
     }
 }
コード例 #13
0
ファイル: Week.cs プロジェクト: colargol/dotnetprograms
 public virtual void AddUsage(HourUsage usage)
 {
     if (!Usages.Contains(usage))
     {
         usage.Week = this;
         Usages.Add(usage);
     }
 }
コード例 #14
0
 public JsonWebKey(string kid, Usages use, IEnumerable <KeyOperations> keyOperations) : this(kid)
 {
     Use             = use;
     KeyOperationLst = keyOperations.Select(s => new JsonWebKeyKeyOperation
     {
         Operation = s
     }).ToList();
 }
コード例 #15
0
ファイル: EMEDF2HTML.cs プロジェクト: AinTunez/DarkScript3
 public static bool Equals(Usages a, Usages b)
 {
     if (a == null || b == null)
     {
         return((a == null) == (b == null));
     }
     return(a.Files.SequenceEqual(b.Files));
 }
コード例 #16
0
        public ObjectUnderTestBuilder WithUsages(DateTime start, DateTime end, float firstValue, float step)
        {
            var usages = new Usages(start, end, firstValue, step);

            _objectUnderTest.SetUsagesForLastUtilityAccount(usages);

            return(this);
        }
コード例 #17
0
ファイル: EMEDF2HTML.cs プロジェクト: AinTunez/DarkScript3
 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>(),
     });
 }
コード例 #18
0
        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));
        }
コード例 #19
0
        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));
        }
コード例 #20
0
            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);
            }
コード例 #21
0
ファイル: EMEDF2HTML.cs プロジェクト: AinTunez/DarkScript3
 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>");
     }
 }
コード例 #22
0
            /// <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);
            }
コード例 #23
0
 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()
     });
 }
コード例 #24
0
            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);
            }
コード例 #25
0
        /// <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);
        }
コード例 #26
0
 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]);
 }
コード例 #27
0
        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]);
            }
        }
コード例 #28
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();
        }
コード例 #29
0
 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);
     }
 }
コード例 #30
0
ファイル: EMEDF2HTML.cs プロジェクト: AinTunez/DarkScript3
            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);
            }
コード例 #31
0
        /// <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;
        }
コード例 #32
0
        /// <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);
            }
        }
コード例 #33
0
        /// <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;
        }