|
Hello
I want to share a folder through coding, within a network.
Thanks
Devesh Mishra
|
|
|
|
|
Hi,
You can use the "SetAccessControl" method of the DirectoryInfo class for this purpose.
Manoj
Never Gives up
|
|
|
|
|
I have a table of data 'properties' containing
PropertyID int ident,
PropertyName varchar,
PropertyRequired bit,
PropertyType varchar,
PropertyValue varchar
I'm looking to create a BLL with a class MyProperties and an enum MyPropertyTypes
The MyPropertyTypes are Number, Text, Date, Boolean, ListFixed, ListCustom, Range
For the Number,Text,Date,Boolean only a single value is present but for the rest they can have more than one value
what is the best way to model a class/es to incorporate the properties common to all (ID, Name, Required, Type) and the properties specific to each PropertyType which can vary by both number and object type?
Thanks in advance
Mac.
|
|
|
|
|
class MyBase
{
int ID;
string Name;
bool Required;
string Type;
}
class Derived<T> : MyBase
{
T type
}
-- modified at 10:32 Wednesday 30th May, 2007
only two letters away from being an asset
|
|
|
|
|
Thanks Mark,
I'm still not sure though how I could load the classes if I don't know the type in advance?
Take the following scenario
Property 1 is a number
Property 2 is a range
MyProperty oProperty = new MyProperty(1);
if(oProperty.Type == MyPropertyType.Number)
{
//load property again?
MyNumberProperty nProp = new MyNumberProperty(1);
nProp.Value = 1;
}
MyProperty oProperty = new MyProperty(2);
if(oProperty.Type == MyPropertyType.Number)
{
//cast to the correct type?
MyRangeProperty rProp = (RangeProperty)oProperty;
rProperty.StartValue 1;
rProperty.EndValue = 100;
}
or another method, generics perhaps?
Thanks in advance
Mac.
|
|
|
|
|
wwwlicious wrote: MyProperty oProperty = new MyProperty(2);
You are creating a instance of the base class here. You create the instance of the specific type and use it. Also, when you will create a instance of the specifix type it will contain the type information.
i.e.
MyRangeProperty rProp = new MyRangeProperty();
rProp.StartVale = 1;
rProp.EndValue = 100;
rProp.type = Number //See here you need to set the type while creating instance.
Now, the instance of MyRangeProperty have all the info. Even if you cast it to base class, you will be able to access the "type" info, to decide what type of properties has been stored there.
Manoj
Never Gives up
|
|
|
|
|
Thanks Manoj,
how do I know which type to create an instance of in the first place if I start with only an ID though?
Thanks in advance
Mac.
|
|
|
|
|
See, whenever you get the info regarding which type you want, you can create that type of properties and get the values set. Why do you want to create a abstract type of properties? Sorry, but seems I am not able to understand your requirement properly.
Manoj
Never Gives up
|
|
|
|
|
ok a bit more explanation required I think. The properties apply to products, each product can have any number of properties attached to it.
The requirement is for properties to be shared for all products and strongly typed.
Each type has validation rules which are both common and specific per type
All properties must have a name
Required properties must have a valid value
Number can have a min + max numeric range along with prefixes and suffixes
Text can have max character limit, no pre/suffix
Boolean, no pre/suffix
Date, no pre/suffix, min + max date range
List, no pre/suffix, unlimited string values
Example
Product 1 has 4 properties color, weight, temperature range and optional
color is a list type
weight is a number type
temp range is a range type
optional is a boolean type
The property table has
ID Name Prefix Suffix Min Max DefaultValue
1 color Black|White|Red|Green
2 weight kg 0 9999 0
3 temp ºC -273 20000 -10|70
4 optional 1
The product property table holds
ID PropertyID Ordinal Required Value
1 1 1 1 Red
1 2 2 1 0.4
1 3 3 0 20|40
When a product is loaded, it contains a collection of Properties. the idea is to access the collection using and index and return an abstract or generic type of some kind to work with.
Hope that all makes sense. Its a bit more complex than I suggest but that's the basics.
Thanks in advance
Mac.
|
|
|
|
|
Since this sounds like a homework assignment I'll give you expand on what I've already said and let you complete it.
public class Property<T><br />
{<br />
private T m_Value;<br />
private string m_Name;<br />
<br />
public Property(string name, T value)<br />
{<br />
m_Name = name;<br />
m_Value = value;<br />
}<br />
<br />
new public Type GetType()<br />
{<br />
return typeof(T);<br />
}<br />
}<br />
<br />
Property<int> propWeight = new Property<int>("weight", 1);<br />
Property<bool> propOptional = new Property<bool>("optional", false);<br />
<br />
only two letters away from being an asset
|
|
|
|
|
Thanks Mark for your example, it's definately not a homework assignment (I wish!). I generalized the example quite a lot to hopefully explain the issue clearly.
I have looked at generics but I still can't get my head around how I could have a constructor to load a property from an ID without knowing the type in advance.
I won't have the name and value with which to load the property as in your example above, just an int ID.
<br />
Property propAny = new Property(1);<br />
<br />
Property<?> propAny = new Property<?>(1);<br />
? =
sorry if I'm missing the obvious here but I don't see how this works.
Thanks in advance
Mac.
|
|
|
|
|
You are going to have to rethink your architecture then. Other than using object for everything there is no way I know of to support all cases of unknown types.
only two letters away from being an asset
|
|
|
|
|
ok will have a think about it, I don't like the idea of using object much, seems like a hack approach but I liked the idea of having the values strongly typed each with the business rules encapsulated.
thanks for the help though, much appreciated.
Mac.
|
|
|
|
|
can anybody help me reading the elements of xml document???
Regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
Get the document element using following code:
XmlDocument xmlDoc = new XmlDocument();
xmlNode root = xmlDoc.DocumentElement;
XmlNode node = root.FirstChild;
Now you can traverse all nodes of xml file depending upon the structure of file, using a simple while loop....
while (node != null)
{
node = node.NextSibling;
// or
node = node.FirstChild;
// etc.
}
Hope that helps....
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
Hi!
I am using datagridview control to display records, in my datagridview mostly more than 50000 records are displayed. after every 5 seconds the control is refreshed and new datasource is assigned to it.
Now when i am scrolling the datagridview and meanwhile timer refreshes the control, it brings me back to the first row of control. which is quite annoying when you are on 30000th row.
I want to maintain the view of control after it is refreshed. I tried to save the e.oldValue of ScrollEventArgs in dgv1_Scroll eventhandler and then after refresh assigning it to e.newValue but it did'nt worked....
I achieved this by saving the index of selected row and then after refresh selecting that row again, but i want to do it without selecting any row...is it possible to save the scoll value and then restore it....?
Thanks in advance...
Regards,
Affan Ahmad Toor
.....................................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
Hi Codeguru´s,
Can somebody help me - i´ve a big problem:
In my C# Windows Application i want to get all entries from our MS Exchange Server 2003 public Folger (Calendar).
have someone an idea?
bye
Markus
|
|
|
|
|
Is there any way to integre the DIVX player.
else
Is there any light movie player controller which can support all type of movies, if the relavent codec is installed.
any help is appriciated
Ravikumar
|
|
|
|
|
Hi
how can i read xml string in c#??
Regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
hi
XmlDocument doc = new XmlDocument();
doc.LoadXML(xmlString);
regards
|
|
|
|
|
If the user input data in textbox, i want to get that data and store it.
Just like, Console.Write(); / Console.Read();
---// in textbox????
thanks in advance,
to know everything is to know yourself...
|
|
|
|
|
Don't double post, I have already answered your question
|
|
|
|
|
As far as i understood your question, there is a property named Text for a textbox, you can store it using textbox1.Text!
Adeel
--
|
|
|
|
|
When the user input a data in textbox, i wanna get that data
and store it. just like in Console.Write / Console.Read
--// in textbox???
thanks in advance.
to know everything is to know yourself...
|
|
|
|
|
Text property of the textbox class will help you. You can get it or set
|
|
|
|