Alguien me puede pasar este codigo a C#??

12/08/2004 - 10:40 por Jorge | Informe spam
Private Function GetCategoryByDefinition(ByVal product_id, ByVal
category_definiton_name As String, ByVal CatalogWebServiceUrl, ByVal
catalog_name) As String

'initialize the catalog
Dim cat_item As CatalogItemsDataSet.CatalogItem

Dim csa As New CatalogServiceAgent(CatalogWebServiceUrl)

Dim ctxt As CatalogContext = CatalogContext.Create(csa, New
ConsoleDebugContext(DebugMode.Checked))

Dim obj_catalog as ProductCatalog = ctxt.GetCatalog("store")

'get the product from the product_id
Dim obj_product as Product = obj_catalog.GetProduct(product_id)

'get the categories associated with the product
Dim categories As CatalogItemsDataSet.CatalogItemsDataTable obj_product.ParentCategories.CatalogItems

'loop through the categories to find the value of the category that
matches the category defition you'd like to find out if the product
belongs to.
For Each cat_item In categories

Try

'FNull tests for IsDbNull and returns an empty string,
otherwise returns value
If (FNull(cat_item.DefinitionName) = category_def) Then

Return cat_item.CategoryName

Exit Function

End If

Catch

End Try

Next

Preguntas similare

Leer las respuestas

#1 Oscar Onorato
12/08/2004 - 15:27 | Informe spam
Jorge, podes encontrar traductores de C# a VB.NET o viceversa en google.
En este momento no tengo un link para pasarte porque los tengo en el
trabajo. Pero hay muchas buenas páginas traductoras. Yo las encontré
buscando por:
"C# Translator"

Suerte.





"Jorge" escribió en el mensaje
news:
Private Function GetCategoryByDefinition(ByVal product_id, ByVal
category_definiton_name As String, ByVal CatalogWebServiceUrl, ByVal
catalog_name) As String

'initialize the catalog
Dim cat_item As CatalogItemsDataSet.CatalogItem

Dim csa As New CatalogServiceAgent(CatalogWebServiceUrl)

Dim ctxt As CatalogContext = CatalogContext.Create(csa, New
ConsoleDebugContext(DebugMode.Checked))

Dim obj_catalog as ProductCatalog = ctxt.GetCatalog("store")

'get the product from the product_id
Dim obj_product as Product = obj_catalog.GetProduct(product_id)

'get the categories associated with the product
Dim categories As CatalogItemsDataSet.CatalogItemsDataTable > obj_product.ParentCategories.CatalogItems

'loop through the categories to find the value of the category that
matches the category defition you'd like to find out if the product
belongs to.
For Each cat_item In categories

Try

'FNull tests for IsDbNull and returns an empty string,
otherwise returns value
If (FNull(cat_item.DefinitionName) = category_def) Then

Return cat_item.CategoryName

Exit Function

End If

Catch

End Try

Next


Respuesta Responder a este mensaje
#2 Guillermo guille
12/08/2004 - 16:18 | Informe spam
A ver si esta aproximación:
xxx
private string GetCategoryByDefinition(object product_id, string
category_definiton_name, object CatalogWebServiceUrl, object catalog_name) {

//initialize the catalog
CatalogItemsDataSet.CatalogItem cat_item;

CatalogServiceAgent csa = new CatalogServiceAgent(CatalogWebServiceUrl);

CatalogContext ctxt = CatalogContext.Create(csa, new
ConsoleDebugContext(DebugMode.Checked));

obj_catalog as ProductCatalog = ctxt.GetCatalog("store");

//get the product from the product_id
obj_product as Product = obj_catalog.GetProduct(product_id);

//get the categories associated with the product
CatalogItemsDataSet.CatalogItemsDataTable categories obj_product.ParentCategories.CatalogItems;

//loop through the categories to find the value of the category that matches
the category defition you'd like to find out if the product belongs to.
foreach(CatalogItemsDataSet.CatalogItem /*TODO: cambiar el nombre de la
variable*/ cat_item in categories){

try{

//FNull tests for IsDbNull and returns an empty string, otherwise
returns value
if( (FNull(cat_item.DefinitionName) == category_def) ){

return cat_item.CategoryName;

return;

}

}catch{

}

}
}
xxx

En mi sitio hay un conversor de VB a C# que "medio" funciona:
http://www.elguille.info/NET/dotnet/deVBaCS.asp

Nos vemos.
Guillermo
Microsoft VB MVP desde 1997
Te invito a mi sitio dedicado al VB y más...
http://www.elguille.info/
http://www.mundoprogramacion.com/
(puede que el correo usado sea anti-spam)


"Jorge" wrote in message
news:
Respuesta Responder a este mensaje
#3 Guillermo guille
12/08/2004 - 16:23 | Informe spam
Aunque el conversor es sensible a mayúsculas y minúsculas y si "As" no lo
escribimos bien... pues...

private string GetCategoryByDefinition(object product_id, string
category_definiton_name, object CatalogWebServiceUrl, object catalog_name) {

//initialize the catalog
//Dim cat_item As CatalogItemsDataSet.CatalogItem

CatalogServiceAgent csa = new CatalogServiceAgent(CatalogWebServiceUrl);

CatalogContext ctxt = CatalogContext.Create(csa, new
ConsoleDebugContext(DebugMode.Checked));

ProductCatalog obj_catalog = ctxt.GetCatalog("store");

//get the product from the product_id
Product obj_product = obj_catalog.GetProduct(product_id);

//get the categories associated with the product
CatalogItemsDataSet.CatalogItemsDataTable categories obj_product.ParentCategories.CatalogItems;

//loop through the categories to find the value of the category that matches
the category defition you'd like to find out if the product belongs to.
foreach(CatalogItemsDataSet.CatalogItem cat_item in categories){
try{
//FNull tests for IsDbNull and returns an empty string, otherwise
returns value
if( (FNull(cat_item.DefinitionName) == category_def) ){
return cat_item.CategoryName;
//return;
}
}catch{
}
}
}

Nos vemos.
Guillermo
Microsoft VB MVP desde 1997
Te invito a mi sitio dedicado al VB y más...
http://www.elguille.info/
http://www.mundoprogramacion.com/
(puede que el correo usado sea anti-spam)
Respuesta Responder a este mensaje
#4 Zenkius
13/08/2004 - 21:08 | Informe spam
Esta es la URL de un conversor de VB.NET a C# y viceversa; este es el que yo
uso y para mi gusto está bastante bueno.Espero que te sea útil.

http://myweb.hinet.net/home4/s63041...ertNet.zip

Saludos;

Zenkius.


"Jorge" wrote in message
news:
Private Function GetCategoryByDefinition(ByVal product_id, ByVal
category_definiton_name As String, ByVal CatalogWebServiceUrl, ByVal
catalog_name) As String

'initialize the catalog
Dim cat_item As CatalogItemsDataSet.CatalogItem

Dim csa As New CatalogServiceAgent(CatalogWebServiceUrl)

Dim ctxt As CatalogContext = CatalogContext.Create(csa, New
ConsoleDebugContext(DebugMode.Checked))

Dim obj_catalog as ProductCatalog = ctxt.GetCatalog("store")

'get the product from the product_id
Dim obj_product as Product = obj_catalog.GetProduct(product_id)

'get the categories associated with the product
Dim categories As CatalogItemsDataSet.CatalogItemsDataTable > obj_product.ParentCategories.CatalogItems

'loop through the categories to find the value of the category that
matches the category defition you'd like to find out if the product
belongs to.
For Each cat_item In categories

Try

'FNull tests for IsDbNull and returns an empty string,
otherwise returns value
If (FNull(cat_item.DefinitionName) = category_def) Then

Return cat_item.CategoryName

Exit Function

End If

Catch

End Try

Next


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida