public ServerSerializationContextProvider(ITypeResolver typeMapper, IUriResolver uriResolver, IResourceResolver resourceResolver, IContainer container) { if (typeMapper == null) { throw new ArgumentNullException(nameof(typeMapper)); } if (uriResolver == null) { throw new ArgumentNullException(nameof(uriResolver)); } if (resourceResolver == null) { throw new ArgumentNullException(nameof(resourceResolver)); } if (container == null) { throw new ArgumentNullException(nameof(container)); } this.typeMapper = typeMapper; this.uriResolver = uriResolver; this.resourceResolver = resourceResolver; this.container = container; }
public static ContentDialog SetOkToClose(this ContentDialog dialog, IResourceResolver resolver = null) { resolver = resolver ?? Settings.DefaultResolver; dialog.PrimaryButtonText = resolver.Resolve(ResourceTypes.Ok); dialog.IsPrimaryButtonEnabled = true; return(dialog); }
public ElementDefinitionCollection(IResourceResolver resolver, List <ElementDefinition> elements) { // This is the "root" of the StructureDefinition, so we need to grab the first element, then populate the children _resolver = resolver; MyElementDefinition = elements.First(); // Scan through the immediate children var immediateChildren = FilterCollectionForImmediateChildren(elements, MyElementDefinition.Path).ToArray(); for (int n = 0; n < immediateChildren.Length; n++) { int startIndex = elements.IndexOf(immediateChildren[n]); List <ElementDefinition> childsElements; if (n != immediateChildren.Length - 1) { int endIndex = elements.IndexOf(immediateChildren[n + 1]) - 1; childsElements = elements.Skip(startIndex).Take(endIndex - startIndex + 1).ToList(); } else { childsElements = elements.Skip(startIndex).ToList(); } Children.Add(new ElementDefinitionCollection(_resolver, childsElements)); } }
// Helper method to retrieve debugger display strings for well-known implementations // http://blogs.msdn.com/b/jaredpar/archive/2011/03/18/debuggerdisplay-attribute-best-practices.aspx internal static string DebuggerDisplayString(this IResourceResolver resolver) { if (resolver is DirectorySource ds) { return(ds.DebuggerDisplay); } if (resolver is ZipSource zs) { return(zs.DebuggerDisplay); } // if (resolver is WebResolver wr) { return wr.DebuggerDisplay; } if (resolver is MultiResolver mr) { return(mr.DebuggerDisplay); } if (resolver is CachedResolver cr) { return(cr.DebuggerDisplay); } if (resolver is SnapshotSource ss) { return(ss.DebuggerDisplay); } return(resolver.GetType().Name); }
public static DoubleArrayTrie NewInstance(IResourceResolver resolver) { using (var stream = resolver.Resolve(DoubleArrayTrieFileName)) { return(Read(stream)); } }
/// <summary> /// Factory method to create an <see cref="IValidationRule"/> based on this attribute. /// </summary> public IValidationRule CreateRule(PropertyInfo property, IResourceResolver resourceResolver) { PropertyGetter getter = CreatePropertyGetter(property); string customMessage = GetLocalizedCustomMessage(resourceResolver); return(CreateRule(property, getter, customMessage)); }
private void refreshProfileSource() { try { var profilePath = txtProfileDirectory.Text; if (!String.IsNullOrEmpty(profilePath) && Directory.Exists(profilePath)) { // We not only have a source for core data, we also read data from a user-specified directory. We also cache the contents of this source, like // we did with the CoreSource above. DirectorySource = new CachedResolver(new DirectorySource(profilePath, includeSubdirectories: true)); // Finally, we combine both sources, so we will find profiles both from the core zip as well as from the directory. // By mentioning the directory source first, anything in the user directory will override what is in the core zip. CombinedSource = new MultiResolver(DirectorySource, CoreSource); } else { CombinedSource = CoreSource; } } catch (Exception e) { MessageBox.Show($"Composing the profile source failed: {e.Message}", "Profile source"); } }
public static MailMessage AddHtmlView(this MailMessage mail, string htmlBody, List<string> resources, IResourceResolver resourceResolver) { if (mail != null && htmlBody.Clear() != null && resources != null && resources.Any()) { if (resourceResolver == null) { throw new Exception("ResourceResolver not set"); } AlternateView av = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html); resources.ForEach(r => { HtmlResource hr = resourceResolver.GetHtmlResource(r); if (hr != null) { MemoryStream ms = new MemoryStream(hr.Content); LinkedResource lr; if (hr.MediaType.Clear() != null) { lr = new LinkedResource(ms, hr.MediaType.Clear()); } else { lr = new LinkedResource(ms); } lr.ContentId = hr.ContentId; av.LinkedResources.Add(lr); } mail.AlternateViews.Add(av); }); } return mail; }
/// <summary> /// Constructor. Values passed to this constructor will override any <see cref="FolderPathAttribute"/> declaration. /// </summary> /// <param name="path"></param> /// <param name="startExpanded"></param> protected Folder(Path path, bool startExpanded) { // establish default resource resolver on this assembly (not the assembly of the derived class) _resourceResolver = new ResourceResolver(typeof(Folder).Assembly); _folderPath = path; _startExpanded = startExpanded; }
public static MailMessage AddAttachments(this MailMessage mail, List<string> attachments, IResourceResolver resourceResolver) { if (mail != null && attachments != null && attachments.Any()) { if (resourceResolver == null) { throw new Exception("ResourceResolver not set"); } attachments.ForEach(a => { MailAttachment att = resourceResolver.GetMailAttachment(a); if (att != null) { MemoryStream ms = new MemoryStream(att.Content); if (att.MediaType.Clear() != null) { mail.Attachments.Add(new Attachment(ms, att.Name, att.MediaType)); } else { mail.Attachments.Add(new Attachment(ms, att.Name)); } } }); } return mail; }
private IEntity LocateResource(ConnectorRequest request, ApiResourceMapping mapping, out ConnectorResponse errorResponse) { // Check path if (request.ApiPath == null || request.ApiPath.Length < 3) { errorResponse = new ConnectorResponse(HttpStatusCode.MethodNotAllowed); return(null); } if (request.ApiPath.Length > 3) { errorResponse = new ConnectorResponse(HttpStatusCode.NotFound); return(null); } // Get resource ID field value (i.e. the string being used to locate the resource, e.g. name) string resourceIdFieldValue = request.ApiPath [2]; if (string.IsNullOrEmpty(resourceIdFieldValue)) { throw new Exception("Empty resource identity was received."); // assert false .. this should be blocked earlier. } // Resolve resource from string IResourceResolver resolver = _resourceResolverProvider.GetResolverForResourceMapping(mapping); ResourceResolverEntry resolveResult = resolver.ResolveResource(resourceIdFieldValue); if (resolveResult.Entity == null) { throw new WebArgumentNotFoundException( ); // Resource could not be located, so ensure a 404 is thrown } errorResponse = null; return(resolveResult.Entity); }
public FolderConfigurationNode(IFolder folder) : base(folder.Visible) { _folder = folder; _text = folder.Name; _resourceResolver = new ResourceResolver(typeof(ContainerNode).Assembly); }
public void Test_WithType_NullIdentity(string identity) { IResourceResolverProvider provider = GetResolverProvider( ); IResourceResolver resolver = provider.GetResolverForType(new EntityRef("test:employee").Id); Assert.Throws <ArgumentNullException>(() => resolver.ResolveResource(identity)); }
public static ConnectionCosts NewInstance(IResourceResolver resolver) { using (var resource = resolver.Resolve(ConnectionCostsFileName)) { return(Read(resource)); } }
/// <summary> /// Create a delegate that will copy a single relationship member from a reader to an entity. /// </summary> private MemberProcessor CreateRelationshipProcessor(ApiRelationshipMapping mapping, ReaderToEntityAdapterSettings settings) { // Get relationship definition Relationship relationship = mapping.MappedRelationship; Direction dir = mapping.MapRelationshipInReverse == true ? Direction.Reverse : Direction.Forward; if (relationship == null) { throw new ConnectorConfigException(string.Format(Messages.RelationshipMappingHasNoRelationship, mapping.Name)); } // Determine if mandatory bool mandatory = mapping.ApiMemberIsRequired == true || (dir == Direction.Forward && relationship.RelationshipIsMandatory == true) || (dir == Direction.Reverse && relationship.RevRelationshipIsMandatory == true); // Get a resolver IResourceResolver resourceResolver = _resourceResolverProvider.GetResolverForRelationshipMapping(mapping); // Get mapping name string memberName = mapping.Name; string relName = (dir == Direction.Forward ? relationship.ToName : relationship.FromName) ?? relationship.Name; string reportingName = GetReportingName(memberName, relName, settings); // Support lookup on other fields Field lookupField = mapping.MappedRelationshipLookupField; // Create callback that can read the target identifier(s) out of an object reader. bool isLookup = relationship.IsLookup(dir); Func <IObjectReader, string, IReadOnlyCollection <object> > identityReader; if (lookupField != null && lookupField.Is <IntField>( )) { if (isLookup) { identityReader = GetIntIdentityFromLookup; } else { identityReader = GetIntIdentitiesFromRelationship; } } else { if (isLookup) { identityReader = GetStringIdentityFromLookup; } else { identityReader = GetStringIdentitiesFromRelationship; } } // Create processor that copies value. Action <IEnumerable <ReaderEntityPair>, IImportReporter> processor = (readerEntityPairs, reporter) => RelationshipProcessorImpl(readerEntityPairs, identityReader, resourceResolver, memberName, relationship.Id, dir, mandatory, reporter, reportingName); return(new MemberProcessor(processor)); }
public PrintImageViewerComponent(IDesktopWindow desktopWindow) { _resourceResolver = new ApplicationThemeResourceResolver(this.GetType().Assembly); _shortcutManager = new PrintViewerShortcutManager(this); _setupHelper = new PrintViewerSetupHelper(); _setupHelper.SetImageViewer(this); PrintPresentationImagesHost.ImageViewerComponent = this; }
/// <summary>Creates a new artifact resolver that caches loaded resources in memory.</summary> /// <param name="source">Internal resolver from which artifacts are initially resolved on a cache miss.</param> /// <param name="cacheDuration">Default expiration time of a cache entry, in seconds.</param> public CachedResolver(IResourceResolver source, int cacheDuration = DEFAULT_CACHE_DURATION) { Source = source ?? throw Error.ArgumentNull(nameof(source)); CacheDuration = cacheDuration; _resourcesByUri = new Cache <Resource>(id => InternalResolveByUri(id), CacheDuration); _resourcesByCanonical = new Cache <Resource>(id => InternalResolveByCanonicalUri(id), CacheDuration); }
// [WMR 20170227] NEW // TODO: // - Analyze possible re-use by Validator // - Maybe move this method to another (public) class? /// <summary> /// Determines if the specified <see cref="StructureDefinition"/> is compatible with <paramref name="type"/>. /// Walks up the profile hierarchy by resolving base profiles from the current <see cref="IResourceResolver"/> instance. /// </summary> /// <returns><c>true</c> if the profile type is equal to or derived from the specified type, or <c>false</c> otherwise.</returns> /// <param name="resolver">A resource resolver instance.</param> /// <param name="type">A FHIR type.</param> /// <param name="profile">A StructureDefinition instance.</param> public static bool IsValidTypeProfile(this IResourceResolver resolver, FHIRDefinedType?type, StructureDefinition profile) { if (resolver == null) { throw new ArgumentNullException(nameof(resolver)); } return(isValidTypeProfile(resolver, new HashSet <string>(), type, profile)); }
/// <summary>Artifact resolver decorator to cache loaded resources in memory.</summary> /// <param name="source">ArtifactSource that will be used to get data from on a cache miss</param> /// <param name="cacheDuration">Duration before trying to refresh the cache, in seconds</param> public CachedResolver(IResourceResolver source, int cacheDuration = DEFAULT_CACHE_DURATION) { Source = source; CacheDuration = cacheDuration; _resourcesByUri = new Cache <Resource>(id => InternalResolveByUri(id), CacheDuration); _resourcesByCanonical = new Cache <Resource>(id => InternalResolveByCanonicalUri(id), CacheDuration); }
public ResolverThreadPool(int aMinThreads, int aMaxThreads, IResourceResolver aResolver, WebServer aServer) { m_minThreads = aMinThreads; m_maxThreads = aMaxThreads; resolver = aResolver; m_server = aServer; SetUp(); }
internal Item(ImageComparer imageComparer, bool reverse) { _resourceResolver = new ResourceResolver(imageComparer.GetType(), false); _description = imageComparer.Description; Name = imageComparer.Name; IsReverse = reverse; Comparer = imageComparer.GetComparer(reverse); }
/// <summary> /// Initializes a new instance of the <see cref="IwSerialise"/> class. /// </summary> /// <param name="stream"> /// The stream. /// </param> /// <param name="mode"> /// The mode. /// </param> /// <param name="classRegistry"> /// The class Registry. /// </param> /// <param name="resourceResolver"> /// The resource Resolver. /// </param> public IwSerialise( Stream stream, IwSerialiseMode mode, ClassRegistry classRegistry, IResourceResolver resourceResolver) { this.stream = stream; this.mode = mode; this.classRegistry = classRegistry; this.resourceResolver = resourceResolver; }
public CrudActionModelExtension(IResourceResolver resource) : base(true, true, true, resource) { string icon = "Icons.VerifyDicomPrinterToolSmall.png"; string displayName = "VerifyDicomPrinter"; base.AddAction(obj, displayName, icon); }
public void Test_ResolveMultiple_Null( ) { long typeId = new EntityType( ).Id; IResourceResolverProvider provider = GetResolverProvider( ); IResourceResolver resolver = provider.GetResolverForType(typeId); Assert.Throws <ArgumentNullException>(() => resolver.ResolveResources(null)); }
protected override IView CreateView(VirtualPath pathToView, IResourceResolver resolver) { var resource = resolver.GetResource(pathToView); if (resource == null || !resource.IsFile) { return null; } return new NustacheView(this, pathToView, resource, resolver); }
public IResourceResolver GetSource() { if (_source == null) { _source = GetResolver(); } return(_source); }
/// <summary> /// Gets a string identifier that uniquely identifies the resolved icon, suitable for dictionary keying purposes. /// </summary> /// <param name="iconSize">The size of the desired icon.</param> /// <param name="resourceResolver">The resource resolver with which to resolve the requested icon resource.</param> /// <returns>A string identifier that uniquely identifies the resolved icon.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="resourceResolver"/> is null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="resourceResolver"/> was unable to resolve the requested icon resource.</exception> public override string GetIconKey(IconSize iconSize, IResourceResolver resourceResolver) { string baseIconKey = base.GetIconKey(iconSize, resourceResolver); if (this.ShowMouseButtonIconOverlay) { return(string.Format("{0}:{1}", baseIconKey, _assignedButton)); } return(baseIconKey); }
/// <summary> /// Constructor. /// </summary> /// <param name="identifier">The unique identifier of the <see cref="AnnotationItem"/>.</param> /// <param name="displayName">The <see cref="AnnotationItem"/>'s display name.</param> /// <param name="label">The <see cref="AnnotationItem"/>'s label.</param> /// <param name="resourceResolver">The object that will resolve the display name and label parameters as the keys representing localized strings.</param> protected AnnotationItem(string identifier, string displayName, string label, IResourceResolver resourceResolver) { Platform.CheckForEmptyString(identifier, "identifier"); Platform.CheckForEmptyString(displayName, "displayName"); _standardResourceResolver = resourceResolver ?? new ResourceResolver(GetType(), false); _identifier = identifier; _displayName = displayName; _label = label ?? ""; }
public ServerDeserializationContext(ITypeResolver typeMapper, IResourceResolver resourceResolver, IResourceNode targetNode, IContainer container) { this.typeMapper = typeMapper; this.resourceResolver = resourceResolver; TargetNode = targetNode; this.container = container; }
/// <summary> /// Instantiates an active template from an embedded resource. /// </summary> /// <param name="resource"></param> /// <param name="resolver"></param> /// <returns></returns> public static ActiveTemplate FromEmbeddedResource(string resource, IResourceResolver resolver) { using (var stream = resolver.OpenResource(resource)) { using (var reader = new StreamReader(stream)) { return(new ActiveTemplate(reader)); } } }
/// <summary> /// Initializes the <see cref="ApplicationThemeResourceProviderBase"/>. /// </summary> /// <param name="id">The string that identifies the theme.</param> /// <param name="name">The name of the theme. May be a key to a string resource in an SR table in the same assembly as the implementing type.</param> /// <param name="description">A description of the theme. May be a key to a string resource in an SR table in the same assembly as the implementing type.</param> /// <param name="icon">A resource name to an icon for the theme in the same assembly as the implementing type. May be NULL or empty if no icon is available.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="id"/> is NULL or empty.</exception> protected ApplicationThemeResourceProviderBase(string id, string name, string description, string icon) { Platform.CheckForEmptyString(id, @"id"); _id = id; _name = !string.IsNullOrEmpty(name) ? name : id; _description = description ?? string.Empty; _icon = icon ?? string.Empty; _resourceResolver = new ResourceResolver(GetType(), false); _colors = new ApplicationThemeColors(this); }
private IAction CreateAction(TransferSyntax syntax, IResourceResolver resolver) { ClickAction action = new ClickAction(syntax.UidString, new ActionPath("explorerlocal-contextmenu/Change Transfer Syntax/" + syntax.ToString(), resolver), ClickActionFlags.None, resolver); action.SetClickHandler(delegate { ChangeToSyntax(syntax); }); action.Label = syntax.ToString(); return(action); }
/// <summary> /// Instantiates an active template from an embedded resource. /// </summary> /// <param name="resource"></param> /// <param name="resolver"></param> /// <returns></returns> public static ActiveTemplate FromEmbeddedResource(string resource, IResourceResolver resolver) { using (var stream = resolver.OpenResource(resource)) { using (var reader = new StreamReader(stream)) { return new ActiveTemplate(reader); } } }
/// <summary> /// Gets the XML schema source. /// </summary> /// <param name="xsdMoniker">The XSD moniker.</param> /// <param name="link">The link.</param> /// <returns></returns> public static string GetXmlSchemaSource(string xsdMoniker, IArtifactLink link) { Guard.ArgumentNotNullOrEmptyString(xsdMoniker, "xsdMoniker"); Guard.ArgumentNotNull(link, "link"); IResourceResolver resolver = (link as IResourceResolver) ?? new XmlSchemaResourceResolver(link); XmlSchemaElementMoniker uri = new XmlSchemaElementMoniker(xsdMoniker); return(uri.ElementName != null ? resolver.GetResourcePath(uri.XmlSchemaPath) : null); }
public DotLiquidView(VirtualPath path, IResource resource, IResourceResolver resolver) { _path = path; _resolver = resolver; using (var stream = resource.Open()) using (var reader = new StreamReader(stream)) { string tpl = reader.ReadToEnd(); _template = Template.Parse(tpl); } }
/// <summary> /// Constructor. /// </summary> /// <param name="name">The name of the page.</param> /// <param name="component">The <see cref="IApplicationComponent"/> to be hosted in this page.</param> /// <param name="title">The text to display on the title bar.</param> /// <param name="iconSet">The icon to display on the title bar.</param> /// <param name="fallbackResolver">Resource resolver to fall back on in case the default failed to find resources.</param> public StackTabPage(string name, IApplicationComponent component, string title, IconSet iconSet, IResourceResolver fallbackResolver) : base(name, component) { _title = title; _iconSet = iconSet; _resourceResolver = new ApplicationThemeResourceResolver(typeof(StackTabPage).Assembly, fallbackResolver); }
public NustacheView(NustacheViewEngine engine, VirtualPath path, IResource resource, IResourceResolver resolver) { _engine = engine; _path = path; _resolver = resolver; using (var stream = resource.Open()) using (var reader = new StreamReader(stream)) { Template = new Template(); Template.Load(reader); } }
private IAction CreateAction(TransferSyntax syntax, IResourceResolver resolver) { var action = new ClickAction(syntax.UidString, new ActionPath("dicomstudybrowser-contextmenu/Change Transfer Syntax/" + syntax.ToString(), resolver), ClickActionFlags.None, resolver) {Enabled = Enabled}; this.EnabledChanged += (sender, args) => action.Enabled = Enabled; action.SetClickHandler(() => ChangeToSyntax(syntax)); action.Label = syntax.ToString(); return action; }
public ServerSerializationContextProvider(IUriResolver uriResolver, IResourceResolver resourceResolver, NancyContext nancyContext) { if (uriResolver == null) throw new ArgumentNullException("uriResolver"); if (resourceResolver == null) throw new ArgumentNullException("resourceResolver"); if (nancyContext == null) throw new ArgumentNullException("nancyContext"); this.uriResolver = uriResolver; this.resourceResolver = resourceResolver; this.nancyContext = nancyContext; }
public override Image CreateIcon(IconSize iconSize, IResourceResolver resourceResolver) { var bitmap = new Bitmap(_dimensions.Width, _dimensions.Height); using(var g = System.Drawing.Graphics.FromImage(bitmap)) { g.FillRectangle(Brushes.White, 0, 0, _dimensions.Width - 1, _dimensions.Height - 1); g.DrawRectangle(Pens.DarkGray, 0, 0, _dimensions.Width - 1, _dimensions.Height - 1); g.FillRectangle(GetBrush(), 1, 1, Math.Min((int)(_dimensions.Width*_percent/100), _dimensions.Width - 2), _dimensions.Height - 2); } return bitmap; }
/// <summary> /// Creates an icon using the specified icon resource and resource resolver. /// </summary> /// <param name="iconSize">The size of the desired icon.</param> /// <param name="resourceResolver">The resource resolver with which to resolve the requested icon resource.</param> /// <returns>An <see cref="Image"/> constructed from the requested resource.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="resourceResolver"/> is null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="resourceResolver"/> was unable to resolve the requested icon resource.</exception> public override Image CreateIcon(IconSize iconSize, IResourceResolver resourceResolver) { var iconBase = base.CreateIcon(iconSize, resourceResolver); var iconOverlay = GetOverlayIcon(iconSize); if (iconOverlay != null) { using (var g = Graphics.FromImage(iconBase)) { g.DrawImageUnscaledAndClipped(iconOverlay, new Rectangle(Point.Empty, iconBase.Size)); } iconOverlay.Dispose(); } return iconBase; }
/// <summary> /// Constructor. /// </summary> /// <param name="actionID">The logical action ID.</param> /// <param name="path">The action path.</param> /// <param name="resourceResolver">A resource resolver that will be used to resolve icons associated with this action.</param> protected Action(string actionID, ActionPath path, IResourceResolver resourceResolver) { _actionID = actionID; _path = path; _resourceResolver = resourceResolver; // smart defaults _enabled = true; _visible = true; _available = true; _persistent = false; FormerActionIDs = new List<string>(); }
public IView GetView(VirtualPath pathToView, IResourceResolver resolver) { if (_settings.Debug) { return CreateView(pathToView, resolver); } IView result = null; string key = pathToView.Path; if (!_cache.TryGetValue(key, out result)) { result = CreateView(pathToView, resolver); _cache[key] = result; } return result; }
private AbstractAction(string id, string path, IResourceResolver resourceResolver) { Platform.CheckForEmptyString(id, "id"); Platform.CheckForEmptyString(path, "path"); _resourceResolver = resourceResolver; _actionId = id; _formerActionIds = new List<string>(); _path = new ActionPath(path, resourceResolver); _groupHint = new GroupHint(string.Empty); _label = string.Empty; _tooltip = string.Empty; _iconSet = null; _available = true; _permissible = false; }
/// <summary> /// Constructor that allows specifying which of Add, Edit, and Delete actions should appear. /// </summary> /// <param name="add"></param> /// <param name="edit"></param> /// <param name="delete"></param> /// <param name="fallBackResolver"></param> public CrudActionModel(bool add, bool edit, bool delete, IResourceResolver fallBackResolver) : base(new ApplicationThemeResourceResolver(typeof(CrudActionModel).Assembly, fallBackResolver)) { if (add) { this.AddAction(AddKey, SR.TitleAdd, IconAddResource); } if (edit) { this.AddAction(EditKey, SR.TitleEdit, IconEditResource); } if (delete) { this.AddAction(DeleteKey, SR.TitleDelete, IconDeleteResource); } }
public EmailService(EmailServiceParams serviceParams, IResourceResolver resourceResolver) { if (serviceParams.FromAddress.Clear() == null) { throw new Exception("From address cannot be null or empty"); } if (serviceParams.SmtpAddress.Clear() == null || serviceParams.SmtpPort == 0) { throw new Exception("Invalid SMTP server configuration"); } ServiceParams = serviceParams; From = ExtensionsLocal.GetMailAddress(serviceParams.FromAddress, serviceParams.FromDisplayName); Sender = ExtensionsLocal.GetMailAddress(serviceParams.SenderAddress, serviceParams.SenderDisplayName) ?? From; UseAuthentication = false; ResourceResolver = resourceResolver; }
public override Image CreateIcon(IconSize iconSize, IResourceResolver resourceResolver) { //TODO: make unsafe. Not enabling unsafe code just for this, though. var bitmap = (Bitmap) base.CreateIcon(iconSize, resourceResolver); for (int x = 0; x < bitmap.Width; ++x) { for (int y = 0; y < bitmap.Height; ++y) { var pixel = bitmap.GetPixel(x, y); int gray = (int) (pixel.R*0.3f + pixel.G*0.59F + pixel.B*0.11f); if (gray > 255) gray = 255; bitmap.SetPixel(x, y, Color.FromArgb(pixel.A, gray, gray, gray)); } } return bitmap; }
public ServerSerializationContextProvider(ITypeResolver typeMapper, IUriResolver uriResolver, IResourceResolver resourceResolver, IContainer container) { if (typeMapper == null) throw new ArgumentNullException(nameof(typeMapper)); if (uriResolver == null) throw new ArgumentNullException(nameof(uriResolver)); if (resourceResolver == null) throw new ArgumentNullException(nameof(resourceResolver)); if (container == null) throw new ArgumentNullException(nameof(container)); this.typeMapper = typeMapper; this.uriResolver = uriResolver; this.resourceResolver = resourceResolver; this.container = container; }
/// <summary> /// Constructs a controller that uses the 32-bit colour ARGB bitmap specified by the resource name and resource resolver. /// </summary> /// <param name="resourceName">The partially or fully qualified name of the resource to access.</param> /// <param name="resourceResolver">A resource resolver for the resource.</param> public FlashOverlayController(string resourceName, IResourceResolver resourceResolver) : this() { using (Bitmap bitmap = new Bitmap(resourceResolver.OpenResource(resourceName))) { BitmapData data = bitmap.LockBits(new Rectangle(Point.Empty, bitmap.Size), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); try { int length = data.Stride*data.Height; _pixelData = new byte[length]; _rows = data.Height; _columns = data.Width; Marshal.Copy(data.Scan0, _pixelData, 0, length); } finally { bitmap.UnlockBits(data); } } }
public ResourceInterceptorStub(IResourceResolver resolver) : base(resolver) { }
/// <summary> /// Gets the custom message localized according to the specified resource resolver. /// </summary> protected string GetLocalizedCustomMessage(IResourceResolver resourceResolver) { return string.IsNullOrEmpty(_message) ? null : resourceResolver.LocalizeString(_message); }
/// <summary> /// Gets a string identifier that uniquely identifies the resolved icon, suitable for dictionary keying purposes. /// </summary> /// <param name="iconSize">The size of the desired icon.</param> /// <param name="resourceResolver">The resource resolver with which to resolve the requested icon resource.</param> /// <returns>A string identifier that uniquely identifies the resolved icon.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="resourceResolver"/> is null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="resourceResolver"/> was unable to resolve the requested icon resource.</exception> public override string GetIconKey(IconSize iconSize, IResourceResolver resourceResolver) { string baseIconKey = base.GetIconKey(iconSize, resourceResolver); if (this.ShowMouseButtonIconOverlay) return string.Format("{0}:{1}", baseIconKey, _assignedButton); return baseIconKey; }
/// <summary> /// Factory method to create an <see cref="IValidationRule"/> based on this attribute. /// </summary> public IValidationRule CreateRule(PropertyInfo property, IResourceResolver resourceResolver) { PropertyGetter getter = CreatePropertyGetter(property); string customMessage = GetLocalizedCustomMessage(resourceResolver); return CreateRule(property, getter, customMessage); }
private AbstractAction(IAction concreteAction) { Platform.CheckForNullReference(concreteAction, "concreteAction"); Platform.CheckTrue(concreteAction.Persistent, "Action must be persistent."); _resourceResolver = concreteAction.ResourceResolver; _actionId = concreteAction.ActionID; _formerActionIds = new List<string>(concreteAction.FormerActionIDs); _path = new ActionPath(concreteAction.Path.ToString(), concreteAction.ResourceResolver); _groupHint = new GroupHint(concreteAction.GroupHint.Hint); _label = concreteAction.Label; _tooltip = concreteAction.Tooltip; _iconSet = concreteAction.IconSet; _available = concreteAction.Available; _permissible = concreteAction.Permissible; }
public MyArtifactLink(string itemPath, string itemName) { this.resolver = new AssemblyResourceResolver(); this.itemPath = itemPath; this.ItemName = itemName; if (!string.IsNullOrEmpty(itemPath) && !string.IsNullOrEmpty(itemName)) { Utility.SetData(this, new XmlSchemaElementMoniker(itemPath, this.ItemName).ToString(), XmlSchemaCodeGenerationStrategy.ElementDataKey); } }
public static AbstractAction Create(string id, string path, bool isClickAction, IResourceResolver resourceResolver) { if (isClickAction) return new AbstractClickAction(id, path, resourceResolver); return new AbstractAction(id, path, resourceResolver); }
public AbstractClickAction(string id, string path, IResourceResolver resourceResolver) : base(id, path, resourceResolver) { _keyStroke = XKeys.None; }