///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Share the image with another sprite /// </summary> /// /// <param name="spriteToCopy">The original sprite</param> /// <param name="newSprite">The sprite that will get the same image as the sprite that is being copied</param> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public bool CopyTexture(Impl.Sprite spriteToCopy, Impl.Sprite newSprite) { // Ignore null pointers if (spriteToCopy.texture == null) { newSprite.texture = null; return true; } // Loop all our textures to check if we already have this one foreach (var pair in m_ImageMap) { ImageMapData data = pair.Value; foreach (Impl.Texture texture in data.data) { // Check if the pointer points to our texture if (texture == spriteToCopy.texture) { // The texture is now used at multiple places ++(texture.users); newSprite.texture = spriteToCopy.texture; newSprite.sprite = new Sprite (spriteToCopy.sprite); return true; } } } Internal.Output("TGUI warning: Can't copy texture that wasn't loaded by TextureManager."); return false; }
public static string PrintStartMenuEntries( IEnumerable<string> entryPaths) { Impl impl = new Impl(); impl.PrintStartMenuEntries(entryPaths); return impl.Result; }
public static void Main (string[] args) { var i = new Impl(); i.Method(); var ii = (IInterface)i; ii.Method(); }
/// <summary> /// Creates a collector for a group. /// </summary> /// <param name="other">Parent collector</param> /// <param name="group">The field that starts the group</param> private TraceLoggingMetadataCollector( TraceLoggingMetadataCollector other, FieldMetadata group) { this.impl = other.impl; this.currentGroup = group; }
public static void Main(string[] args) { IIntf1 intf = new Impl(); IIntf2 intf2 = intf as IIntf2; if (intf2 != null) { string str = intf2.GetType(0); } }
/// <summary> /// Create a new <c>SingletonGlTask</c> that confines tasks to the /// given queue. /// </summary> /// <param name="taskQueue">The queue to which tasks will be confined</param> public SingletonGlTask(GlTaskQueue taskQueue) { if (taskQueue == null) { throw new NullReferenceException("taskQueue"); } this.impl = new Impl(taskQueue); }
public static string Render(string template, Impl.Lookup<string, string> dataLookup) { return Regex .Matches(template, @"\$[\w\.]+\$") .Cast<Match>() //.Select(x => x.Groups.Cast<Group>().Skip(1).First()) .Aggregate( template, (str, match) => str.Replace(match.Value, dataLookup.Get(match.Value))); }
internal static void Go(string fileName, Stream stream) { using (AssemblyHelper.SubscribeResolve()) using (var xunit = new XunitFrontController( AppDomainSupport.Denied, assemblyFileName: fileName, diagnosticMessageSink: new MessageVisitor(), shadowCopy: false)) using (var writer = new ClientWriter(stream)) using (var impl = new Impl(xunit, writer)) { xunit.Find(includeSourceInformation: false, messageSink: impl, discoveryOptions: TestFrameworkOptions.ForDiscovery()); impl.Finished.WaitOne(); writer.Write(TestDataKind.EndOfData); } }
public override void PreMethodCall(Interfaces.IApiMethodCall method, Impl.ApiContext context, System.Collections.Generic.IEnumerable<object> arguments) { //Store to cache try { if (!IsNeededToThrottle(context.RequestContext))//Local server requests { return; } //Try detect referer if it's from site call var cache = ServiceLocator.Current.GetInstance<ICacheManager>(); var callCount = cache[method + context.RequestContext.HttpContext.Request.UserHostAddress] as CallCount; if (callCount == null) { //This means it's not in cache cache.Add(method + context.RequestContext.HttpContext.Request.UserHostAddress, new CallCount(1), CacheItemPriority.Normal, null, Time); } else { if (callCount.AddCall() > MaxRate) { context.RequestContext.HttpContext.Response.AddHeader("Retry-After", ((int)TimeSpan.FromMilliseconds(_cooldown).TotalSeconds).ToString(CultureInfo.InvariantCulture)); context.RequestContext.HttpContext.Response.StatusCode = 503; context.RequestContext.HttpContext.Response.StatusDescription = "Limit reached"; _log.Warn("limiting requests for {0} to cd:{1}", method + context.RequestContext.HttpContext.Request.UserHostAddress, _cooldown); throw new SecurityException("Rate limit reached. Try again after " + _cooldown + " ms"); } } } catch (SecurityException e) { _log.Error(e,"limit requests"); throw;//Throw this exceptions } catch (Exception) { } }
public Class(string name, Impl impl) { this.name_ = name; this.impl = impl; }
protected virtual bool baseEquals(Impl.MdaMemberImpl p) { return parentMdaClass.Equals(p.GetParentMdaType()); }
public virtual Task AuthenticateAsServerAsync(X509Certificate serverCertificate) { return(Impl.AuthenticateAsServerAsync(serverCertificate)); }
/// <summary> /// Never called: the first <see cref="Apply(Impl.IProtoRouteConfigurationContext)"/> does not register this object /// since we have nothing more to do than adding the route. /// </summary> /// <param name="context">Enables context lookup and manipulation, exposes a <see cref="IActivityMonitor"/> to use.</param> protected internal override void Apply( Impl.IRouteConfigurationContext context ) { }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Loads a texture /// </summary> /// /// <param name="filename">Filename of the image to load</param> /// <param name="sprite">The sprite object to store the loaded image</param> /// <param name="rect">Load only this part of the image.</param> /// /// The second time you call this function with the same filename, the previously loaded image will be reused. /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void GetTexture(string filename, Impl.Sprite sprite, SFML.Graphics.IntRect rect = new SFML.Graphics.IntRect()) { // Look if we already had this image ImageMapData data; if (m_ImageMap.TryGetValue(filename, out data)) { // Loop all our textures to find the one containing the image foreach (Impl.Texture tex in data.data) { // Only reuse the texture when the exact same part of the image is used if ((tex.rect.Left == rect.Left) && (tex.rect.Top == rect.Top) && (tex.rect.Width == rect.Width) && (tex.rect.Height == rect.Height)) { // The texture is now used at multiple places ++(tex.users); // We already have the texture, so pass the data sprite.texture = tex; // Set the texture in the sprite sprite.sprite.Texture = tex.texture; return; } } } else // The image doesn't exist yet { data = new ImageMapData (); data.data = new List<Impl.Texture> (); m_ImageMap.Add (filename, data); } // Add new data to the list Impl.Texture texture = new Impl.Texture(); sprite.texture = texture; sprite.texture.image = data.image; sprite.texture.rect = rect; data.data.Add(texture); // Load the image if (Global.ResourceManager == null) { sprite.texture.image = new SFML.Graphics.Image (filename); } else { if (Global.ResourceManager.GetObject(filename) is byte[]) { byte[] raw = Global.ResourceManager.GetObject(filename) as byte[]; MemoryStream mem = new MemoryStream(raw); sprite.texture.image = new SFML.Graphics.Image(mem); } else if (Global.ResourceManager.GetObject(filename) is System.Drawing.Image) { System.Drawing.Image raw = Global.ResourceManager.GetObject(filename) as System.Drawing.Image; MemoryStream mem = new MemoryStream(); // Copy the image to the Stream raw.Save(mem, raw.RawFormat); // Copy stream into new memory stream - prevents an AccessViolationException mem = new MemoryStream(mem.ToArray()); sprite.texture.image = new SFML.Graphics.Image(mem); } } // Create a texture from the image if ((rect.Left == 0) && (rect.Top == 0) && (rect.Width == 0) && (rect.Height == 0)) sprite.texture.texture = new SFML.Graphics.Texture (sprite.texture.image); else sprite.texture.texture = new SFML.Graphics.Texture (sprite.texture.image, rect); // Set the texture in the sprite sprite.sprite.Texture = sprite.texture.texture; // Set the other members of the data sprite.texture.filename = filename; sprite.texture.users = 1; }
/// <summary> /// Lower bound for minimum support as a fraction or number of instances. /// </summary> public FPGrowth LowerBoundMinSupport(double v) { Impl.setLowerBoundMinSupport(v); return(this); }
/// <summary> /// The number of execution slots (threads) to use for constructing the /// ensemble. /// </summary> public Bagging NumExecutionSlots(int numSlots) { Impl.setNumExecutionSlots(numSlots); return(this); }
/// <summary> /// Minimum metric score. Consider only rules with scores higher than this /// value. /// </summary> public FPGrowth MinMetric(double v) { Impl.setMinMetric(v); return(this); }
/// <summary> /// Size of each bag, as a percentage of the training set size. /// </summary> public Bagging BagSizePercent(int newBagSizePercent) { Impl.setBagSizePercent(newBagSizePercent); return(this); }
/// <summary> /// Whether the out-of-bag error is calculated. /// </summary> public Bagging CalcOutOfBag(bool calcOutOfBag) { Impl.setCalcOutOfBag(calcOutOfBag); return(this); }
public Bagging(Runtime rt) : base(rt, new weka.classifiers.meta.Bagging()) { Impl.setSeed(Runtime.GlobalRandomSeed); }
public Data(Impl impl, bool takeWrite, IDisposable nest) { this.impl = impl; ownsWrite = takeWrite; nested = nest; }
/// <summary> /// A constant option. Ranker is only capable of generating attribute /// rankings. /// </summary> public Ranker GenerateRanking(bool doRank) { Impl.setGenerateRanking(doRank); return(this); }
/// <summary> /// Specify the number of attributes to retain. The default value (-1) /// indicates that all attributes are to be retained. Use either this option or a /// threshold to reduce the attribute set. /// </summary> public Ranker NumToSelect(int n) { Impl.setNumToSelect(n); return(this); }
/// <summary> /// The number of iterations to be performed. /// </summary> public Bagging NumIterations(int numIterations) { Impl.setNumIterations(numIterations); return(this); }
/// <summary> /// Calls <see cref="Impl.IRouteConfigurationContext.AddDeclaredAction"/> to add the <see cref="DeclaredName"/> with this name. /// </summary> /// <param name="context">Enables context lookup and manipulation, exposes a <see cref="IActivityMonitor"/> to use.</param> protected internal override void Apply( Impl.IRouteConfigurationContext context ) { context.AddDeclaredAction( _name, _declaredName, false ); }
/// <summary> /// The base classifier to be used. /// </summary> public Bagging Classifier(PicNetML.Clss.IBaseClassifier <weka.classifiers.Classifier> newClassifier) { Impl.setClassifier(newClassifier.Impl); return(this); }
/// <summary> /// The number of rules to output /// </summary> public FPGrowth NumRulesToFind(int numR) { Impl.setNumRulesToFind(numR); return(this); }
/// <summary> /// If set to true, classifier may output additional info to the console. /// </summary> public Bagging Debug(bool debug) { Impl.setDebug(debug); return(this); }
/// <summary> /// The maximum number of items to include in frequent item sets. -1 means no /// limit. /// </summary> public FPGrowth MaxNumberOfItems(int max) { Impl.setMaxNumberOfItems(max); return(this); }
public virtual void AuthenticateAsClient(string targetHost) { Impl.AuthenticateAsClient(targetHost); }
public virtual Task AuthenticateAsClientAsync(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation) { return(Impl.AuthenticateAsClientAsync(targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation)); }
public virtual void AuthenticateAsClient(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation) { Impl.AuthenticateAsClient(targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation); }
/// <summary> /// Applies the configuration (first step) by calling <see cref="Impl.IProtoRouteConfigurationContext.AddRoute"/>. /// </summary> /// <param name="protoContext">Enables context lookup and manipulation, exposes a <see cref="IActivityMonitor"/> to use.</param> protected internal override void Apply( Impl.IProtoRouteConfigurationContext protoContext ) { protoContext.AddRoute( _route ); }
// [HostProtection (ExternalThreading=true)] public virtual IAsyncResult BeginAuthenticateAsClient(string targetHost, AsyncCallback asyncCallback, object asyncState) { return(Impl.BeginAuthenticateAsClient(targetHost, asyncCallback, asyncState)); }
public Instance(int id, Impl impl) { this.id_ = id; this.impl = impl; }
/// <summary> /// Specify a set of attributes to ignore. When generating the ranking, /// Ranker will not evaluate the attributes in this list. This is specified as a /// comma seperated list off attribute indexes starting at 1. It can include /// ranges. Eg. 1,2,5-9,17. /// </summary> public Ranker StartSet(string startSet) { Impl.setStartSet(startSet); return(this); }
/// <summary> /// forceBuggyRemove is not used here since this client is not lockable. /// </summary> void IActivityMonitorBoundClient.SetMonitor( Impl.IActivityMonitorImpl source, bool forceBuggyRemove ) { if( source != null && _source != null ) throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException( this ); if( _source != null ) { _bridgeTarget.RemoveCallback( this ); // Unregistering. for( int i = 0; i < _openedGroups.Count; ++i ) { if( _openedGroups[i] ) { _targetMonitor.CloseGroup( new ActivityLogGroupConclusion( ActivityMonitorResources.ClosedByBridgeRemoved, TagBridgePrematureClose ) ); } } _openedGroups.Clear(); } else { _bridgeTarget.AddCallback( this ); _targetActualFilter = _bridgeTarget.TargetFinalFilter; if( _pullTargetTopicAndAutoTagsFromTarget ) { source.InitializeTopicAndAutoTags( this._targetMonitor.Topic, _targetMonitor.AutoTags ); } } _source = source; Interlocked.MemoryBarrier(); }
public static void AttachCenteringBehavior(this Control control, Control centerAboveControl) { var impl = new Impl(control, centerAboveControl); impl.Attach(); }
// [HostProtection (ExternalThreading=true)] public virtual IAsyncResult BeginAuthenticateAsClient(string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState) { return(Impl.BeginAuthenticateAsClient(targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState)); }
/// <summary> /// Set threshold by which attributes can be discarded. Default value results /// in no attributes being discarded. Use either this option or numToSelect to /// reduce the attribute set. /// </summary> public Ranker Threshold(double threshold) { Impl.setThreshold(threshold); return(this); }
/// <summary> /// Note: description is for debugging purposes only. /// </summary> public OleCommandTarget(string description, ICommandTarget commandTarget) { _description = description; _commandTarget = commandTarget; _impl = new Impl(this); }
public virtual void EndAuthenticateAsClient(IAsyncResult asyncResult) { Impl.EndAuthenticateAsClient(asyncResult); }
public virtual void AuthenticateAsServer(X509Certificate serverCertificate) { Impl.AuthenticateAsServer(serverCertificate); }
public virtual void AuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation) { Impl.AuthenticateAsServer(serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Load the texture that is described by the value /// </summary> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void ReadTexture(int i, string folder, Impl.Sprite sprite) { // The shortest string needs three character if (Values [i].Length < 2) throw new Exception ("The value of property " + Properties[i] + " in section " + m_Section + " doesn't contain a filename between quotes."); // The first character has to be a quote if (Values [i] [0] != '"') throw new Exception ("The value of property " + Properties[i] + " in section " + m_Section + " didn't begin with a double quote."); // There has to be another quote int index = Values [i].IndexOf ('"', 1); if (index == -1) throw new Exception ("The value of property " + Properties[i] + " in section " + m_Section + " didn't contain an ending quote."); // There can't be more than two quotes int unexistingIndex = Values [i].IndexOf ('"', index + 1); if (unexistingIndex != -1) throw new Exception ("The value of property " + Properties[i] + " in section " + m_Section + " contains more than two quotes."); // Check if there is still something behind the quotes IntRect rect = new IntRect (); if (Values [i].Length > index + 1) { // Drop the brackets if (Values [i] [index + 1] == '(' && Values [i] [Values [i].Length-1] == ')') { string rectStr = Values [i].Substring (index + 2, Values [i].Length - index - 3); // Extract the rect string[] rectComponents = rectStr.Split (','); // A rectangle has 4 components (left, top, right, height) if (rectComponents.Length == 4) { rect = new IntRect (Convert.ToInt32(rectComponents [0]), Convert.ToInt32(rectComponents [1]), Convert.ToInt32(rectComponents [2]), Convert.ToInt32(rectComponents [3])); } else throw new Exception ("The value of property " + Properties[i] + " in section " + m_Section + " contains brackets after the filename, but without four components split by commas."); } else // The string doesn't begin and end with a bracket throw new Exception ("The value of property " + Properties[i] + " in section " + m_Section + " contains contains characters after the filename of which the first and last are not brackets."); } // Try to load the strings between the quotes Global.TextureManager.GetTexture (folder + Values[i].Substring(1, index - 1), sprite, rect); }
/// <summary> /// Creates a root-level collector. /// </summary> internal TraceLoggingMetadataCollector() { this.impl = new Impl(); }
protected Parameter(int size, Impl impl, Constraint constraint) { impl_ = impl; params_ = new Vector(size); constraint_ = constraint; }
public RiakException(Impl.ProtoBuf.Response.Error error) : base( error.Message.FromBytes() ) { ErrorCode = error.Code; }
private void OnCompilationStart(CompilationStartAnalysisContext compilationContext) { var additionalFiles = compilationContext.Options.AdditionalFiles; if (!_extraAdditionalFiles.IsDefaultOrEmpty) { additionalFiles = additionalFiles.AddRange(_extraAdditionalFiles); } ApiData shippedData; ApiData unshippedData; if (!TryGetApiData(additionalFiles, compilationContext.CancellationToken, out shippedData, out unshippedData)) { return; } List<Diagnostic> errors; if (!ValidateApiFiles(shippedData, unshippedData, out errors)) { compilationContext.RegisterCompilationEndAction(context => { foreach (var cur in errors) { context.ReportDiagnostic(cur); } }); return; } var impl = new Impl(shippedData, unshippedData); compilationContext.RegisterSymbolAction( impl.OnSymbolAction, SymbolKind.NamedType, SymbolKind.Event, SymbolKind.Field, SymbolKind.Method); compilationContext.RegisterCompilationEndAction(impl.OnCompilationEnd); }
void IActivityMonitorBoundClient.SetMonitor( Impl.IActivityMonitorImpl source, bool forceBuggyRemove ) { if( !forceBuggyRemove ) { if( source != null && _source != null ) throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException( this ); } _openGroups.Clear(); _source = source; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Removes the sprite /// </summary> /// /// <param name="sprite">The sprite that should be removed</param> /// /// When no other sprite is using the same image then the image will be removed from memory. /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void RemoveTexture(Impl.Sprite sprite) { // Ignore already removed sprites if (sprite.texture == null) return; // Loop all our textures to check which one it is foreach (var pair in m_ImageMap) { ImageMapData data = pair.Value; foreach (Impl.Texture texture in data.data) { // Check if the pointer points to our texture if (texture == sprite.texture) { // If this was the only place where the texture is used then delete it if (--(texture.users) == 0) { int usage = 0; foreach (Impl.Texture t in data.data) { if (t.image == data.image) usage++; } // Remove the texture from the list, or even the whole image if it isn't used anywhere else if (usage == 1) m_ImageMap.Remove(pair.Key); else data.data.Remove(texture); } // The pointer is now useless sprite.texture = null; return; } } } // Internal.Output("TGUI warning: Can't remove texture that wasn't loaded by TextureManager."); return; }
// [HostProtection (ExternalThreading=true)] public virtual Task AuthenticateAsClientAsync(string targetHost) { return(Impl.AuthenticateAsClientAsync(targetHost)); }
// [HostProtection (ExternalThreading=true)] public virtual IAsyncResult BeginAuthenticateAsServer(X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState) { return(Impl.BeginAuthenticateAsServer(serverCertificate, asyncCallback, asyncState)); }
/// <summary> /// Iteratively decrease support by this factor. Reduces support until min /// support is reached or required number of rules has been generated. /// </summary> public FPGrowth Delta(double v) { Impl.setDelta(v); return(this); }
public virtual IAsyncResult BeginAuthenticateAsServer(X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState) { return(Impl.BeginAuthenticateAsServer(serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState)); }
public virtual void EndAuthenticateAsServer(IAsyncResult asyncResult) { Impl.EndAuthenticateAsServer(asyncResult); }
public void Test3() { Check.ThatCode(() => { Impl impl = new Impl { BaseProperty = "Any1", ImplProperty = "Any" }; Impl impl2 = new Impl { BaseProperty = "Any2", ImplProperty = "Any" }; Check.That(impl).HasFieldsWithSameValues(impl2); }) .ThrowsAny(); }
/// <summary> /// Creates a XIL-S code transformation which limits the number of simultaneous constant-loading instructions. /// </summary> /// <remarks> /// This kind of transformation is useful for horizontally microcoded architectures where each constant needs to be stored /// in program ROM. The more constant-loading instructions run in parallel, the wider a row inside program ROM. Therefore, /// it makes sense to limit that kind of parallelism. /// </remarks> /// <param name="max">maximum admissible number of simultaneous constant-loading instructions</param> /// <returns>resulting transformation</returns> public static IXILSRewriter LimitConstantLoads(int max) { var pl = new Impl(); pl.AddParLimit(InstructionCodes.LdConst, max); return pl; }