/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } if (IconClassName != null) { hashCode = hashCode * 59 + IconClassName.GetHashCode(); } if (IconUrl != null) { hashCode = hashCode * 59 + IconUrl.GetHashCode(); } if (Score != null) { hashCode = hashCode * 59 + Score.GetHashCode(); } if (Class != null) { hashCode = hashCode * 59 + Class.GetHashCode(); } return(hashCode); } }
public void PackagedNodeSearchElementLoadedType() { var category = "abc.xyz.somepackage"; var name = "My Node"; var creationName = "create abc xyz"; var expectedQualifiedName = "pkg://abc.xyz.somepackage.My Node"; var path = @"C:\temp\packages\test.dll"; var moq = new Mock <TestNodeSearchElement>(category, name, ElementTypes.Packaged, path) { CallBase = true }; var element = moq.Object; moq.Setup(e => e.CreationName).Returns(creationName); var provider = new NodeItemDataProvider(new NodeSearchModel()); var item = provider.CreateLoadedTypeItem <LoadedTypeItem>(element); Assert.AreEqual(expectedQualifiedName, item.fullyQualifiedName); Assert.AreEqual(creationName, item.contextData); Assert.AreEqual("abc, xyz, somepackage", item.keywords); var url = new IconUrl(new Uri(item.iconUrl)); Assert.AreEqual("My%20Node.Small", url.Name); Assert.AreEqual(path, url.Path); }
//--------------------------------------------------------------------------------------------------------------------- /// <summary>Loads service the root directories for file system and web access.</summary> protected void GetRootDirectories() { if (fileRootDir != null || relativeUrl != null) { return; } if (RootDirectory != null) { if (RootDirectory.StartsWith("$(SERVICEROOT)")) { fileRootDir = (RootDirectory.Replace("$(SERVICEROOT)", context.ServiceFileRoot)).Replace('/', System.IO.Path.DirectorySeparatorChar); relativeUrl = RootDirectory.Replace("$(SERVICEROOT)", context.ServiceWebRoot); } else { fileRootDir = (context.SiteRootFolder + "/" + RootDirectory).Replace('/', System.IO.Path.DirectorySeparatorChar); relativeUrl = RootDirectory; } relativeUrl = Regex.Replace(relativeUrl, "/+$", String.Empty); } if (IconUrl != null) { IconUrl = IconUrl.Replace("$(SERVICEROOT)", context.ServiceWebRoot); } if (ViewUrl != null) { ViewUrl = ViewUrl.Replace("$(SERVICEROOT)", context.ServiceWebRoot); } }
public void VerifyIconsForLibraryItems() { var iconProvider = new IconResourceProvider(GetModel().PathManager); var request = new Mock <IRequest>(); var resource = "ViewExtensionLibraryTests.resources.libraryItems.json"; using (var s = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) { var data = GetLoadedTypesFromJson(s); var types = data.loadedTypes; var unresolved = new List <LoadedTypeItem>(); foreach (var item in types) { request.Setup(r => r.Url).Returns(item.iconUrl); string extension = "txt"; using (var stream = iconProvider.GetResource(request.Object, out extension)) { Assert.AreEqual("png", extension); if (stream == null || stream.Length == 0) { unresolved.Add(item); } } } var sb = new StringBuilder(); unresolved.ForEach(e => { var url = new IconUrl(new Uri(e.iconUrl)); sb.AppendFormat("Node: {0}, Image: {1}/{2}\n", e.fullyQualifiedName, url.Name, url.Path); }); Assert.AreEqual(0, unresolved.Count, sb.ToString()); } }
protected override void Execute(NativeActivityContext context) { var pModel = new PackageModel(); pModel.Id = PackageId.Get(context); pModel.Description = Description.Get(context); pModel.Version = Models.PackageModel.CreateFullVersionFromMajorMinor(MajorVersion.Get(context), MinorVersion.Get(context)); pModel.Authors = Authors.Get(context); pModel.Owners = Owners.Get(context); pModel.LicenseUrl = LicenseUrl.Get(context); pModel.ProjectUrl = ProjectUrl.Get(context); pModel.IconUrl = IconUrl.Get(context); pModel.RequireLicenseAcceptance = RequireLicenseAcceptance.Get(context); pModel.ReleaseNotes = ReleaseNotes.Get(context); pModel.Copyright = Copyright.Get(context); pModel.Tags = Tags.Get(context); pModel.DirectorySet = DirectorySet.Get(context); pModel.ModelsAssemblyGuid = ModelsAssemblyGuid.Get(context) ?? Guid.NewGuid().ToString(); pModel.ActivitiesAssemblyGuid = ActivitiesAssemblyGuid.Get(context) ?? Guid.NewGuid().ToString(); this.PackageModel.Set(context, pModel); context.Properties.Add("PackageModel", pModel); context.ScheduleActivity(this.Body); }
public void CustomNodeIconUrlIsCorrectWhenCustomizationDllExists() { var name = "c4a6b7cc-f860-4afc-bc74-72d8888002f2"; var packagePath = Path.Combine(TestDirectory, "pkgs", "IconizedCustomNode"); var customNodePath = Path.Combine(packagePath, "dyf", "MyOR.dyf"); var url = new IconUrl(name, customNodePath, true); var binaryPath = Path.Combine(packagePath, "bin", "Package.dll"); Assert.AreEqual($"http://localhost/icons/{name}.Small?path={binaryPath}", url.Url); }
public override int GetHashCode() { unchecked { var hashCode = ContentId.GetHashCode(); hashCode = (hashCode * 397) ^ (IconUrl?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Id.GetHashCode(); hashCode = (hashCode * 397) ^ (InternalName?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (SupportedGameModes?.GetHashCode() ?? 0); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = Color?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ ContentId.GetHashCode(); hashCode = (hashCode * 397) ^ (Description?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (IconUrl?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Id; hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0); return(hashCode); } }
public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + Humidity.GetHashCode(); hash = hash * 23 + IconUrl.GetHashCode(); hash = hash * 23 + Pressure.GetHashCode(); hash = hash * 23 + Temperature.GetHashCode(); hash = hash * 23 + TemperatureFormat.GetHashCode(); hash = hash * 23 + WeatherDescription.GetHashCode(); hash = hash * 23 + WindSpeed.GetHashCode(); return(hash); } }
public override int GetHashCode() { unchecked { var hashCode = ContentId.GetHashCode(); hashCode = (hashCode * 397) ^ EndDate.GetHashCode(); hashCode = (hashCode * 397) ^ (IconUrl?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Id.GetHashCode(); hashCode = (hashCode * 397) ^ IsActive.GetHashCode(); hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Playlists?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (StartDate?.GetHashCode() ?? 0); return(hashCode); } }
public override int GetHashCode() { unchecked { var n = 23; var hash = 17; hash = hash * n + IconUrl.GetHashCode(); hash = hash * n + IconColour.GetHashCode(); hash = hash * n + IconScale.GetHashCode(); hash = hash * n + LineColour.GetHashCode(); hash = hash * n + LineWidth.GetHashCode(); hash = hash * n + PolygonColour.GetHashCode(); return(hash); } }
public override int GetHashCode() { int hash = 1; if (ImageUrl.Length != 0) { hash ^= ImageUrl.GetHashCode(); } if (IconUrl.Length != 0) { hash ^= IconUrl.GetHashCode(); } if (NameKey.Length != 0) { hash ^= NameKey.GetHashCode(); } return(hash); }
public void IconUrlRoundTrip() { var name = "icon"; var path = @"C:\some where\resource.dll"; var url = new IconUrl(name, path); Assert.AreEqual(name + ".Small", url.Name); Assert.AreEqual(path, url.Path); var newUrl = new IconUrl(new System.Uri(url.Url)); Assert.AreEqual(url.Name, newUrl.Name); Assert.AreEqual(url.Path, newUrl.Path); //For custom node, if the customization dll doesn't exist at the //given path it is turned to default. var customNode = new IconUrl(name, path, true); Assert.AreEqual(IconUrl.DefaultPath, customNode.Path); Assert.AreEqual(IconUrl.DefaultIcon, customNode.Name); }
protected override PackageModel Execute(CodeActivityContext context) { var pModel = new PackageModel(); pModel.Id = PackageId.Get(context); pModel.Description = Description.Get(context); pModel.Version = Version.Get(context); pModel.Authors = Authors.Get(context); pModel.Owners = Owners.Get(context); pModel.LicenseUrl = LicenseUrl.Get(context); pModel.ProjectUrl = ProjectUrl.Get(context); pModel.IconUrl = IconUrl.Get(context); pModel.RequireLicenseAcceptance = RequireLicenseAcceptance.Get(context); pModel.ReleaseNotes = ReleaseNotes.Get(context); pModel.Copyright = Copyright.Get(context); pModel.Tags = Tags.Get(context); pModel.DirectorySet = DirectorySet.Get(context); pModel.ModelsAssemblyGuid = ModelsAssemblyGuid.Get(context); pModel.ActivitiesAssemblyGuid = ActivitiesAssemblyGuid.Get(context); return(pModel); }
public override int GetHashCode() { int hash = 1; if (ImageUrl.Length != 0) { hash ^= ImageUrl.GetHashCode(); } if (IconUrl.Length != 0) { hash ^= IconUrl.GetHashCode(); } if (NameKey.Length != 0) { hash ^= NameKey.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Returns true if FreeStyleProjecthealthReport instances are equal /// </summary> /// <param name="other">Instance of FreeStyleProjecthealthReport to be compared</param> /// <returns>Boolean</returns> public bool Equals(FreeStyleProjecthealthReport other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Description == other.Description || Description != null && Description.Equals(other.Description) ) && ( IconClassName == other.IconClassName || IconClassName != null && IconClassName.Equals(other.IconClassName) ) && ( IconUrl == other.IconUrl || IconUrl != null && IconUrl.Equals(other.IconUrl) ) && ( Score == other.Score || Score != null && Score.Equals(other.Score) ) && ( Class == other.Class || Class != null && Class.Equals(other.Class) )); }
public void CustomNodeSearchElementLoadedType() { var category = "abc.xyz.somepackage"; var name = "My Node"; var path = @"C:\temp\xyz.dyf"; var guid = Guid.NewGuid(); var info = new CustomNodeInfo(guid, name, category, "some description", path); var expectedQualifiedName = "dyf://abc.xyz.somepackage.My Node"; var moq = new Mock <ICustomNodeSource>(); var element = new CustomNodeSearchElement(moq.Object, info); var provider = new NodeItemDataProvider(new NodeSearchModel()); var item = provider.CreateLoadedTypeItem <LoadedTypeItem>(element); Assert.AreEqual(expectedQualifiedName, item.fullyQualifiedName); Assert.AreEqual(guid.ToString(), item.contextData); Assert.AreEqual(string.Empty, item.keywords); var url = new IconUrl(new Uri(item.iconUrl)); Assert.AreEqual(IconUrl.DefaultIcon, url.Name); Assert.AreEqual(IconUrl.DefaultPath, url.Path); }
//public SlackClient slackClient; //public SlackHttpClient httpClient; protected override void Append(log4net.Core.LoggingEvent loggingEvent) { var attachments = new List <Attachment>(); if (AddAttachment) { // Set fallback string var theAttachment = new Attachment(string.Format("[{0}] {1} in {2} on {3}", loggingEvent.Level.DisplayName, loggingEvent.LoggerName, currentProcess.ProcessName, Environment.MachineName)); // Determine attachment color switch (loggingEvent.Level.DisplayName.ToLowerInvariant()) { case "warn": theAttachment.Color = "warning"; break; case "error": case "fatal": theAttachment.Color = "danger"; break; } //override colors from config if available var mapping = mappings?.FirstOrDefault(m => m.level.Equals(loggingEvent.Level.DisplayName, StringComparison.InvariantCultureIgnoreCase)); if (mapping != null) { var color = Color.FromName(mapping.backColor); var hex = color.IsKnownColor ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : mapping.backColor; theAttachment.Color = !string.IsNullOrEmpty(hex) ? hex : theAttachment.Color; } // Add attachment fields theAttachment.Fields = new List <Field> { new Field("Process", currentProcess.ProcessName, true), new Field("Machine", Environment.MachineName, true), new Field("Environment", ProgramEnvironment, true), }; if (!UsernameAppendLoggerName) { theAttachment.Fields.Insert(0, new Field("Logger", loggingEvent.LoggerName, true)); } // Add exception fields if exception occurred var exception = loggingEvent.ExceptionObject; if (exception != null) { theAttachment.Fields.Insert(0, new Field("Exception Type", exception.GetType().Name, true)); if (AddExceptionTraceField && !string.IsNullOrWhiteSpace(exception.StackTrace)) { var parts = exception.StackTrace.SplitOn(1990).ToArray(); // Split call stack into consecutive fields of ~2k characters for (int idx = parts.Length - 1; idx >= 0; idx--) { var name = "Exception Trace" + (idx > 0 ? $" {idx + 1}" : null); theAttachment.Fields.Insert(0, new Field(name, "```" + parts[idx].Replace("```", "'''") + "```")); } } theAttachment.Fields.Insert(0, new Field("Exception Message", exception.Message)); } attachments.Add(theAttachment); } var formattedMessage = (Layout != null ? Layout.FormatString(loggingEvent) : loggingEvent.RenderedMessage); var username = Username.Expand() + (UsernameAppendLoggerName ? " - " + loggingEvent.LoggerName : null); SlackHttpClient.PostMessageAsync(formattedMessage, WebhookUrl.Expand(), username, Channel.Expand(), IconUrl.Expand(), IconEmoji.Expand(), attachments, LinkNames); }
/// <summary> /// Convert the page object to XElement. /// </summary> /// <param name="withNamespace"></param> /// <returns>A xelement contains web page definition.</returns> public XElement Element(bool withNamespace = false) { XNamespace ns = "http://www.dotnetage.com/XML/Schema/page"; XNamespace wns = "http://www.dotnetage.com/XML/Schema/widget-data"; var element = new XElement(ns + PAGE, new XAttribute("xmlns", ns), new XAttribute(VIEWMODE, (PageViewModes)this.ViewMode), new XAttribute(SLUG, this.Slug)); if (withNamespace) { element.Add(new XAttribute(XNamespace.Xmlns + "w", wns)); } #region attributes if (!this.ShowInMenu) { element.Add(new XAttribute(SHOW_IN_MENU, false)); } if (!this.ShowInSitemap) { element.Add(new XAttribute(SHOW_IN_SITEMAP, false)); } if (!this.AllowAnonymous) { element.Add(new XAttribute(ANONYMOUS, false)); if (this.Roles != null && this.Roles.Length > 0) { element.Add(new XAttribute(ROLES, string.Join(",", this.Roles))); } } if (this.IsStatic) { element.Add(new XAttribute(STATIC, true)); } if (this.IsShared) { element.Add(new XAttribute(SHARED, true)); } if (!string.IsNullOrEmpty(this.Target)) { element.Add(new XAttribute(TARGET, this.Target)); } if (!string.IsNullOrEmpty(this.Dir)) { element.Add(new XAttribute(DIR, this.Dir)); } #endregion #region elements if (!string.IsNullOrEmpty(Title)) { element.Add(new XElement(ns + TITLE, this.Title)); } if (!string.IsNullOrEmpty(Description)) { element.Add(new XElement(ns + DESC, new XCData(this.Description))); } if (!string.IsNullOrEmpty(Keywords)) { element.Add(new XElement(ns + KEY_WORDS, this.Keywords)); } if (!string.IsNullOrEmpty(this.LinkTo)) { element.Add(new XElement(ns + LINK, this.LinkTo)); } if (!string.IsNullOrEmpty(this.IconUrl)) { if (IconUrl.StartsWith("data:image")) { element.Add(new XElement(ns + ICON, new XCData(IconUrl))); } else { element.Add(new XElement(ns + ICON, "images/" + System.IO.Path.GetFileName(this.IconUrl))); } } if (!string.IsNullOrEmpty(this.ImageUrl)) { if (ImageUrl.StartsWith("data:image")) { element.Add(new XElement(ns + ICON, new XCData(ImageUrl))); } else { element.Add(new XElement(ns + IMAGE, new XAttribute("src", "images/" + System.IO.Path.GetFileName(this.ImageUrl)))); } } if (!string.IsNullOrEmpty(this.ViewName) || !string.IsNullOrEmpty(this.ViewData)) { var layout = new XElement(ns + LAYOUT); if (!string.IsNullOrEmpty(this.ViewName)) { if (string.IsNullOrEmpty(this.ViewData)) { layout.Add(new XAttribute(NAME, this.ViewName)); } } if (!string.IsNullOrEmpty(this.ViewData)) { layout.Add(new XCData(this.ViewData)); } element.Add(layout); } if (this.StyleSheets != null && this.StyleSheets.Length > 0) { foreach (var ss in StyleSheets) { var fileName = System.IO.Path.GetFileName(ss); element.Add(new XElement(ns + STYLE, new XAttribute(SRC, "css/" + fileName))); } } if (this.Scripts != null && this.Scripts.Length > 0) { foreach (var s in Scripts) { var fileName = System.IO.Path.GetFileName(s); element.Add(new XElement(ns + SCRIPT, new XAttribute(SRC, "scripts/" + fileName))); } } #endregion #region pages if (this.Children != null && this.Children.Count() > 0) { var childrenElement = new XElement(ns + PAGES); foreach (var child in Children) { if (child.IsStatic && child.IsStatic) { continue; } childrenElement.Add(child.Element()); } element.Add(childrenElement); } #endregion #region widgets if (this.Widgets != null && this.Widgets.Count() > 0) { var widgetsElement = new XElement(ns + WIDGETS); foreach (var widget in this.Widgets) { if (widget.PageID == this.ID) { widgetsElement.Add(widget.Element()); } } element.Add(widgetsElement); } #endregion return(element); }
protected override void Append(log4net.Core.LoggingEvent loggingEvent) { // Initialze the Slack client var slackClient = new SlackClient(WebhookUrl.Expand()); var attachments = new List <Attachment>(); if (AddAttachment) { // Set fallback string var theAttachment = new Attachment(string.Format("[{0}] {1} in {2} on {3}", loggingEvent.Level.DisplayName, loggingEvent.LoggerName, _currentProcess.ProcessName, Environment.MachineName)); // Determine attachment color switch (loggingEvent.Level.DisplayName.ToLowerInvariant()) { case "warn": theAttachment.Color = "warning"; break; case "error": case "fatal": theAttachment.Color = "danger"; break; } // Add attachment fields theAttachment.Fields = new List <Field> { new Field("Process", Value: _currentProcess.ProcessName, Short: true), new Field("Machine", Value: Environment.MachineName, Short: true) }; if (!UsernameAppendLoggerName) { theAttachment.Fields.Insert(0, new Field("Logger", Value: loggingEvent.LoggerName, Short: true)); } // Add exception fields if exception occurred var exception = loggingEvent.ExceptionObject; if (exception != null) { theAttachment.Fields.Insert(0, new Field("Exception Type", Value: exception.GetType().Name, Short: true)); if (AddExceptionTraceField && !string.IsNullOrWhiteSpace(exception.StackTrace)) { var parts = exception.StackTrace.SplitOn(1990).ToArray(); // Split call stack into consecutive fields of ~2k characters for (int idx = parts.Length - 1; idx >= 0; idx--) { var name = "Exception Trace" + (idx > 0 ? string.Format(" {0}", idx + 1) : null); theAttachment.Fields.Insert(0, new Field(name, Value: "```" + parts[idx].Replace("```", "'''") + "```")); } } theAttachment.Fields.Insert(0, new Field("Exception Message", Value: exception.Message)); } attachments.Add(theAttachment); } var formattedMessage = (Layout != null ? Layout.FormatString(loggingEvent) : loggingEvent.RenderedMessage); var username = Username.Expand() + (UsernameAppendLoggerName ? " - " + loggingEvent.LoggerName : null); slackClient.PostMessageAsync(formattedMessage, username, Channel.Expand(), IconUrl.Expand(), IconEmoji.Expand(), attachments); }