|
lol...that is an amusing theory.
|
|
|
|
|
Sir, plz send link to Downloads tab.
|
|
|
|
|
ts ts Dave, you shouldn't shout to a blind person.
|
|
|
|
|
You mean they can't hear you any better when you scream at them?
|
|
|
|
|
Only hearing impaired people may hear and understand you any better when you scream at them.
Blind people in general tend to have developed better hearing, the hearing sense trying to compensate for a visual impairment.
|
|
|
|
|
And foreigners, apparently.
They all know English or American, just you have to shout to get them to admit it!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
="1.0"
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime maxRequestLength="2097150"
useFullyQualifiedRedirectUrl="true"
executionTimeout="14400" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128"
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
|
|
|
|
|
From where?
Name and IP address are both representing same thing. I cannot really understand why would you want to do that.
"You'd have to be a floating database guru clad in a white toga and ghandi level of sereneness to fix this goddamn clusterfuck.", BruceN[ ^]
|
|
|
|
|
I have a Buffer that is flushed/renewed based on the Buffer size. The events:
var KeyDown = Observable.FromEventPattern<KeyEventArgs>(this, "PreviewKeyDown");
var KeyUp = Observable.FromEventPattern<KeyEventArgs>(this, "PreviewKeyUp");
Where the buffer is done like the following:
KeyDown.Buffer(() => Observable.Merge(KeyDown.Where(evt=>evt.EventArgs.IsRepeat==false).Buffer(2), KeyDown.Where(evt=>evt.EventArgs.IsRepeat==false).Buffer(3)));
The Buffer(3) never happens, and this looks correct, but If I change the code slightly:
KeyDown.Buffer(() => Observable.Merge(KeyDown.Where(evt=>evt.EventArgs.IsRepeat==false).Buffer(2), KeyUp.Where(evt=>evt.EventArgs.Key==Key.LeftCtrl).Buffer(1)));
The Buffer(2) just hits once, I don't understand why the Buffer(2) dosent hit several times, if I hit 4 keystrokes for instance.
|
|
|
|
|
I'm really going to have to try this out as this looks unnecessarily complicated to me. I do have to wonder what you're trying to achieve with the KeyDown.Buffer as you aren't supplying a buffer value for this. Primarily I would have to see what you were doing when you actually observed the sequence as I don't see the actual observation happening here.
This space for rent
|
|
|
|
|
To be honest I don't consider this to have any practical use, it is just that I don't seem to get a clear picture of when the buffer, inside the buffer is cleared i.a.:
MyStream.Buffer(()=>Observable.Merge(MyStream.Buffer(9),MyStream.Buffer(7))
It seems as all the buffers are connected, flushed at the same time, so the highest Buffer is never reached.
|
|
|
|
|
EDIT this was an accidental post, problem is fixed!!
I am running / fixing all my unit test for my home made utilities.
I have a weak event build method which look like that
public static PropertyChangedEventHandler AddWeakHandler<T>(this INotifyPropertyChanged model, T target, Action<T, PropertyChangedEventArgs> action)
where T : class
{
var weakRef = new WeakReference(target);
PropertyChangedEventHandler handler = null;
handler = new PropertyChangedEventHandler(
(s, e) =>
{
var strongRef = weakRef.Target as T;
if (strongRef != null)
{
action(strongRef, e);
}
else
{
model.PropertyChanged -= handler;
handler = null;
}
});
model.PropertyChanged += handler;
return handler;
}
it is used like that (to show that there are no captured variable in the lambda expression
public object Source
{
get { return mSource; }
set
{
var p = Property;
if (p == null)
value = null;
if (value == mSource)
return;
if (Source is INotifyPropertyChanged)
{
((INotifyPropertyChanged)Source).PropertyChanged -= previous;
previous = null;
}
mSource = value;
if (Source is INotifyPropertyChanged)
{
previous = WeakEvents.AddWeakHandler((INotifyPropertyChanged)Source, this, (x, arg) => x.OnSourcePropertyChanged(Source, arg));
}
if (p != null)
{
p.OnPropertyChanged();
}
}
}
I have a simple (XUnit) test looking like that
[Fact]
public void CheckPropertyPathIsWeakEvent()
{
var m = new ModelForPathCheck();
int n = 0;
Action<string> onChanged = s => n++;
TriggerWeakEvent(m, onChanged, 2);
GC.Collect();
m.Name = "mooo";
Assert.Equal(2, n);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
static void TriggerWeakEvent(ModelForPathCheck path, Action<string> onNameChanged, int nTimeChanged)
{
var pv = PropertyPath.Link(path, x => x.Name, onNameChanged);
for (int i = 0; i < nTimeChanged; i++)
path.Name = i.ToString();
GC.KeepAlive(pv);
}
sadly... the count is always 3 instead of 2 (in the assert)
any idea what might have gone wrong?!
modified 5-Mar-16 21:44pm.
|
|
|
|
|
I'm confused. The notification is raised (and usually collected) at the class level. There should be no point in changing the INotifyPreoprtyChanged, but whatever floats your boat I guess.
|
|
|
|
|
My bad... I should not have posted that!!!
Garbage collection worked fine (as test finalizer indicated) but the event was spuriously triggered in the PropertyPath constructor! all solved! ^^
|
|
|
|
|
on a side note I didn't understand your confusion!
|
|
|
|
|
full source code, for your understanding!
public class PropertyPath<TProp> : PropertyPath
{
internal PropertyPath()
{
}
public new TProp Value
{
get
{
var v = base.Value;
if (v is TProp)
return (TProp)v;
return default(TProp);
}
set { base.Value = value; }
}
}
public class PropertyPath : ModelBase
{
public static PropertyPath<TP> Link<T, TP>(T root, Expression<Func<T, TP>> e, Action<TP> onValueChanged)
{
var pv = new PropertyPath<TP>();
pv.PropertyChanged += (o, eargs) =>
{
if (string.IsNullOrEmpty(eargs.PropertyName) || eargs.PropertyName == "Value")
{
onValueChanged(pv.Value);
}
};
pv.Initialize(e);
pv.Root = root;
return pv;
}
public static PropertyPath<TP> Link<TP>(Expression<Func<TP>> e, Action<TP> onValueChanged)
{
var pv = new PropertyPath<TP>();
pv.PropertyChanged += (o, eargs) =>
{
if (string.IsNullOrEmpty(eargs.PropertyName) || eargs.PropertyName == "Value")
{
onValueChanged(pv.Value);
}
};
pv.Initialize(e);
return pv;
}
public static PropertyPath<TP> Create<T, TP>(T root, Expression<Func<T, TP>> e)
{
var pv = new PropertyPath<TP>();
pv.Initialize(e);
pv.Root = root;
return pv;
}
public static PropertyPath<TP> Create<TP>(Expression<Func<TP>> e)
{
var pv = new PropertyPath<TP>();
pv.Initialize(e);
return pv;
}
internal PropertyPath()
{
}
void Initialize(LambdaExpression e)
{
object root;
var path = ReflectionEx.GetLambdaPath(e, out root);
if (path.Length == 0)
throw new ArgumentException();
pvalues = new PropertyValue[path.Length];
roValues = new ReadOnlyCollection<PropertyValue>(pvalues);
for (int i = 0; i < path.Length; i++)
{
var meIndex = i;
var pv = new PropertyValue(this, i, path[i]);
pvalues[i] = pv;
}
Root = root;
}
PropertyValue[] pvalues;
ReadOnlyCollection<PropertyValue> roValues;
public object Root
{
get { return root; }
set
{
if (Equals(Root, value))
return;
if (value != null && !pvalues[0].Member.DeclaringType.IsInstanceOf(value))
throw new InvalidCastException();
root = value;
pvalues[0].Object = root;
OnPropertyChanged();
}
}
object root;
public object Value
{
get { return pvalues[pvalues.Length - 1].Value; }
set { pvalues[pvalues.Length - 1].Value = value; }
}
public ReadOnlyCollection<PropertyValue> Elements { get { return roValues; } }
#region class PropertyValue
public class PropertyValue
{
internal PropertyValue(PropertyPath path, int index, MemberInfo member)
{
this.index = index;
Path = path;
Member = member;
}
int index;
public PropertyPath Path { get; private set; }
public MemberInfo Member { get; private set; }
public string Name { get { return Member.Name; } }
void SetMemberValue(object value)
{
if (Member is FieldInfo)
((FieldInfo)Member).SetValue(Object, value);
else if (Member is PropertyInfo)
((PropertyInfo)Member).SetValue(Object, value);
else
throw new InvalidOperationException();
}
object GetMemberValue()
{
if (Member is FieldInfo)
return ((FieldInfo)Member).GetValue(Object);
else if (Member is PropertyInfo)
return ((PropertyInfo)Member).GetValue(Object, null);
else
throw new InvalidOperationException();
}
public object Object
{
get { return mObject; }
internal set
{
if (value == mObject)
return;
if (mObject is INotifyPropertyChanged)
{
((INotifyPropertyChanged)mObject).PropertyChanged -= watcher;
}
mObject = value;
UpdateValue();
if (mObject is INotifyPropertyChanged)
{
watcher = WeakEvents.AddWeakHandler((INotifyPropertyChanged)mObject, this, (x, args) =>
{
if (args.PropertyName == null || args.PropertyName == x.Name)
x.UpdateValue();
});
}
}
}
object mObject;
PropertyChangedEventHandler watcher;
void UpdateValue()
{
var v = GetMemberValue();
if (Equals(v, Value))
return;
mValue = v;
OnValueChanged();
}
public object Value
{
get { return mValue; }
internal set
{
if (Equals(value, Value))
return;
SetMemberValue(value);
mValue = value;
OnValueChanged();
}
}
object mValue;
void OnValueChanged()
{
if (index == Path.Elements.Count - 1)
Path.OnPropertyChanged(nameof(Value));
else
Path.Elements[index + 1].Object = Value;
ValueChanged?.Invoke(this, EventArgs.Empty);
}
public event EventHandler ValueChanged;
}
#endregion
}
|
|
|
|
|
What you might have misread... the class is NOT registering a listener to its own change!
It's listening to change in the source object (!= this!) !!
|
|
|
|
|
No worries, I just saw the little code snippet and I don't know what your requirements are. My knee jerk reaction was that there has to be a simpler way of doing this.
Btw, there is a standard WeakEventManager inside .NET (first intoduced in 3.0)
WeakEventManager Class (System.Windows)[^]
|
|
|
|
|
It's not supported by the PCL!!!
But no worries, it's simple enough to implement that I made my own PCL version!
|
|
|
|
|
|
|
How to connect MySQL to datagridview, project in Visual Studio 2015 with C#.
|
|
|
|
|
You need to learn to do the minimum research [^]before asking a question.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
There are many things wrong with this question:
- The question implies you have no experience at all in software development. One of the most important rules is "seperation of concerns". Basically you divide a problem in smaller problems and solve them one by one. In this case, connecting database records directly to a grid is just not done.
- The question implies you have not done any research on the subject, which also implies you're taking the easy road.
- You have not even read this forum's guidelines[^]
To answer your question and hoping you will first start reading a book or getting some classes before diving in database development:
1.
You need to create some sort of DAL (DataAccess Layer) that will connect to the database and is able to perform several actions (CRUD eg, look that up in google). In your case getting data back into the application. One of my articles explains this and has sample code.
Building a Framework - Part I (DAL)[^]
2.
Once you have the data you should not connect it to the grid directly, rather create underlying objects that are useful. These objects can do little (just copy data to the object) or a lot (combining data, checking, reformatting, ...). That is done in the BLL (Business Logic Layer).
3.
Finally, when you have done that and you have a desirable list of objects you can bind that to the grid in the GUI (Graphical User Interface).
This is about the most basic (3-tier) model you can do, there are many more additional models/layers, design patterns you can add/do.
Seriously, if your intent is to go for a professional career, start out with the "hello world" program and build up from there.
hope this helps.
|
|
|
|
|
1. Make SQL connection via code, use a reader
2. Populate a collection of objects (classes) with the details you want on the grid
3. Bind the collection to the grid
<tag>I have no tag
|
|
|
|