Similar Threads:
1.Difficult Question: Assigning string default values to class/struct ConfigurationProperty attributes
Hello Group,
I posted this in microsoft.public.dotnet.general about a week ago but
haven't had any replies....
The Visual Studio 2005 help for
ConfigurationPropertyAttribute.DefaultValue
provides the following sample:
/////////////////////////////////////////////////
[ConfigurationProperty("maxIdleTime",
DefaultValue = "0:10:0",
IsRequired = false)]
[TimeSpanValidator(MinValueString = "0:0:30",
MaxValueString = "5:00:0",
ExcludeRange = false)]
public TimeSpan MaxIdleTime
{
get
{
return (TimeSpan)this["maxIdleTime"];
}
set
{
this["maxIdleTime"] = value;
}
}
/////////////////////////////////////////////////
What I am wondering is how does the DefaultValue parameter from the
sample code work, i.e.:
>> DefaultValue = "0:10:0",
TimeSpan does not have a constructor or "=" operator that takes a
string parameter, and TimeSpan does not implement IConvertible. For
example, the following does not complile:
>> TimeSpan ts = "0:10:0";
TimeSpan does have a Parse() method that takes a string parameter,
i.e.
>> public static TimeSpan Parse(string s);
but I do not see how it is associated in the above sample code.
So again how does this code from the sample work in regards to
assigning a string
DefaultValue to a TimeSpan value? i.e.:
>> DefaultValue = "0:10:0",
My guess is TimeSpan.Parse() is somehow being called, but where?
TIA,
Keller Beyer
XXXX@XXXXX.COM
2.Mashaling a VB6 Array Of Struct to C# Array of Struct
Hello,
Is it possible to convert a VB6 Array of Struct
to
a C# Array Of Struct ?
The test context is a C# application calling a VB6 ActiveX DLL Function
using UDT (User Defined Type) and array of UDT.
***************************************
Example : (VB6AX is an ActiveX VB6 DLL)
***************************************
(VB6 Side)
Type VB6Struct
d1 as double
d2 as double
l1 as long
End Type
(C# Side)
struct CSharpStruct
{
double d1;
double d2;
double d3;
long l1;
}
private VB6AX.CTest AXInstance; // ActiveX Class Instance
AXInstance = new VB6AX.CTest(); // Instanciate vb6 class
AXInstance.VB6Struct myData = new AXInstance.VB6Struct();
AXInstance.FillStruct(ref myData);
// (FillStruct is a vb6 class method to fill the structure)
IT WORKS, BUT...IF I DO
CSharpStruct myData = new CSharpStruct();
AXInstance.FillStruct(ref myData);
I have a
'cannot convert from ref CSharpStruct to ref AXInstance.VB6Struct'.
How to convert the ActiveX DLL Struct to the C# managed struct ?
The end of the story is that I would like my VB6 ActiveX DLL to fill an
array of structure, called by the C# client.
The filled array of structure should be a 'managed' array of struct so I
do have fast access speed to its elements later on in the application.
-> How to convert/mashal a VB6 Array Of Struct to a C# Array of Struct
(the C# array should be definied as an array of managed struct and not
through the ActiveX unmanaged structure declaration)
VB6AX.VB6Struct[] array1 = null; // array of unmanaged VB6 Struct
CSharpStruct[] array2 = null; // array of C# managed Struct
// bot struct represents the same thg
-> How to convert a ref VB6AX.VB6Struct to a ref CSharpStruct ?
-> How to convert a ref VB6AX.VB6Struct[] to a ref CSharpStruct[] ?
Can you help ?
Thanks.
3.Array string value assigned to a structure
The following code puts a structure location in an array field:
XrefArray(i) = "ArrayIn(i).Field" & RefText.Substring(NumStart + 1)
--------------------------------------------------------
Array(i).Field1 is the value now assigned to XrefArray(i)
--------------------------------------------------------
How can I now assign the value in this array and,
therefore, the value in ArrayIn(i).Field1 to another struct?
OutputArray(i).Field1 = XrefArray(i)
Or can I?
Thanks for any help.
4.assign byte array to struct or class
Hi,
how can I assign a byte array (read from a device) to a C# class or struct?
Christian
5.array of struct containing array of struct
I have a c++ function which requires that I pass an array of
structures which contain further arrays of other structures. I have
been unable to do this in c#. Could anyone give me some pointers on
how I might be able to perform this task? I have my structures as
follows, and i'm passing an array of MySchema (possibly over a dozen)
into the function to be filled. Each MySchema contains a 16 element
array of MyDataFormat. I've managed to perform quite a bit of interop
programming successfully, but this one is really stumping me.
[StructLayout(LayoutKind.Sequential)]
public struct MyVersion
{
public uint Major;
public uint Minor;
}
[StructLayout(LayoutKind.Sequential)]
public struct MyDataFormat
{
public ushort formatOwner;
public ushort formatID;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public struct MySchema
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst=16)]
public byte[] moduleID;
public uint deviceID;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=68)]
public char[] Name;
public MyVersion specVersion;
public MyVersion productVersion;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=68)]
public char[] vender;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=16)]
public MyDataFormat[] supportedFormats;
public uint numSupportedFormats;
public uint factorsMask;
public uint operations;
public uint options;
public uint payloadPolicy;
public uint maxPayloadSize;
public uint maxSize;
public uint maxIdentify;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=68)]
public char[] description;
public char path;
}
6. Marshaling struct containing pointer to array of arrays of struct
7. problem assigning value to struct member in for each
8. How Can I assign value to Struct variables?