本文整理汇总了C#中MgResourceIdentifier.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# MgResourceIdentifier.Validate方法的具体用法?C# MgResourceIdentifier.Validate怎么用?C# MgResourceIdentifier.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MgResourceIdentifier
的用法示例。
在下文中一共展示了MgResourceIdentifier.Validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string [] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
//Must call MgPlatform.Initialize() before we can work with anything from the MapGuide API
try
{
var sw = new Stopwatch();
sw.Start();
MgdPlatform.Initialize("Platform.ini");
sw.Stop();
Trace.TraceInformation("Platform initialization took {0}ms", sw.ElapsedMilliseconds);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
return;
}
//MgAppWindow is our Main Window class full of drag-and-drop component goodness. Go ahead and
//take a look at MgAppWindow.cs source, not much code there except for the 3 generic invoke components and the
//single custom selection handler. Everything else is encapsulated by designer-friendly drag and drop components
//Most of the work is dragging and dropping components into the designer surface, and setting lots of properties
var frm = new MgAppWindow();
//We can initialize without specifying a map (allowing for components that do not
//require a loaded map to still be used). You just have to call LoadMap() on the MgMapViewer
//instance when ready (not demonstrated here). So if you do load a package here, you will
//have to restart the application
MgResourceIdentifier resId = null;
if (args.Length == 1)
{
resId = new MgResourceIdentifier(args[0]);
resId.Validate();
}
var fact = new MgdServiceFactory();
var resSvc = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService);
MgdMap map = null;
if (resId != null && resSvc.ResourceExists(resId))
map = new MgdMap(resId);
//This is just a pass-through call to MgMapViewer.Init()
frm.LoadMap(new MgDesktopMapViewerProvider(map));
Application.ApplicationExit += new EventHandler(OnAppExit);
Application.Run(frm);
}
示例2: btnOk_Click
private void btnOk_Click(object sender, EventArgs e)
{
try
{
var resId = new MgResourceIdentifier(txtResourceId.Text);
resId.Validate();
var fact = new MgdServiceFactory();
var resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
if (!resSvc.ResourceExists(resId))
{
MessageBox.Show("The specified resource does not exist");
return;
}
this.ResourceID = resId;
this.DialogResult = DialogResult.OK;
}
catch (MgException ex)
{
MessageBox.Show(ex.Message);
ex.Dispose();
}
}
示例3: GetResourcesByType
public Dictionary<string, string> GetResourcesByType(string resourceType)
{
//TODO:
if (!IsValidMap3DResourceType(resourceType))
{
throw new ApplicationException("unspported resource type by Map3D");
}
Dictionary<string, string> resources = new Dictionary<string, string>();
try
{
string rootPath = "Library://";
MgResourceIdentifier rootResId = new MgResourceIdentifier(rootPath);
rootResId.Validate();
MgByteReader reader = ResourceService.EnumerateResources(rootResId, -1, resourceType.ToString());
//Convert to string
String resStr = reader.ToString();
//Load into XML document so we can parse and get the names of the maps
XmlDocument doc = new XmlDocument();
doc.LoadXml(resStr);
//let's extract the resource names and list them
XmlNodeList resIdNodeList;
XmlElement root = doc.DocumentElement;
resIdNodeList = root.SelectNodes("//ResourceId");
int resCount = resIdNodeList.Count;
for (int i = 0; i < resCount; i++)
{
XmlNode resIdNode = resIdNodeList.Item(i);
String resId = resIdNode.InnerText;
int index1 = resId.LastIndexOf('/') + 1;
int index2 = resId.IndexOf(resourceType) - 2;
int length = index2 - index1 + 1;
string resName = resId.Substring(index1, length);
resources.Add(resName, resId);
}
}
catch (Exception ex)
{
string msg = ex.Message;
Debug.WriteLine(msg);
}
return resources;
}