|
I tried doing "http://192.x.x.x\network_(a).wmv"
However it doesn't load and plays the video
Again , the coding on my C# event handler is currently
Video.Source = new Uri(@".\Videos\Network\network_(a).wmv", UriKind.Relative);
Video.Play();
which loads the video from my video folder
|
|
|
|
|
Ok, did you change the UriKind to Absolute?
What is the Video object. Can you tell us the name of the video class and it's full namespace?
Rob
Architecture is extensible, code is minimal.
|
|
|
|
|
I want to extract numbers from a string [Shipment ID]
"string sentence = "Shipment ID: 212857,1212,Invoice No: 1202127, 25-JAN-10 (PDF) "
so the extracted numbers will be 212857 and 1212
I have tried with Regex but not getting the desired result.
Can anyone help
String data = Regex.Match(sentence , @"ID:\d{10}", RegexOptions.IgnoreCase).Value;
string[] digits = Regex.Split(sentence, @"\D+");
|
|
|
|
|
string pattern = @"\b[0-9]+\b";
string input = "Shipment ID: 212857,1212,Invoice No: 1202127, 25-JAN-10 (PDF)";
foreach (Match item in Regex.Matches(input, pattern))
Console.WriteLine(item);
Console.ReadKey();
Try this...
|
|
|
|
|
Only trouble is that also picks up the Invoice, the day of the month, the year...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
You should have posted this to the Regular Expressions forum[^], but try using named groups and processing the line more carefully:
string s = "Shipment ID: 212857,1212,Invoice No: 1202127, 25-JAN-10 (PDF)";
Match m = Regex.Match(s, @"ID:\s(?<SID>\d+),(?<SID2>\d+)");
Console.WriteLine(m.Groups["SID"].Value + "," + m.Groups["SID2"].Value);
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
But this will hard code the "ID" string.
|
|
|
|
|
Precisely. It targets the information the OP requested, rather than returning spurious information that then needs further processing to remove or ignore.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Forget the Regex and go for somethying like...
sentence = sentence.Replace("Shipment ID: ", "");
sentence = sentence.Substring(0, sentence.IndexOf("Invoice No:"));
string[] numbers = sentence.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries);
return 5;
|
|
|
|
|
Hi,
I have another javascript on a poppup window in asp.net to return the value back to the parent .
but it gives me an error: opener.document is null or not an object.
opener.document.getElementById("TextBox1").value = "hello";
I even ammended the main parent javascript so as to open this popup as a return value back to a variable.
any help will be highly appreciated.
Thanks
|
|
|
|
|
You were told in your previous post to try Javascript forum. It seems that wasn't clear to you. This is wrong forum. Post your question in Javascript forum or Q & A with proper tags.
|
|
|
|
|
oh.. din't read that.. am deleting this now.
|
|
|
|
|
|
yes...
but i've changed this question to javascript forum..
thanks
|
|
|
|
|
See the code below, specifically the following line:
// ??? How do I access the TestProperty of oTest1, and instance of the Test1 class, which is a subclass of TestBase ???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace TreadStackMemberAccess
{
public class Program
{
static void Main(string[] args)
{
Test1 oTest1 = new Test1();
oTest1.Method1();
}
}
public class TestBase
{
public string TestProperty { get; set; }
}
public class Test1 : TestBase
{
public void Method1()
{
TestProperty = "Test1";
Test2 oTest2 = new Test2();
oTest2.Method2();
}
}
public class Test2
{
public void Method2()
{
Test3 oTest3 = new Test3();
oTest3.Method3();
}
}
public class Test3
{
public void Method3()
{
System.Diagnostics.StackFrame[] oStackFrames = (new System.Diagnostics.StackTrace()).GetFrames();
for (int i = 0; i < oStackFrames.Length; i++)
{
System.Diagnostics.StackFrame oStackFrame = (System.Diagnostics.StackFrame)(oStackFrames[i]);
if (oStackFrame.GetMethod().ReflectedType.IsSubclassOf(typeof(TestBase)))
{
}
}
}
}
}
|
|
|
|
|
I am not too sure if StackFrame will give you the access to the instance. The list of properties and methods in the class clearly should that it is not straightforward. I do not think it will be possible even via reflection.
BTW, why do want to know which instance called the method? You may get replies with alternate approach.
|
|
|
|
|
Thanks for the reply.
I actually don't care which instance called the method, I just need to know it is a subclass of TestBase. I only called out the specific instance information here for clarity.
|
|
|
|
|
So you already have that code then isn't it? Although it can be done without StackFrame as well.
|
|
|
|
|
I have the code in place to use stack frames to determine if the caller, at some point in the stack frame, was a subclass of TestBase...but, I've failed to figure out how to access the object's TestProperty value.
|
|
|
|
|
That's what I have replied. I am not sure if it is possible at all. It tells the type but never gives you access to that very instance. If you just want to access that property information, this should help:
Type t = oStackFrame.GetMethod().ReflectedType;
PropertyInfo property = t.GetProperty("property name here");
|
|
|
|
|
I got to the point where I can create a PropetyInfo instance, but I cannot figure out how to use the PropertyInfo instance get the TestProperty string value.
Can you continue the code you sent to show accessing the actual property value (instead of just creating a PropertyInfo instance)?
Thanks
|
|
|
|
|
It's simple.
propertyInfo.GetValue(objectInstance, null);
|
|
|
|
|
I got that far too
But, I could never figure out how to access the object instance - i.e. what do you set the objectInstance to?
|
|
|
|
|
You cannot access that. I had told that in my first reply itself.
There is no way you can access oTest1 in Method2 through this approach.
|
|
|
|
|
You can't. The stack frame is not the object instance.
|
|
|
|